laura is hosted by Hepforge, IPPP Durham
Laura++  v3r2
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauBifurcatedGaussPdf.cc
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2006 - 2013.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 // Authors:
7 // Thomas Latham
8 // John Back
9 // Paul Harrison
10 
15 #include <iostream>
16 #include <vector>
17 
18 #include "TMath.h"
19 #include "TSystem.h"
20 
21 #include "LauBifurcatedGaussPdf.hh"
22 #include "LauConstants.hh"
23 
25 
26 
27 LauBifurcatedGaussPdf::LauBifurcatedGaussPdf(const TString& theVarName, const std::vector<LauAbsRValue*>& params, Double_t minAbscissa, Double_t maxAbscissa) :
28  LauAbsPdf(theVarName, params, minAbscissa, maxAbscissa),
29  mean_(0),
30  sigmaL_(0),
31  sigmaR_(0)
32 {
33  // Constructor for the bifurcated Gaussian PDF.
34  // The bifurcated Gaussian combines the left half of a
35  // Gaussian with resolution sigmaL with the right half
36  // of a Gaussian with resolution sigmaR, both having
37  // a common mean (or more correctly, peak position).
38 
39  // NB the parameters in params are the mean, sigmaL and sigmaR
40  // The last two arguments specify the range in which the PDF is defined, and the PDF
41  // will be normalised w.r.t. these limits.
42 
43  mean_ = this->findParameter("mean");
44  sigmaL_ = this->findParameter("sigmaL");
45  sigmaR_ = this->findParameter("sigmaR");
46 
47  if ((this->nParameters() != 3) || (mean_ == 0) || (sigmaL_ == 0) || (sigmaR_ == 0) ) {
48  std::cerr << "ERROR in LauBifurcatedGaussPdf constructor: LauBifurcatedGaussPdf requires 3 parameters: \"mean\", \"sigmaL\" and \"sigmaR\"." << std::endl;
49  gSystem->Exit(EXIT_FAILURE);
50  }
51 
52  // Cache the normalisation factor
53  this->calcNorm();
54 }
55 
57 {
58  // Destructor
59 }
60 
62 {
63 
64  // Check that the given abscissa is within the allowed range
65  if (!this->checkRange(abscissas)) {
66  gSystem->Exit(EXIT_FAILURE);
67  }
68 
69  // Get our abscissa
70  Double_t abscissa = abscissas[0];
71 
72  // Get the up to date parameter values
73  Double_t mean = mean_->unblindValue();
74  Double_t sigmaL = sigmaL_->unblindValue();
75  Double_t sigmaR = sigmaR_->unblindValue();
76 
77  // Evaluate the Birfucated Gaussian PDF value
78  Double_t arg = abscissa - mean;
79  Double_t coef(0.0);
80  Double_t value(0.0);
81 
82  if (arg < 0.0){
83  if (TMath::Abs(sigmaL) > 1e-30) {
84  coef = -0.5/(sigmaL*sigmaL);
85  }
86  } else {
87  if (TMath::Abs(sigmaR) > 1e-30) {
88  coef = -0.5/(sigmaR*sigmaR);
89  }
90  }
91  value = TMath::Exp(coef*arg*arg);
92 
93  // Calculate the norm
94  Double_t xscaleL = LauConstants::root2*sigmaL;
95  Double_t xscaleR = LauConstants::root2*sigmaR;
96 
97  Double_t integral(0.0);
98  Double_t norm(0.0);
99  Double_t result(0.0);
100 
101 
102  if(this->getMaxAbscissa() < mean){
103  integral = sigmaL * ( TMath::Erf((this->getMaxAbscissa() - mean)/xscaleL) - TMath::Erf((this->getMinAbscissa() - mean)/xscaleL));
104  }else if (this->getMinAbscissa() > mean){
105  integral = sigmaR * (TMath::Erf((this->getMaxAbscissa() - mean)/xscaleR) - TMath::Erf((this->getMinAbscissa() - mean)/xscaleR));
106  }else{
107  integral = sigmaR*TMath::Erf((this->getMaxAbscissa() -mean)/xscaleR) - sigmaL*TMath::Erf((this->getMinAbscissa() - mean)/xscaleL);
108  }
109 
110  norm = LauConstants::rootPiBy2*integral;
111 
112  // the result
113  result = value/norm;
114  this->setUnNormPDFVal(result);
115 
116 }
117 
119 {
120  // Nothing to do here, since it already normalized
121  this->setNorm(1.0);
122 }
123 
124 
126 {
127  if (this->heightUpToDate()) {
128  return;
129  }
130 
131  // Get the up to date parameter values
132  Double_t mean = mean_->unblindValue();
133 
134  LauAbscissas maxPoint(1);
135  maxPoint[0] = mean;
136 
137  // Calculate the PDF height for the Bifurcated Gaussian function.
138  if (mean>this->getMaxAbscissa()) {
139  maxPoint[0] = this->getMaxAbscissa();
140  } else if (mean<this->getMinAbscissa()) {
141  maxPoint[0] = this->getMinAbscissa();
142  }
143  this->calcLikelihoodInfo(maxPoint);
144 
145  Double_t height = this->getUnNormLikelihood();
146  this->setMaxHeight(height);
147 }
148 
149 
150 
151 
LauAbsRValue * sigmaL_
Sigma of left Gaussian.
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:369
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:117
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:264
ClassImp(LauAbsCoeffSet)
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:196
virtual void setNorm(Double_t norm)
Set the normalisation factor.
Definition: LauAbsPdf.hh:325
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:213
virtual void calcPDFHeight(const LauKinematics *kinematics)
Calculate the PDF height.
virtual ~LauBifurcatedGaussPdf()
Destructor.
virtual Double_t unblindValue() const =0
The unblinded value of the parameter.
const Double_t rootPiBy2
Square root of Pi divided by two.
File containing declaration of LauBifurcatedGaussPdf class.
const Double_t root2
Square root of two.
virtual Double_t getMaxAbscissa() const
Retrieve the maximum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:123
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:331
Class for defining a bifurcated Gaussian PDF.
LauAbsRValue * sigmaR_
Sigma of right Gaussian.
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)
Calculate the likelihood (and intermediate info) for a given abscissa.
LauAbsRValue * mean_
Gaussian mean.
File containing LauConstants namespace.
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:41
Class for calculating 3-body kinematic quantities.
Double_t value() const
The value of the parameter.
virtual void calcNorm()
Calculate the normalisation.
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:29
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:45