laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauBifurcatedGaussPdf.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 "LauBifurcatedGaussPdf.hh"
30 
31 #include "LauConstants.hh"
32 
33 #include "TMath.h"
34 #include "TSystem.h"
35 
36 #include <iostream>
37 #include <vector>
38 
40  const std::vector<LauAbsRValue*>& params,
41  Double_t minAbscissa,
42  Double_t maxAbscissa ) :
43  LauAbsPdf( theVarName, params, minAbscissa, maxAbscissa ),
44  mean_( 0 ),
45  sigmaL_( 0 ),
46  sigmaR_( 0 )
47 {
48  // Constructor for the bifurcated Gaussian PDF.
49  // The bifurcated Gaussian combines the left half of a
50  // Gaussian with resolution sigmaL with the right half
51  // of a Gaussian with resolution sigmaR, both having
52  // a common mean (or more correctly, peak position).
53 
54  // NB the parameters in params are the mean, sigmaL and sigmaR
55  // The last two arguments specify the range in which the PDF is defined, and the PDF
56  // will be normalised w.r.t. these limits.
57 
58  mean_ = this->findParameter( "mean" );
59  sigmaL_ = this->findParameter( "sigmaL" );
60  sigmaR_ = this->findParameter( "sigmaR" );
61 
62  if ( ( this->nParameters() != 3 ) || ( mean_ == 0 ) || ( sigmaL_ == 0 ) || ( sigmaR_ == 0 ) ) {
63  std::cerr << "ERROR in LauBifurcatedGaussPdf constructor: LauBifurcatedGaussPdf requires 3 parameters: \"mean\", \"sigmaL\" and \"sigmaR\"."
64  << std::endl;
65  gSystem->Exit( EXIT_FAILURE );
66  }
67 
68  // Cache the normalisation factor
69  this->calcNorm();
70 }
71 
73 {
74  // Destructor
75 }
76 
78 {
79 
80  // Check that the given abscissa is within the allowed range
81  if ( ! this->checkRange( abscissas ) ) {
82  gSystem->Exit( EXIT_FAILURE );
83  }
84 
85  // Get our abscissa
86  Double_t abscissa = abscissas[0];
87 
88  // Get the up to date parameter values
89  Double_t mean = mean_->unblindValue();
90  Double_t sigmaL = sigmaL_->unblindValue();
91  Double_t sigmaR = sigmaR_->unblindValue();
92 
93  // Evaluate the Birfucated Gaussian PDF value
94  Double_t arg = abscissa - mean;
95  Double_t coef( 0.0 );
96  Double_t value( 0.0 );
97 
98  if ( arg < 0.0 ) {
99  if ( TMath::Abs( sigmaL ) > 1e-30 ) {
100  coef = -0.5 / ( sigmaL * sigmaL );
101  }
102  } else {
103  if ( TMath::Abs( sigmaR ) > 1e-30 ) {
104  coef = -0.5 / ( sigmaR * sigmaR );
105  }
106  }
107  value = TMath::Exp( coef * arg * arg );
108 
109  // Calculate the norm
110  Double_t xscaleL = LauConstants::root2 * sigmaL;
111  Double_t xscaleR = LauConstants::root2 * sigmaR;
112 
113  Double_t integral( 0.0 );
114  Double_t norm( 0.0 );
115  Double_t result( 0.0 );
116 
117  if ( this->getMaxAbscissa() < mean ) {
118  integral = sigmaL * ( TMath::Erf( ( this->getMaxAbscissa() - mean ) / xscaleL ) -
119  TMath::Erf( ( this->getMinAbscissa() - mean ) / xscaleL ) );
120  } else if ( this->getMinAbscissa() > mean ) {
121  integral = sigmaR * ( TMath::Erf( ( this->getMaxAbscissa() - mean ) / xscaleR ) -
122  TMath::Erf( ( this->getMinAbscissa() - mean ) / xscaleR ) );
123  } else {
124  integral = sigmaR * TMath::Erf( ( this->getMaxAbscissa() - mean ) / xscaleR ) -
125  sigmaL * TMath::Erf( ( this->getMinAbscissa() - mean ) / xscaleL );
126  }
127 
128  norm = LauConstants::rootPiBy2 * integral;
129 
130  // the result
131  result = value / norm;
132  this->setUnNormPDFVal( result );
133 }
134 
136 {
137  // Nothing to do here, since it already normalized
138  this->setNorm( 1.0 );
139 }
140 
142 {
143  if ( this->heightUpToDate() ) {
144  return;
145  }
146 
147  // Get the up to date parameter values
148  Double_t mean = mean_->unblindValue();
149 
150  LauAbscissas maxPoint( 1 );
151  maxPoint[0] = mean;
152 
153  // Calculate the PDF height for the Bifurcated Gaussian function.
154  if ( mean > this->getMaxAbscissa() ) {
155  maxPoint[0] = this->getMaxAbscissa();
156  } else if ( mean < this->getMinAbscissa() ) {
157  maxPoint[0] = this->getMinAbscissa();
158  }
159  this->calcLikelihoodInfo( maxPoint );
160 
161  Double_t height = this->getUnNormLikelihood();
162  this->setMaxHeight( height );
163 }
File containing declaration of LauBifurcatedGaussPdf class.
virtual void calcNorm()
Calculate the normalisation.
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
LauBifurcatedGaussPdf(const TString &theVarName, const std::vector< LauAbsRValue * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor.
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:58
LauAbsRValue * sigmaL_
Sigma of left Gaussian.
virtual LauAbsRValue * findParameter(const TString &parName)
Retrieve the specified parameter.
Definition: LauAbsPdf.cc:431
const Double_t root2
Square root of two.
virtual void calcPDFHeight(const LauKinematics *kinematics)
Calculate the PDF height.
virtual ~LauBifurcatedGaussPdf()
Destructor.
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)
Calculate the likelihood (and intermediate info) for a given abscissa.
LauAbsRValue * sigmaR_
Sigma of right Gaussian.
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.
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:394
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.
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:218
LauAbsRValue * mean_
Gaussian mean.
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