laura is hosted by Hepforge, IPPP Durham
Laura++  v3r5
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauExponentialPdf.cc
Go to the documentation of this file.
1 
2 /*
3 Copyright 2011 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 
29 #include <iostream>
30 #include <vector>
31 using std::cout;
32 using std::cerr;
33 using std::endl;
34 using std::vector;
35 
36 #include "TMath.h"
37 #include "TSystem.h"
38 
39 #include "LauConstants.hh"
40 #include "LauExponentialPdf.hh"
41 
43 
44 
45 LauExponentialPdf::LauExponentialPdf(const TString& theVarName, const vector<LauAbsRValue*>& params, Double_t minAbscissa, Double_t maxAbscissa) :
46  LauAbsPdf(theVarName, params, minAbscissa, maxAbscissa),
47  slope_(0)
48 {
49  // Constructor for the Exponential PDF.
50  //
51  // The parameter in param is the slope of the exponential ie exp(slope*x).
52  // The last two arguments specify the range in which the PDF is defined, and the PDF
53  // will be normalised w.r.t. these limits.
54 
55  slope_ = this->findParameter("slope");
56 
57  if ((this->nParameters() != 1) || (slope_ == 0)) {
58  cerr<<"ERROR in LauExponentialPdf constructor: LauExponentialPdf requires 1 parameter: \"slope\"."<<endl;
59  gSystem->Exit(EXIT_FAILURE);
60  }
61 
62  // Cache the normalisation factor
63  this->calcNorm();
64 }
65 
67 {
68  // Destructor
69 }
70 
72 {
73  // Check that the given abscissa is within the allowed range
74  if (!this->checkRange(abscissas)) {
75  gSystem->Exit(EXIT_FAILURE);
76  }
77 
78  // Get our abscissa
79  Double_t abscissa = abscissas[0];
80 
81  // Get the up to date parameter values
82  Double_t slope = slope_->unblindValue();
83 
84  // Calculate the value of the Exponential for the given value of the abscissa.
85 
86  Double_t exponent(0.0);
87  if(slope != 0){
88  exponent = slope*abscissa;
89  }
90 
91  Double_t value = TMath::Exp(exponent);
92  this->setUnNormPDFVal(value);
93 
94  // if the parameters are floating then we
95  // need to recalculate the normalisation
96  if (!this->cachePDF() && !this->withinNormCalc() && !this->withinGeneration()) {
97  this->calcNorm();
98  }
99 
100 }
101 
103 {
104  // Get the up to date parameter values
105  Double_t slope = slope_->unblindValue();
106 
107  // Calculate the normalisation of the exponential and cache it.
108  Double_t norm(0.0);
109 
110  if(slope != 0){
111  norm = (1/slope)*(TMath::Exp(slope*this->getMaxAbscissa()) - TMath::Exp(slope*this->getMinAbscissa())) ;
112  }
113 
114  this->setNorm(norm);
115 }
116 
118 {
119  if (this->heightUpToDate()) {
120  return;
121  }
122 
123  // Get the up to date parameter values
124  Double_t slope = slope_->unblindValue();
125 
126  LauAbscissas maxPoint(1);
127  maxPoint[0] = 0;
128 
129  // Calculate the PDF height for the Exponential function.
130  if (slope > 0) {
131  maxPoint[0] = this->getMaxAbscissa();
132  } else if (slope < 0) {
133  maxPoint[0] = this->getMinAbscissa();
134  }
135  this->calcLikelihoodInfo(maxPoint);
136 
137  Double_t height = this->getUnNormLikelihood();
138  this->setMaxHeight(height);
139 }
140 
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:383
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:131
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:278
ClassImp(LauAbsCoeffSet)
File containing declaration of LauExponentialPdf class.
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:210
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
virtual Bool_t withinNormCalc() const
Check whether the calcNorm method is running.
Definition: LauAbsPdf.hh:437
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:137
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:345
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:449
virtual Bool_t cachePDF() const
Check if the PDF is to be cached.
Definition: LauAbsPdf.hh:290
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:55
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:43
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:59