laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
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 "LauAbsRValue.hh"
41 #include "LauFitDataTree.hh"
42 #include "LauParamFixed.hh"
43 #include "LauParameter.hh"
44 
45 #include "Rtypes.h"
46 #include "TRandom.h"
47 #include "TString.h"
48 
49 #include <map>
50 #include <vector>
51 
52 class LauKinematics;
53 
54 class LauAbsPdf {
55 
56  public:
58  typedef std::vector<Double_t> LauAbscissas;
59 
61  enum IntMethod {
63  Trapezoid
64  };
65 
67 
73  LauAbsPdf( const TString& theVarName,
74  const std::vector<LauAbsRValue*>& params,
75  Double_t minAbscissa,
76  Double_t maxAbscissa );
77 
79 
85  LauAbsPdf( const std::vector<TString>& theVarNames,
86  const std::vector<LauAbsRValue*>& params,
87  const LauFitData& minAbscissas,
88  const LauFitData& maxAbscissas );
89 
91  virtual ~LauAbsPdf() {}
92 
94 
97  virtual const TString& varName() const { return varNames_.find( 0 )->second; }
98 
100 
103  virtual std::vector<TString> varNames() const;
104 
106 
109  virtual UInt_t nParameters() const { return param_.size(); }
110 
112 
115  virtual UInt_t nFixedParameters() const;
116 
118 
121  virtual UInt_t nInputVars() const { return varNames_.size(); }
122 
124 
129  virtual Bool_t isDPDependent() const { return kFALSE; }
130 
132 
135  virtual Double_t getMinAbscissa() const { return minAbscissas_.front(); }
136 
138 
141  virtual Double_t getMaxAbscissa() const { return maxAbscissas_.front(); }
142 
144 
147  virtual Double_t getRange() const { return this->getMaxAbscissa() - this->getMinAbscissa(); }
148 
150 
154  virtual Double_t getMinAbscissa( const TString& theVarName ) const;
155 
157 
161  virtual Double_t getMaxAbscissa( const TString& theVarName ) const;
162 
164 
168  virtual Double_t getRange( const TString& theVarName ) const
169  {
170  return this->getMaxAbscissa( theVarName ) - this->getMinAbscissa( theVarName );
171  }
172 
174 
177  virtual LauFitData getMinAbscissas() const;
178 
180 
183  virtual LauFitData getMaxAbscissas() const;
184 
186 
189  virtual LauFitData getRanges() const;
190 
192  virtual void updatePulls();
193 
195 
200  virtual void cacheInfo( const LauFitDataTree& inputData );
201 
203 
206  virtual void calcLikelihoodInfo( const LauAbscissas& abscissas ) = 0;
207 
209 
212  virtual void calcLikelihoodInfo( UInt_t iEvt );
213 
215 
218  virtual Double_t getUnNormLikelihood() const { return unNormPDFVal_; }
219 
221 
224  virtual Double_t getNorm() const { return norm_; }
225 
227 
230  virtual Double_t getLikelihood() const;
231 
233 
238  virtual Double_t getLikelihood( const TString& theVarName ) const;
239 
241 
244  virtual Double_t getMaxHeight() const { return maxHeight_; }
245 
247 
250  virtual LauFitData generate( const LauKinematics* kinematics );
251 
253 
256  virtual void setRandomFun( TRandom* randomFun ) { randomFun_ = randomFun; }
257 
259 
262  virtual const std::vector<LauAbsRValue*>& getParameters() const { return param_; }
263 
265 
268  virtual std::vector<LauAbsRValue*>& getParameters() { return param_; }
269 
271 
275  virtual void calcNorm();
276 
278 
281  virtual void calcPDFHeight( const LauKinematics* kinematics ) = 0;
282 
284 
287  virtual Bool_t heightUpToDate() const { return heightUpToDate_; }
288 
290 
293  virtual void heightUpToDate( Bool_t hutd ) { heightUpToDate_ = hutd; }
294 
296 
299  virtual Bool_t cachePDF() const { return cachePDF_; }
300 
302 
305  virtual Int_t nNormPoints() const { return nNormPoints_; }
306 
308 
311  virtual void nNormPoints( Int_t nPoints ) { nNormPoints_ = nPoints; }
312 
314 
317  virtual IntMethod integMethod() const { return integMethod_; }
318 
320 
323  virtual void integMethod( IntMethod method ) { integMethod_ = method; }
324 
325  protected:
327 
330  virtual void cachePDF( Bool_t doCachePDF ) { cachePDF_ = doCachePDF; }
331 
333 
336  virtual Double_t integrGaussLegendre();
337 
339 
342  virtual Double_t integTrapezoid();
343 
345 
348  virtual void setNorm( Double_t norm ) { norm_ = norm; }
349 
351 
354  virtual void setMaxHeight( Double_t maxHeight )
355  {
356  maxHeight_ = maxHeight;
357  this->heightUpToDate( kTRUE );
358  }
359 
361 
365  virtual void setMinAbscissa( const TString& theVarName, Double_t minAbscissa );
366 
368 
372  virtual void setMaxAbscissa( const TString& theVarName, Double_t maxAbscissa );
373 
375 
380  virtual void setRange( const TString& theVarName, Double_t minAbscissa, Double_t maxAbscissa )
381  {
382  this->setMinAbscissa( theVarName, minAbscissa );
383  this->setMaxAbscissa( theVarName, maxAbscissa );
384  }
385 
387 
391  virtual Bool_t checkRange( const LauAbscissas& abscissas ) const;
392 
394  virtual void setUnNormPDFVal( Double_t unNormPDFVal ) { unNormPDFVal_ = unNormPDFVal; }
395 
397 
400  virtual LauAbsRValue* findParameter( const TString& parName );
401 
403 
406  virtual const LauAbsRValue* findParameter( const TString& parName ) const;
407 
409 
412  virtual TRandom* getRandomFun() const { return randomFun_; }
413 
415 
418  virtual std::vector<LauAbscissas>& getAbscissas() { return abscissas_; }
419 
421 
424  virtual const std::vector<LauAbscissas>& getAbscissas() const { return abscissas_; }
425 
427 
430  virtual std::vector<Double_t>& getUnNormPDFValues() { return unNormPDFValues_; }
431 
433 
436  virtual const std::vector<Double_t>& getUnNormPDFValues() const { return unNormPDFValues_; }
437 
439 
442  virtual void addParameters( std::vector<LauAbsRValue*>& params );
443 
445 
448  virtual Bool_t withinNormCalc() const { return withinNormCalc_; }
449 
451 
454  virtual void withinNormCalc( Bool_t yorn ) { withinNormCalc_ = yorn; }
455 
457 
460  virtual Bool_t withinGeneration() const { return withinGeneration_; }
461 
463 
466  virtual void withinGeneration( Bool_t yorn ) { withinGeneration_ = yorn; }
467 
469 
472  virtual Bool_t normWeightsDone() const { return normWeightsDone_; }
473 
475 
478  virtual void normWeightsDone( Bool_t yorn ) { normWeightsDone_ = yorn; }
479 
481  virtual void getNormWeights();
482 
484 
487  virtual const std::vector<LauAbscissas>& normAbscissas() const { return normAbscissas_; }
488 
490 
493  virtual const std::vector<Double_t>& normWeights() const { return normWeights_; }
494 
495  private:
497  LauAbsPdf( const LauAbsPdf& rhs );
498 
500  LauAbsPdf& operator=( const LauAbsPdf& rhs );
501 
503  std::map<UInt_t, TString> varNames_;
504 
506  std::vector<LauAbsRValue*> param_;
507 
509  Double_t norm_;
510 
512  Double_t maxHeight_;
513 
516 
519 
522 
524  TRandom* randomFun_;
525 
527  std::vector<LauAbscissas> abscissas_;
528 
530  std::vector<Double_t> unNormPDFValues_;
531 
533 
534  Bool_t cachePDF_;
535 
537  Double_t unNormPDFVal_;
538 
541 
544 
547 
550 
553 
555  std::vector<LauAbscissas> normAbscissas_;
556 
558  std::vector<Double_t> normWeights_;
559 
560  ClassDef( LauAbsPdf, 0 ) // Define the abstract PDF class
561 };
562 
563 #endif
virtual void withinNormCalc(Bool_t yorn)
Set flag to track whether the calcNorm method is running.
Definition: LauAbsPdf.hh:454
Bool_t normWeightsDone_
Whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:552
Double_t maxHeight_
Maximum height of the PDF.
Definition: LauAbsPdf.hh:512
virtual UInt_t nFixedParameters() const
Retrieve the number of fixed PDF parameters.
Definition: LauAbsPdf.cc:133
virtual LauFitData generate(const LauKinematics *kinematics)
Generate an event from the PDF.
Definition: LauAbsPdf.cc:338
virtual Double_t getMaxAbscissa() const
Retrieve the maximum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:141
Bool_t withinGeneration_
Flag to keep track of whether the generate method is running.
Definition: LauAbsPdf.hh:549
virtual Double_t getMaxHeight() const
Retrieve the maximum height.
Definition: LauAbsPdf.hh:244
Bool_t withinNormCalc_
Flag to keep track of whether the calcNorm method is running.
Definition: LauAbsPdf.hh:546
Bool_t heightUpToDate_
Track whether the height is up to date.
Definition: LauAbsPdf.hh:515
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:135
virtual void setMaxAbscissa(const TString &theVarName, Double_t maxAbscissa)
Set the maximum value of the specified abscissa.
Definition: LauAbsPdf.cc:227
virtual LauFitData getMaxAbscissas() const
Retrieve the maximum values of all the abscissas.
Definition: LauAbsPdf.cc:183
LauAbscissas maxAbscissas_
The maximum value(s) of the abscissa(s)
Definition: LauAbsPdf.hh:521
std::vector< Double_t > normWeights_
The normalisation weights.
Definition: LauAbsPdf.hh:558
virtual const std::vector< LauAbscissas > & getAbscissas() const
Retrieve the abscissa(s)
Definition: LauAbsPdf.hh:424
virtual void calcNorm()
Calculate the normalisation factor of the PDF.
Definition: LauAbsPdf.cc:485
File containing declaration of LauParamFixed class.
IntMethod
The possible numerical intergration methods.
Definition: LauAbsPdf.hh:61
virtual Bool_t isDPDependent() const
Specifies whether or not the PDF is DP dependent.
Definition: LauAbsPdf.hh:129
virtual Bool_t cachePDF() const
Check if the PDF is to be cached.
Definition: LauAbsPdf.hh:299
Int_t nNormPoints_
number of points to integrate over when normalising
Definition: LauAbsPdf.hh:540
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:58
File containing declaration of LauParameter class.
std::vector< LauAbscissas > normAbscissas_
The normalisation abscissas.
Definition: LauAbsPdf.hh:555
virtual Double_t getRange() const
Retrieve the range of the (primary) abscissa.
Definition: LauAbsPdf.hh:147
File containing declaration of LauFitDataTree class.
std::vector< LauAbscissas > abscissas_
Cached values of the abscissas.
Definition: LauAbsPdf.hh:527
virtual void calcPDFHeight(const LauKinematics *kinematics)=0
Calculate the maximum height of the PDF.
virtual void normWeightsDone(Bool_t yorn)
Set whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:478
virtual LauAbsRValue * findParameter(const TString &parName)
Retrieve the specified parameter.
Definition: LauAbsPdf.cc:431
virtual Bool_t normWeightsDone() const
Check whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:472
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:268
std::vector< LauAbsRValue * > param_
The parameters of the PDF (if any)
Definition: LauAbsPdf.hh:506
LauAbsPdf & operator=(const LauAbsPdf &rhs)
Copy assignment operator (not implemented)
virtual void cacheInfo(const LauFitDataTree &inputData)
Cache information from data.
Definition: LauAbsPdf.cc:275
virtual Double_t integrGaussLegendre()
Integrate the PDF using the Gauss-Legendre method.
Definition: LauAbsPdf.cc:505
virtual Bool_t withinNormCalc() const
Check whether the calcNorm method is running.
Definition: LauAbsPdf.hh:448
Class to store the input fit variables.
File containing declaration of LauAbsRValue class.
LauAbsPdf(const TString &theVarName, const std::vector< LauAbsRValue * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor for a 1D PDF.
Definition: LauAbsPdf.cc:43
virtual UInt_t nParameters() const
Retrieve the number of PDF parameters.
Definition: LauAbsPdf.hh:109
virtual void setNorm(Double_t norm)
Set the normalisation factor.
Definition: LauAbsPdf.hh:348
virtual void setRange(const TString &theVarName, Double_t minAbscissa, Double_t maxAbscissa)
Set the range of the specified abscissa.
Definition: LauAbsPdf.hh:380
virtual Double_t integTrapezoid()
Integrate the PDF using the simple trapezoid method.
Definition: LauAbsPdf.cc:579
std::vector< Double_t > unNormPDFValues_
Cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:530
virtual std::vector< TString > varNames() const
Retrieve the names of the abscissas.
Definition: LauAbsPdf.cc:122
virtual std::vector< LauAbscissas > & getAbscissas()
Retrieve the abscissa(s)
Definition: LauAbsPdf.hh:418
virtual void heightUpToDate(Bool_t hutd)
Set whether the height is up to date.
Definition: LauAbsPdf.hh:293
IntMethod integMethod_
The integration method used for normalising the PDF.
Definition: LauAbsPdf.hh:543
virtual TRandom * getRandomFun() const
Retrieve the random function used for MC generation.
Definition: LauAbsPdf.hh:412
virtual UInt_t nInputVars() const
Retrieve the number of abscissas.
Definition: LauAbsPdf.hh:121
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:394
virtual void integMethod(IntMethod method)
Set the integration method used to normalise the PDF.
Definition: LauAbsPdf.hh:323
LauAbscissas minAbscissas_
The minimum value(s) of the abscissa(s)
Definition: LauAbsPdf.hh:518
std::map< UInt_t, TString > varNames_
The names of the PDF variables.
Definition: LauAbsPdf.hh:503
virtual Double_t getRange(const TString &theVarName) const
Retrieve the range of the specified abscissa.
Definition: LauAbsPdf.hh:168
TRandom * randomFun()
Access the singleton random number generator with a particular seed.
Definition: LauRandom.cc:33
virtual void withinGeneration(Bool_t yorn)
Set flag to track whether the generate method is running.
Definition: LauAbsPdf.hh:466
Double_t norm_
Normalisation factor of the PDF.
Definition: LauAbsPdf.hh:509
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)=0
Calculate the likelihood (and all associated information) given value(s) of the abscissa(s)
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:54
virtual ~LauAbsPdf()
Destructor.
Definition: LauAbsPdf.hh:91
virtual const std::vector< Double_t > & normWeights() const
Retrieve the weights used for normalisation.
Definition: LauAbsPdf.hh:493
TRandom * randomFun_
The random function used for MC generation.
Definition: LauAbsPdf.hh:524
virtual Double_t getLikelihood() const
Retrieve the normalised likelihood value.
Definition: LauAbsPdf.cc:403
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:460
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:45
virtual void setMinAbscissa(const TString &theVarName, Double_t minAbscissa)
Set the minimum value of the specified abscissa.
Definition: LauAbsPdf.cc:211
virtual LauFitData getMinAbscissas() const
Retrieve the minimum values of all the abscissas.
Definition: LauAbsPdf.cc:171
Double_t unNormPDFVal_
The unnormalised liklihood value.
Definition: LauAbsPdf.hh:537
Bool_t cachePDF_
Whether the unnormalised PDF values are cached.
Definition: LauAbsPdf.hh:534
virtual void getNormWeights()
Calculate the weights and abscissas used for normalisation.
Definition: LauAbsPdf.cc:527
virtual void updatePulls()
Update the pulls for all parameters.
Definition: LauAbsPdf.cc:464
std::map< TString, Double_t > LauFitData
Type for holding event data.
virtual LauFitData getRanges() const
Retrieve the ranges of all the abscissas.
Definition: LauAbsPdf.cc:195
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:354
virtual void cachePDF(Bool_t doCachePDF)
Set whether the PDF is to be cached.
Definition: LauAbsPdf.hh:330
virtual Double_t getNorm() const
Retrieve the normalisation factor.
Definition: LauAbsPdf.hh:224
virtual const std::vector< LauAbscissas > & normAbscissas() const
Retrieve the abscissa points used for normalisation.
Definition: LauAbsPdf.hh:487
virtual void addParameters(std::vector< LauAbsRValue * > &params)
Add parameters to the PDF.
Definition: LauAbsPdf.cc:478
virtual std::vector< Double_t > & getUnNormPDFValues()
Retrieve the cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:430
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:262
LauAbsPdf(const LauAbsPdf &rhs)
Copy constructor (not implemented)
Class for calculating 3-body kinematic quantities.
virtual IntMethod integMethod() const
Retrieve the integration method used to normalise the PDF.
Definition: LauAbsPdf.hh:317
virtual const TString & varName() const
Retrieve the name of the abscissa.
Definition: LauAbsPdf.hh:97
virtual void nNormPoints(Int_t nPoints)
Set the number of points to integrate over when normalising.
Definition: LauAbsPdf.hh:311
virtual Int_t nNormPoints() const
Retrieve the number of points to integrate over when normalising.
Definition: LauAbsPdf.hh:305
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:218
@ GaussLegendre
Definition: LauAbsPdf.hh:62
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:287
virtual const std::vector< Double_t > & getUnNormPDFValues() const
Retrieve the cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:436
virtual void setRandomFun(TRandom *randomFun)
Set the random function used for toy MC generation.
Definition: LauAbsPdf.hh:256
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:243