laura is hosted by Hepforge, IPPP Durham
Laura++  v3r5
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 <vector>
41 
42 #include "TString.h"
43 
44 #include "LauAbsFitModel.hh"
45 #include "LauComplex.hh"
46 #include "LauParameter.hh"
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 
58 
60 
61  public:
63 
66  explicit LauSimpleFitModel(LauIsobarDynamics* sigDPModel);
67 
69  virtual ~LauSimpleFitModel();
70 
72 
75  virtual void setNSigEvents(LauParameter* nSigEvents);
76 
78 
83  virtual void setNBkgndEvents(LauAbsRValue* nBkgndEvents);
84 
86 
90  void setBkgndDPModel(const TString& bkgndClass, LauAbsBkgndDPModel* bkgndModel);
91 
93 
103  void splitSignalComponent( const TH2* dpHisto, const Bool_t upperHalf = kFALSE, const Bool_t fluctuateBins = kFALSE, LauScfMap* scfMap = 0 );
104 
106 
113  void splitSignalComponent( const Double_t scfFrac, const Bool_t fixed );
114 
116  Bool_t useSCF() const { return useSCF_; }
117 
119  Bool_t useSCFHist() const { return useSCFHist_; }
120 
122  Bool_t smearSCFDP() const { return (scfMap_ != 0); }
123 
125 
128  void setSignalPdf(LauAbsPdf* pdf);
129 
131 
134  void setSCFPdf(LauAbsPdf* pdf);
135 
137 
141  void setBkgndPdf(const TString& bkgndClass, LauAbsPdf* pdf);
142 
144 
151  void embedSignal(const TString& fileName, const TString& treeName,
152  Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment = kFALSE,
153  Bool_t useReweighting = kFALSE);
154 
156 
163  void embedBkgnd(const TString& bkgndClass, const TString& fileName, const TString& treeName,
164  Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment = kFALSE);
165 
167 
174  virtual void setAmpCoeffSet(LauAbsCoeffSet* coeffSet);
175 
176  protected:
178  typedef std::map< TString, std::pair<Int_t,Double_t> > LauGenInfo;
179 
181  typedef std::vector<LauAbsBkgndDPModel*> LauBkgndDPModelList;
182 
184  typedef std::vector<LauPdfList> LauBkgndPdfsList;
185 
187  typedef std::vector<LauAbsRValue*> LauBkgndYieldList;
188 
190  typedef std::vector<LauEmbeddedData*> LauBkgndEmbDataList;
191 
193  typedef std::vector<Bool_t> LauBkgndReuseEventsList;
194 
196 
200  virtual void weightEvents( const TString& dataFileName, const TString& dataTreeName );
201 
203  virtual void initialise();
204 
206  virtual void initialiseDPModels();
207 
209  virtual void recalculateNormalisation();
210 
212  virtual void updateCoeffs();
213 
215  virtual Bool_t genExpt();
216 
218  virtual void propagateParUpdates();
219 
221  virtual void cacheInputFitVars();
222 
224  virtual void checkInitFitParams();
225 
227 
230  virtual void finaliseFitResults(const TString& tablePrefixName);
231 
233 
236  virtual void printFitFractions(std::ostream& output);
237 
239 
242  virtual void writeOutTable(const TString& outputFile);
243 
245 
248  virtual void savePDFPlots(const TString& label);
249 
251 
255  virtual void savePDFPlotsWave(const TString& label, const Int_t& spin);
256 
258  virtual void storePerEvtLlhds();
259 
260  // Methods to do with calculating the likelihood functions
261  // and manipulating the fitting parameters.
262 
264 
267  virtual Double_t getTotEvtLikelihood(UInt_t iEvt);
268 
270 
273  virtual void getEvtDPLikelihood(UInt_t iEvt);
274 
276 
279  virtual Double_t getEvtSCFDPLikelihood(UInt_t iEvt);
280 
282 
285  virtual void getEvtExtraLikelihoods(UInt_t iEvt);
286 
288 
291  virtual Double_t getEventSum() const;
292 
294  void setSignalDPParameters();
295 
297  void setExtraPdfParameters();
298 
300  void setFitNEvents();
301 
303  void setExtraNtupleVars();
304 
306  void randomiseInitFitPars();
307 
309  virtual void setupBkgndVectors();
310 
312  std::pair<LauGenInfo,Bool_t> eventsToGenerate();
313 
315  Bool_t generateSignalEvent();
316 
318 
321  Bool_t generateBkgndEvent(UInt_t bkgndID);
322 
324  void setupGenNtupleBranches();
325 
327  void setDPBranchValues();
328 
330 
334  void generateExtraPdfValues(LauPdfList* extraPdfs, LauEmbeddedData* embeddedData);
335 
337 
341  void addSPlotNtupleBranches(const LauPdfList* extraPdfs, const TString& prefix);
342 
344 
349  Double_t setSPlotNtupleBranchValues(LauPdfList* extraPdfs, const TString& prefix, UInt_t iEvt);
350 
352  void updateSigEvents();
353 
355  virtual void setupSPlotNtupleBranches();
356 
358  virtual LauSPlot::NameSet variableNames() const;
359 
361  virtual LauSPlot::NumbMap freeSpeciesNames() const;
362 
364  virtual LauSPlot::NumbMap fixdSpeciesNames() const;
365 
367  virtual LauSPlot::TwoDMap twodimPDFs() const;
368 
370  virtual Bool_t splitSignal() const {return this->useSCF();}
371 
373  virtual Bool_t scfDPSmear() const {return (scfMap_ != 0);}
374 
376 
386  void appendBinCentres( LauFitDataTree* inputData );
387 
388  private:
391 
394 
397 
400 
403 
406 
409 
412 
414  Bool_t usingBkgnd_;
415 
417  UInt_t nSigComp_;
418 
420  UInt_t nSigDPPar_;
421 
423  UInt_t nExtraPdfPar_;
424 
426  UInt_t nNormPar_;
427 
429  std::vector<LauAbsCoeffSet*> coeffPars_;
430 
433 
436 
439 
442 
445 
448 
450  Bool_t useSCF_;
451 
453  Bool_t useSCFHist_;
454 
457 
460 
463 
465  std::vector<Double_t> recoSCFFracs_;
466 
468  std::vector<Double_t> fakeSCFFracs_;
469 
471  std::vector<Double_t> recoJacobians_;
472 
474  std::vector<Double_t> fakeJacobians_;
475 
478 
480  std::vector<LauComplex> coeffs_;
481 
482  // Embedding full simulation events
483 
486 
489 
491  Bool_t reuseSignal_;
492 
495 
498 
500  Double_t sigDPLike_;
501 
503  Double_t scfDPLike_;
504 
506  std::vector<Double_t> bkgndDPLike_;
507 
509  Double_t sigExtraLike_;
510 
512  Double_t scfExtraLike_;
513 
515  std::vector<Double_t> bkgndExtraLike_;
516 
518  Double_t sigTotalLike_;
519 
521  Double_t scfTotalLike_;
522 
524  std::vector<Double_t> bkgndTotalLike_;
525 
526  ClassDef(LauSimpleFitModel,0) // Total fit/ToyMC model
527 
528 };
529 
530 #endif
void setSignalPdf(LauAbsPdf *pdf)
Set the signal PDF for a given variable.
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.
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.
LauEffModel * scfFracHist_
The histogram giving the DP-dependence of the SCF fraction.
virtual Double_t getTotEvtLikelihood(UInt_t iEvt)
Get the total likelihood for each event.
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.
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.
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 savePDFPlots(const TString &label)
Save the pdf Plots for all the resonances of experiment number fitExp.
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:82
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()
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 &quot;sin&quot; of experiment number fitExp...
LauBkgndReuseEventsList reuseBkgnd_
Vector of booleans to reuse background events.
ClassDef(LauSimFitSlave, 0)
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.
virtual void setNSigEvents(LauParameter *nSigEvents)
Set the signal event yield.
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.
LauIsobarDynamics * sigDPModel_
The signal Dalitz plot model.
LauSimpleFitModel(LauIsobarDynamics *sigDPModel)
Constructor.
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 normalisation parameters (i.e. yields)
void setupGenNtupleBranches()
Setup the required ntuple branches.
void appendBinCentres(LauFitDataTree *inputData)
Append fake data points to the inputData for each bin in the SCF smearing matrix. ...
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.
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:76
std::vector< LauAbsBkgndDPModel * > LauBkgndDPModelList
Typedef for a vector of background DP models.
Bool_t useSCF_
Is the signal split into TM and SCF.
File containing declaration of LauComplex class.
virtual void setupBkgndVectors()
Define the length of the background vectors.
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:49
LauBkgndDPModelList bkgndDPModels_
The background Dalitz Plot model.
Class to store the data for embedding in toy experiments.
LauParArray fitFracEffUnCorr_
Fit fractions (uncorrected for the efficiency)
virtual void recalculateNormalisation()
Recalculate Normalization the signal DP models.
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.
LauSimpleFitModel & operator=(const LauSimpleFitModel &rhs)
Copy assignment operator (not implemented)
LauPdfList scfPdfs_
The SCF PDFs.
Class that implements the efficiency description across the signal Dalitz plot.
Definition: LauEffModel.hh:51
Bool_t usingBkgnd_
Background boolean.
LauParameter * signalEvents_
Signal yield.
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.
Class for defining signal dynamics using the isobar model.
UInt_t nSigDPPar_
Number of signal DP parameters.
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:43
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:55
Class for calculating 3-body kinematic quantities.
std::pair< LauGenInfo, Bool_t > eventsToGenerate()
Determine the number of events to generate for each hypothesis.
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.
virtual void setNBkgndEvents(LauAbsRValue *nBkgndEvents)
Set the background event yield(s)
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.
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:43
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:73
virtual void initialiseDPModels()
Initialise the signal DP model.
LauBkgndEmbDataList bkgndTree_
The background event tree.
Bool_t generateSignalEvent()
Generate signal event.