laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauDPDepGaussPdf.cc
Go to the documentation of this file.
1 
2 /*
3 Copyright 2009 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::cerr;
32 using std::cout;
33 using std::endl;
34 
35 #include "LauConstants.hh"
36 #include "LauDPDepGaussPdf.hh"
37 #include "LauDaughters.hh"
38 #include "LauKinematics.hh"
39 
40 #include "TMath.h"
41 #include "TSystem.h"
42 
43 LauDPDepGaussPdf::LauDPDepGaussPdf( const TString& theVarName,
44  const std::vector<LauAbsRValue*>& params,
45  Double_t minAbscissa,
46  Double_t maxAbscissa,
47  const LauDaughters* daughters,
48  const std::vector<Double_t>& meanCoeffs,
49  const std::vector<Double_t>& sigmaCoeffs,
50  DPAxis dpAxis ) :
51  LauAbsPdf( theVarName, params, minAbscissa, maxAbscissa ),
52  kinematics_( daughters ? daughters->getKinematics() : 0 ),
53  mean_( 0 ),
54  sigma_( 0 ),
55  meanVal_( 0.0 ),
56  sigmaVal_( 0.0 ),
57  meanCoeffs_( meanCoeffs ),
58  sigmaCoeffs_( sigmaCoeffs ),
59  dpAxis_( dpAxis )
60 {
61  // Constructor for the Gaussian PDF.
62 
63  // Check we have a valid kinematics object
64  if ( ! kinematics_ ) {
65  cerr << "ERROR in LauDPDepGaussPdf::LauDPDepGaussPdf : Have not been provided with a valid DP kinematics object."
66  << endl;
67  gSystem->Exit( EXIT_FAILURE );
68  }
69 
70  // The parameters in params are the mean and the sigma (half the width) of the gaussian.
71  // The last two arguments specify the range in which the PDF is defined, and the PDF
72  // will be normalised w.r.t. these limits.
73 
74  mean_ = this->findParameter( "mean" );
75  sigma_ = this->findParameter( "sigma" );
76 
77  if ( ( this->nParameters() != 2 ) || ( mean_ == 0 ) || ( sigma_ == 0 ) ) {
78  cerr << "ERROR in LauDPDepGaussPdf constructor: LauDPDepGaussPdf requires 2 parameters: \"mean\" and \"sigma\"."
79  << endl;
80  gSystem->Exit( EXIT_FAILURE );
81  }
82 
83  // Cache the normalisation factor
84  this->calcNorm();
85 }
86 
88 {
89  // Destructor
90 }
91 
93 {
94  this->setNorm( 1.0 );
95 }
96 
98 {
99  // Check that the given abscissa is within the allowed range
100  if ( ! this->checkRange( abscissas ) ) {
101  gSystem->Exit( EXIT_FAILURE );
102  }
103 
104  // Get our abscissa
105  Double_t abscissa = abscissas[0];
106 
107  // Get the up to date parameter values
110 
111  // Find out the DP position
112  Double_t dpPos( 0.0 );
113  UInt_t nVars = this->nInputVars();
114  if ( abscissas.size() == nVars + 2 ) {
115  Double_t m13Sq = abscissas[nVars];
116  Double_t m23Sq = abscissas[nVars + 1];
117 
118  if ( dpAxis_ == M12 ) {
119  dpPos = kinematics_->calcThirdMassSq( m13Sq, m23Sq );
120  } else if ( dpAxis_ == M13 ) {
121  dpPos = m13Sq;
122  } else if ( dpAxis_ == M23 ) {
123  dpPos = m23Sq;
124  } else if ( dpAxis_ == MMIN ) {
125  dpPos = TMath::Min( m13Sq, m23Sq );
126  } else if ( dpAxis_ == MMAX ) {
127  dpPos = TMath::Max( m13Sq, m23Sq );
128  } else {
129  dpPos = kinematics_->distanceFromDPCentre( m13Sq, m23Sq );
130  }
131  }
132 
133  // Scale the parameters according to the DP position
134  this->scalePars( dpPos );
135 
136  // Calculate the value of the Gaussian for the given value of the abscissa.
137  Double_t arg = abscissa - meanVal_;
138 
139  Double_t exponent( 0.0 );
140  if ( TMath::Abs( sigmaVal_ ) > 1e-10 ) {
141  exponent = -0.5 * arg * arg / ( sigmaVal_ * sigmaVal_ );
142  }
143 
144  Double_t value = TMath::Exp( exponent );
145 
146  Double_t norm( 0.0 );
147  Double_t scale = LauConstants::root2 * sigmaVal_;
148  if ( TMath::Abs( sigmaVal_ ) > 1e-10 ) {
150  ( TMath::Erf( ( this->getMaxAbscissa() - meanVal_ ) / scale ) -
151  TMath::Erf( ( this->getMinAbscissa() - meanVal_ ) / scale ) );
152  }
153 
154  value /= norm;
155 
156  this->setUnNormPDFVal( value );
157 }
158 
159 void LauDPDepGaussPdf::scalePars( Double_t dpPos )
160 {
161  Int_t power = 1;
162  for ( std::vector<Double_t>::const_iterator iter = meanCoeffs_.begin(); iter != meanCoeffs_.end();
163  ++iter ) {
164  Double_t coeff = ( *iter );
165  meanVal_ += coeff * TMath::Power( dpPos, power );
166  ++power;
167  }
168 
169  power = 1;
170  for ( std::vector<Double_t>::const_iterator iter = sigmaCoeffs_.begin();
171  iter != sigmaCoeffs_.end();
172  ++iter ) {
173  Double_t coeff = ( *iter );
174  sigmaVal_ += coeff * TMath::Power( dpPos, power );
175  ++power;
176  }
177 }
178 
180 {
181  // Get the up to date parameter values
183 
184  // Find out the DP position
185  Double_t dpPos( 0.0 );
186  if ( dpAxis_ == M12 ) {
187  dpPos = kinematics->getm12Sq();
188  } else if ( dpAxis_ == M13 ) {
189  dpPos = kinematics->getm13Sq();
190  } else if ( dpAxis_ == M23 ) {
191  dpPos = kinematics->getm23Sq();
192  } else if ( dpAxis_ == MMIN ) {
193  Double_t m13Sq = kinematics->getm13Sq();
194  Double_t m23Sq = kinematics->getm23Sq();
195  dpPos = TMath::Min( m13Sq, m23Sq );
196  } else if ( dpAxis_ == MMAX ) {
197  Double_t m13Sq = kinematics->getm13Sq();
198  Double_t m23Sq = kinematics->getm23Sq();
199  dpPos = TMath::Max( m13Sq, m23Sq );
200  } else {
201  dpPos = kinematics->distanceFromDPCentre();
202  }
203 
204  // Scale the parameters according to the DP position
205  this->scalePars( dpPos );
206 
207  LauAbscissas maxPoint( 3 );
208  maxPoint[0] = meanVal_;
209  maxPoint[1] = kinematics->getm13Sq();
210  maxPoint[2] = kinematics->getm23Sq();
211 
212  // Calculate the PDF height for the Gaussian function.
213  if ( meanVal_ > this->getMaxAbscissa() ) {
214  maxPoint[0] = this->getMaxAbscissa();
215  } else if ( meanVal_ < this->getMinAbscissa() ) {
216  maxPoint[0] = this->getMinAbscissa();
217  }
218  this->calcLikelihoodInfo( maxPoint );
219 
220  Double_t height = this->getUnNormLikelihood();
221  this->setMaxHeight( height );
222 }
void scalePars(Double_t dpPos)
Scale parameters by their dependence on the DP position.
virtual Double_t getMaxAbscissa() const
Retrieve the maximum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:141
LauAbsRValue * mean_
Gaussian mean.
virtual void calcNorm()
Calculate the normalisation.
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
Double_t getm12Sq() const
Get the m12 invariant mass square.
Double_t meanVal_
Gaussian mean.
Double_t distanceFromDPCentre() const
Calculate the distance from the currently set (m13Sq, m23Sq) point to the centre of the Dalitz plot (...
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:58
virtual ~LauDPDepGaussPdf()
Destructor.
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)
Calculate the likelihood (and intermediate info) for a given abscissa.
LauAbsRValue * sigma_
Gaussian sigma.
virtual LauAbsRValue * findParameter(const TString &parName)
Retrieve the specified parameter.
Definition: LauAbsPdf.cc:431
const Double_t root2
Square root of two.
Double_t calcThirdMassSq(const Double_t firstMassSq, const Double_t secondMassSq) const
Calculate the third invariant mass square from the two provided (e.g. mjkSq from mijSq and mikSq)
Double_t sigmaVal_
Gaussian sigma.
const LauKinematics * kinematics_
The current DP kinematics.
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 Double_t unblindValue() const =0
The unblinded value of the parameter.
DPAxis
Define possibilties for the DP axes.
File containing declaration of LauDPDepGaussPdf class.
virtual UInt_t nInputVars() const
Retrieve the number of abscissas.
Definition: LauAbsPdf.hh:121
File containing declaration of LauDaughters class.
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:394
LauDPDepGaussPdf(const TString &theVarName, const std::vector< LauAbsRValue * > &params, Double_t minAbscissa, Double_t maxAbscissa, const LauDaughters *daughters, const std::vector< Double_t > &meanCoeffs, const std::vector< Double_t > &sigmaCoeffs, DPAxis dpAxis)
Constructor.
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:54
File containing LauConstants namespace.
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:354
Class for calculating 3-body kinematic quantities.
const Double_t rootPiBy2
Square root of Pi divided by two.
const std::vector< Double_t > sigmaCoeffs_
Coefficients of Gaussian sigma.
Class that defines the particular 3-body decay under study.
Definition: LauDaughters.hh:47
Double_t getm23Sq() const
Get the m23 invariant mass square.
virtual void calcPDFHeight(const LauKinematics *kinematics)
Calculate the PDF height.
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:218
DPAxis dpAxis_
The DP axis we depend on.
Double_t getm13Sq() const
Get the m13 invariant mass square.
const std::vector< Double_t > meanCoeffs_
Coefficients of Gaussian mean.
File containing declaration of LauKinematics class.
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:243