laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauNovosibirskPdf.cc
Go to the documentation of this file.
1 
2 /*
3 Copyright 2008 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 
31 using std::cerr;
32 using std::cout;
33 using std::endl;
34 
35 #include "LauConstants.hh"
36 #include "LauNovosibirskPdf.hh"
37 
38 #include "TMath.h"
39 #include "TSystem.h"
40 
41 LauNovosibirskPdf::LauNovosibirskPdf( const TString& theVarName,
42  const std::vector<LauAbsRValue*>& params,
43  Double_t minAbscissa,
44  Double_t maxAbscissa ) :
45  LauAbsPdf( theVarName, params, minAbscissa, maxAbscissa ),
46  mean_( 0 ),
47  sigma_( 0 ),
48  tail_( 0 )
49 {
50  // Constructor for the Novosibirsk PDF.
51  //
52  // The parameters in params are the mean, sigma and tail.
53  // The last two arguments specify the range in which the PDF is defined, and the PDF
54  // will be normalised w.r.t. these limits.
55 
56  mean_ = this->findParameter( "mean" );
57  sigma_ = this->findParameter( "sigma" );
58  tail_ = this->findParameter( "tail" );
59 
60  if ( ( this->nParameters() != 3 ) || ( mean_ == 0 ) || ( sigma_ == 0 ) || ( tail_ == 0 ) ) {
61  cerr << "ERROR in LauNovosibirskPdf constructor: LauNovosibirskPdf requires 3 parameters: \"mean\", \"sigma\"and \"tail\" "
62  << endl;
63  gSystem->Exit( EXIT_FAILURE );
64  }
65 
66  // Cache the normalisation factor
67  this->calcNorm();
68 }
69 
71 {
72  // Destructor
73 }
74 
76 {
77  // Check that the given abscissa is within the allowed range
78  if ( ! this->checkRange( abscissas ) ) {
79  gSystem->Exit( EXIT_FAILURE );
80  }
81 
82  // Get our abscissa
83  Double_t abscissa = abscissas[0];
84 
85  // Get the up to date parameter values
86  Double_t mean = mean_->unblindValue();
87  Double_t sigma = sigma_->unblindValue();
88  Double_t tail = tail_->unblindValue();
89 
90  // Evaluate the Novosibirsk PDF value
91 
92  Double_t qa( 0.0 ), qb( 0.0 ), qx( 0.0 ), qy( 0.0 );
93  Double_t arg( 0.0 );
94  Double_t value( 0.0 );
95 
96  if ( TMath::Abs( tail ) < 1.e-7 )
97  arg = 0.5 * ( ( abscissa - mean ) / sigma ) * ( ( abscissa - mean ) / sigma );
98  else {
99  qa = tail * TMath::Sqrt( LauConstants::log4 );
100  qb = TMath::SinH( qa ) / qa;
101  qx = ( abscissa - mean ) / sigma * qb;
102  qy = 1.0 + tail * qx;
103 
104  //---- Cutting curve from right side
105 
106  if ( qy > 1.E-7 ) {
107  arg = 0.5 * ( ( log( qy ) / tail ) * ( log( qy ) / tail ) + tail * tail );
108  } else {
109  arg = 15.0;
110  }
111  }
112 
113  value = TMath::Exp( -arg );
114 
115  // if the parameters are floating then we
116  // need to recalculate the normalisation
117  if ( ! this->cachePDF() && ! this->withinNormCalc() && ! this->withinGeneration() ) {
118  this->calcNorm();
119  }
120  this->setUnNormPDFVal( value );
121 }
122 
123 void LauNovosibirskPdf::calcPDFHeight( const LauKinematics* /*kinematics*/ )
124 {
125  if ( this->heightUpToDate() ) {
126  return;
127  }
128 
129  // Get the up to date parameter values
130  Double_t mean = mean_->unblindValue();
131 
132  LauAbscissas maxPoint( 1 );
133  maxPoint[0] = mean;
134 
135  // Calculate the PDF height for the Bifurcated Gaussian function.
136 
137  if ( mean < this->getMinAbscissa() ) {
138  maxPoint[0] = this->getMinAbscissa();
139  } else if ( mean > this->getMaxAbscissa() ) {
140  maxPoint[0] = this->getMaxAbscissa();
141  }
142 
143  this->calcLikelihoodInfo( maxPoint );
144  Double_t height = this->getUnNormLikelihood();
145 
146  // Multiply by a small factor to avoid problems from rounding errors
147  height *= ( 1.0 + 1e-1 );
148 
149  this->setMaxHeight( height );
150 }
LauAbsRValue * mean_
Gaussian mean.
virtual ~LauNovosibirskPdf()
Destructor.
File containing declaration of LauNovosibirskPdf class.
virtual void calcPDFHeight(const LauKinematics *kinematics)
Calculate the PDF height.
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
LauAbsRValue * sigma_
Gaussian sigma.
virtual void calcNorm()
Calculate the normalisation factor of the PDF.
Definition: LauAbsPdf.cc:485
const Double_t log4
Logarithm of four.
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
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 Double_t unblindValue() const =0
The unblinded value of the parameter.
LauNovosibirskPdf(const TString &theVarName, const std::vector< LauAbsRValue * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor.
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
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:460
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.
LauAbsRValue * tail_
Gaussian tail.
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:218
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)
Calculate the likelihood (and intermediate info) for a given abscissa.
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