laura is hosted by Hepforge, IPPP Durham
Laura++  v3r5
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauSPlot.hh
Go to the documentation of this file.
1 
2 /*
3 Copyright 2006 University of Warwick
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 */
17 
18 /*
19 Laura++ package authors:
20 John Back
21 Paul Harrison
22 Thomas Latham
23 */
24 
47 /**********************************************************************
48  * *
49  * Copyright (c) 2005 ROOT Foundation, CERN/PH-SFT *
50  * *
51  **********************************************************************/
52 
53 #ifndef LAU_SPLOT
54 #define LAU_SPLOT
55 
56 #include <vector>
57 #include <map>
58 #include <set>
59 
60 #include "TMatrixD.h"
61 #include "TString.h"
62 
63 class TEventList;
64 class TLeaf;
65 class TFile;
66 class TTree;
67 
68 
69 class LauSPlot : public TObject {
70 
71  public:
73  typedef std::set<TString> NameSet;
74 
76  typedef std::map<TString,Double_t> NumbMap;
77 
79  typedef std::map<TString,TLeaf*> LeafMap;
80 
82  typedef std::multimap< TString, std::pair<TString,TString> > TwoDMap;
83 
85 
97  LauSPlot(const TString& fileName, const TString& treeName,
98  Int_t firstExpt,
99  Int_t nExpt,
100  const NameSet& variableNames,
101  const LauSPlot::NumbMap& freeSpecies,
102  const LauSPlot::NumbMap& fixdSpecies,
103  const TwoDMap& twodimPDFs,
104  Bool_t sigSplit = kFALSE,
105  Bool_t scfDPSmeared = kFALSE);
106 
108  virtual ~LauSPlot();
109 
111 
117  void runCalculations(const TString& option = "q");
118 
120  void writeOutResults();
121 
123 
126  const std::vector<LauSPlot::NumbMap>& totalPdf() const {return pdfTot_;}
127 
128  protected:
130 
133  Bool_t readInput() const {return readInput_;}
134 
136 
139  void readInput(Bool_t ok) {readInput_ = ok;}
140 
142 
145  Bool_t signalSplit() const {return signalSplit_;}
146 
148 
151  Bool_t scfDPSmear() const {return scfDPSmear_;}
152 
154 
157  Bool_t definedCNBranches() const {return definedCNBranches_;}
158 
160 
163  void definedCNBranches(Bool_t defined) {definedCNBranches_ = defined;}
164 
166 
170 
172 
175  void definedSWeightBranches(Bool_t defined) {definedSWeightBranches_ = defined;}
176 
178  void openInputFileAndTree();
179 
181  void readInputInfo();
182 
184  Bool_t readInputLeaves();
185 
187  Bool_t checkLeaves() const;
188 
190  void createCNTree();
192  void defineCNBranches();
193 
195  void createSWeightTree();
197  void defineSWeightBranches();
198 
200 
203  void setExperiment(Int_t iExpt);
204 
206  void readExpt();
207 
209  void checkFitter() const;
210 
212 
215  void initialiseFitter(const TString& opt);
216 
218  void setFitParameters() const;
219 
221  void runFit();
222 
224 
227  void retrieveFittedParameters(const TString& opt);
228 
230 
233  void printCovMatrixElements(const Double_t * covmat = 0) const;
234 
236 
239  void printSumOfWeights(const TString& exclName) const;
240 
241  // Calculate the covariance matrix from the various PDFs
245  Bool_t calcCovMatrix();
246 
248 
251  void calcTotPDFValues(const TString& exclName);
252 
254 
258  void calcCNCoeffs(const TString& exclName, const Double_t * covmat = 0);
259 
261 
265  void calcSWeights(const TString& exclName, Double_t * covmat = 0);
266 
268 
271  void copyEventWeights(Int_t iEvent);
272 
274  void fillCNBranches();
275 
277  void fillSWeightBranches();
278 
280  void addFriendTree();
281 
282  private:
284  LauSPlot(const LauSPlot& rhs);
285 
287  LauSPlot& operator=(const LauSPlot& rhs);
288 
290  TString fileName_;
292  TString inputTreeName_;
294  TString cnTreeName_;
298  TFile* file_;
300  TTree* inputTree_;
302  TTree* cnTree_;
304  TTree* sweightTree_;
305 
307  TEventList* eventList_;
308 
311 
324 
326  const Bool_t signalSplit_;
328  const Bool_t scfDPSmear_;
329 
331  Bool_t readInput_;
336 
338  Int_t firstExpt_;
340  Int_t nExpt_;
342  Int_t iExpt_;
344  Int_t nEvents_;
346  Int_t nDiscVars_;
352  Int_t nSpecies_;
353 
355  std::vector<NumbMap> pdfTot_;
357  std::vector<std::map<TString,NumbMap> > discPdf_;
359  std::vector<Double_t> scfFrac_;
360 
362  TMatrixD covMat_;
363 
365  std::vector< std::map<TString,NumbMap> > sWeights_;
367  std::map<TString,NumbMap> sWeightsCurrent_;
369  std::map<TString,NumbMap> cN_;
370 
371  ClassDef(LauSPlot, 0)
372 };
373 
374 #endif
Class for defining the SPlot technique.
Definition: LauSPlot.hh:69
std::map< TString, NumbMap > cN_
The extended sPlot coefficients (for each species and for each combination of excluded vars) ...
Definition: LauSPlot.hh:369
Int_t nDiscVars_
Number of discriminating variables.
Definition: LauSPlot.hh:346
void runFit()
Perform the minimisation wrt the yields alone.
Definition: LauSPlot.cc:806
std::vector< NumbMap > pdfTot_
The per-event values of the total PDF for each species.
Definition: LauSPlot.hh:355
Bool_t definedSWeightBranches_
Flag whether the sWeights branches have already been created.
Definition: LauSPlot.hh:335
void initialiseFitter(const TString &opt)
Initialise Minuit, set the verbosity.
Definition: LauSPlot.cc:749
void setFitParameters() const
Add the species yields as fit parameters and fix them as appropriate.
Definition: LauSPlot.cc:775
void runCalculations(const TString &option="q")
Method to calculate the sWeights and cN coeffs.
Definition: LauSPlot.cc:640
Int_t nFixdSpecies_
Number of species fixed in the fit.
Definition: LauSPlot.hh:350
LauSPlot(const TString &fileName, const TString &treeName, Int_t firstExpt, Int_t nExpt, const NameSet &variableNames, const LauSPlot::NumbMap &freeSpecies, const LauSPlot::NumbMap &fixdSpecies, const TwoDMap &twodimPDFs, Bool_t sigSplit=kFALSE, Bool_t scfDPSmeared=kFALSE)
Constructor.
Definition: LauSPlot.cc:63
void calcTotPDFValues(const TString &exclName)
Calculate the total likelihood for each species by multiply together all the PDFs for that species...
Definition: LauSPlot.cc:942
Int_t nEvents_
Number of events in current experiment.
Definition: LauSPlot.hh:344
void fillCNBranches()
Fill the cN branches.
Definition: LauSPlot.cc:1196
NumbMap freeSpecies_
The names and estimated yields of the free species.
Definition: LauSPlot.hh:315
void readInputInfo()
Read the leaf structure from the tree and check the status of the read (calls LauSPlot::readInputLeav...
Definition: LauSPlot.cc:144
std::vector< std::map< TString, NumbMap > > discPdf_
The per-event values of the PDFs for each species for each disc variable.
Definition: LauSPlot.hh:357
TEventList * eventList_
Pointer to an event list, that is used to loop through the experiments.
Definition: LauSPlot.hh:307
void printSumOfWeights(const TString &exclName) const
Print the sum of sWeights for all species.
Definition: LauSPlot.cc:873
std::multimap< TString, std::pair< TString, TString > > TwoDMap
Type to associate the name of the species that have 2D PDFs with the names of the two variables invol...
Definition: LauSPlot.hh:82
void createCNTree()
Create (if not already done) the tree for storing the cN coeffs.
Definition: LauSPlot.cc:372
TString inputTreeName_
The name of the input tree (containing the per-event llhds)
Definition: LauSPlot.hh:292
TFile * file_
Pointer to the data file object.
Definition: LauSPlot.hh:298
void fillSWeightBranches()
Fill the sWeights branches.
Definition: LauSPlot.cc:1207
TwoDMap twodimPDFs_
The names of the species that have 2D PDFs and the names of the variables involved.
Definition: LauSPlot.hh:323
void readExpt()
Reads the values of each PDF likelihood for every event in the experiment.
Definition: LauSPlot.cc:508
std::vector< Double_t > scfFrac_
The per-event values of the SCF fraction.
Definition: LauSPlot.hh:359
Bool_t readInput_
Flag whether the input tree has been successfully read.
Definition: LauSPlot.hh:331
TString cnTreeName_
The name of the cn tree (containing the cN coefficients)
Definition: LauSPlot.hh:294
Int_t iExpt_
The current experiment.
Definition: LauSPlot.hh:342
Bool_t signalSplit() const
Check whether the signal is split into Truth Matched and Self Cross Feed.
Definition: LauSPlot.hh:145
void writeOutResults()
Save the sWeight results as a friend tree to the input tree (in the same file)
Definition: LauSPlot.cc:1238
Int_t nExpt_
Number of experiments.
Definition: LauSPlot.hh:340
void checkFitter() const
Make sure that we&#39;re using Minuit.
Definition: LauSPlot.cc:736
void calcSWeights(const TString &exclName, Double_t *covmat=0)
Computes the sWeights from the PDFs and covariance matrix.
Definition: LauSPlot.cc:1162
void defineCNBranches()
Create the branches for each cN coefficient.
Definition: LauSPlot.cc:400
NumbMap origFreeSpecies_
The names and estimated yields of the free species - need to keep the original values.
Definition: LauSPlot.hh:319
LeafMap leaves_
Collection to hold pointers to the leaves of the input tree.
Definition: LauSPlot.hh:310
const Bool_t scfDPSmear_
If so then is the SCF smeared in the DP?
Definition: LauSPlot.hh:328
const Bool_t signalSplit_
Is the signal split into TM and SCF?
Definition: LauSPlot.hh:326
TTree * cnTree_
Pointer to the output tree containing the cN coefficients.
Definition: LauSPlot.hh:302
Int_t firstExpt_
First experiment.
Definition: LauSPlot.hh:338
NameSet variableNames_
The names of the discriminating variables.
Definition: LauSPlot.hh:313
void copyEventWeights(Int_t iEvent)
Copy the sWeight of a given event into LauSPlot::sWeightsCurrent_, from which they can be stored in t...
Definition: LauSPlot.cc:1226
void openInputFileAndTree()
Method to open the file in &quot;update&quot; mode and grab the input tree for reading.
Definition: LauSPlot.cc:121
void setExperiment(Int_t iExpt)
Set the event list to contain only events from the given experiment.
Definition: LauSPlot.cc:473
std::map< TString, Double_t > NumbMap
Type to associate a category name with a double precision number, e.g. a yield or PDF value for a giv...
Definition: LauSPlot.hh:76
virtual ~LauSPlot()
Destructor.
Definition: LauSPlot.cc:109
TString sweightTreeName_
The name of the sweight tree (containing the sWeights)
Definition: LauSPlot.hh:296
void printCovMatrixElements(const Double_t *covmat=0) const
Print the supplied covariance matrix or, if pointer is null, the one previously calculated.
Definition: LauSPlot.cc:828
void createSWeightTree()
Create (if not already done) the tree for storing the sWeights.
Definition: LauSPlot.cc:386
std::map< TString, TLeaf * > LeafMap
Type to associate a variable name with the leaf of the input tree.
Definition: LauSPlot.hh:79
Bool_t readInput() const
Check whether the input tree has been successfully read.
Definition: LauSPlot.hh:133
void calcCNCoeffs(const TString &exclName, const Double_t *covmat=0)
Computes the cN for the extended sPlots from the covariance matrix.
Definition: LauSPlot.cc:1136
LauSPlot & operator=(const LauSPlot &rhs)
Copy assignment operator (not implemented)
const std::vector< LauSPlot::NumbMap > & totalPdf() const
Access the per-event total PDF values for each species.
Definition: LauSPlot.hh:126
TTree * sweightTree_
Pointer to the output tree containing the sWeights.
Definition: LauSPlot.hh:304
std::map< TString, NumbMap > sWeightsCurrent_
The current-event values of the computed sWeights.
Definition: LauSPlot.hh:367
Bool_t readInputLeaves()
Read the leaf structure from the tree and setup the leaf map.
Definition: LauSPlot.cc:160
Bool_t definedCNBranches_
Flag whether the cN branches have already been created.
Definition: LauSPlot.hh:333
Int_t nSpecies_
Total number of species (free + fixed)
Definition: LauSPlot.hh:352
NumbMap fixdSpecies_
The names and estimated yields of the fixed species.
Definition: LauSPlot.hh:317
Bool_t calcCovMatrix()
Definition: LauSPlot.cc:888
void retrieveFittedParameters(const TString &opt)
Update the yields with the newly fitted values and print them (unless print option is &quot;Q&quot;)...
Definition: LauSPlot.cc:851
TString fileName_
The name of the data file.
Definition: LauSPlot.hh:290
void readInput(Bool_t ok)
Set that the input tree has been successfully read.
Definition: LauSPlot.hh:139
TMatrixD covMat_
The calculated covariance matrix.
Definition: LauSPlot.hh:362
void definedCNBranches(Bool_t defined)
Set that the cN branches have been already defined.
Definition: LauSPlot.hh:163
void addFriendTree()
Add the sWeightTree as a friend tree of the input tree.
Definition: LauSPlot.cc:1260
void definedSWeightBranches(Bool_t defined)
Set that the sWeights branches have been already defined.
Definition: LauSPlot.hh:175
Bool_t definedSWeightBranches() const
Check whether the sWeights branches have been already created.
Definition: LauSPlot.hh:169
Bool_t definedCNBranches() const
Check whether the cN branches have been already created.
Definition: LauSPlot.hh:157
std::vector< std::map< TString, NumbMap > > sWeights_
The per-event values of the computed sWeights (for each species and for each combination of excluded ...
Definition: LauSPlot.hh:365
Bool_t checkLeaves() const
Check whether the leaf structure makes sense given the PDFs we are expecting.
Definition: LauSPlot.cc:203
Int_t nFreeSpecies_
Number of species free to float in the fit.
Definition: LauSPlot.hh:348
std::set< TString > NameSet
Type to store names, e.g. of the discriminating/control variables.
Definition: LauSPlot.hh:73
void defineSWeightBranches()
Create the branches to store the sWeights.
Definition: LauSPlot.cc:438
TTree * inputTree_
Pointer to the input tree.
Definition: LauSPlot.hh:300
Bool_t scfDPSmear() const
Check whether the Self Cross Feed is smeared in the DP.
Definition: LauSPlot.hh:151
NumbMap origFixdSpecies_
The names and estimated yields of the fixed species - need to keep the original values.
Definition: LauSPlot.hh:321