laura is hosted by Hepforge, IPPP Durham
Laura++  v3r0p1
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauAbsPdf.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_ABS_PDF
24 #define LAU_ABS_PDF
25 
26 #include <map>
27 #include <vector>
28 
29 #include "Rtypes.h"
30 #include "TRandom.h"
31 #include "TString.h"
32 
33 #include "LauFitDataTree.hh"
34 #include "LauAbsRValue.hh"
35 #include "LauParameter.hh"
36 #include "LauParamFixed.hh"
37 
38 class LauKinematics;
39 
40 
41 class LauAbsPdf {
42 
43  public:
45  typedef std::vector<Double_t> LauAbscissas;
46 
48  enum IntMethod {
51  };
52 
54 
60  LauAbsPdf(const TString& theVarName, const std::vector<LauAbsRValue*>& params,
61  Double_t minAbscissa, Double_t maxAbscissa);
62 
64 
70  LauAbsPdf(const std::vector<TString>& theVarNames, const std::vector<LauAbsRValue*>& params,
71  const LauFitData& minAbscissas, const LauFitData& maxAbscissas);
72 
74  virtual ~LauAbsPdf() {}
75 
77 
80  virtual const TString& varName() const {return varNames_.find(0)->second;}
81 
83 
86  virtual std::vector<TString> varNames() const;
87 
89 
92  virtual UInt_t nParameters() const {return param_.size();}
93 
95 
98  virtual UInt_t nFixedParameters() const;
99 
101 
104  virtual UInt_t nInputVars() const {return varNames_.size();}
105 
107 
111  virtual Bool_t isDPDependent() const {return kFALSE;}
112 
114 
117  virtual Double_t getMinAbscissa() const {return minAbscissas_.front();}
118 
120 
123  virtual Double_t getMaxAbscissa() const {return maxAbscissas_.front();}
124 
126 
129  virtual Double_t getRange() const {return this->getMaxAbscissa() - this->getMinAbscissa();}
130 
132 
136  virtual Double_t getMinAbscissa( const TString& theVarName ) const;
137 
139 
143  virtual Double_t getMaxAbscissa( const TString& theVarName ) const;
144 
146 
150  virtual Double_t getRange( const TString& theVarName ) const {return this->getMaxAbscissa(theVarName) - this->getMinAbscissa(theVarName);}
151 
153 
156  virtual LauFitData getMinAbscissas() const;
157 
159 
162  virtual LauFitData getMaxAbscissas() const;
163 
165 
168  virtual LauFitData getRanges() const;
169 
171  virtual void updatePulls();
172 
174 
178  virtual void cacheInfo(const LauFitDataTree& inputData);
179 
181 
184  virtual void calcLikelihoodInfo(const LauAbscissas& abscissas) = 0;
185 
187 
190  virtual void calcLikelihoodInfo(UInt_t iEvt);
191 
193 
196  virtual Double_t getUnNormLikelihood() const {return unNormPDFVal_;}
197 
199 
202  virtual Double_t getNorm() const {return norm_;}
203 
205 
208  virtual Double_t getLikelihood() const;
209 
211 
215  virtual Double_t getLikelihood( const TString& theVarName ) const;
216 
218 
221  virtual Double_t getMaxHeight() const {return maxHeight_;}
222 
224 
227  virtual LauFitData generate(const LauKinematics* kinematics);
228 
230 
233  virtual void setRandomFun(TRandom* randomFun) {randomFun_ = randomFun;}
234 
236 
239  virtual const std::vector<LauAbsRValue*>& getParameters() const { return param_; }
240 
242 
245  virtual std::vector<LauAbsRValue*>& getParameters() { return param_; }
246 
248 
252  virtual void calcNorm();
253 
255 
258  virtual void calcPDFHeight( const LauKinematics* kinematics ) = 0;
259 
261 
264  virtual Bool_t heightUpToDate() const {return heightUpToDate_;}
265 
267 
270  virtual void heightUpToDate(Bool_t hutd) {heightUpToDate_ = hutd;}
271 
273 
276  virtual Bool_t cachePDF() const {return cachePDF_;}
277 
279 
282  virtual Int_t nNormPoints() const {return nNormPoints_;}
283 
285 
288  virtual void nNormPoints(Int_t nPoints) {nNormPoints_ = nPoints;}
289 
291 
294  virtual IntMethod integMethod() const {return integMethod_;}
295 
297 
300  virtual void integMethod(IntMethod method) {integMethod_ = method;}
301 
302  protected:
304 
307  virtual void cachePDF( Bool_t doCachePDF ) {cachePDF_ = doCachePDF;}
308 
310 
313  virtual Double_t integrGaussLegendre();
314 
316 
319  virtual Double_t integTrapezoid();
320 
322 
325  virtual void setNorm(Double_t norm) {norm_ = norm;}
326 
328 
331  virtual void setMaxHeight(Double_t maxHeight) {
332  maxHeight_ = maxHeight;
333  this->heightUpToDate(kTRUE);
334  }
335 
337 
341  virtual void setMinAbscissa(const TString& theVarName, Double_t minAbscissa);
342 
344 
348  virtual void setMaxAbscissa(const TString& theVarName, Double_t maxAbscissa);
349 
351 
356  virtual void setRange(const TString& theVarName, Double_t minAbscissa, Double_t maxAbscissa) {
357  this->setMinAbscissa(theVarName, minAbscissa);
358  this->setMaxAbscissa(theVarName, maxAbscissa);
359  }
360 
362 
366  virtual Bool_t checkRange(const LauAbscissas& abscissas) const;
367 
369  virtual void setUnNormPDFVal(Double_t unNormPDFVal) {unNormPDFVal_ = unNormPDFVal;}
370 
372 
375  virtual LauAbsRValue* findParameter(const TString& parName);
376 
378 
381  virtual const LauAbsRValue* findParameter(const TString& parName) const;
382 
384 
387  virtual TRandom* getRandomFun() const {return randomFun_;}
388 
390 
393  virtual std::vector<LauAbscissas>& getAbscissas() {return abscissas_;}
394 
396 
399  virtual const std::vector<LauAbscissas>& getAbscissas() const {return abscissas_;}
400 
402 
405  virtual std::vector<Double_t>& getUnNormPDFValues() {return unNormPDFValues_;}
406 
408 
411  virtual const std::vector<Double_t>& getUnNormPDFValues() const {return unNormPDFValues_;}
412 
414 
417  virtual void addParameters(std::vector<LauAbsRValue*>& params);
418 
420 
423  virtual Bool_t withinNormCalc() const {return withinNormCalc_;}
424 
426 
429  virtual void withinNormCalc(Bool_t yorn) {withinNormCalc_ = yorn;}
430 
432 
435  virtual Bool_t withinGeneration() const {return withinGeneration_;}
436 
438 
441  virtual void withinGeneration(Bool_t yorn) {withinGeneration_ = yorn;}
442 
444 
447  virtual Bool_t normWeightsDone() const {return normWeightsDone_;}
448 
450 
453  virtual void normWeightsDone(Bool_t yorn) {normWeightsDone_ = yorn;}
454 
456  virtual void getNormWeights();
457 
459 
462  virtual const std::vector<LauAbscissas>& normAbscissas() const {return normAbscissas_;}
463 
465 
468  virtual const std::vector<Double_t>& normWeights() const {return normWeights_;}
469 
470  private:
472  LauAbsPdf(const LauAbsPdf& rhs);
473 
475  LauAbsPdf& operator=(const LauAbsPdf& rhs);
476 
478  std::map<UInt_t,TString> varNames_;
479 
481  std::vector<LauAbsRValue*> param_;
482 
484  Double_t norm_;
485 
487  Double_t maxHeight_;
488 
491 
494 
497 
499  TRandom* randomFun_;
500 
502  std::vector<LauAbscissas> abscissas_;
503 
505  std::vector<Double_t> unNormPDFValues_;
506 
508 
509  Bool_t cachePDF_;
510 
512  Double_t unNormPDFVal_;
513 
516 
519 
522 
525 
528 
530  std::vector<LauAbscissas> normAbscissas_;
531 
533  std::vector<Double_t> normWeights_;
534 
535  ClassDef(LauAbsPdf,0) // Define the abstract PDF class
536 };
537 
538 #endif
virtual Double_t integrGaussLegendre()
Integrate the PDF using the Gauss-Legendre method.
Definition: LauAbsPdf.cc:448
virtual const std::vector< Double_t > & getUnNormPDFValues() const
Retrieve the cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:411
TRandom * randomFun()
Access the singleton random number generator with a particular seed.
Definition: LauRandom.cc:20
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:369
File containing declaration of LauFitDataTree class.
virtual void nNormPoints(Int_t nPoints)
Set the number of points to integrate over when normalising.
Definition: LauAbsPdf.hh:288
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:117
virtual Bool_t normWeightsDone() const
Check whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:447
Double_t unNormPDFVal_
The unnormalised liklihood value.
Definition: LauAbsPdf.hh:512
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:264
File containing declaration of LauParamFixed class.
virtual const TString & varName() const
Retrieve the name of the abscissa.
Definition: LauAbsPdf.hh:80
virtual void withinNormCalc(Bool_t yorn)
Set flag to track whether the calcNorm method is running.
Definition: LauAbsPdf.hh:429
virtual void setRange(const TString &theVarName, Double_t minAbscissa, Double_t maxAbscissa)
Set the range of the specified abscissa.
Definition: LauAbsPdf.hh:356
virtual LauAbsRValue * findParameter(const TString &parName)
Retrieve the specified parameter.
Definition: LauAbsPdf.cc:381
virtual std::vector< LauAbsRValue * > & getParameters()
Retrieve the parameters of the PDF, e.g. so that they can be loaded into a fit.
Definition: LauAbsPdf.hh:245
virtual UInt_t nParameters() const
Retrieve the number of PDF parameters.
Definition: LauAbsPdf.hh:92
virtual const std::vector< LauAbscissas > & normAbscissas() const
Retrieve the abscissa points used for normalisation.
Definition: LauAbsPdf.hh:462
Bool_t normWeightsDone_
Whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:527
std::vector< LauAbscissas > normAbscissas_
The normalisation abscissas.
Definition: LauAbsPdf.hh:530
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:196
virtual void calcPDFHeight(const LauKinematics *kinematics)=0
Calculate the maximum height of the PDF.
virtual void setNorm(Double_t norm)
Set the normalisation factor.
Definition: LauAbsPdf.hh:325
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:213
LauAbsPdf & operator=(const LauAbsPdf &rhs)
Copy assignment operator (not implemented)
virtual Int_t nNormPoints() const
Retrieve the number of points to integrate over when normalising.
Definition: LauAbsPdf.hh:282
virtual void setMinAbscissa(const TString &theVarName, Double_t minAbscissa)
Set the minimum value of the specified abscissa.
Definition: LauAbsPdf.cc:185
virtual LauFitData generate(const LauKinematics *kinematics)
Generate an event from the PDF.
Definition: LauAbsPdf.cc:298
std::map< TString, Double_t > LauFitData
Type for holding event data.
TRandom * randomFun_
The random function used for MC generation.
Definition: LauAbsPdf.hh:499
virtual Bool_t withinNormCalc() const
Check whether the calcNorm method is running.
Definition: LauAbsPdf.hh:423
LauAbsPdf(const TString &theVarName, const std::vector< LauAbsRValue * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor for a 1D PDF.
Definition: LauAbsPdf.cc:30
virtual void heightUpToDate(Bool_t hutd)
Set whether the height is up to date.
Definition: LauAbsPdf.hh:270
virtual TRandom * getRandomFun() const
Retrieve the random function used for MC generation.
Definition: LauAbsPdf.hh:387
Bool_t cachePDF_
Whether the unnormalised PDF values are cached.
Definition: LauAbsPdf.hh:509
virtual const std::vector< LauAbscissas > & getAbscissas() const
Retrieve the abscissa(s)
Definition: LauAbsPdf.hh:399
virtual void normWeightsDone(Bool_t yorn)
Set whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:453
virtual Double_t getMaxHeight() const
Retrieve the maximum height.
Definition: LauAbsPdf.hh:221
Int_t nNormPoints_
number of points to integrate over when normalising
Definition: LauAbsPdf.hh:515
LauAbscissas minAbscissas_
The minimum value(s) of the abscissa(s)
Definition: LauAbsPdf.hh:493
virtual void cachePDF(Bool_t doCachePDF)
Set whether the PDF is to be cached.
Definition: LauAbsPdf.hh:307
Double_t norm_
Normalisation factor of the PDF.
Definition: LauAbsPdf.hh:484
std::vector< LauAbsRValue * > param_
The parameters of the PDF (if any)
Definition: LauAbsPdf.hh:481
virtual void setMaxAbscissa(const TString &theVarName, Double_t maxAbscissa)
Set the maximum value of the specified abscissa.
Definition: LauAbsPdf.cc:199
std::vector< LauAbscissas > abscissas_
Cached values of the abscissas.
Definition: LauAbsPdf.hh:502
virtual LauFitData getMinAbscissas() const
Retrieve the minimum values of all the abscissas.
Definition: LauAbsPdf.cc:147
virtual LauFitData getRanges() const
Retrieve the ranges of all the abscissas.
Definition: LauAbsPdf.cc:169
File containing declaration of LauAbsRValue class.
virtual void updatePulls()
Update the pulls for all parameters.
Definition: LauAbsPdf.cc:411
Bool_t heightUpToDate_
Track whether the height is up to date.
Definition: LauAbsPdf.hh:490
virtual void integMethod(IntMethod method)
Set the integration method used to normalise the PDF.
Definition: LauAbsPdf.hh:300
std::vector< Double_t > normWeights_
The normalisation weights.
Definition: LauAbsPdf.hh:533
File containing declaration of LauParameter class.
virtual ~LauAbsPdf()
Destructor.
Definition: LauAbsPdf.hh:74
virtual std::vector< TString > varNames() const
Retrieve the names of the abscissas.
Definition: LauAbsPdf.cc:103
virtual Double_t getMaxAbscissa() const
Retrieve the maximum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:123
virtual Bool_t isDPDependent() const
Specifies whether or not the PDF is DP dependent.
Definition: LauAbsPdf.hh:111
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:331
Bool_t withinNormCalc_
Flag to keep track of whether the calcNorm method is running.
Definition: LauAbsPdf.hh:521
virtual void addParameters(std::vector< LauAbsRValue * > &params)
Add parameters to the PDF.
Definition: LauAbsPdf.cc:423
std::vector< Double_t > unNormPDFValues_
Cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:505
virtual std::vector< LauAbscissas > & getAbscissas()
Retrieve the abscissa(s)
Definition: LauAbsPdf.hh:393
virtual const std::vector< LauAbsRValue * > & getParameters() const
Retrieve the parameters of the PDF, e.g. so that they can be loaded into a fit.
Definition: LauAbsPdf.hh:239
IntMethod integMethod_
The integration method used for normalising the PDF.
Definition: LauAbsPdf.hh:518
virtual void withinGeneration(Bool_t yorn)
Set flag to track whether the generate method is running.
Definition: LauAbsPdf.hh:441
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:435
virtual const std::vector< Double_t > & normWeights() const
Retrieve the weights used for normalisation.
Definition: LauAbsPdf.hh:468
virtual LauFitData getMaxAbscissas() const
Retrieve the maximum values of all the abscissas.
Definition: LauAbsPdf.cc:158
virtual std::vector< Double_t > & getUnNormPDFValues()
Retrieve the cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:405
virtual Bool_t cachePDF() const
Check if the PDF is to be cached.
Definition: LauAbsPdf.hh:276
virtual Double_t getLikelihood() const
Retrieve the normalised likelihood value.
Definition: LauAbsPdf.cc:354
virtual Double_t getRange(const TString &theVarName) const
Retrieve the range of the specified abscissa.
Definition: LauAbsPdf.hh:150
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)=0
Calculate the likelihood (and all associated information) given value(s) of the abscissa(s) ...
Bool_t withinGeneration_
Flag to keep track of whether the generate method is running.
Definition: LauAbsPdf.hh:524
virtual void getNormWeights()
Calculate the weights and abscissas used for normalisation.
Definition: LauAbsPdf.cc:470
std::map< UInt_t, TString > varNames_
The names of the PDF variables.
Definition: LauAbsPdf.hh:478
virtual void calcNorm()
Calculate the normalisation factor of the PDF.
Definition: LauAbsPdf.cc:430
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:41
virtual IntMethod integMethod() const
Retrieve the integration method used to normalise the PDF.
Definition: LauAbsPdf.hh:294
Class for calculating 3-body kinematic quantities.
virtual UInt_t nFixedParameters() const
Retrieve the number of fixed PDF parameters.
Definition: LauAbsPdf.cc:113
virtual void cacheInfo(const LauFitDataTree &inputData)
Cache information from data.
Definition: LauAbsPdf.cc:241
LauAbscissas maxAbscissas_
The maximum value(s) of the abscissa(s)
Definition: LauAbsPdf.hh:496
virtual UInt_t nInputVars() const
Retrieve the number of abscissas.
Definition: LauAbsPdf.hh:104
Double_t maxHeight_
Maximum height of the PDF.
Definition: LauAbsPdf.hh:487
virtual Double_t getRange() const
Retrieve the range of the (primary) abscissa.
Definition: LauAbsPdf.hh:129
IntMethod
The possible numerical intergration methods.
Definition: LauAbsPdf.hh:48
virtual void setRandomFun(TRandom *randomFun)
Set the random function used for toy MC generation.
Definition: LauAbsPdf.hh:233
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:29
virtual Double_t getNorm() const
Retrieve the normalisation factor.
Definition: LauAbsPdf.hh:202
virtual Double_t integTrapezoid()
Integrate the PDF using the simple trapezoid method.
Definition: LauAbsPdf.cc:521
Class to store the input fit variables.
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:45