laura is hosted by Hepforge, IPPP Durham
Laura++  v3r4
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauArgusPdf.cc
Go to the documentation of this file.
1 
2 /*
3 Copyright 2006 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 
32 #include "TMath.h"
33 #include "TSystem.h"
34 
35 #include "LauArgusPdf.hh"
36 #include "LauConstants.hh"
37 
39 
40 
41 LauArgusPdf::LauArgusPdf(const TString& theVarName, const std::vector<LauAbsRValue*>& params, Double_t minAbscissa, Double_t maxAbscissa) :
42  LauAbsPdf(theVarName, params, minAbscissa, maxAbscissa),
43  xi_(0),
44  m0_(0)
45 {
46  // Constructor for the ARGUS PDF.
47  //
48  // The parameters in params are the shape, xi, and the end-point of the curve.
49  // The last two arguments specify the range in which the PDF is defined, and the PDF
50  // will be normalised w.r.t. these limits.
51 
52  xi_ = this->findParameter("xi");
53  m0_ = this->findParameter("m0");
54 
55  if ((this->nParameters() != 2) || (xi_ == 0) || (m0_ == 0)) {
56  std::cerr << "ERROR in LauArgusPdf constructor: LauArgusPdf requires 2 parameters: argus shape parameter, \"xi\", and end-point, \"m0\"." << std::endl;
57  gSystem->Exit(EXIT_FAILURE);
58  }
59 
60  // Cache the normalisation factor.
61  this->calcNorm();
62 }
63 
65 {
66  // Destructor
67 }
68 
70 {
71  // Check that the given abscissa is within the allowed range
72  if (!this->checkRange(abscissas)) {
73  gSystem->Exit(EXIT_FAILURE);
74  }
75 
76  // Get our abscissa
77  Double_t abscissa = abscissas[0];
78 
79  // Get the up to date parameter values
80  Double_t xi = xi_->unblindValue();
81  Double_t m0 = m0_->unblindValue();
82 
83  // Calculate the value of the ARGUS function for the given value of the abscissa.
84  Double_t x = abscissa/m0;
85 
86  Double_t term = 1.0 - x*x;
87  if (term < 0.0) {term = 0.0;} // In case |x| > 1.0 (which should happen rarely).
88 
89  Double_t value = abscissa*TMath::Sqrt(term)*TMath::Exp(-xi*term);
90  this->setUnNormPDFVal(value);
91 
92  // if the parameters are floating then we
93  // need to recalculate the normalisation
94  if (!this->cachePDF() && !this->withinNormCalc() && !this->withinGeneration()) {
95  this->calcNorm();
96  }
97 }
98 
100 {
101  // Calculate the PDF normalisation and cache it
102 
103  // Get the up to date parameter values
104  Double_t xi = xi_->unblindValue();
105  Double_t m0 = m0_->unblindValue();
106 
107  // Since the PDF is 0 above m0 by definition need to check whether m0 is within the range, above it or below it
108  Double_t min = (this->getMinAbscissa() < m0) ? this->getMinAbscissa() : m0;
109  Double_t max = (this->getMaxAbscissa() < m0) ? this->getMaxAbscissa() : m0;
110 
111  // Define variables equivalent to "term" in calcLikelihoodInfo above but at the min and max points
112  Double_t termMin = 1.0 - (min/m0)*(min/m0);
113  Double_t termMax = 1.0 - (max/m0)*(max/m0);
114 
115  // Calculate the various terms in the integrals
116  Double_t norm1 = TMath::Sqrt(termMax)*TMath::Exp(-xi*termMax) - TMath::Sqrt(termMin)*TMath::Exp(-xi*termMin);
117  Double_t norm2 = LauConstants::rootPi/(2.0*TMath::Sqrt(xi)) * ( TMath::Erf(TMath::Sqrt(xi*termMax)) - TMath::Erf(TMath::Sqrt(xi*termMin)) );
118 
119  // Combine them and set the normalisation
120  Double_t norm = m0*m0*(norm1 - norm2)/(2.0*xi);
121 
122  this->setNorm(norm);
123 }
124 
125 void LauArgusPdf::calcPDFHeight( const LauKinematics* /*kinematics*/ )
126 {
127  if (this->heightUpToDate()) {
128  return;
129  }
130 
131  // Calculate the PDF height of the ARGUS function.
132  // Get the up to date parameter values
133  Double_t xi = xi_->unblindValue();
134  Double_t m0 = m0_->unblindValue();
135 
136  // First make sure that the limits are not larger than the end-point.
137  // (Btw, use the logarithmic derivative to derive this formula)
138  Double_t term = xi*xi + 1.0;
139  Double_t x = TMath::Sqrt((TMath::Sqrt(term) - 1.0 + xi)/(2.0*xi));
140  x = (x*m0 >= this->getMinAbscissa()) ? x*m0 : this->getMinAbscissa();
141 
142  LauAbscissas abscissa(1);
143  abscissa[0] = x;
144  this->calcLikelihoodInfo(abscissa);
145 
146  Double_t height = this->getUnNormLikelihood();
147  this->setMaxHeight(height);
148 }
149 
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)
virtual ~LauArgusPdf()
Destructor.
Definition: LauArgusPdf.cc:64
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:210
virtual void calcNorm()
Calculate the normalisation.
Definition: LauArgusPdf.cc:99
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 Double_t unblindValue() const =0
The unblinded value of the parameter.
virtual void calcPDFHeight(const LauKinematics *kinematics)
Calculate the PDF height.
Definition: LauArgusPdf.cc:125
File containing declaration of LauArgusPdf class.
LauAbsRValue * m0_
Endpoint of curve.
Definition: LauArgusPdf.hh:93
virtual Double_t getMaxAbscissa() const
Retrieve the maximum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:137
const Double_t rootPi
Square root of Pi.
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
LauAbsRValue * xi_
Shape of curve.
Definition: LauArgusPdf.hh:90
virtual Bool_t cachePDF() const
Check if the PDF is to be cached.
Definition: LauAbsPdf.hh:290
File containing LauConstants namespace.
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.
Class for defining an ARGUS PDF.
Definition: LauArgusPdf.hh:48
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:43
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)
Calculate the likelihood (and intermediate info) for a given abscissa.
Definition: LauArgusPdf.cc:69
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:59