laura is hosted by Hepforge, IPPP Durham
Laura++  v3r5
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauAbsPdf.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_ABS_PDF
38 #define LAU_ABS_PDF
39 
40 #include <map>
41 #include <vector>
42 
43 #include "Rtypes.h"
44 #include "TRandom.h"
45 #include "TString.h"
46 
47 #include "LauFitDataTree.hh"
48 #include "LauAbsRValue.hh"
49 #include "LauParameter.hh"
50 #include "LauParamFixed.hh"
51 
52 class LauKinematics;
53 
54 
55 class LauAbsPdf {
56 
57  public:
59  typedef std::vector<Double_t> LauAbscissas;
60 
62  enum IntMethod {
65  };
66 
68 
74  LauAbsPdf(const TString& theVarName, const std::vector<LauAbsRValue*>& params,
75  Double_t minAbscissa, Double_t maxAbscissa);
76 
78 
84  LauAbsPdf(const std::vector<TString>& theVarNames, const std::vector<LauAbsRValue*>& params,
85  const LauFitData& minAbscissas, const LauFitData& maxAbscissas);
86 
88  virtual ~LauAbsPdf() {}
89 
91 
94  virtual const TString& varName() const {return varNames_.find(0)->second;}
95 
97 
100  virtual std::vector<TString> varNames() const;
101 
103 
106  virtual UInt_t nParameters() const {return param_.size();}
107 
109 
112  virtual UInt_t nFixedParameters() const;
113 
115 
118  virtual UInt_t nInputVars() const {return varNames_.size();}
119 
121 
125  virtual Bool_t isDPDependent() const {return kFALSE;}
126 
128 
131  virtual Double_t getMinAbscissa() const {return minAbscissas_.front();}
132 
134 
137  virtual Double_t getMaxAbscissa() const {return maxAbscissas_.front();}
138 
140 
143  virtual Double_t getRange() const {return this->getMaxAbscissa() - this->getMinAbscissa();}
144 
146 
150  virtual Double_t getMinAbscissa( const TString& theVarName ) const;
151 
153 
157  virtual Double_t getMaxAbscissa( const TString& theVarName ) const;
158 
160 
164  virtual Double_t getRange( const TString& theVarName ) const {return this->getMaxAbscissa(theVarName) - this->getMinAbscissa(theVarName);}
165 
167 
170  virtual LauFitData getMinAbscissas() const;
171 
173 
176  virtual LauFitData getMaxAbscissas() const;
177 
179 
182  virtual LauFitData getRanges() const;
183 
185  virtual void updatePulls();
186 
188 
192  virtual void cacheInfo(const LauFitDataTree& inputData);
193 
195 
198  virtual void calcLikelihoodInfo(const LauAbscissas& abscissas) = 0;
199 
201 
204  virtual void calcLikelihoodInfo(UInt_t iEvt);
205 
207 
210  virtual Double_t getUnNormLikelihood() const {return unNormPDFVal_;}
211 
213 
216  virtual Double_t getNorm() const {return norm_;}
217 
219 
222  virtual Double_t getLikelihood() const;
223 
225 
229  virtual Double_t getLikelihood( const TString& theVarName ) const;
230 
232 
235  virtual Double_t getMaxHeight() const {return maxHeight_;}
236 
238 
241  virtual LauFitData generate(const LauKinematics* kinematics);
242 
244 
247  virtual void setRandomFun(TRandom* randomFun) {randomFun_ = randomFun;}
248 
250 
253  virtual const std::vector<LauAbsRValue*>& getParameters() const { return param_; }
254 
256 
259  virtual std::vector<LauAbsRValue*>& getParameters() { return param_; }
260 
262 
266  virtual void calcNorm();
267 
269 
272  virtual void calcPDFHeight( const LauKinematics* kinematics ) = 0;
273 
275 
278  virtual Bool_t heightUpToDate() const {return heightUpToDate_;}
279 
281 
284  virtual void heightUpToDate(Bool_t hutd) {heightUpToDate_ = hutd;}
285 
287 
290  virtual Bool_t cachePDF() const {return cachePDF_;}
291 
293 
296  virtual Int_t nNormPoints() const {return nNormPoints_;}
297 
299 
302  virtual void nNormPoints(Int_t nPoints) {nNormPoints_ = nPoints;}
303 
305 
308  virtual IntMethod integMethod() const {return integMethod_;}
309 
311 
314  virtual void integMethod(IntMethod method) {integMethod_ = method;}
315 
316  protected:
318 
321  virtual void cachePDF( Bool_t doCachePDF ) {cachePDF_ = doCachePDF;}
322 
324 
327  virtual Double_t integrGaussLegendre();
328 
330 
333  virtual Double_t integTrapezoid();
334 
336 
339  virtual void setNorm(Double_t norm) {norm_ = norm;}
340 
342 
345  virtual void setMaxHeight(Double_t maxHeight) {
346  maxHeight_ = maxHeight;
347  this->heightUpToDate(kTRUE);
348  }
349 
351 
355  virtual void setMinAbscissa(const TString& theVarName, Double_t minAbscissa);
356 
358 
362  virtual void setMaxAbscissa(const TString& theVarName, Double_t maxAbscissa);
363 
365 
370  virtual void setRange(const TString& theVarName, Double_t minAbscissa, Double_t maxAbscissa) {
371  this->setMinAbscissa(theVarName, minAbscissa);
372  this->setMaxAbscissa(theVarName, maxAbscissa);
373  }
374 
376 
380  virtual Bool_t checkRange(const LauAbscissas& abscissas) const;
381 
383  virtual void setUnNormPDFVal(Double_t unNormPDFVal) {unNormPDFVal_ = unNormPDFVal;}
384 
386 
389  virtual LauAbsRValue* findParameter(const TString& parName);
390 
392 
395  virtual const LauAbsRValue* findParameter(const TString& parName) const;
396 
398 
401  virtual TRandom* getRandomFun() const {return randomFun_;}
402 
404 
407  virtual std::vector<LauAbscissas>& getAbscissas() {return abscissas_;}
408 
410 
413  virtual const std::vector<LauAbscissas>& getAbscissas() const {return abscissas_;}
414 
416 
419  virtual std::vector<Double_t>& getUnNormPDFValues() {return unNormPDFValues_;}
420 
422 
425  virtual const std::vector<Double_t>& getUnNormPDFValues() const {return unNormPDFValues_;}
426 
428 
431  virtual void addParameters(std::vector<LauAbsRValue*>& params);
432 
434 
437  virtual Bool_t withinNormCalc() const {return withinNormCalc_;}
438 
440 
443  virtual void withinNormCalc(Bool_t yorn) {withinNormCalc_ = yorn;}
444 
446 
449  virtual Bool_t withinGeneration() const {return withinGeneration_;}
450 
452 
455  virtual void withinGeneration(Bool_t yorn) {withinGeneration_ = yorn;}
456 
458 
461  virtual Bool_t normWeightsDone() const {return normWeightsDone_;}
462 
464 
467  virtual void normWeightsDone(Bool_t yorn) {normWeightsDone_ = yorn;}
468 
470  virtual void getNormWeights();
471 
473 
476  virtual const std::vector<LauAbscissas>& normAbscissas() const {return normAbscissas_;}
477 
479 
482  virtual const std::vector<Double_t>& normWeights() const {return normWeights_;}
483 
484  private:
486  LauAbsPdf(const LauAbsPdf& rhs);
487 
489  LauAbsPdf& operator=(const LauAbsPdf& rhs);
490 
492  std::map<UInt_t,TString> varNames_;
493 
495  std::vector<LauAbsRValue*> param_;
496 
498  Double_t norm_;
499 
501  Double_t maxHeight_;
502 
505 
508 
511 
513  TRandom* randomFun_;
514 
516  std::vector<LauAbscissas> abscissas_;
517 
519  std::vector<Double_t> unNormPDFValues_;
520 
522 
523  Bool_t cachePDF_;
524 
526  Double_t unNormPDFVal_;
527 
530 
533 
536 
539 
542 
544  std::vector<LauAbscissas> normAbscissas_;
545 
547  std::vector<Double_t> normWeights_;
548 
549  ClassDef(LauAbsPdf,0) // Define the abstract PDF class
550 };
551 
552 #endif
virtual Double_t integrGaussLegendre()
Integrate the PDF using the Gauss-Legendre method.
Definition: LauAbsPdf.cc:462
virtual const std::vector< Double_t > & getUnNormPDFValues() const
Retrieve the cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:425
TRandom * randomFun()
Access the singleton random number generator with a particular seed.
Definition: LauRandom.cc:34
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:383
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:302
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:131
virtual Bool_t normWeightsDone() const
Check whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:461
Double_t unNormPDFVal_
The unnormalised liklihood value.
Definition: LauAbsPdf.hh:526
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:278
File containing declaration of LauParamFixed class.
virtual const TString & varName() const
Retrieve the name of the abscissa.
Definition: LauAbsPdf.hh:94
virtual void withinNormCalc(Bool_t yorn)
Set flag to track whether the calcNorm method is running.
Definition: LauAbsPdf.hh:443
virtual void setRange(const TString &theVarName, Double_t minAbscissa, Double_t maxAbscissa)
Set the range of the specified abscissa.
Definition: LauAbsPdf.hh:370
virtual LauAbsRValue * findParameter(const TString &parName)
Retrieve the specified parameter.
Definition: LauAbsPdf.cc:395
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:259
virtual UInt_t nParameters() const
Retrieve the number of PDF parameters.
Definition: LauAbsPdf.hh:106
virtual const std::vector< LauAbscissas > & normAbscissas() const
Retrieve the abscissa points used for normalisation.
Definition: LauAbsPdf.hh:476
Bool_t normWeightsDone_
Whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:541
std::vector< LauAbscissas > normAbscissas_
The normalisation abscissas.
Definition: LauAbsPdf.hh:544
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:210
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:339
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:227
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:296
virtual void setMinAbscissa(const TString &theVarName, Double_t minAbscissa)
Set the minimum value of the specified abscissa.
Definition: LauAbsPdf.cc:199
virtual LauFitData generate(const LauKinematics *kinematics)
Generate an event from the PDF.
Definition: LauAbsPdf.cc:312
std::map< TString, Double_t > LauFitData
Type for holding event data.
TRandom * randomFun_
The random function used for MC generation.
Definition: LauAbsPdf.hh:513
virtual Bool_t withinNormCalc() const
Check whether the calcNorm method is running.
Definition: LauAbsPdf.hh:437
LauAbsPdf(const TString &theVarName, const std::vector< LauAbsRValue * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor for a 1D PDF.
Definition: LauAbsPdf.cc:44
virtual void heightUpToDate(Bool_t hutd)
Set whether the height is up to date.
Definition: LauAbsPdf.hh:284
virtual TRandom * getRandomFun() const
Retrieve the random function used for MC generation.
Definition: LauAbsPdf.hh:401
Bool_t cachePDF_
Whether the unnormalised PDF values are cached.
Definition: LauAbsPdf.hh:523
virtual const std::vector< LauAbscissas > & getAbscissas() const
Retrieve the abscissa(s)
Definition: LauAbsPdf.hh:413
virtual void normWeightsDone(Bool_t yorn)
Set whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:467
virtual Double_t getMaxHeight() const
Retrieve the maximum height.
Definition: LauAbsPdf.hh:235
Int_t nNormPoints_
number of points to integrate over when normalising
Definition: LauAbsPdf.hh:529
LauAbscissas minAbscissas_
The minimum value(s) of the abscissa(s)
Definition: LauAbsPdf.hh:507
virtual void cachePDF(Bool_t doCachePDF)
Set whether the PDF is to be cached.
Definition: LauAbsPdf.hh:321
Double_t norm_
Normalisation factor of the PDF.
Definition: LauAbsPdf.hh:498
std::vector< LauAbsRValue * > param_
The parameters of the PDF (if any)
Definition: LauAbsPdf.hh:495
virtual void setMaxAbscissa(const TString &theVarName, Double_t maxAbscissa)
Set the maximum value of the specified abscissa.
Definition: LauAbsPdf.cc:213
std::vector< LauAbscissas > abscissas_
Cached values of the abscissas.
Definition: LauAbsPdf.hh:516
virtual LauFitData getMinAbscissas() const
Retrieve the minimum values of all the abscissas.
Definition: LauAbsPdf.cc:161
virtual LauFitData getRanges() const
Retrieve the ranges of all the abscissas.
Definition: LauAbsPdf.cc:183
File containing declaration of LauAbsRValue class.
virtual void updatePulls()
Update the pulls for all parameters.
Definition: LauAbsPdf.cc:425
Bool_t heightUpToDate_
Track whether the height is up to date.
Definition: LauAbsPdf.hh:504
virtual void integMethod(IntMethod method)
Set the integration method used to normalise the PDF.
Definition: LauAbsPdf.hh:314
std::vector< Double_t > normWeights_
The normalisation weights.
Definition: LauAbsPdf.hh:547
File containing declaration of LauParameter class.
virtual ~LauAbsPdf()
Destructor.
Definition: LauAbsPdf.hh:88
virtual std::vector< TString > varNames() const
Retrieve the names of the abscissas.
Definition: LauAbsPdf.cc:117
virtual Double_t getMaxAbscissa() const
Retrieve the maximum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:137
virtual Bool_t isDPDependent() const
Specifies whether or not the PDF is DP dependent.
Definition: LauAbsPdf.hh:125
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:345
Bool_t withinNormCalc_
Flag to keep track of whether the calcNorm method is running.
Definition: LauAbsPdf.hh:535
virtual void addParameters(std::vector< LauAbsRValue * > &params)
Add parameters to the PDF.
Definition: LauAbsPdf.cc:437
std::vector< Double_t > unNormPDFValues_
Cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:519
virtual std::vector< LauAbscissas > & getAbscissas()
Retrieve the abscissa(s)
Definition: LauAbsPdf.hh:407
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:253
IntMethod integMethod_
The integration method used for normalising the PDF.
Definition: LauAbsPdf.hh:532
virtual void withinGeneration(Bool_t yorn)
Set flag to track whether the generate method is running.
Definition: LauAbsPdf.hh:455
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:449
virtual const std::vector< Double_t > & normWeights() const
Retrieve the weights used for normalisation.
Definition: LauAbsPdf.hh:482
virtual LauFitData getMaxAbscissas() const
Retrieve the maximum values of all the abscissas.
Definition: LauAbsPdf.cc:172
virtual std::vector< Double_t > & getUnNormPDFValues()
Retrieve the cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:419
virtual Bool_t cachePDF() const
Check if the PDF is to be cached.
Definition: LauAbsPdf.hh:290
virtual Double_t getLikelihood() const
Retrieve the normalised likelihood value.
Definition: LauAbsPdf.cc:368
virtual Double_t getRange(const TString &theVarName) const
Retrieve the range of the specified abscissa.
Definition: LauAbsPdf.hh:164
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:538
virtual void getNormWeights()
Calculate the weights and abscissas used for normalisation.
Definition: LauAbsPdf.cc:484
std::map< UInt_t, TString > varNames_
The names of the PDF variables.
Definition: LauAbsPdf.hh:492
virtual void calcNorm()
Calculate the normalisation factor of the PDF.
Definition: LauAbsPdf.cc:444
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:55
virtual IntMethod integMethod() const
Retrieve the integration method used to normalise the PDF.
Definition: LauAbsPdf.hh:308
Class for calculating 3-body kinematic quantities.
virtual UInt_t nFixedParameters() const
Retrieve the number of fixed PDF parameters.
Definition: LauAbsPdf.cc:127
virtual void cacheInfo(const LauFitDataTree &inputData)
Cache information from data.
Definition: LauAbsPdf.cc:255
LauAbscissas maxAbscissas_
The maximum value(s) of the abscissa(s)
Definition: LauAbsPdf.hh:510
virtual UInt_t nInputVars() const
Retrieve the number of abscissas.
Definition: LauAbsPdf.hh:118
Double_t maxHeight_
Maximum height of the PDF.
Definition: LauAbsPdf.hh:501
virtual Double_t getRange() const
Retrieve the range of the (primary) abscissa.
Definition: LauAbsPdf.hh:143
IntMethod
The possible numerical intergration methods.
Definition: LauAbsPdf.hh:62
virtual void setRandomFun(TRandom *randomFun)
Set the random function used for toy MC generation.
Definition: LauAbsPdf.hh:247
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:43
virtual Double_t getNorm() const
Retrieve the normalisation factor.
Definition: LauAbsPdf.hh:216
virtual Double_t integTrapezoid()
Integrate the PDF using the simple trapezoid method.
Definition: LauAbsPdf.cc:535
Class to store the input fit variables.
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:59