laura is hosted by Hepforge, IPPP Durham
Laura++  v1r0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauNovosibirskPdf.cc
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2008 - 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 
17 using std::cout;
18 using std::cerr;
19 using std::endl;
20 
21 #include "TMath.h"
22 #include "TSystem.h"
23 
24 #include "LauNovosibirskPdf.hh"
25 #include "LauConstants.hh"
26 
27 ClassImp(LauNovosibirskPdf)
28 
29 LauNovosibirskPdf::LauNovosibirskPdf(const TString& theVarName, const vector<LauParameter*>& params, Double_t minAbscissa, Double_t maxAbscissa) :
30  LauAbsPdf(theVarName, params, minAbscissa, maxAbscissa),
31  mean_(0),
32  sigma_(0),
33  tail_(0)
34 {
35  // Constructor for the Novosibirsk PDF.
36  //
37  // The parameters in params are the mean, sigma and tail.
38  // The last two arguments specify the range in which the PDF is defined, and the PDF
39  // will be normalised w.r.t. these limits.
40 
41  mean_ = this->findParameter("mean");
42  sigma_ = this->findParameter("sigma");
43  tail_ = this->findParameter("tail");
44 
45  if ((this->nParameters() != 3) || (mean_ == 0) || (sigma_ == 0) || (tail_ == 0)) {
46  cerr<<"ERROR in LauNovosibirskPdf constructor: LauNovosibirskPdf requires 3 parameters: \"mean\", \"sigma\"and \"tail\" "<<endl;
47  gSystem->Exit(EXIT_FAILURE);
48  }
49 
50  // Cache the normalisation factor
51  this->calcNorm();
52 }
53 
55 {
56  // Destructor
57 }
58 
59 LauNovosibirskPdf::LauNovosibirskPdf(const LauNovosibirskPdf& other) : LauAbsPdf(other.varName(), other.getParameters(), other.getMinAbscissa(), other.getMaxAbscissa()),
60  mean_( other.mean_ ),
61  sigma_( other.sigma_ ),
62  tail_( other.tail_ )
63 {
64  // Copy constructor
65  this->setRandomFun(other.getRandomFun());
66  this->calcNorm();
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 mean = mean_->value();
81  Double_t sigma = sigma_->value();
82  Double_t tail = tail_->value();
83 
84  // Evaluate the Novosibirsk PDF value
85 
86 
87  Double_t qa(0.0), qb(0.0), qx(0.0), qy(0.0);
88  Double_t arg(0.0);
89  Double_t value(0.0);
90 
91 
92  if(TMath::Abs(tail) < 1.e-7)
93  arg = 0.5*((abscissa - mean)/sigma)*((abscissa - mean)/sigma);
94  else {
95  qa = tail*TMath::Sqrt(LauConstants::log4);
96  qb = TMath::SinH(qa)/qa;
97  qx = (abscissa - mean)/sigma*qb;
98  qy = 1.0+ tail*qx;
99 
100  //---- Cutting curve from right side
101 
102  if( qy > 1.E-7) {
103  arg = 0.5*( (log(qy)/tail)*(log(qy)/tail) + tail*tail);
104  }else{
105  arg = 15.0;
106  }
107  }
108 
109  value = TMath::Exp(-arg);
110 
111  // if the parameters are floating then we
112  // need to recalculate the normalisation
113  if (!this->cachePDF() && !this->withinNormCalc() && !this->withinGeneration()) {
114  this->calcNorm();
115  }
116  this->setUnNormPDFVal(value);
117 }
118 
119 void LauNovosibirskPdf::calcPDFHeight( const LauKinematics* /*kinematics*/ )
120 {
121  if (this->heightUpToDate()) {
122  return;
123  }
124 
125  // Get the up to date parameter values
126  Double_t mean = mean_->value();
127 
128  LauAbscissas maxPoint(1);
129  maxPoint[0] = mean;
130 
131 
132  // Calculate the PDF height for the Bifurcated Gaussian function.
133 
134  if (mean < this->getMinAbscissa()) {
135  maxPoint[0] = this->getMinAbscissa();
136  } else if (mean > this->getMaxAbscissa()) {
137  maxPoint[0] = this->getMaxAbscissa();
138  }
139 
140  this->calcLikelihoodInfo(maxPoint);
141  Double_t height = this->getUnNormLikelihood();
142 
143  // Multiply by a small factor to avoid problems from rounding errors
144  height *= (1.0 + 1e-1);
145 
146  this->setMaxHeight(height);
147 }
148 
LauParameter * tail_
Gaussian tail.
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:454
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:158
Class for defining a Novosibirsk function PDF.
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:349
LauNovosibirskPdf(const TString &theVarName, const vector< LauParameter * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor.
virtual void calcPDFHeight(const LauKinematics *kinematics)
Calculate the PDF height.
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:278
File containing declaration of LauNovosibirskPdf class.
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:213
virtual ~LauNovosibirskPdf()
Destructor.
virtual Bool_t withinNormCalc() const
Check whether the calcNorm method is running.
Definition: LauAbsPdf.hh:508
virtual TRandom * getRandomFun() const
Retrieve the random function used for MC generation.
Definition: LauAbsPdf.hh:472
LauParameter * sigma_
Gaussian sigma.
virtual Double_t getMaxAbscissa() const
Retrieve the maximum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:164
LauParameter * mean_
Gaussian mean.
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:416
Class for defining the fit parameter objects.
Definition: LauParameter.hh:31
const Double_t log4
Logarithm of four.
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:520
virtual Bool_t cachePDF() const
Check if the PDF is to be cached.
Definition: LauAbsPdf.hh:355
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)
Calculate the likelihood (and intermediate info) for a given abscissa.
File containing LauConstants namespace.
virtual void calcNorm()
Calculate the normalisation factor of the PDF.
Definition: LauAbsPdf.cc:529
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:40
Class for calculating 3-body kinematic quantities.
Double_t value() const
The value of the parameter.
virtual void setRandomFun(TRandom *randomFun)
Set the random function used for toy MC generation.
Definition: LauAbsPdf.hh:315
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:44