laura is hosted by Hepforge, IPPP Durham
Laura++  v3r1
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauSPlot.hh
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2006 - 2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 // Authors:
7 // Thomas Latham
8 // John Back
9 // Paul Harrison
10 
33 /**********************************************************************
34  * *
35  * Copyright (c) 2005 ROOT Foundation, CERN/PH-SFT *
36  * *
37  **********************************************************************/
38 
39 #ifndef LAU_SPLOT
40 #define LAU_SPLOT
41 
42 #include <vector>
43 #include <map>
44 #include <set>
45 
46 #include "TMatrixD.h"
47 #include "TString.h"
48 
49 class TEventList;
50 class TLeaf;
51 class TFile;
52 class TTree;
53 
54 
55 class LauSPlot : public TObject {
56 
57  public:
59  typedef std::set<TString> NameSet;
60 
62  typedef std::map<TString,Double_t> NumbMap;
63 
65  typedef std::map<TString,TLeaf*> LeafMap;
66 
68  typedef std::multimap< TString, std::pair<TString,TString> > TwoDMap;
69 
71 
83  LauSPlot(const TString& fileName, const TString& treeName,
84  Int_t firstExpt,
85  Int_t nExpt,
86  const NameSet& variableNames,
87  const LauSPlot::NumbMap& freeSpecies,
88  const LauSPlot::NumbMap& fixdSpecies,
89  const TwoDMap& twodimPDFs,
90  Bool_t sigSplit = kFALSE,
91  Bool_t scfDPSmeared = kFALSE);
92 
94  virtual ~LauSPlot();
95 
97 
103  void runCalculations(const TString& option = "q");
104 
106  void writeOutResults();
107 
109 
112  const std::vector<LauSPlot::NumbMap>& totalPdf() const {return pdfTot_;}
113 
114  protected:
116 
119  Bool_t readInput() const {return readInput_;}
120 
122 
125  void readInput(Bool_t ok) {readInput_ = ok;}
126 
128 
131  Bool_t signalSplit() const {return signalSplit_;}
132 
134 
137  Bool_t scfDPSmear() const {return scfDPSmear_;}
138 
140 
143  Bool_t definedCNBranches() const {return definedCNBranches_;}
144 
146 
149  void definedCNBranches(Bool_t defined) {definedCNBranches_ = defined;}
150 
152 
156 
158 
161  void definedSWeightBranches(Bool_t defined) {definedSWeightBranches_ = defined;}
162 
164  void openInputFileAndTree();
165 
167  void readInputInfo();
168 
170  Bool_t readInputLeaves();
171 
173  Bool_t checkLeaves() const;
174 
176  void createCNTree();
178  void defineCNBranches();
179 
181  void createSWeightTree();
183  void defineSWeightBranches();
184 
186 
189  void setExperiment(Int_t iExpt);
190 
192  void readExpt();
193 
195  void checkFitter() const;
196 
198 
201  void initialiseFitter(const TString& opt);
202 
204  void setFitParameters() const;
205 
207  void runFit();
208 
210 
213  void retrieveFittedParameters(const TString& opt);
214 
216 
219  void printCovMatrixElements(const Double_t * covmat = 0) const;
220 
222 
225  void printSumOfWeights(const TString& exclName) const;
226 
227  // Calculate the covariance matrix from the various PDFs
231  Bool_t calcCovMatrix();
232 
234 
237  void calcTotPDFValues(const TString& exclName);
238 
240 
244  void calcCNCoeffs(const TString& exclName, const Double_t * covmat = 0);
245 
247 
251  void calcSWeights(const TString& exclName, Double_t * covmat = 0);
252 
254 
257  void copyEventWeights(Int_t iEvent);
258 
260  void fillCNBranches();
261 
263  void fillSWeightBranches();
264 
266  void addFriendTree();
267 
268  private:
270  LauSPlot(const LauSPlot& rhs);
271 
273  LauSPlot& operator=(const LauSPlot& rhs);
274 
276  TString fileName_;
278  TString inputTreeName_;
280  TString cnTreeName_;
284  TFile* file_;
286  TTree* inputTree_;
288  TTree* cnTree_;
290  TTree* sweightTree_;
291 
293  TEventList* eventList_;
294 
297 
310 
312  const Bool_t signalSplit_;
314  const Bool_t scfDPSmear_;
315 
317  Bool_t readInput_;
322 
324  Int_t firstExpt_;
326  Int_t nExpt_;
328  Int_t iExpt_;
330  Int_t nEvents_;
332  Int_t nDiscVars_;
338  Int_t nSpecies_;
339 
341  std::vector<NumbMap> pdfTot_;
343  std::vector<std::map<TString,NumbMap> > discPdf_;
345  std::vector<Double_t> scfFrac_;
346 
348  TMatrixD covMat_;
349 
351  std::vector< std::map<TString,NumbMap> > sWeights_;
353  std::map<TString,NumbMap> sWeightsCurrent_;
355  std::map<TString,NumbMap> cN_;
356 
357  ClassDef(LauSPlot, 0)
358 };
359 
360 #endif
Class for defining the SPlot technique.
Definition: LauSPlot.hh:55
std::map< TString, NumbMap > cN_
The extended sPlot coefficients (for each species and for each combination of excluded vars) ...
Definition: LauSPlot.hh:355
Int_t nDiscVars_
Number of discriminating variables.
Definition: LauSPlot.hh:332
void runFit()
Perform the minimisation wrt the yields alone.
Definition: LauSPlot.cc:792
std::vector< NumbMap > pdfTot_
The per-event values of the total PDF for each species.
Definition: LauSPlot.hh:341
Bool_t definedSWeightBranches_
Flag whether the sWeights branches have already been created.
Definition: LauSPlot.hh:321
void initialiseFitter(const TString &opt)
Initialise Minuit, set the verbosity.
Definition: LauSPlot.cc:735
void setFitParameters() const
Add the species yields as fit parameters and fix them as appropriate.
Definition: LauSPlot.cc:761
void runCalculations(const TString &option="q")
Method to calculate the sWeights and cN coeffs.
Definition: LauSPlot.cc:626
Int_t nFixdSpecies_
Number of species fixed in the fit.
Definition: LauSPlot.hh:336
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:49
void calcTotPDFValues(const TString &exclName)
Calculate the total likelihood for each species by multiply together all the PDFs for that species...
Definition: LauSPlot.cc:928
Int_t nEvents_
Number of events in current experiment.
Definition: LauSPlot.hh:330
void fillCNBranches()
Fill the cN branches.
Definition: LauSPlot.cc:1182
NumbMap freeSpecies_
The names and estimated yields of the free species.
Definition: LauSPlot.hh:301
void readInputInfo()
Read the leaf structure from the tree and check the status of the read (calls LauSPlot::readInputLeav...
Definition: LauSPlot.cc:130
std::vector< std::map< TString, NumbMap > > discPdf_
The per-event values of the PDFs for each species for each disc variable.
Definition: LauSPlot.hh:343
TEventList * eventList_
Pointer to an event list, that is used to loop through the experiments.
Definition: LauSPlot.hh:293
void printSumOfWeights(const TString &exclName) const
Print the sum of sWeights for all species.
Definition: LauSPlot.cc:859
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:68
void createCNTree()
Create (if not already done) the tree for storing the cN coeffs.
Definition: LauSPlot.cc:358
TString inputTreeName_
The name of the input tree (containing the per-event llhds)
Definition: LauSPlot.hh:278
TFile * file_
Pointer to the data file object.
Definition: LauSPlot.hh:284
void fillSWeightBranches()
Fill the sWeights branches.
Definition: LauSPlot.cc:1193
TwoDMap twodimPDFs_
The names of the species that have 2D PDFs and the names of the variables involved.
Definition: LauSPlot.hh:309
void readExpt()
Reads the values of each PDF likelihood for every event in the experiment.
Definition: LauSPlot.cc:494
std::vector< Double_t > scfFrac_
The per-event values of the SCF fraction.
Definition: LauSPlot.hh:345
Bool_t readInput_
Flag whether the input tree has been successfully read.
Definition: LauSPlot.hh:317
TString cnTreeName_
The name of the cn tree (containing the cN coefficients)
Definition: LauSPlot.hh:280
Int_t iExpt_
The current experiment.
Definition: LauSPlot.hh:328
Bool_t signalSplit() const
Check whether the signal is split into Truth Matched and Self Cross Feed.
Definition: LauSPlot.hh:131
void writeOutResults()
Save the sWeight results as a friend tree to the input tree (in the same file)
Definition: LauSPlot.cc:1224
Int_t nExpt_
Number of experiments.
Definition: LauSPlot.hh:326
void checkFitter() const
Make sure that we&#39;re using Minuit.
Definition: LauSPlot.cc:722
void calcSWeights(const TString &exclName, Double_t *covmat=0)
Computes the sWeights from the PDFs and covariance matrix.
Definition: LauSPlot.cc:1148
void defineCNBranches()
Create the branches for each cN coefficient.
Definition: LauSPlot.cc:386
NumbMap origFreeSpecies_
The names and estimated yields of the free species - need to keep the original values.
Definition: LauSPlot.hh:305
LeafMap leaves_
Collection to hold pointers to the leaves of the input tree.
Definition: LauSPlot.hh:296
const Bool_t scfDPSmear_
If so then is the SCF smeared in the DP?
Definition: LauSPlot.hh:314
const Bool_t signalSplit_
Is the signal split into TM and SCF?
Definition: LauSPlot.hh:312
TTree * cnTree_
Pointer to the output tree containing the cN coefficients.
Definition: LauSPlot.hh:288
Int_t firstExpt_
First experiment.
Definition: LauSPlot.hh:324
NameSet variableNames_
The names of the discriminating variables.
Definition: LauSPlot.hh:299
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:1212
void openInputFileAndTree()
Method to open the file in &quot;update&quot; mode and grab the input tree for reading.
Definition: LauSPlot.cc:107
void setExperiment(Int_t iExpt)
Set the event list to contain only events from the given experiment.
Definition: LauSPlot.cc:459
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:62
virtual ~LauSPlot()
Destructor.
Definition: LauSPlot.cc:95
TString sweightTreeName_
The name of the sweight tree (containing the sWeights)
Definition: LauSPlot.hh:282
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:814
void createSWeightTree()
Create (if not already done) the tree for storing the sWeights.
Definition: LauSPlot.cc:372
std::map< TString, TLeaf * > LeafMap
Type to associate a variable name with the leaf of the input tree.
Definition: LauSPlot.hh:65
Bool_t readInput() const
Check whether the input tree has been successfully read.
Definition: LauSPlot.hh:119
void calcCNCoeffs(const TString &exclName, const Double_t *covmat=0)
Computes the cN for the extended sPlots from the covariance matrix.
Definition: LauSPlot.cc:1122
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:112
TTree * sweightTree_
Pointer to the output tree containing the sWeights.
Definition: LauSPlot.hh:290
std::map< TString, NumbMap > sWeightsCurrent_
The current-event values of the computed sWeights.
Definition: LauSPlot.hh:353
Bool_t readInputLeaves()
Read the leaf structure from the tree and setup the leaf map.
Definition: LauSPlot.cc:146
Bool_t definedCNBranches_
Flag whether the cN branches have already been created.
Definition: LauSPlot.hh:319
Int_t nSpecies_
Total number of species (free + fixed)
Definition: LauSPlot.hh:338
NumbMap fixdSpecies_
The names and estimated yields of the fixed species.
Definition: LauSPlot.hh:303
Bool_t calcCovMatrix()
Definition: LauSPlot.cc:874
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:837
TString fileName_
The name of the data file.
Definition: LauSPlot.hh:276
void readInput(Bool_t ok)
Set that the input tree has been successfully read.
Definition: LauSPlot.hh:125
TMatrixD covMat_
The calculated covariance matrix.
Definition: LauSPlot.hh:348
void definedCNBranches(Bool_t defined)
Set that the cN branches have been already defined.
Definition: LauSPlot.hh:149
void addFriendTree()
Add the sWeightTree as a friend tree of the input tree.
Definition: LauSPlot.cc:1246
void definedSWeightBranches(Bool_t defined)
Set that the sWeights branches have been already defined.
Definition: LauSPlot.hh:161
Bool_t definedSWeightBranches() const
Check whether the sWeights branches have been already created.
Definition: LauSPlot.hh:155
Bool_t definedCNBranches() const
Check whether the cN branches have been already created.
Definition: LauSPlot.hh:143
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:351
Bool_t checkLeaves() const
Check whether the leaf structure makes sense given the PDFs we are expecting.
Definition: LauSPlot.cc:189
Int_t nFreeSpecies_
Number of species free to float in the fit.
Definition: LauSPlot.hh:334
std::set< TString > NameSet
Type to store names, e.g. of the discriminating/control variables.
Definition: LauSPlot.hh:59
void defineSWeightBranches()
Create the branches to store the sWeights.
Definition: LauSPlot.cc:424
TTree * inputTree_
Pointer to the input tree.
Definition: LauSPlot.hh:286
Bool_t scfDPSmear() const
Check whether the Self Cross Feed is smeared in the DP.
Definition: LauSPlot.hh:137
NumbMap origFixdSpecies_
The names and estimated yields of the fixed species - need to keep the original values.
Definition: LauSPlot.hh:307