laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
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 "LauArgusPdf.hh"
30 
31 #include "LauConstants.hh"
32 
33 #include "TMath.h"
34 #include "TSystem.h"
35 
36 #include <iostream>
37 #include <vector>
38 
39 LauArgusPdf::LauArgusPdf( const TString& theVarName,
40  const std::vector<LauAbsRValue*>& params,
41  Double_t minAbscissa,
42  Double_t maxAbscissa ) :
43  LauAbsPdf( theVarName, params, minAbscissa, maxAbscissa ),
44  xi_( 0 ),
45  m0_( 0 )
46 {
47  // Constructor for the ARGUS PDF.
48  //
49  // The parameters in params are the shape, xi, and the end-point of the curve.
50  // The last two arguments specify the range in which the PDF is defined, and the PDF
51  // will be normalised w.r.t. these limits.
52 
53  xi_ = this->findParameter( "xi" );
54  m0_ = this->findParameter( "m0" );
55 
56  if ( ( this->nParameters() != 2 ) || ( xi_ == 0 ) || ( m0_ == 0 ) ) {
57  std::cerr << "ERROR in LauArgusPdf constructor: LauArgusPdf requires 2 parameters: argus shape parameter, \"xi\", and end-point, \"m0\"."
58  << std::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 xi = xi_->unblindValue();
83  Double_t m0 = m0_->unblindValue();
84 
85  // Calculate the value of the ARGUS function for the given value of the abscissa.
86  Double_t x = abscissa / m0;
87 
88  Double_t term = 1.0 - x * x;
89  if ( term < 0.0 ) {
90  term = 0.0;
91  } // In case |x| > 1.0 (which should happen rarely).
92 
93  Double_t value = abscissa * TMath::Sqrt( term ) * TMath::Exp( -xi * term );
94  this->setUnNormPDFVal( value );
95 
96  // if the parameters are floating then we
97  // need to recalculate the normalisation
98  if ( ! this->cachePDF() && ! this->withinNormCalc() && ! this->withinGeneration() ) {
99  this->calcNorm();
100  }
101 }
102 
104 {
105  // Calculate the PDF normalisation and cache it
106 
107  // Get the up to date parameter values
108  Double_t xi = xi_->unblindValue();
109  Double_t m0 = m0_->unblindValue();
110 
111  // Since the PDF is 0 above m0 by definition need to check whether m0 is within the range, above it or below it
112  Double_t min = ( this->getMinAbscissa() < m0 ) ? this->getMinAbscissa() : m0;
113  Double_t max = ( this->getMaxAbscissa() < m0 ) ? this->getMaxAbscissa() : m0;
114 
115  // Define variables equivalent to "term" in calcLikelihoodInfo above but at the min and max points
116  Double_t termMin = 1.0 - ( min / m0 ) * ( min / m0 );
117  Double_t termMax = 1.0 - ( max / m0 ) * ( max / m0 );
118 
119  // Calculate the various terms in the integrals
120  Double_t norm1 = TMath::Sqrt( termMax ) * TMath::Exp( -xi * termMax ) -
121  TMath::Sqrt( termMin ) * TMath::Exp( -xi * termMin );
122  Double_t norm2 = LauConstants::rootPi / ( 2.0 * TMath::Sqrt( xi ) ) *
123  ( TMath::Erf( TMath::Sqrt( xi * termMax ) ) -
124  TMath::Erf( TMath::Sqrt( xi * termMin ) ) );
125 
126  // Combine them and set the normalisation
127  Double_t norm = m0 * m0 * ( norm1 - norm2 ) / ( 2.0 * xi );
128 
129  this->setNorm( norm );
130 }
131 
132 void LauArgusPdf::calcPDFHeight( const LauKinematics* /*kinematics*/ )
133 {
134  if ( this->heightUpToDate() ) {
135  return;
136  }
137 
138  // Calculate the PDF height of the ARGUS function.
139  // Get the up to date parameter values
140  Double_t xi = xi_->unblindValue();
141  Double_t m0 = m0_->unblindValue();
142 
143  // First make sure that the limits are not larger than the end-point.
144  // (Btw, use the logarithmic derivative to derive this formula)
145  Double_t term = xi * xi + 1.0;
146  Double_t x = TMath::Sqrt( ( TMath::Sqrt( term ) - 1.0 + xi ) / ( 2.0 * xi ) );
147  x = ( x * m0 >= this->getMinAbscissa() ) ? x * m0 : this->getMinAbscissa();
148 
149  LauAbscissas abscissa( 1 );
150  abscissa[0] = x;
151  this->calcLikelihoodInfo( abscissa );
152 
153  Double_t height = this->getUnNormLikelihood();
154  this->setMaxHeight( height );
155 }
virtual Double_t getMaxAbscissa() const
Retrieve the maximum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:141
Double_t value() const
The value of the parameter.
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:135
virtual Bool_t cachePDF() const
Check if the PDF is to be cached.
Definition: LauAbsPdf.hh:299
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:58
LauArgusPdf(const TString &theVarName, const std::vector< LauAbsRValue * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor.
Definition: LauArgusPdf.cc:39
LauAbsRValue * m0_
Endpoint of curve.
Definition: LauArgusPdf.hh:95
virtual LauAbsRValue * findParameter(const TString &parName)
Retrieve the specified parameter.
Definition: LauAbsPdf.cc:431
virtual Bool_t withinNormCalc() const
Check whether the calcNorm method is running.
Definition: LauAbsPdf.hh:448
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
LauAbsRValue * xi_
Shape of curve.
Definition: LauArgusPdf.hh:92
virtual Double_t unblindValue() const =0
The unblinded value of the parameter.
virtual void calcNorm()
Calculate the normalisation.
Definition: LauArgusPdf.cc:103
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:394
virtual void calcPDFHeight(const LauKinematics *kinematics)
Calculate the PDF height.
Definition: LauArgusPdf.cc:132
File containing declaration of LauArgusPdf class.
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:54
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:460
File containing LauConstants namespace.
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)
Calculate the likelihood (and intermediate info) for a given abscissa.
Definition: LauArgusPdf.cc:71
const Double_t rootPi
Square root of Pi.
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:354
Class for calculating 3-body kinematic quantities.
virtual ~LauArgusPdf()
Destructor.
Definition: LauArgusPdf.cc:66
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:218
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:287
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:243