laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
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 "TMatrixD.h"
57 #include "TString.h"
58 
59 #include <map>
60 #include <set>
61 #include <vector>
62 
63 class TEventList;
64 class TLeaf;
65 class TFile;
66 class TTree;
67 
68 class LauSPlot : public TObject {
69 
70  public:
72  typedef std::set<TString> NameSet;
73 
75  typedef std::map<TString, Double_t> NumbMap;
76 
78  typedef std::map<TString, TLeaf*> LeafMap;
79 
81  typedef std::multimap<TString, std::pair<TString, TString>> TwoDMap;
82 
84 
96  LauSPlot( const TString& fileName,
97  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
Int_t nDiscVars_
Number of discriminating variables.
Definition: LauSPlot.hh:346
const Bool_t signalSplit_
Is the signal split into TM and SCF?
Definition: LauSPlot.hh:326
void calcSWeights(const TString &exclName, Double_t *covmat=0)
Computes the sWeights from the PDFs and covariance matrix.
Definition: LauSPlot.cc:1271
Int_t nEvents_
Number of events in current experiment.
Definition: LauSPlot.hh:344
void defineSWeightBranches()
Create the branches to store the sWeights.
Definition: LauSPlot.cc:471
void readInput(Bool_t ok)
Set that the input tree has been successfully read.
Definition: LauSPlot.hh:139
TString sweightTreeName_
The name of the sweight tree (containing the sWeights)
Definition: LauSPlot.hh:296
TTree * cnTree_
Pointer to the output tree containing the cN coefficients.
Definition: LauSPlot.hh:302
Bool_t checkLeaves() const
Check whether the leaf structure makes sense given the PDFs we are expecting.
Definition: LauSPlot.cc:208
std::vector< Double_t > scfFrac_
The per-event values of the SCF fraction.
Definition: LauSPlot.hh:359
void printSumOfWeights(const TString &exclName) const
Print the sum of sWeights for all species.
Definition: LauSPlot.cc:951
std::map< TString, NumbMap > sWeightsCurrent_
The current-event values of the computed sWeights.
Definition: LauSPlot.hh:367
void readExpt()
Reads the values of each PDF likelihood for every event in the experiment.
Definition: LauSPlot.cc:553
void runCalculations(const TString &option="q")
Method to calculate the sWeights and cN coeffs.
Definition: LauSPlot.cc:703
Bool_t readInput_
Flag whether the input tree has been successfully read.
Definition: LauSPlot.hh:331
void checkFitter() const
Make sure that we're using Minuit.
Definition: LauSPlot.cc:804
Int_t nExpt_
Number of experiments.
Definition: LauSPlot.hh:340
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
void openInputFileAndTree()
Method to open the file in "update" mode and grab the input tree for reading.
Definition: LauSPlot.cc:122
Bool_t scfDPSmear() const
Check whether the Self Cross Feed is smeared in the DP.
Definition: LauSPlot.hh:151
void readInputInfo()
Read the leaf structure from the tree and check the status of the read (calls LauSPlot::readInputLeav...
Definition: LauSPlot.cc:147
void definedCNBranches(Bool_t defined)
Set that the cN branches have been already defined.
Definition: LauSPlot.hh:163
Int_t nFreeSpecies_
Number of species free to float in the fit.
Definition: LauSPlot.hh:348
void retrieveFittedParameters(const TString &opt)
Update the yields with the newly fitted values and print them (unless print option is "Q").
Definition: LauSPlot.cc:925
void defineCNBranches()
Create the branches for each cN coefficient.
Definition: LauSPlot.cc:426
std::set< TString > NameSet
Type to store names, e.g. of the discriminating/control variables.
Definition: LauSPlot.hh:72
TString cnTreeName_
The name of the cn tree (containing the cN coefficients)
Definition: LauSPlot.hh:294
TwoDMap twodimPDFs_
The names of the species that have 2D PDFs and the names of the variables involved.
Definition: LauSPlot.hh:323
Bool_t readInputLeaves()
Read the leaf structure from the tree and setup the leaf map.
Definition: LauSPlot.cc:163
std::map< TString, TLeaf * > LeafMap
Type to associate a variable name with the leaf of the input tree.
Definition: LauSPlot.hh:78
void addFriendTree()
Add the sWeightTree as a friend tree of the input tree.
Definition: LauSPlot.cc:1384
std::vector< NumbMap > pdfTot_
The per-event values of the total PDF for each species.
Definition: LauSPlot.hh:355
void createSWeightTree()
Create (if not already done) the tree for storing the sWeights.
Definition: LauSPlot.cc:412
TTree * inputTree_
Pointer to the input tree.
Definition: LauSPlot.hh:300
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:75
void calcTotPDFValues(const TString &exclName)
Calculate the total likelihood for each species by multiply together all the PDFs for that species.
Definition: LauSPlot.cc:1030
Int_t firstExpt_
First experiment.
Definition: LauSPlot.hh:338
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:1344
void initialiseFitter(const TString &opt)
Initialise Minuit, set the verbosity.
Definition: LauSPlot.cc:818
NumbMap origFixdSpecies_
The names and estimated yields of the fixed species - need to keep the original values.
Definition: LauSPlot.hh:321
Class for defining the SPlot technique.
Definition: LauSPlot.hh:68
TString fileName_
The name of the data file.
Definition: LauSPlot.hh:290
const std::vector< LauSPlot::NumbMap > & totalPdf() const
Access the per-event total PDF values for each species.
Definition: LauSPlot.hh:126
void runFit()
Perform the minimisation wrt the yields alone.
Definition: LauSPlot.cc:876
virtual ~LauSPlot()
Destructor.
Definition: LauSPlot.cc:106
TFile * file_
Pointer to the data file object.
Definition: LauSPlot.hh:298
NumbMap freeSpecies_
The names and estimated yields of the free species.
Definition: LauSPlot.hh:315
Bool_t definedSWeightBranches_
Flag whether the sWeights branches have already been created.
Definition: LauSPlot.hh:335
TTree * sweightTree_
Pointer to the output tree containing the sWeights.
Definition: LauSPlot.hh:304
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:59
Bool_t definedCNBranches() const
Check whether the cN branches have been already created.
Definition: LauSPlot.hh:157
LauSPlot & operator=(const LauSPlot &rhs)
Copy assignment operator (not implemented)
void fillCNBranches()
Fill the cN branches.
Definition: LauSPlot.cc:1312
void definedSWeightBranches(Bool_t defined)
Set that the sWeights branches have been already defined.
Definition: LauSPlot.hh:175
Bool_t calcCovMatrix()
Definition: LauSPlot.cc:967
Int_t iExpt_
The current experiment.
Definition: LauSPlot.hh:342
Bool_t readInput() const
Check whether the input tree has been successfully read.
Definition: LauSPlot.hh:133
TString inputTreeName_
The name of the input tree (containing the per-event llhds)
Definition: LauSPlot.hh:292
void fillSWeightBranches()
Fill the sWeights branches.
Definition: LauSPlot.cc:1323
Bool_t definedSWeightBranches() const
Check whether the sWeights branches have been already created.
Definition: LauSPlot.hh:169
void createCNTree()
Create (if not already done) the tree for storing the cN coeffs.
Definition: LauSPlot.cc:398
LauSPlot(const LauSPlot &rhs)
Copy constructor (not implemented)
void setFitParameters() const
Add the species yields as fit parameters and fix them as appropriate.
Definition: LauSPlot.cc:844
NameSet variableNames_
The names of the discriminating variables.
Definition: LauSPlot.hh:313
TMatrixD covMat_
The calculated covariance matrix.
Definition: LauSPlot.hh:362
Bool_t definedCNBranches_
Flag whether the cN branches have already been created.
Definition: LauSPlot.hh:333
NumbMap fixdSpecies_
The names and estimated yields of the fixed species.
Definition: LauSPlot.hh:317
Int_t nFixdSpecies_
Number of species fixed in the fit.
Definition: LauSPlot.hh:350
TEventList * eventList_
Pointer to an event list, that is used to loop through the experiments.
Definition: LauSPlot.hh:307
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
void writeOutResults()
Save the sWeight results as a friend tree to the input tree (in the same file)
Definition: LauSPlot.cc:1359
NumbMap origFreeSpecies_
The names and estimated yields of the free species - need to keep the original values.
Definition: LauSPlot.hh:319
Int_t nSpecies_
Total number of species (free + fixed)
Definition: LauSPlot.hh:352
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:898
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:81
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
std::map< TString, NumbMap > cN_
The extended sPlot coefficients (for each species and for each combination of excluded vars)
Definition: LauSPlot.hh:369
void calcCNCoeffs(const TString &exclName, const Double_t *covmat=0)
Computes the cN for the extended sPlots from the covariance matrix.
Definition: LauSPlot.cc:1243
Bool_t signalSplit() const
Check whether the signal is split into Truth Matched and Self Cross Feed.
Definition: LauSPlot.hh:145
void setExperiment(Int_t iExpt)
Set the event list to contain only events from the given experiment.
Definition: LauSPlot.cc:514