laura is hosted by Hepforge, IPPP Durham
Laura++  v3r0p1
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauExponentialPdf.cc
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2011 - 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 
15 #include <iostream>
16 #include <vector>
17 using std::cout;
18 using std::cerr;
19 using std::endl;
20 using std::vector;
21 
22 #include "TMath.h"
23 #include "TSystem.h"
24 
25 #include "LauConstants.hh"
26 #include "LauExponentialPdf.hh"
27 
29 
30 
31 LauExponentialPdf::LauExponentialPdf(const TString& theVarName, const vector<LauAbsRValue*>& params, Double_t minAbscissa, Double_t maxAbscissa) :
32  LauAbsPdf(theVarName, params, minAbscissa, maxAbscissa),
33  slope_(0)
34 {
35  // Constructor for the Exponential PDF.
36  //
37  // The parameter in param is the slope of the exponential ie exp(slope*x).
38  // The last two arguments specify the range in which the PDF is defined, and the PDF
39  // will be normalised w.r.t. these limits.
40 
41  slope_ = this->findParameter("slope");
42 
43  if ((this->nParameters() != 1) || (slope_ == 0)) {
44  cerr<<"ERROR in LauExponentialPdf constructor: LauExponentialPdf requires 1 parameter: \"slope\"."<<endl;
45  gSystem->Exit(EXIT_FAILURE);
46  }
47 
48  // Cache the normalisation factor
49  this->calcNorm();
50 }
51 
53 {
54  // Destructor
55 }
56 
58 {
59  // Check that the given abscissa is within the allowed range
60  if (!this->checkRange(abscissas)) {
61  gSystem->Exit(EXIT_FAILURE);
62  }
63 
64  // Get our abscissa
65  Double_t abscissa = abscissas[0];
66 
67  // Get the up to date parameter values
68  Double_t slope = slope_->value();
69 
70  // Calculate the value of the Exponential for the given value of the abscissa.
71 
72  Double_t exponent(0.0);
73  if(slope != 0){
74  exponent = slope*abscissa;
75  }
76 
77  Double_t value = TMath::Exp(exponent);
78  this->setUnNormPDFVal(value);
79 
80  // if the parameters are floating then we
81  // need to recalculate the normalisation
82  if (!this->cachePDF() && !this->withinNormCalc() && !this->withinGeneration()) {
83  this->calcNorm();
84  }
85 
86 }
87 
89 {
90  // Get the up to date parameter values
91  Double_t slope = slope_->value();
92 
93  // Calculate the normalisation of the exponential and cache it.
94  Double_t norm(0.0);
95 
96  if(slope != 0){
97  norm = (1/slope)*(TMath::Exp(slope*this->getMaxAbscissa()) - TMath::Exp(slope*this->getMinAbscissa())) ;
98  }
99 
100  this->setNorm(norm);
101 }
102 
104 {
105  if (this->heightUpToDate()) {
106  return;
107  }
108 
109  // Get the up to date parameter values
110  Double_t slope = slope_->value();
111 
112  LauAbscissas maxPoint(1);
113  maxPoint[0] = 0;
114 
115  // Calculate the PDF height for the Exponential function.
116  if (slope > 0) {
117  maxPoint[0] = this->getMaxAbscissa();
118  } else if (slope < 0) {
119  maxPoint[0] = this->getMinAbscissa();
120  }
121  this->calcLikelihoodInfo(maxPoint);
122 
123  Double_t height = this->getUnNormLikelihood();
124  this->setMaxHeight(height);
125 }
126 
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:369
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:117
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:264
ClassImp(LauAbsCoeffSet)
File containing declaration of LauExponentialPdf class.
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:196
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
virtual Bool_t withinNormCalc() const
Check whether the calcNorm method is running.
Definition: LauAbsPdf.hh:423
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)
Calculate the likelihood (and intermediate info) for a given abscissa.
virtual void calcNorm()
Calculate the normalisation.
virtual Double_t getMaxAbscissa() const
Retrieve the maximum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:123
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:331
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:435
virtual Bool_t cachePDF() const
Check if the PDF is to be cached.
Definition: LauAbsPdf.hh:276
Class for defining an Exponential PDF.
File containing LauConstants namespace.
virtual ~LauExponentialPdf()
Destructor.
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:41
Class for calculating 3-body kinematic quantities.
Double_t value() const
The value of the parameter.
virtual void calcPDFHeight(const LauKinematics *kinematics)
Calculate the PDF height.
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:29
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:45