laura is hosted by Hepforge, IPPP Durham
Laura++  v1r0
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  TString fileName_;
272  TString inputTreeName_;
274  TString cnTreeName_;
278  TFile* file_;
280  TTree* inputTree_;
282  TTree* cnTree_;
284  TTree* sweightTree_;
285 
287  TEventList* eventList_;
288 
291 
304 
306  const Bool_t signalSplit_;
308  const Bool_t scfDPSmear_;
309 
311  Bool_t readInput_;
316 
318  Int_t firstExpt_;
320  Int_t nExpt_;
322  Int_t iExpt_;
324  Int_t nEvents_;
326  Int_t nDiscVars_;
332  Int_t nSpecies_;
333 
335  std::vector<NumbMap> pdfTot_;
337  std::vector<std::map<TString,NumbMap> > discPdf_;
339  std::vector<Double_t> scfFrac_;
340 
342  TMatrixD covMat_;
343 
345  std::vector< std::map<TString,NumbMap> > sWeights_;
347  std::map<TString,NumbMap> sWeightsCurrent_;
349  std::map<TString,NumbMap> cN_;
350 
351  ClassDef(LauSPlot, 0)
352 };
353 
354 #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:349
Int_t nDiscVars_
Number of discriminating variables.
Definition: LauSPlot.hh:326
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:335
Bool_t definedSWeightBranches_
Flag whether the sWeights branches have already been created.
Definition: LauSPlot.hh:315
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:330
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:324
void fillCNBranches()
Fill the cN branches.
Definition: LauSPlot.cc:1182
NumbMap freeSpecies_
The names and estimated yields of the free species.
Definition: LauSPlot.hh:295
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:337
TEventList * eventList_
Pointer to an event list, that is used to loop through the experiments.
Definition: LauSPlot.hh:287
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:272
TFile * file_
Pointer to the data file object.
Definition: LauSPlot.hh:278
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:303
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:339
Bool_t readInput_
Flag whether the input tree has been successfully read.
Definition: LauSPlot.hh:311
TString cnTreeName_
The name of the cn tree (containing the cN coefficients)
Definition: LauSPlot.hh:274
Int_t iExpt_
The current experiment.
Definition: LauSPlot.hh:322
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:320
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:299
LeafMap leaves_
Collection to hold pointers to the leaves of the input tree.
Definition: LauSPlot.hh:290
const Bool_t scfDPSmear_
If so then is the SCF smeared in the DP?
Definition: LauSPlot.hh:308
const Bool_t signalSplit_
Is the signal split into TM and SCF?
Definition: LauSPlot.hh:306
TTree * cnTree_
Pointer to the output tree containing the cN coefficients.
Definition: LauSPlot.hh:282
Int_t firstExpt_
First experiment.
Definition: LauSPlot.hh:318
NameSet variableNames_
The names of the discriminating variables.
Definition: LauSPlot.hh:293
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:276
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
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:284
std::map< TString, NumbMap > sWeightsCurrent_
The current-event values of the computed sWeights.
Definition: LauSPlot.hh:347
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:313
Int_t nSpecies_
Total number of species (free + fixed)
Definition: LauSPlot.hh:332
NumbMap fixdSpecies_
The names and estimated yields of the fixed species.
Definition: LauSPlot.hh:297
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:270
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:342
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:345
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:328
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:280
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:301