laura is hosted by Hepforge, IPPP Durham
Laura++  v3r2
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauCPFitModel.hh
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2004 - 2014.
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 
26 #ifndef LAU_CP_FIT_MODEL
27 #define LAU_CP_FIT_MODEL
28 
29 #include <vector>
30 
31 #include "TString.h"
32 
33 #include "LauAbsFitModel.hh"
34 #include "LauComplex.hh"
35 #include "LauParameter.hh"
36 
37 class TH2;
38 class LauAbsBkgndDPModel;
39 class LauAbsCoeffSet;
40 class LauIsobarDynamics;
41 class LauAbsPdf;
42 class LauEffModel;
43 class LauEmbeddedData;
44 class LauKinematics;
45 class LauScfMap;
46 
47 
48 class LauCPFitModel : public LauAbsFitModel {
49 
50  public:
52 
58  LauCPFitModel(LauIsobarDynamics* negModel, LauIsobarDynamics* posModel, Bool_t tagged = kTRUE, const TString& tagVarName = "charge");
59 
61  virtual ~LauCPFitModel();
62 
64 
67  virtual void setNSigEvents(LauParameter* nSigEvents);
68 
70 
75  virtual void setNSigEvents(LauParameter* nSigEvents, LauParameter* sigAsym, Bool_t forceAsym = kFALSE);
76 
78 
83  virtual void setNBkgndEvents(LauParameter* nBkgndEvents);
84 
86 
92  virtual void setNBkgndEvents(LauParameter* nBkgndEvents, LauParameter* bkgndAsym);
93 
95 
100  void setBkgndDPModels(const TString& bkgndClass, LauAbsBkgndDPModel* negModel, LauAbsBkgndDPModel* posModel);
101 
103 
113  void splitSignalComponent( const TH2* dpHisto, const Bool_t upperHalf = kFALSE, const Bool_t fluctuateBins = kFALSE, LauScfMap* scfMap = 0 );
114 
116 
123  void splitSignalComponent( const Double_t scfFrac, const Bool_t fixed );
124 
126  Bool_t useSCF() const { return useSCF_; }
127 
129  Bool_t useSCFHist() const { return useSCFHist_; }
130 
132  Bool_t smearSCFDP() const { return (scfMap_ != 0); }
133 
134  // Set the DeltaE and mES models, i.e. give us the PDFs
136 
140  void setSignalPdfs(LauAbsPdf* negPdf, LauAbsPdf* posPdf);
141 
143 
147  void setSCFPdfs(LauAbsPdf* negPdf, LauAbsPdf* posPdf);
148 
150 
155  void setBkgndPdfs(const TString& bkgndClass, LauAbsPdf* negPdf, LauAbsPdf* posPdf);
156 
158 
165  void embedNegSignal(const TString& fileName, const TString& treeName,
166  Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment = kFALSE,
167  Bool_t useReweighting = kFALSE);
168 
170 
177  void embedNegBkgnd(const TString& bgClass, const TString& fileName, const TString& treeName,
178  Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment = kFALSE);
179 
181 
188  void embedPosSignal(const TString& fileName, const TString& treeName,
189  Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment = kFALSE,
190  Bool_t useReweighting = kFALSE);
191 
193 
200  void embedPosBkgnd(const TString& bgClass, const TString& fileName, const TString& treeName,
201  Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment = kFALSE);
202 
204 
211  virtual void setAmpCoeffSet(LauAbsCoeffSet* coeffSet);
212 
213  protected:
215  typedef std::map< std::pair<TString,Int_t>, std::pair<Int_t,Double_t> > LauGenInfo;
216 
218  typedef std::vector<LauAbsBkgndDPModel*> LauBkgndDPModelList;
219 
221  typedef std::vector<LauPdfList> LauBkgndPdfsList;
222 
224  typedef std::vector<LauParameter*> LauBkgndYieldList;
225 
227  typedef std::vector<LauEmbeddedData*> LauBkgndEmbDataList;
228 
230  typedef std::vector<Bool_t> LauBkgndReuseEventsList;
231 
232 
234 
238  virtual void weightEvents( const TString& dataFileName, const TString& dataTreeName );
239 
241  virtual void initialise();
242 
244  virtual void initialiseDPModels();
245 
247  virtual void recalculateNormalisation();
248 
250  virtual void updateCoeffs();
251 
253  virtual Bool_t genExpt();
254 
256  virtual void propagateParUpdates();
257 
259  virtual void cacheInputFitVars();
260 
262  virtual void checkInitFitParams();
263 
265 
268  virtual void finaliseFitResults(const TString& tablePrefixName);
269 
271 
274  virtual void printFitFractions(std::ostream& output);
275 
277 
280  virtual void printAsymmetries(std::ostream& output);
281 
283 
286  virtual void writeOutTable(const TString& outputFile);
287 
289 
292  virtual void savePDFPlots(const TString& label);
293 
295 
299  virtual void savePDFPlotsWave(const TString& label, const Int_t& spin);
300 
301 
303  virtual void storePerEvtLlhds();
304 
305  // Methods to do with calculating the likelihood functions
306  // and manipulating the fitting parameters.
308 
311  virtual Double_t getTotEvtLikelihood(UInt_t iEvt);
312 
314 
317  virtual void getEvtDPLikelihood(UInt_t iEvt);
318 
320 
323  virtual Double_t getEvtSCFDPLikelihood(UInt_t iEvt);
324 
326 
329  virtual void getEvtExtraLikelihoods(UInt_t iEvt);
330 
332 
335  virtual Double_t getEventSum() const;
336 
338  void setSignalDPParameters();
339 
341  void setExtraPdfParameters();
342 
344  void setFitNEvents();
345 
347  void setExtraNtupleVars();
348 
350  void randomiseInitFitPars();
351 
353 
356  void calcExtraFractions(Bool_t initValues = kFALSE);
357 
359 
362  void calcAsymmetries(Bool_t initValues = kFALSE);
363 
365  virtual void setupBkgndVectors();
366 
368  std::pair<LauGenInfo,Bool_t> eventsToGenerate();
369 
371  Bool_t generateSignalEvent();
372 
374 
377  Bool_t generateBkgndEvent(UInt_t bgID);
378 
380  void setupGenNtupleBranches();
381 
383  void setDPBranchValues();
384 
386 
390  void generateExtraPdfValues(LauPdfList* extraPdfs, LauEmbeddedData* embeddedData);
391 
393 
396  Bool_t storeSignalMCMatch(LauEmbeddedData* embeddedData);
397 
399 
403  void addSPlotNtupleBranches(const LauPdfList* extraPdfs, const TString& prefix);
404 
406 
411  Double_t setSPlotNtupleBranchValues(LauPdfList* extraPdfs, const TString& prefix, UInt_t iEvt);
412 
414  void updateSigEvents();
415 
417  virtual void setupSPlotNtupleBranches();
418 
420  virtual LauSPlot::NameSet variableNames() const;
421 
423  virtual LauSPlot::NumbMap freeSpeciesNames() const;
424 
426  virtual LauSPlot::NumbMap fixdSpeciesNames() const;
427 
429  virtual LauSPlot::TwoDMap twodimPDFs() const;
430 
432  virtual Bool_t splitSignal() const {return this->useSCF();}
433 
435  virtual Bool_t scfDPSmear() const {return (scfMap_ != 0);}
436 
438 
448  void appendBinCentres( LauFitDataTree* inputData );
449 
452 
453  private:
455  LauCPFitModel(const LauCPFitModel& rhs);
456 
459 
462 
465 
468 
471 
474 
477 
480 
483 
486 
489 
492 
495 
497  Bool_t usingBkgnd_;
498 
500  UInt_t nSigComp_;
501 
503  UInt_t nSigDPPar_;
504 
507 
509  UInt_t nNormPar_;
510 
512  std::vector<LauAbsCoeffSet*> coeffPars_;
513 
516 
519 
522 
525 
528 
531 
533  std::vector<LauParameter> fitFracAsymm_;
534 
536  std::vector<LauParameter> acp_;
537 
540 
543 
546 
549 
552 
555 
557  Bool_t forceAsym_;
558 
561 
564 
566  const Bool_t tagged_;
567 
569  const TString tagVarName_;
570 
573 
575  std::vector<Int_t> evtCharges_;
576 
578  Bool_t useSCF_;
579 
581  Bool_t useSCFHist_;
582 
585 
588 
591 
593  std::vector<Double_t> recoSCFFracs_;
594 
596  std::vector<Double_t> fakeSCFFracs_;
597 
599  std::vector<Double_t> recoJacobians_;
600 
602  std::vector<Double_t> fakeJacobians_;
603 
606 
608  TString negParent_;
609 
611  TString posParent_;
612 
614  std::vector<LauComplex> negCoeffs_;
615 
617  std::vector<LauComplex> posCoeffs_;
618 
619  // Embedding full simulation events
620 
623 
626 
629 
632 
634  Bool_t reuseSignal_;
635 
638 
641 
644 
645  // Likelihood values
647  Double_t sigDPLike_;
648 
650  Double_t scfDPLike_;
651 
653  std::vector<Double_t> bkgndDPLike_;
654 
656  Double_t sigExtraLike_;
657 
659  Double_t scfExtraLike_;
660 
662  std::vector<Double_t> bkgndExtraLike_;
663 
665  Double_t sigTotalLike_;
666 
668  Double_t scfTotalLike_;
669 
671  std::vector<Double_t> bkgndTotalLike_;
672 
673  ClassDef(LauCPFitModel,0) // CP fit/ToyMC model
674 
675 };
676 
677 #endif
void generateExtraPdfValues(LauPdfList *extraPdfs, LauEmbeddedData *embeddedData)
Generate from the extra PDFs.
Bool_t generateSignalEvent()
Generate signal event.
The abstract interface for a background Dalitz plot model.
std::vector< LauParameter > acp_
A_CP parameter.
virtual LauSPlot::NameSet variableNames() const
Returns the names of all variables in the fit.
LauKinematics * negKinematics_
The B- Dalitz plot kinematics object.
virtual void printAsymmetries(std::ostream &output)
Print the asymmetries.
LauPdfList negSignalPdfs_
The B- signal PDFs.
Bool_t smearSCFDP() const
Determine if we are smearing the SCF DP PDF.
void addSPlotNtupleBranches(const LauPdfList *extraPdfs, const TString &prefix)
Add sPlot branches for the extra PDFs.
Bool_t forceAsym_
Option to force an asymmetry.
Double_t scfTotalLike_
Total SCF likelihood.
void setExtraPdfParameters()
Set the fit parameters for the extra PDFs.
LauBkgndDPModelList posBkgndDPModels_
The B+ background Dalitz plot models.
UInt_t nNormPar_
Number of normalisation parameters (yields, asymmetries)
Bool_t useSCF() const
Determine whether we are splitting the signal into TM and SCF parts.
LauEmbeddedData * posSignalTree_
The B+ signal event tree.
LauIsobarDynamics * getPosSigModel()
File containing declaration of LauAbsFitModel class.
Int_t curEvtCharge_
Current event charge.
void calcExtraFractions(Bool_t initValues=kFALSE)
Calculate the CP-conserving and CP-violating fit fractions.
LauEmbeddedData * negSignalTree_
The B- signal event tree.
Bool_t useNegReweighting_
Boolean to use reweighting for B-.
std::vector< LauComplex > negCoeffs_
The complex coefficients for B-.
LauBkgndPdfsList posBkgndPdfs_
The B+ background PDFs.
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
Bool_t compareFitData_
Run choice variables.
virtual Bool_t scfDPSmear() const
Check if the mis-reconstructed signal is to be smeared in the DP.
LauParArray negFitFrac_
The B- fit fractions.
virtual void getEvtExtraLikelihoods(UInt_t iEvt)
Determine the signal and background likelihood for the extra variables for a given event...
Double_t sigDPLike_
Signal DP likelihood value.
LauPdfList negScfPdfs_
The B- SCF PDFs.
Bool_t useSCF_
Is the signal split into TM and SCF.
virtual Bool_t genExpt()
Toy MC generation and fitting overloaded functions.
TString negParent_
Name of the parent particle.
TString posParent_
Name of the parent particle.
void embedNegSignal(const TString &fileName, const TString &treeName, Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment=kFALSE, Bool_t useReweighting=kFALSE)
Embed full simulation events for the B- signal, rather than generating toy from the PDFs...
std::pair< LauGenInfo, Bool_t > eventsToGenerate()
Determine the number of events to generate for each hypothesis.
std::vector< Double_t > fakeSCFFracs_
The cached values of the SCF fraction for each bin centre.
ClassDef(LauSimFitSlave, 0)
std::vector< std::vector< LauParameter > > LauParArray
Type to define an array of parameters.
Bool_t storeSignalMCMatch(LauEmbeddedData *embeddedData)
Store the MC truth info on the TM/SCF nature of the embedded signal event.
Bool_t usingBkgnd_
Background boolean.
std::vector< LauAbsPdf * > LauPdfList
List of Pdfs.
LauBkgndYieldList bkgndAsym_
Background asymmetries(s)
LauIsobarDynamics * negSigModel_
The B- signal Dalitz plot model.
LauParameter negDPRate_
The average DP rate for B-.
std::vector< Double_t > bkgndTotalLike_
Total background likelihood(s)
std::vector< Double_t > recoSCFFracs_
The cached values of the SCF fraction for each event.
LauParameter posDPRate_
The average DP rate for B+.
std::vector< Double_t > bkgndExtraLike_
Background likelihood value(s) from extra PDFs.
void setupGenNtupleBranches()
Setup the required ntuple branches.
Double_t scfExtraLike_
SCF likelihood from extra PDFs.
Bool_t reuseSignal_
Boolean to reuse signal events.
LauParArray posFitFrac_
The B+ fit fractions.
virtual void cacheInputFitVars()
Read in the input fit data variables, e.g. m13Sq and m23Sq.
void setSignalDPParameters()
Set the fit parameters for the DP model.
void randomiseInitFitPars()
Randomise the initial fit parameters.
void appendBinCentres(LauFitDataTree *inputData)
Append fake data points to the inputData for each bin in the SCF smearing matrix. ...
virtual void savePDFPlotsWave(const TString &label, const Int_t &spin)
Save the pdf Plots for the sum of resonances of a given spin.
virtual void checkInitFitParams()
Check the initial fit parameters.
virtual void recalculateNormalisation()
Recalculate Normalization the signal DP models.
const Bool_t tagged_
IS the analysis tagged?
UInt_t nExtraPdfPar_
Number of extra PDF parameters.
virtual void finaliseFitResults(const TString &tablePrefixName)
Get the fit results and store them.
virtual void printFitFractions(std::ostream &output)
Print the fit fractions, total DP rate and mean efficiency.
LauParArray negFitFracEffUnCorr_
Fit B- fractions (uncorrected for the efficiency)
Class for defining a CP fit model.
Abstract interface to the fitting and toy MC model.
const TString tagVarName_
Event charge.
LauParameter * signalEvents_
Signal yield.
LauParArray posFitFracEffUnCorr_
Fit B+ fractions (uncorrected for the efficiency)
std::vector< LauAbsBkgndDPModel * > LauBkgndDPModelList
Typedef for a vector of background DP models.
std::vector< Int_t > evtCharges_
Vector to store event charges.
File containing declaration of LauParameter class.
virtual Bool_t splitSignal() const
Check if the signal is split into well-reconstructed and mis-reconstructed types. ...
std::vector< LauPdfList > LauBkgndPdfsList
Typedef for a vector of background PDFs.
void calcAsymmetries(Bool_t initValues=kFALSE)
Calculate the CP asymmetries.
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
LauScfMap * scfMap_
The smearing matrix for the SCF DP PDF.
File containing declaration of LauComplex class.
Double_t sigExtraLike_
Signal likelihood from extra PDFs.
virtual void setNBkgndEvents(LauParameter *nBkgndEvents)
Set the background event yield(s)
virtual void initialise()
Initialise the fit.
virtual LauSPlot::NumbMap fixdSpeciesNames() const
Returns the names and yields of species that are fixed in the fit.
Class for defining the abstract interface for complex coefficient classes.
Double_t sigTotalLike_
Total signal likelihood.
virtual void setAmpCoeffSet(LauAbsCoeffSet *coeffSet)
Set the DP amplitude coefficients.
Class for defining the fit parameter objects.
Definition: LauParameter.hh:35
Class to store the data for embedding in toy experiments.
UInt_t nSigComp_
Number of signal components.
virtual void setupSPlotNtupleBranches()
Add branches to store experiment number and the event number within the experiment.
LauParameter * signalAsym_
Signal asymmetry.
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.
virtual void savePDFPlots(const TString &label)
Save the pdf Plots for all the resonances.
std::vector< Double_t > bkgndDPLike_
Background DP likelihood value(s)
void embedNegBkgnd(const TString &bgClass, 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...
LauBkgndEmbDataList negBkgndTree_
The B- background event tree.
LauIsobarDynamics * getNegSigModel()
LauBkgndReuseEventsList reuseBkgnd_
Vector of booleans to reuse background events.
std::vector< LauAbsCoeffSet * > coeffPars_
Magnitudes and Phases.
LauParameter posMeanEff_
The mean efficiency for B+ model.
LauParArray CPCFitFrac_
The CP conserving fit fraction.
virtual void setNSigEvents(LauParameter *nSigEvents)
Set the signal event yield.
virtual void weightEvents(const TString &dataFileName, const TString &dataTreeName)
Weight events based on the DP model.
Bool_t usePosReweighting_
Boolean to use reweighting for B+.
Bool_t generateBkgndEvent(UInt_t bgID)
Generate background event.
virtual void writeOutTable(const TString &outputFile)
Write the fit results in latex table format.
std::vector< LauParameter * > LauBkgndYieldList
Typedef for a vector of background yields.
LauCPFitModel(LauIsobarDynamics *negModel, LauIsobarDynamics *posModel, Bool_t tagged=kTRUE, const TString &tagVarName="charge")
Constructor.
Bool_t useSCFHist() const
Determine whether the SCF fraction is DP-dependent.
Class that implements the efficiency description across the signal Dalitz plot.
Definition: LauEffModel.hh:37
virtual void updateCoeffs()
Update the coefficients.
Double_t setSPlotNtupleBranchValues(LauPdfList *extraPdfs, const TString &prefix, UInt_t iEvt)
Set the branches for the sPlot ntuple with extra PDFs.
virtual ~LauCPFitModel()
Destructor.
std::vector< LauComplex > posCoeffs_
The complex coefficients for B+.
virtual void initialiseDPModels()
Initialise the signal DP models.
void updateSigEvents()
Update the signal events after Minuit sets background parameters.
Class for defining signal dynamics using the isobar model.
virtual void setupBkgndVectors()
Define the length of the background vectors.
LauCPFitModel & operator=(const LauCPFitModel &rhs)
Copy assignment operator (not implemented)
void setSignalPdfs(LauAbsPdf *negPdf, LauAbsPdf *posPdf)
Set the signal PDFs.
void setFitNEvents()
Set the initial yields.
virtual LauSPlot::TwoDMap twodimPDFs() const
Returns the species and variables for all 2D PDFs in the fit.
virtual LauSPlot::NumbMap freeSpeciesNames() const
Returns the names and yields of species that are free in the fit.
LauEffModel * scfFracHist_
The histogram giving the DP-dependence of the SCF fraction.
UInt_t nSigDPPar_
Number of signal DP parameters.
virtual void propagateParUpdates()
Calculate things that depend on the fit parameters after they have been updated by Minuit...
Class for representing the 4D smearing matrix for mis-reconstructed signal (self cross feed) ...
Definition: LauScfMap.hh:29
virtual void storePerEvtLlhds()
Store the per event likelihood values.
Double_t scfDPLike_
SCF DP likelihood value.
std::vector< Double_t > recoJacobians_
The cached values of the sqDP jacobians for each event.
std::vector< Bool_t > LauBkgndReuseEventsList
Typedef for a vector of booleans to flag if events are reused.
virtual Double_t getEventSum() const
Get the total number of events.
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:41
LauIsobarDynamics * posSigModel_
The B+ signal Dalitz plot model.
LauPdfList posScfPdfs_
The B+ SCF PDFs.
LauBkgndYieldList bkgndEvents_
Background yield(s)
Class for calculating 3-body kinematic quantities.
LauBkgndDPModelList negBkgndDPModels_
The B- background Dalitz plot models.
LauParArray CPVFitFrac_
The CP violating fit fraction.
LauPdfList posSignalPdfs_
The B+ signal PDFs.
std::vector< Double_t > fakeJacobians_
The cached values of the sqDP jacobians for each true bin.
void embedPosBkgnd(const TString &bgClass, 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...
virtual Double_t getEvtSCFDPLikelihood(UInt_t iEvt)
Calculate the SCF likelihood for the DP for a given event.
std::vector< LauEmbeddedData * > LauBkgndEmbDataList
Typedef for a vector of embedded data objects.
void setSCFPdfs(LauAbsPdf *negPdf, LauAbsPdf *posPdf)
Set the SCF PDF for a given variable.
std::map< std::pair< TString, Int_t >, std::pair< Int_t, Double_t > > LauGenInfo
Define a map to be used to store a category name and numbers.
Bool_t useSCFHist_
Is the SCF fraction DP-dependent.
LauParameter negMeanEff_
The mean efficiency for B- model.
void setBkgndPdfs(const TString &bkgndClass, LauAbsPdf *negPdf, LauAbsPdf *posPdf)
Set the background PDFs.
virtual Double_t getTotEvtLikelihood(UInt_t iEvt)
Get the total likelihood for each event.
virtual void getEvtDPLikelihood(UInt_t iEvt)
Calculate the signal and background likelihoods for the DP for a given event.
LauBkgndEmbDataList posBkgndTree_
The B+ background event tree.
void setBkgndDPModels(const TString &bkgndClass, LauAbsBkgndDPModel *negModel, LauAbsBkgndDPModel *posModel)
Set the background DP models.
LauBkgndPdfsList negBkgndPdfs_
The B- background PDFs.
Class to store the input fit variables.
LauParameter scfFrac_
The (global) SCF fraction parameter.
std::set< TString > NameSet
Type to store names, e.g. of the discriminating/control variables.
Definition: LauSPlot.hh:59
void setDPBranchValues()
Store all of the DP information.
LauKinematics * posKinematics_
The B+ Dalitz plot kinematics object.
void embedPosSignal(const TString &fileName, const TString &treeName, Bool_t reuseEventsWithinEnsemble, Bool_t reuseEventsWithinExperiment=kFALSE, Bool_t useReweighting=kFALSE)
Embed full simulation events for the B+ signal, rather than generating toy from the PDFs...
std::vector< LauParameter > fitFracAsymm_
The fit fraction asymmetries.
void setExtraNtupleVars()
Set-up other parameters that are derived from the fit results, e.g. fit fractions.