laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauSimpleFitModel.hh
Go to the documentation of this file.
1 
2 /*
3 Copyright 2004 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 
37 #ifndef LAU_SIMPLE_FIT_MODEL
38 #define LAU_SIMPLE_FIT_MODEL
39 
40 #include "LauAbsFitModel.hh"
41 #include "LauComplex.hh"
42 #include "LauParameter.hh"
43 
44 #include "TString.h"
45 
46 #include <vector>
47 
48 class TH2;
49 class LauAbsBkgndDPModel;
50 class LauAbsCoeffSet;
51 class LauIsobarDynamics;
52 class LauAbsPdf;
53 class LauEffModel;
54 class LauEmbeddedData;
55 class LauKinematics;
56 class LauScfMap;
57 
59 
60  public:
62 
65  explicit LauSimpleFitModel( LauIsobarDynamics* sigDPModel );
66 
68  virtual ~LauSimpleFitModel();
69 
71 
74  virtual void setNSigEvents( LauParameter* nSigEvents );
75 
77 
82  virtual void setNBkgndEvents( LauAbsRValue* nBkgndEvents );
83 
85 
89  void setBkgndDPModel( const TString& bkgndClass, LauAbsBkgndDPModel* bkgndModel );
90 
92 
102  void splitSignalComponent( const TH2* dpHisto,
103  const Bool_t upperHalf = kFALSE,
104  const Bool_t fluctuateBins = kFALSE,
105  LauScfMap* scfMap = 0 );
106 
108 
115  void splitSignalComponent( const Double_t scfFrac, const Bool_t fixed );
116 
118  Bool_t useSCF() const { return useSCF_; }
119 
121  Bool_t useSCFHist() const { return useSCFHist_; }
122 
124  Bool_t smearSCFDP() const { return ( scfMap_ != 0 ); }
125 
127 
130  void setSignalPdf( LauAbsPdf* pdf );
131 
133 
136  void setSCFPdf( LauAbsPdf* pdf );
137 
139 
143  void setBkgndPdf( const TString& bkgndClass, LauAbsPdf* pdf );
144 
146 
153  void embedSignal( const TString& fileName,
154  const TString& treeName,
155  Bool_t reuseEventsWithinEnsemble,
156  Bool_t reuseEventsWithinExperiment = kFALSE,
157  Bool_t useReweighting = kFALSE );
158 
160 
167  void embedBkgnd( const TString& bkgndClass,
168  const TString& fileName,
169  const TString& treeName,
170  Bool_t reuseEventsWithinEnsemble,
171  Bool_t reuseEventsWithinExperiment = kFALSE );
172 
174 
181  virtual void setAmpCoeffSet( LauAbsCoeffSet* coeffSet );
182 
184 
191  virtual std::map<TString, LauComplex> getDPAmps( const Double_t m13Sq, const Double_t m23Sq );
192 
194 
201  virtual std::map<TString, Double_t> getDPLikelihoods( const Double_t m13Sq, const Double_t m23Sq );
202 
203  protected:
205  typedef std::map<TString, std::pair<Int_t, Double_t>> LauGenInfo;
206 
208  typedef std::vector<LauAbsBkgndDPModel*> LauBkgndDPModelList;
209 
211  typedef std::vector<LauPdfPList> LauBkgndPdfsList;
212 
214  typedef std::vector<LauAbsRValue*> LauBkgndYieldList;
215 
217  typedef std::vector<LauEmbeddedData*> LauBkgndEmbDataList;
218 
220  typedef std::vector<Bool_t> LauBkgndReuseEventsList;
221 
223 
227  virtual void weightEvents( const TString& dataFileName, const TString& dataTreeName );
228 
230  virtual void initialise();
231 
233  virtual void initialiseDPModels();
234 
236  virtual void recalculateNormalisation();
237 
239  virtual void updateCoeffs();
240 
242  virtual Bool_t genExpt();
243 
245  virtual void propagateParUpdates();
246 
248  virtual void cacheInputFitVars();
249 
251  virtual void checkInitFitParams();
252 
254 
257  virtual void finaliseFitResults( const TString& tablePrefixName );
258 
260 
263  virtual void printFitFractions( std::ostream& output );
264 
266 
269  virtual void writeOutTable( const TString& outputFile );
270 
272 
275  virtual void savePDFPlots( const TString& label );
276 
278 
282  virtual void savePDFPlotsWave( const TString& label, const Int_t& spin );
283 
285  virtual void storePerEvtLlhds();
286 
287  // Methods to do with calculating the likelihood functions
288  // and manipulating the fitting parameters.
289 
291 
294  virtual Double_t getTotEvtLikelihood( UInt_t iEvt );
295 
297 
300  virtual void getEvtDPLikelihood( UInt_t iEvt );
301 
303 
306  virtual Double_t getEvtSCFDPLikelihood( UInt_t iEvt );
307 
309 
312  virtual void getEvtExtraLikelihoods( UInt_t iEvt );
313 
315 
318  virtual Double_t getEventSum() const;
319 
321  void setSignalDPParameters();
322 
324  void setExtraPdfParameters();
325 
327  void setFitNEvents();
328 
330  void setExtraNtupleVars();
331 
333  void randomiseInitFitPars();
334 
336  virtual void setupBkgndVectors();
337 
339  std::pair<LauGenInfo, Bool_t> eventsToGenerate();
340 
342  Bool_t generateSignalEvent();
343 
345 
348  Bool_t generateBkgndEvent( UInt_t bkgndID );
349 
351  void setupGenNtupleBranches();
352 
354  void setDPBranchValues();
355 
357 
361  void generateExtraPdfValues( LauPdfPList* extraPdfs, LauEmbeddedData* embeddedData );
362 
364 
368  void addSPlotNtupleBranches( const LauPdfPList* extraPdfs, const TString& prefix );
369 
371 
376  Double_t setSPlotNtupleBranchValues( LauPdfPList* extraPdfs, const TString& prefix, UInt_t iEvt );
377 
379  void updateSigEvents();
380 
382  virtual void setupSPlotNtupleBranches();
383 
385  virtual LauSPlot::NameSet variableNames() const;
386 
388  virtual LauSPlot::NumbMap freeSpeciesNames() const;
389 
391  virtual LauSPlot::NumbMap fixdSpeciesNames() const;
392 
394  virtual LauSPlot::TwoDMap twodimPDFs() const;
395 
397  virtual Bool_t splitSignal() const { return this->useSCF(); }
398 
400  virtual Bool_t scfDPSmear() const { return ( scfMap_ != 0 ); }
401 
403 
413  void appendBinCentres( LauFitDataTree* inputData );
414 
415  private:
418 
421 
424 
427 
430 
433 
436 
439 
441  Bool_t usingBkgnd_;
442 
444  UInt_t nSigComp_;
445 
447  UInt_t nSigDPPar_;
448 
451 
453  UInt_t nNormPar_;
454 
456  std::vector<LauAbsCoeffSet*> coeffPars_;
457 
460 
463 
466 
469 
472 
475 
477  Bool_t useSCF_;
478 
480  Bool_t useSCFHist_;
481 
484 
487 
490 
492  std::vector<Double_t> recoSCFFracs_;
493 
495  std::vector<Double_t> fakeSCFFracs_;
496 
498  std::vector<Double_t> recoJacobians_;
499 
501  std::vector<Double_t> fakeJacobians_;
502 
505 
507  std::vector<LauComplex> coeffs_;
508 
509  // Embedding full simulation events
510 
513 
516 
518  Bool_t reuseSignal_;
519 
522 
525 
527  Double_t sigDPLike_;
528 
530  Double_t scfDPLike_;
531 
533  std::vector<Double_t> bkgndDPLike_;
534 
536  Double_t sigExtraLike_;
537 
539  Double_t scfExtraLike_;
540 
542  std::vector<Double_t> bkgndExtraLike_;
543 
545  Double_t sigTotalLike_;
546 
548  Double_t scfTotalLike_;
549 
551  std::vector<Double_t> bkgndTotalLike_;
552 
553  ClassDef( LauSimpleFitModel, 0 ) // Total fit/ToyMC model
554 };
555 
556 #endif
std::map< TString, std::pair< Int_t, Double_t > > LauGenInfo
Define a map to be used to store a category name and numbers.
void splitSignalComponent(const TH2 *dpHisto, const Bool_t upperHalf=kFALSE, const Bool_t fluctuateBins=kFALSE, LauScfMap *scfMap=0)
Split the signal component into well-reconstructed and mis-reconstructed parts.
File containing declaration of LauAbsFitModel class.
virtual Bool_t splitSignal() const
Check if the signal is split into well-reconstructed and mis-reconstructed types.
virtual void weightEvents(const TString &dataFileName, const TString &dataTreeName)
Weight events based on the DP model.
Double_t scfExtraLike_
SCF likelihood from extra PDFs.
virtual void updateCoeffs()
Update the coefficients.
virtual void getEvtDPLikelihood(UInt_t iEvt)
Calculate the signal and background likelihoods for the DP for a given event.
std::vector< Double_t > fakeSCFFracs_
The cached values of the SCF fraction for each bin centre.
Double_t scfDPLike_
SCF likelihood value.
void setSCFPdf(LauAbsPdf *pdf)
Set the SCF PDF for a given variable.
Class for defining the abstract interface for complex coefficient classes.
Class for defining the fit parameter objects.
Definition: LauParameter.hh:49
virtual void setNSigEvents(LauParameter *nSigEvents)
Set the signal event yield.
virtual Double_t getEventSum() const
Get the total number of events.
virtual void finaliseFitResults(const TString &tablePrefixName)
Get the fit results and store them.
Bool_t compareFitData_
Run choice variables.
virtual void initialiseDPModels()
Initialise the signal DP model.
Double_t scfTotalLike_
Total SCF likelihood.
void setBkgndPdf(const TString &bkgndClass, LauAbsPdf *pdf)
Set the background PDF.
Bool_t useSCF() const
Determine whether we are splitting the signal into TM and SCF parts.
virtual void storePerEvtLlhds()
Store the per event likelihood values.
virtual void printFitFractions(std::ostream &output)
Print the fit fractions, total DP rate and mean efficiency.
LauEmbeddedData * signalTree_
The signal event tree.
The abstract interface for a background Dalitz plot model.
LauParameter dpRate_
The average DP rate.
Double_t sigExtraLike_
Signal likelihood from extra PDFs.
LauIsobarDynamics * sigDPModel_
The signal Dalitz plot model.
UInt_t nNormPar_
Number of normalisation parameters (i.e. yields)
std::vector< Double_t > bkgndExtraLike_
Background likelihood value(s) from extra PDFs.
void setExtraPdfParameters()
Set the fit parameters for the extra PDFs.
File containing declaration of LauParameter class.
virtual void cacheInputFitVars()
Read in the input fit data variables, e.g. m13Sq and m23Sq.
std::vector< LauAbsRValue * > LauBkgndYieldList
Typedef for a vector of background yields.
LauEffModel * scfFracHist_
The histogram giving the DP-dependence of the SCF fraction.
void randomiseInitFitPars()
Randomise the initial fit parameters.
void setSignalPdf(LauAbsPdf *pdf)
Set the signal PDF for a given variable.
virtual Double_t getTotEvtLikelihood(UInt_t iEvt)
Get the total likelihood for each event.
virtual LauSPlot::NameSet variableNames() const
Returns the names of all variables in the fit.
void setDPBranchValues()
Store all of the DP information.
virtual std::map< TString, Double_t > getDPLikelihoods(const Double_t m13Sq, const Double_t m23Sq)
Calculate the DP likelihood(s) for a given DP position.
Bool_t smearSCFDP() const
Determine if we are smearing the SCF DP PDF.
Define a Dalitz plot according to the isobar model.
virtual void savePDFPlots(const TString &label)
Save the pdf Plots for all the resonances of experiment number fitExp.
Double_t sigDPLike_
Signal likelihood value.
std::vector< LauAbsCoeffSet * > coeffPars_
Magnitudes and Phases.
LauParArray fitFracEffUnCorr_
Fit fractions (uncorrected for the efficiency)
std::set< TString > NameSet
Type to store names, e.g. of the discriminating/control variables.
Definition: LauSPlot.hh:72
LauBkgndPdfsList bkgndPdfs_
The background PDFs.
UInt_t nSigComp_
Number of signal components.
virtual void recalculateNormalisation()
Recalculate Normalization the signal DP models.
Class to store the input fit variables.
LauBkgndReuseEventsList reuseBkgnd_
Vector of booleans to reuse background events.
LauSimpleFitModel(const LauSimpleFitModel &rhs)
Copy constructor (not implemented)
Bool_t useSCF_
Is the signal split into TM and SCF.
virtual void initialise()
Initialise the fit.
virtual void propagateParUpdates()
Calculate things that depend on the fit parameters after they have been updated by Minuit.
Bool_t useSCFHist_
Is the SCF fraction DP-dependent.
virtual void savePDFPlotsWave(const TString &label, const Int_t &spin)
Save the pdf Plots for the sum of ressonances correspondint to "sin" of experiment number fitExp.
Class that implements the efficiency description across the signal Dalitz plot.
Definition: LauEffModel.hh:50
std::vector< Double_t > fakeJacobians_
The cached values of the sqDP jacobians for each true bin.
std::vector< Double_t > bkgndTotalLike_
Total background likelihood(s)
Bool_t useReweighting_
Boolean to use reweighting.
virtual LauSPlot::TwoDMap twodimPDFs() const
Returns the species and variables for all 2D PDFs in the fit.
LauSimpleFitModel & operator=(const LauSimpleFitModel &rhs)
Copy assignment operator (not implemented)
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 generateExtraPdfValues(LauPdfPList *extraPdfs, LauEmbeddedData *embeddedData)
Generate from the extra PDFs.
void embedBkgnd(const TString &bkgndClass, const TString &fileName, const TString &treeName, Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment=kFALSE)
Embed full simulation events for the given background class, rather than generating toy from the PDFs...
std::vector< Double_t > recoSCFFracs_
The cached values of the SCF fraction for each event.
std::vector< LauComplex > coeffs_
The complex coefficients.
virtual Double_t getEvtSCFDPLikelihood(UInt_t iEvt)
Calculate the SCF likelihood for the DP for a given event.
Double_t setSPlotNtupleBranchValues(LauPdfPList *extraPdfs, const TString &prefix, UInt_t iEvt)
Set the branches for the sPlot ntuple with extra PDFs.
File containing declaration of LauComplex class.
virtual LauSPlot::NumbMap freeSpeciesNames() const
Returns the names and yields of species that are free in the fit.
Bool_t generateBkgndEvent(UInt_t bkgndID)
Generate background event.
LauParameter scfFrac_
The (global) SCF fraction parameter.
std::vector< std::vector< LauParameter > > LauParArray
Type to define an array of parameters.
std::vector< Double_t > bkgndDPLike_
Background likelihood value(s)
virtual Bool_t scfDPSmear() const
Check if the mis-reconstructed signal is to be smeared in the DP.
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:54
LauSimpleFitModel(LauIsobarDynamics *sigDPModel)
Constructor.
LauBkgndYieldList bkgndEvents_
Background yield(s)
virtual LauSPlot::NumbMap fixdSpeciesNames() const
Returns the names and yields of species that are fixed in the fit.
void setupGenNtupleBranches()
Setup the required ntuple branches.
void setExtraNtupleVars()
Set-up other parameters that are derived from the fit results, e.g. fit fractions.
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:45
std::vector< Bool_t > LauBkgndReuseEventsList
Typedef for a vector of booleans to flag if events are reused.
Double_t sigTotalLike_
Total signal likelihood.
Bool_t useSCFHist() const
Determine whether the SCF fraction is DP-dependent.
virtual ~LauSimpleFitModel()
Destructor.
Class for representing the 4D smearing matrix for mis-reconstructed signal (self cross feed)
Definition: LauScfMap.hh:45
virtual Bool_t genExpt()
Toy MC generation and fitting overloaded functions.
void setFitNEvents()
Set the initial yields.
void updateSigEvents()
Update the signal events after Minuit sets background parameters.
virtual void getEvtExtraLikelihoods(UInt_t iEvt)
Determine the signal and background likelihood for the extra variables for a given event.
LauKinematics * kinematics_
The Dalitz plot kinematics object.
std::pair< LauGenInfo, Bool_t > eventsToGenerate()
Determine the number of events to generate for each hypothesis.
LauPdfPList scfPdfs_
The SCF PDFs.
LauBkgndEmbDataList bkgndTree_
The background event tree.
void appendBinCentres(LauFitDataTree *inputData)
Append fake data points to the inputData for each bin in the SCF smearing matrix.
virtual void setupBkgndVectors()
Define the length of the background vectors.
virtual void checkInitFitParams()
Check the initial fit parameters.
virtual void setupSPlotNtupleBranches()
Add branches to store experiment number and the event number within the experiment.
void setSignalDPParameters()
Set the fit parameters for the DP model.
virtual void setNBkgndEvents(LauAbsRValue *nBkgndEvents)
Set the background event yield(s)
void embedSignal(const TString &fileName, const TString &treeName, Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment=kFALSE, Bool_t useReweighting=kFALSE)
Embed full simulation events for the signal, rather than generating toy from the PDFs.
void setBkgndDPModel(const TString &bkgndClass, LauAbsBkgndDPModel *bkgndModel)
Set the background DP models.
Bool_t reuseSignal_
Boolean to reuse signal events.
void addSPlotNtupleBranches(const LauPdfPList *extraPdfs, const TString &prefix)
Add sPlot branches for the extra PDFs.
LauBkgndDPModelList bkgndDPModels_
The background Dalitz Plot model.
std::vector< LauPdfPList > LauBkgndPdfsList
Typedef for a vector of background PDFs.
LauScfMap * scfMap_
The smearing matrix for the SCF DP PDF.
Class for calculating 3-body kinematic quantities.
std::vector< LauAbsBkgndDPModel * > LauBkgndDPModelList
Typedef for a vector of background DP models.
Bool_t generateSignalEvent()
Generate signal event.
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
LauParameter meanEff_
The mean efficiency.
Class to store the data for embedding in toy experiments.
Bool_t usingBkgnd_
Background boolean.
Class for defining signal dynamics using the isobar model.
std::vector< LauEmbeddedData * > LauBkgndEmbDataList
Typedef for a vector of embedded data objects.
UInt_t nSigDPPar_
Number of signal DP parameters.
Abstract interface to the fitting and toy MC model.
LauParArray fitFrac_
Fit fractions.
LauPdfPList signalPdfs_
The signal PDFs.
UInt_t nExtraPdfPar_
Number of extra PDF parameters.
virtual void setAmpCoeffSet(LauAbsCoeffSet *coeffSet)
Set the DP amplitude coefficients.
virtual void writeOutTable(const TString &outputFile)
Write the fit results in latex table format.
std::vector< LauAbsPdf * > LauPdfPList
List of Pdfs.
virtual std::map< TString, LauComplex > getDPAmps(const Double_t m13Sq, const Double_t m23Sq)
Calculate the DP amplitude(s) for a given DP position.
std::vector< Double_t > recoJacobians_
The cached values of the sqDP jacobians for each event.
LauParameter * signalEvents_
Signal yield.