laura is hosted by Hepforge, IPPP Durham
Laura++  v1r0
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 "LauParameter.hh"
35 #include "LauParamFixed.hh"
36 
37 class LauKinematics;
38 
39 
40 class LauAbsPdf {
41 
42  public:
44  typedef std::vector<Double_t> LauAbscissas;
45 
47  enum IntMethod {
50  };
51 
53 
59  LauAbsPdf(const TString& theVarName, const std::vector<LauParameter*>& params,
60  Double_t minAbscissa, Double_t maxAbscissa);
61 
63 
69  LauAbsPdf(const std::vector<TString>& theVarNames, const std::vector<LauParameter*>& params,
70  const LauFitData& minAbscissas, const LauFitData& maxAbscissas);
71 
73  virtual ~LauAbsPdf() {}
74 
76 
79  virtual const TString& varName() const {return varNames_.find(0)->second;}
80 
82 
85  virtual std::vector<TString> varNames() const;
86 
88 
91  virtual UInt_t nParameters() const {return param_.size();}
92 
94 
97  virtual UInt_t nFixedParameters() const;
98 
100 
103  virtual UInt_t nInputVars() const {return varNames_.size();}
104 
106 
110  virtual Bool_t isDPDependent() const {return kFALSE;}
111 
113 
117  virtual Double_t getParValue(const TString& parName) const;
118 
120 
124  virtual Double_t getParMin(const TString& parName) const;
125 
127 
131  virtual Double_t getParMax(const TString& parName) const;
132 
134 
138  virtual Double_t getParRange(const TString& parName) const;
139 
141 
145  virtual Bool_t parFixed(const TString& parName) const;
146 
148 
152  virtual Bool_t parClone(const TString& parName) const;
153 
155 
158  virtual Double_t getMinAbscissa() const {return minAbscissas_.front();}
159 
161 
164  virtual Double_t getMaxAbscissa() const {return maxAbscissas_.front();}
165 
167 
170  virtual Double_t getRange() const {return this->getMaxAbscissa() - this->getMinAbscissa();}
171 
173 
177  virtual Double_t getMinAbscissa( const TString& theVarName ) const;
178 
180 
184  virtual Double_t getMaxAbscissa( const TString& theVarName ) const;
185 
187 
191  virtual Double_t getRange( const TString& theVarName ) const {return this->getMaxAbscissa(theVarName) - this->getMinAbscissa(theVarName);}
192 
194 
197  virtual LauFitData getMinAbscissas() const;
198 
200 
203  virtual LauFitData getMaxAbscissas() const;
204 
206 
209  virtual LauFitData getRanges() const;
210 
212 
216  virtual void setParValue(const TString& parName, Double_t value);
217 
219 
223  virtual void setParMin(const TString& parName, Double_t minValue);
224 
226 
230  virtual void setParMax(const TString& parName, Double_t maxValue);
231 
233 
238  virtual void setParRange(const TString& parName, Double_t minValue, Double_t maxValue);
239 
241 
244  virtual void fixPar(const TString& parName);
245 
247 
250  virtual void floatPar(const TString& parName);
251 
253  virtual void updatePulls();
254 
256 
260  virtual void cacheInfo(const LauFitDataTree& inputData);
261 
263 
266  virtual void calcLikelihoodInfo(const LauAbscissas& abscissas) = 0;
267 
269 
272  virtual void calcLikelihoodInfo(UInt_t iEvt);
273 
275 
278  virtual Double_t getUnNormLikelihood() const {return unNormPDFVal_;}
279 
281 
284  virtual Double_t getNorm() const {return norm_;}
285 
287 
290  virtual Double_t getLikelihood() const;
291 
293 
297  virtual Double_t getLikelihood( const TString& theVarName ) const;
298 
300 
303  virtual Double_t getMaxHeight() const {return maxHeight_;}
304 
306 
309  virtual LauFitData generate(const LauKinematics* kinematics);
310 
312 
315  virtual void setRandomFun(TRandom* randomFun) {randomFun_ = randomFun;}
316 
318 
321  virtual const std::vector<LauParameter*>& getParameters() const { return param_; }
322 
324 
327  virtual std::vector<LauParameter*>& getParameters() { return param_; }
328 
330  virtual void checkPositiveness() = 0;
331 
333 
337  virtual void calcNorm();
338 
340 
343  virtual void calcPDFHeight( const LauKinematics* kinematics ) = 0;
344 
346 
349  virtual Bool_t heightUpToDate() const {return heightUpToDate_;}
350 
352 
355  virtual Bool_t cachePDF() const {return cachePDF_;}
356 
358 
361  virtual Int_t nNormPoints() const {return nNormPoints_;}
362 
364 
367  virtual void nNormPoints(Int_t nPoints) {nNormPoints_ = nPoints;}
368 
370 
373  virtual IntMethod integMethod() const {return integMethod_;}
374 
376 
379  virtual void integMethod(IntMethod method) {integMethod_ = method;}
380 
381  protected:
383 
386  virtual void cachePDF( Bool_t doCachePDF ) {cachePDF_ = doCachePDF;}
387 
389 
392  virtual void heightUpToDate(Bool_t hutd) {heightUpToDate_ = hutd;}
393 
395 
398  virtual Double_t integrGaussLegendre();
399 
401 
404  virtual Double_t integTrapezoid();
405 
407 
410  virtual void setNorm(Double_t norm) {norm_ = norm;}
411 
413 
416  virtual void setMaxHeight(Double_t maxHeight) {
417  maxHeight_ = maxHeight;
418  this->heightUpToDate(kTRUE);
419  }
420 
422 
426  virtual void setMinAbscissa(const TString& theVarName, Double_t minAbscissa);
427 
429 
433  virtual void setMaxAbscissa(const TString& theVarName, Double_t maxAbscissa);
434 
436 
441  virtual void setRange(const TString& theVarName, Double_t minAbscissa, Double_t maxAbscissa) {
442  this->setMinAbscissa(theVarName, minAbscissa);
443  this->setMaxAbscissa(theVarName, maxAbscissa);
444  }
445 
447 
451  virtual Bool_t checkRange(const LauAbscissas& abscissas) const;
452 
454  virtual void setUnNormPDFVal(Double_t unNormPDFVal) {unNormPDFVal_ = unNormPDFVal;}
455 
457 
460  virtual LauParameter* findParameter(const TString& parName);
461 
463 
466  virtual const LauParameter* findParameter(const TString& parName) const;
467 
469 
472  virtual TRandom* getRandomFun() const {return randomFun_;}
473 
475 
478  virtual std::vector<LauAbscissas>& getAbscissas() {return abscissas_;}
479 
481 
484  virtual const std::vector<LauAbscissas>& getAbscissas() const {return abscissas_;}
485 
487 
490  virtual std::vector<Double_t>& getUnNormPDFValues() {return unNormPDFValues_;}
491 
493 
496  virtual const std::vector<Double_t>& getUnNormPDFValues() const {return unNormPDFValues_;}
497 
499 
502  virtual void addParameters(std::vector<LauParameter*>& params);
503 
505 
508  virtual Bool_t withinNormCalc() const {return withinNormCalc_;}
509 
511 
514  virtual void withinNormCalc(Bool_t yorn) {withinNormCalc_ = yorn;}
515 
517 
520  virtual Bool_t withinGeneration() const {return withinGeneration_;}
521 
523 
526  virtual void withinGeneration(Bool_t yorn) {withinGeneration_ = yorn;}
527 
529 
532  virtual Bool_t normWeightsDone() const {return normWeightsDone_;}
533 
535 
538  virtual void normWeightsDone(Bool_t yorn) {normWeightsDone_ = yorn;}
539 
541  virtual void getNormWeights();
542 
544 
547  virtual const std::vector<LauAbscissas>& normAbscissas() const {return normAbscissas_;}
548 
550 
553  virtual const std::vector<Double_t>& normWeights() const {return normWeights_;}
554 
555  private:
557  std::map<UInt_t,TString> varNames_;
558 
560  std::vector<LauParameter*> param_;
561 
563  Double_t norm_;
564 
566  Double_t maxHeight_;
567 
570 
573 
576 
578  TRandom* randomFun_;
579 
581  std::vector<LauAbscissas> abscissas_;
582 
584  std::vector<Double_t> unNormPDFValues_;
585 
587 
588  Bool_t cachePDF_;
589 
591  Double_t unNormPDFVal_;
592 
595 
598 
601 
604 
607 
609  std::vector<LauAbscissas> normAbscissas_;
610 
612  std::vector<Double_t> normWeights_;
613 
614  ClassDef(LauAbsPdf,0) // Define the abstract PDF class
615 };
616 
617 #endif
std::vector< LauParameter * > param_
The parameters of the PDF (if any)
Definition: LauAbsPdf.hh:560
virtual Double_t integrGaussLegendre()
Integrate the PDF using the Gauss-Legendre method.
Definition: LauAbsPdf.cc:547
virtual void setParMax(const TString &parName, Double_t maxValue)
Change the maximum value of the specified parameter.
Definition: LauAbsPdf.cc:481
virtual const std::vector< Double_t > & getUnNormPDFValues() const
Retrieve the cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:496
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:454
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:367
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:158
virtual Bool_t normWeightsDone() const
Check whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:532
Double_t unNormPDFVal_
The unnormalised liklihood value.
Definition: LauAbsPdf.hh:591
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:349
File containing declaration of LauParamFixed class.
virtual const TString & varName() const
Retrieve the name of the abscissa.
Definition: LauAbsPdf.hh:79
virtual void withinNormCalc(Bool_t yorn)
Set flag to track whether the calcNorm method is running.
Definition: LauAbsPdf.hh:514
virtual void setRange(const TString &theVarName, Double_t minAbscissa, Double_t maxAbscissa)
Set the range of the specified abscissa.
Definition: LauAbsPdf.hh:441
virtual void addParameters(std::vector< LauParameter * > &params)
Add parameters to the PDF.
Definition: LauAbsPdf.cc:522
virtual UInt_t nParameters() const
Retrieve the number of PDF parameters.
Definition: LauAbsPdf.hh:91
virtual const std::vector< LauAbscissas > & normAbscissas() const
Retrieve the abscissa points used for normalisation.
Definition: LauAbsPdf.hh:547
Bool_t normWeightsDone_
Whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:606
std::vector< LauAbscissas > normAbscissas_
The normalisation abscissas.
Definition: LauAbsPdf.hh:609
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:278
virtual void calcPDFHeight(const LauKinematics *kinematics)=0
Calculate the maximum height of the PDF.
virtual const std::vector< LauParameter * > & getParameters() const
Retrieve the parameters of the PDF, e.g. so that they can be loaded into a fit.
Definition: LauAbsPdf.hh:321
virtual void setNorm(Double_t norm)
Set the normalisation factor.
Definition: LauAbsPdf.hh:410
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:213
virtual Double_t getParMin(const TString &parName) const
Retrieve the minimum value of the specified parameter.
Definition: LauAbsPdf.cc:415
virtual void setParMin(const TString &parName, Double_t minValue)
Change the minimum value of the specified parameter.
Definition: LauAbsPdf.cc:473
virtual Int_t nNormPoints() const
Retrieve the number of points to integrate over when normalising.
Definition: LauAbsPdf.hh:361
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:578
virtual Bool_t withinNormCalc() const
Check whether the calcNorm method is running.
Definition: LauAbsPdf.hh:508
virtual void heightUpToDate(Bool_t hutd)
Set whether the height is up to date.
Definition: LauAbsPdf.hh:392
virtual TRandom * getRandomFun() const
Retrieve the random function used for MC generation.
Definition: LauAbsPdf.hh:472
Bool_t cachePDF_
Whether the unnormalised PDF values are cached.
Definition: LauAbsPdf.hh:588
virtual const std::vector< LauAbscissas > & getAbscissas() const
Retrieve the abscissa(s)
Definition: LauAbsPdf.hh:484
virtual void normWeightsDone(Bool_t yorn)
Set whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:538
virtual Double_t getMaxHeight() const
Retrieve the maximum height.
Definition: LauAbsPdf.hh:303
Int_t nNormPoints_
number of points to integrate over when normalising
Definition: LauAbsPdf.hh:594
virtual void setParRange(const TString &parName, Double_t minValue, Double_t maxValue)
Change the range of the specified parameter.
Definition: LauAbsPdf.cc:489
LauAbscissas minAbscissas_
The minimum value(s) of the abscissa(s)
Definition: LauAbsPdf.hh:572
virtual void cachePDF(Bool_t doCachePDF)
Set whether the PDF is to be cached.
Definition: LauAbsPdf.hh:386
Double_t norm_
Normalisation factor of the PDF.
Definition: LauAbsPdf.hh:563
virtual void setMaxAbscissa(const TString &theVarName, Double_t maxAbscissa)
Set the maximum value of the specified abscissa.
Definition: LauAbsPdf.cc:199
virtual void setParValue(const TString &parName, Double_t value)
Change the value of the specified parameter.
Definition: LauAbsPdf.cc:465
std::vector< LauAbscissas > abscissas_
Cached values of the abscissas.
Definition: LauAbsPdf.hh:581
virtual void fixPar(const TString &parName)
Fix the specified parameter.
Definition: LauAbsPdf.cc:497
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
virtual void updatePulls()
Update the pulls for all parameters.
Definition: LauAbsPdf.cc:513
Bool_t heightUpToDate_
Track whether the height is up to date.
Definition: LauAbsPdf.hh:569
virtual void integMethod(IntMethod method)
Set the integration method used to normalise the PDF.
Definition: LauAbsPdf.hh:379
std::vector< Double_t > normWeights_
The normalisation weights.
Definition: LauAbsPdf.hh:612
virtual Bool_t parFixed(const TString &parName) const
Retrieve whether the specified parameter is fixed.
Definition: LauAbsPdf.cc:445
File containing declaration of LauParameter class.
virtual ~LauAbsPdf()
Destructor.
Definition: LauAbsPdf.hh:73
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:164
virtual Bool_t isDPDependent() const
Specifies whether or not the PDF is DP dependent.
Definition: LauAbsPdf.hh:110
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:416
Bool_t withinNormCalc_
Flag to keep track of whether the calcNorm method is running.
Definition: LauAbsPdf.hh:600
Class for defining the fit parameter objects.
Definition: LauParameter.hh:31
std::vector< Double_t > unNormPDFValues_
Cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:584
virtual std::vector< LauAbscissas > & getAbscissas()
Retrieve the abscissa(s)
Definition: LauAbsPdf.hh:478
IntMethod integMethod_
The integration method used for normalising the PDF.
Definition: LauAbsPdf.hh:597
virtual void withinGeneration(Bool_t yorn)
Set flag to track whether the generate method is running.
Definition: LauAbsPdf.hh:526
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:520
virtual const std::vector< Double_t > & normWeights() const
Retrieve the weights used for normalisation.
Definition: LauAbsPdf.hh:553
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:490
virtual Bool_t cachePDF() const
Check if the PDF is to be cached.
Definition: LauAbsPdf.hh:355
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:191
virtual Bool_t parClone(const TString &parName) const
Retrieve whether the specified parameter is a clone.
Definition: LauAbsPdf.cc:455
LauAbsPdf(const TString &theVarName, const std::vector< LauParameter * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor for a 1D PDF.
Definition: LauAbsPdf.cc:30
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)=0
Calculate the likelihood (and all associated information) given value(s) of the abscissa(s) ...
virtual Double_t getParMax(const TString &parName) const
Retrieve the maximum value of the specified parameter.
Definition: LauAbsPdf.cc:425
Bool_t withinGeneration_
Flag to keep track of whether the generate method is running.
Definition: LauAbsPdf.hh:603
virtual void getNormWeights()
Calculate the weights and abscissas used for normalisation.
Definition: LauAbsPdf.cc:569
virtual void checkPositiveness()=0
Ensure the PDF is positive definite.
virtual LauParameter * findParameter(const TString &parName)
Retrieve the specified parameter.
Definition: LauAbsPdf.cc:381
std::map< UInt_t, TString > varNames_
The names of the PDF variables.
Definition: LauAbsPdf.hh:557
virtual void calcNorm()
Calculate the normalisation factor of the PDF.
Definition: LauAbsPdf.cc:529
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:40
virtual Double_t getParRange(const TString &parName) const
Retrieve the range of the specified parameter.
Definition: LauAbsPdf.cc:435
virtual IntMethod integMethod() const
Retrieve the integration method used to normalise the PDF.
Definition: LauAbsPdf.hh:373
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:575
virtual void floatPar(const TString &parName)
Float the specified parameter.
Definition: LauAbsPdf.cc:505
virtual std::vector< LauParameter * > & getParameters()
Retrieve the parameters of the PDF, e.g. so that they can be loaded into a fit.
Definition: LauAbsPdf.hh:327
virtual UInt_t nInputVars() const
Retrieve the number of abscissas.
Definition: LauAbsPdf.hh:103
Double_t maxHeight_
Maximum height of the PDF.
Definition: LauAbsPdf.hh:566
virtual Double_t getRange() const
Retrieve the range of the (primary) abscissa.
Definition: LauAbsPdf.hh:170
IntMethod
The possible numerical intergration methods.
Definition: LauAbsPdf.hh:47
virtual void setRandomFun(TRandom *randomFun)
Set the random function used for toy MC generation.
Definition: LauAbsPdf.hh:315
virtual Double_t getParValue(const TString &parName) const
Retrieve the value of the specified parameter.
Definition: LauAbsPdf.cc:405
virtual Double_t getNorm() const
Retrieve the normalisation factor.
Definition: LauAbsPdf.hh:284
virtual Double_t integTrapezoid()
Integrate the PDF using the simple trapezoid method.
Definition: LauAbsPdf.cc:620
Class to store the input fit variables.
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:44