laura is hosted by Hepforge, IPPP Durham
Laura++  v1r0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauSimpleFitModel.hh
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2004 - 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 
23 #ifndef LAU_SIMPLE_FIT_MODEL
24 #define LAU_SIMPLE_FIT_MODEL
25 
26 #include <vector>
27 
28 #include "TString.h"
29 
30 #include "LauAbsFitModel.hh"
31 #include "LauParameter.hh"
32 
33 class TH2;
34 class LauAbsBkgndDPModel;
35 class LauAbsCoeffSet;
36 class LauAbsDPDynamics;
37 class LauAbsPdf;
38 class LauEffModel;
39 class LauEmbeddedData;
40 class LauKinematics;
41 class LauScfMap;
42 
43 
45 
46  public:
48 
51  explicit LauSimpleFitModel(LauAbsDPDynamics* sigDPModel);
52 
54  virtual ~LauSimpleFitModel();
55 
57 
61  virtual void setNSigEvents(Double_t nSigEvents, Bool_t fixSigEvents = kFALSE);
62 
64 
69  virtual void setNBkgndEvents(const TString& bkgndClass, Double_t nBkgndEvents, Bool_t fixBkgndEvents = kFALSE);
70 
72 
76  void setBkgndDPModel(const TString& bkgndClass, LauAbsBkgndDPModel* bkgndModel);
77 
79 
88  void splitSignalComponent( const TH2* dpHisto, Bool_t upperHalf = kFALSE, LauScfMap* scfMap = 0 );
89 
91 
98  void splitSignalComponent( Double_t scfFrac, Bool_t fixed );
99 
101  Bool_t useSCF() const { return useSCF_; }
102 
104  Bool_t useSCFHist() const { return useSCFHist_; }
105 
107  Bool_t smearSCFDP() const { return (scfMap_ != 0); }
108 
110 
113  void setSignalPdf(LauAbsPdf* pdf);
114 
116 
119  void setSCFPdf(LauAbsPdf* pdf);
120 
122 
126  void setBkgndPdf(const TString& bkgndClass, LauAbsPdf* pdf);
127 
129 
136  void embedSignal(const TString& fileName, const TString& treeName,
137  Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment = kFALSE,
138  Bool_t useReweighting = kFALSE);
139 
141 
148  void embedBkgnd(const TString& bkgndClass, const TString& fileName, const TString& treeName,
149  Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment = kFALSE);
150 
152 
155  virtual void setAmpCoeffSet(LauAbsCoeffSet* coeffSet);
156 
158 
162  virtual void weightEvents( const TString& dataFileName, const TString& dataTreeName );
163 
164  protected:
166  typedef std::map< TString, std::pair<Int_t,Double_t> > LauGenInfo;
167 
169  typedef std::vector<LauAbsBkgndDPModel*> LauBkgndDPModelList;
170 
172  typedef std::vector<LauPdfList> LauBkgndPdfsList;
173 
175  typedef std::vector<LauParameter> LauBkgndYieldList;
176 
178  typedef std::vector<LauEmbeddedData*> LauBkgndEmbDataList;
179 
181  typedef std::vector<Bool_t> LauBkgndReuseEventsList;
182 
184  virtual void initialise();
185 
187  virtual void initialiseDPModels();
188 
190  virtual void updateCoeffs();
191 
193  virtual Bool_t genExpt();
194 
197  virtual void propagateParUpdates();
198 
200  virtual void cacheInputFitVars();
201 
203  virtual void checkInitFitParams();
204 
206 
209  virtual void finaliseFitResults(const TString& tablePrefixName);
210 
212 
215  virtual void printFitFractions(std::ostream& output);
216 
218 
221  virtual void writeOutTable(const TString& outputFile);
222 
224  virtual void storePerEvtLlhds();
225 
226  // Methods to do with calculating the likelihood functions
227  // and manipulating the fitting parameters.
229 
232  virtual Double_t getTotEvtLikelihood(UInt_t iEvt);
233 
235 
238  virtual void getEvtDPLikelihood(UInt_t iEvt);
239 
241 
244  virtual Double_t getEvtSCFDPLikelihood(UInt_t iEvt);
245 
247 
250  virtual void getEvtExtraLikelihoods(UInt_t iEvt);
251 
253 
256  virtual Double_t getEventSum() const;
257 
259  void setSignalDPParameters();
260 
262  void setExtraPdfParameters();
263 
265  void setFitNEvents();
266 
268  void setExtraNtupleVars();
269 
271  void randomiseInitFitPars();
272 
274  virtual void setupBkgndVectors();
275 
278 
280  Bool_t generateSignalEvent();
281 
283 
286  Bool_t generateBkgndEvent(UInt_t bkgndID);
287 
289  void setupGenNtupleBranches();
290 
292  void setDPBranchValues();
293 
295 
299  void generateExtraPdfValues(LauPdfList* extraPdfs, LauEmbeddedData* embeddedData);
300 
302 
306  void addSPlotNtupleBranches(const LauPdfList* extraPdfs, const TString& prefix);
307 
309 
314  Double_t setSPlotNtupleBranchValues(LauPdfList* extraPdfs, const TString& prefix, UInt_t iEvt);
315 
317  void updateSigEvents();
318 
320  virtual void setupSPlotNtupleBranches();
321 
323  virtual LauSPlot::NameSet variableNames() const;
324 
326  virtual LauSPlot::NumbMap freeSpeciesNames() const;
327 
329  virtual LauSPlot::NumbMap fixdSpeciesNames() const;
330 
332  virtual LauSPlot::TwoDMap twodimPDFs() const;
333 
335  virtual Bool_t splitSignal() const {return this->useSCF();}
336 
338  virtual Bool_t scfDPSmear() const {return (scfMap_ != 0);}
339 
346 
349  void appendBinCentres( LauFitDataTree* inputData );
350 
351  private:
354 
357 
360 
363 
366 
369 
371  Bool_t usingBkgnd_;
372 
374  UInt_t nSigComp_;
375 
377  UInt_t nSigDPPar_;
378 
380  UInt_t nExtraPdfPar_;
381 
383  UInt_t nNormPar_;
384 
386  std::vector<LauAbsCoeffSet*> coeffPars_;
387 
390 
393 
396 
399 
402 
404  Bool_t useSCF_;
405 
407  Bool_t useSCFHist_;
408 
411 
414 
417 
419  std::vector<Double_t> recoSCFFracs_;
420 
422  std::vector<Double_t> fakeSCFFracs_;
423 
425  std::vector<Double_t> recoJacobians_;
426 
428  std::vector<Double_t> fakeJacobians_;
429 
432 
434  std::vector<LauComplex> coeffs_;
435 
436  // Embedding SP events
439 
442 
444  Bool_t reuseSignal_;
445 
448 
451 
453  Double_t sigDPLike_;
454 
456  Double_t scfDPLike_;
457 
459  std::vector<Double_t> bkgndDPLike_;
460 
462  Double_t sigExtraLike_;
463 
465  Double_t scfExtraLike_;
466 
468  std::vector<Double_t> bkgndExtraLike_;
469 
471  Double_t sigTotalLike_;
472 
474  Double_t scfTotalLike_;
475 
477  std::vector<Double_t> bkgndTotalLike_;
478 
479  ClassDef(LauSimpleFitModel,0) // Total fit/ToyMC model
480 
481 };
482 
483 #endif
void setSignalPdf(LauAbsPdf *pdf)
Set the signal PDF for a given variable.
LauAbsDPDynamics * sigDPModel_
The signal Dalitz plot model.
void setBkgndDPModel(const TString &bkgndClass, LauAbsBkgndDPModel *bkgndModel)
Set the background DP models.
Bool_t reuseSignal_
Boolean to reuse signal events.
Bool_t useSCFHist() const
Determine whether the SCF fraction is DP-dependent.
void setDPBranchValues()
Store all of the DP information.
Class for defining the abstract interface for signal Dalitz plot dynamics.
The abstract interface for a background Dalitz plot model.
LauParameter meanEff_
The mean efficiency.
Double_t sigExtraLike_
Signal likelihood from extra PDFs.
Bool_t useSCF() const
Determine whether we are splitting the signal into TM and SCF parts.
Double_t sigDPLike_
Signal likelihood value.
void randomiseInitFitPars()
Randomise the initial fit parameters.
LauSimpleFitModel(LauAbsDPDynamics *sigDPModel)
Constructor.
LauEffModel * scfFracHist_
The histogram giving the DP-dependence of the SCF fraction.
virtual void setNBkgndEvents(const TString &bkgndClass, Double_t nBkgndEvents, Bool_t fixBkgndEvents=kFALSE)
Set the background event yield(s)
std::vector< LauParameter > LauBkgndYieldList
Typedef for a vector of background yields.
virtual Double_t getTotEvtLikelihood(UInt_t iEvt)
Get the total likelihood for each event.
virtual void setNSigEvents(Double_t nSigEvents, Bool_t fixSigEvents=kFALSE)
Set the signal event yield.
File containing declaration of LauAbsFitModel class.
std::vector< Double_t > recoJacobians_
The cached values of the sqDP jacobians for each event.
void generateExtraPdfValues(LauPdfList *extraPdfs, LauEmbeddedData *embeddedData)
Generate from the extra PDFs.
virtual void initialise()
Initialise the fit.
std::map< TString, std::pair< Int_t, Double_t > > LauGenInfo
Define a map to be used to store a category name and numbers.
Bool_t smearSCFDP() const
Determine if we are smearing the SCF DP PDF.
virtual void weightEvents(const TString &dataFileName, const TString &dataTreeName)
Weight events based on the DP model.
virtual void setAmpCoeffSet(LauAbsCoeffSet *coeffSet)
Set the DP amplitude coefficients.
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
UInt_t nExtraPdfPar_
Number of extra PDF parameters.
Double_t scfDPLike_
SCF likelihood value.
std::vector< LauPdfList > LauBkgndPdfsList
Typedef for a vector of background PDFs.
virtual void finaliseFitResults(const TString &tablePrefixName)
Get the fit results and store them.
virtual void propagateParUpdates()
Bool_t useSCFHist_
Is the SCF fraction DP-dependent.
LauBkgndReuseEventsList reuseBkgnd_
Vector of booleans to reuse background events.
virtual Bool_t scfDPSmear() const
Check if the mis-reconstructed signal is to be smeared in the DP.
std::vector< std::vector< LauParameter > > LauParArray
Type to define an array of parameters.
void setBkgndPdf(const TString &bkgndClass, LauAbsPdf *pdf)
Set the background PDF.
std::vector< LauAbsPdf * > LauPdfList
List of 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.
LauEmbeddedData * signalTree_
The signal event tree.
void setSCFPdf(LauAbsPdf *pdf)
Set the SCF PDF for a given variable.
Bool_t useReweighting_
Boolean to use reweighting.
virtual void printFitFractions(std::ostream &output)
Print the fit fractions, total DP rate and mean efficiency.
void addSPlotNtupleBranches(const LauPdfList *extraPdfs, const TString &prefix)
Add sPlot branches for the extra PDFs.
virtual LauSPlot::TwoDMap twodimPDFs() const
Returns the species and variables for all 2D PDFs in the fit.
std::vector< LauComplex > coeffs_
The complex coefficients.
std::vector< Double_t > bkgndExtraLike_
Background likelihood value(s) from extra PDFs.
LauBkgndYieldList bkgndEvents_
Background yield(s)
LauPdfList signalPdfs_
The signal PDFs.
void setExtraPdfParameters()
Set the fit parameters for the extra PDFs.
Bool_t generateBkgndEvent(UInt_t bkgndID)
Generate background event.
Double_t scfTotalLike_
Total SCF likelihood.
virtual Bool_t splitSignal() const
Check if the signal is split into well-reconstructed and mis-reconstructed types. ...
void updateSigEvents()
Update the signal events after Minuit sets background parameters.
virtual LauSPlot::NumbMap fixdSpeciesNames() const
Returns the names and yields of species that are fixed in the fit.
LauParameter dpRate_
The average DP rate.
std::vector< Double_t > bkgndDPLike_
Background likelihood value(s)
UInt_t nNormPar_
Number of parameters.
void setupGenNtupleBranches()
Setup the required ntuple branches.
void appendBinCentres(LauFitDataTree *inputData)
virtual void cacheInputFitVars()
Read in the input fit data variables, e.g. m13Sq and m23Sq.
Abstract interface to the fitting and toy MC model.
void setSignalDPParameters()
Set the fit parameters for the DP model.
std::vector< LauAbsCoeffSet * > coeffPars_
Magnitudes and Phases.
virtual LauSPlot::NumbMap freeSpeciesNames() const
Returns the names and yields of species that are free in the fit.
virtual LauSPlot::NameSet variableNames() const
Returns the names of all variables in the fit.
File containing declaration of LauParameter class.
virtual void getEvtExtraLikelihoods(UInt_t iEvt)
Determine the signal and background likelihood for the extra variables for a given event...
LauBkgndPdfsList bkgndPdfs_
The background PDFs.
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
std::vector< LauAbsBkgndDPModel * > LauBkgndDPModelList
Typedef for a vector of background DP models.
Bool_t useSCF_
Is the signal split into TM and SCF.
void splitSignalComponent(const TH2 *dpHisto, Bool_t upperHalf=kFALSE, LauScfMap *scfMap=0)
Split the signal component into well-reconstructed and mis-reconstructed parts.
virtual void setupBkgndVectors()
Define the length of the background vectors.
LauGenInfo eventsToGenerate()
Determine the number of events to generate for each hypothesis.
Class for defining the abstract interface for complex coefficient classes.
std::vector< Double_t > fakeJacobians_
The cached values of the sqDP jacobians for each true bin.
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.
std::vector< Double_t > bkgndTotalLike_
Total background likelihood(s)
Class for defining the fit parameter objects.
Definition: LauParameter.hh:31
LauBkgndDPModelList bkgndDPModels_
The background Dalitz Plot model.
Class to store the data for embedding in toy experiments.
LauScfMap * scfMap_
The smearing matrix for the SCF DP PDF.
UInt_t nSigComp_
Number of signal components.
virtual Double_t getEvtSCFDPLikelihood(UInt_t iEvt)
Calculate the SCF likelihood for the DP for a given event.
Double_t setSPlotNtupleBranchValues(LauPdfList *extraPdfs, const TString &prefix, UInt_t iEvt)
Set the branches for the sPlot ntuple with extra PDFs.
virtual void writeOutTable(const TString &outputFile)
Write the fit results in latex table format.
Define a Dalitz plot according to the isobar model.
LauPdfList scfPdfs_
The SCF PDFs.
Class that implements the efficiency description across the signal Dalitz plot.
Definition: LauEffModel.hh:37
Bool_t usingBkgnd_
Background boolean.
std::vector< LauEmbeddedData * > LauBkgndEmbDataList
Typedef for a vector of embedded data objects.
std::vector< Double_t > recoSCFFracs_
The cached values of the SCF fraction for each event.
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...
Double_t scfExtraLike_
SCF likelihood from extra PDFs.
UInt_t nSigDPPar_
Number of signal DP parameters.
LauParameter signalEvents_
Signal yield.
std::vector< Double_t > fakeSCFFracs_
The cached values of the SCF fraction for each bin centre.
LauParArray fitFrac_
Fit fractions.
Double_t sigTotalLike_
Total signal likelihood.
Class for representing the 4D smearing matrix for mis-reconstructed signal (self cross feed) ...
Definition: LauScfMap.hh:29
LauParameter scfFrac_
The (global) SCF fraction parameter.
virtual ~LauSimpleFitModel()
Destructor.
Bool_t compareFitData_
Run choice variables.
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:40
Class for calculating 3-body kinematic quantities.
virtual void setupSPlotNtupleBranches()
Add branches to store experiment number and the event number within the experiment.
virtual void checkInitFitParams()
Check the initial fit parameters.
void setExtraNtupleVars()
Set-up other parameters that are derived from the fit results, e.g. fit fractions.
virtual void storePerEvtLlhds()
Store the per event likelihood values.
std::vector< Bool_t > LauBkgndReuseEventsList
Typedef for a vector of booleans to flag if events are reused.
virtual Bool_t genExpt()
Toy MC generation and fitting overloaded functions.
void setFitNEvents()
Set the initial yields.
virtual Double_t getEventSum() const
Get the total number of events.
LauKinematics * kinematics_
The Dalitz plot kinematics object.
Class to store the input fit variables.
std::set< TString > NameSet
Type to store names, e.g. of the discriminating/control variables.
Definition: LauSPlot.hh:59
virtual void initialiseDPModels()
Initialise the signal DP model.
LauBkgndEmbDataList bkgndTree_
The background event tree.
Bool_t generateSignalEvent()
Generate signal event.