laura is hosted by Hepforge, IPPP Durham
Laura++  3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauCruijffPdf.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 /*****************************************************************************
30  * Class based on RooFit/RooCruijff. *
31  * Original copyright given below. *
32  *****************************************************************************
33  * Authors: *
34  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
35  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
36  * *
37  * Copyright (c) 2000-2005, Regents of the University of California *
38  * and Stanford University. All rights reserved. *
39  * *
40  * Redistribution and use in source and binary forms, *
41  * with or without modification, are permitted according to the terms *
42  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
43  *****************************************************************************/
44 
45 #include <iostream>
46 #include <vector>
47 using std::cerr;
48 using std::cout;
49 using std::endl;
50 
51 #include "LauConstants.hh"
52 #include "LauCruijffPdf.hh"
53 
54 #include "TMath.h"
55 #include "TSystem.h"
56 
57 LauCruijffPdf::LauCruijffPdf( const TString& theVarName,
58  const std::vector<LauAbsRValue*>& params,
59  Double_t minAbscissa,
60  Double_t maxAbscissa ) :
61  LauAbsPdf( theVarName, params, minAbscissa, maxAbscissa ),
62  mean_( 0 ),
63  sigmaL_( 0 ),
64  sigmaR_( 0 ),
65  alphaL_( 0 ),
66  alphaR_( 0 )
67 {
68  // Constructor for the Cruijff PDF.
69  //
70  // The parameters in params are the mean, sigmaR, sigmaL, alphaR
71  // and alphaL.
72  // The last two arguments specify the range in which the PDF is defined, and the PDF
73  // will be normalised w.r.t. these limits.
74 
75  mean_ = this->findParameter( "mean" );
76  sigmaR_ = this->findParameter( "sigmaR" );
77  sigmaL_ = this->findParameter( "sigmaL" );
78  alphaR_ = this->findParameter( "alphaR" );
79  alphaL_ = this->findParameter( "alphaL" );
80 
81  if ( ( this->nParameters() != 5 ) || ( mean_ == 0 ) || ( sigmaR_ == 0 ) || ( sigmaL_ == 0 ) ||
82  ( alphaL_ == 0 ) || ( alphaR_ == 0 ) ) {
83  cerr << "ERROR in LauCruijffPdf constructor: LauCruijffPdf requires 5 parameters: \"mean\", \"sigmaL\", \"sigmaR\", \"alphaR\" and \"alphaL\"."
84  << endl;
85  gSystem->Exit( EXIT_FAILURE );
86  }
87 
88  // Cache the normalisation factor
89  this->calcNorm();
90 }
91 
93 {
94  // Destructor
95 }
96 
98 {
99 
100  // Check that the given abscissa is within the allowed range
101  if ( ! this->checkRange( abscissas ) ) {
102  gSystem->Exit( EXIT_FAILURE );
103  }
104 
105  // Get our abscissa
106  Double_t abscissa = abscissas[0];
107 
108  // Get the up to date parameter values
109  Double_t mean = mean_->unblindValue();
110  Double_t sigmaL = sigmaL_->unblindValue();
111  Double_t sigmaR = sigmaR_->unblindValue();
112  Double_t alphaL = alphaL_->unblindValue();
113  Double_t alphaR = alphaR_->unblindValue();
114 
115  // Evaluate the LauCruijff PDF value
116 
117  Double_t arg = abscissa - mean;
118  Double_t coef( 0.0 );
119  Double_t value( 0.0 );
120 
121  if ( arg < 0.0 ) {
122  if ( TMath::Abs( sigmaL ) > 1e-30 ) {
123  coef = -1.0 / ( 2.0 * sigmaL * sigmaL + alphaL * arg * arg );
124  }
125  } else {
126  if ( TMath::Abs( sigmaR ) > 1e-30 ) {
127  coef = -1.0 / ( 2.0 * sigmaR * sigmaR + alphaR * arg * arg );
128  }
129  }
130  value = TMath::Exp( coef * arg * arg );
131 
132  // if the parameters are floating then we
133  // need to recalculate the normalisation
134  if ( ! this->cachePDF() && ! this->withinNormCalc() && ! this->withinGeneration() ) {
135  this->calcNorm();
136  }
137 
138  this->setUnNormPDFVal( value );
139 }
140 
141 void LauCruijffPdf::calcPDFHeight( const LauKinematics* /*kinematics*/ )
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
154 
155  if ( mean < this->getMinAbscissa() ) {
156  maxPoint[0] = this->getMinAbscissa();
157  } else if ( mean > this->getMaxAbscissa() ) {
158  maxPoint[0] = this->getMaxAbscissa();
159  }
160 
161  this->calcLikelihoodInfo( maxPoint );
162  Double_t height = this->getUnNormLikelihood();
163 
164  // Multiply by a small factor to avoid problems from rounding errors
165  height *= ( 1.0 + 1e-1 );
166 
167  this->setMaxHeight( height );
168 }
virtual ~LauCruijffPdf()
Destructor.
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 * sigmaL_
Sigma of left Gaussian.
virtual void calcNorm()
Calculate the normalisation factor of the PDF.
Definition: LauAbsPdf.cc:485
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
LauCruijffPdf(const TString &theVarName, const std::vector< LauAbsRValue * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor.
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.
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:394
LauAbsRValue * mean_
Gaussian mean.
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:54
LauAbsRValue * alphaL_
Alpha of left Gaussian.
LauAbsRValue * alphaR_
Alpha of right Gaussian.
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:460
File containing LauConstants namespace.
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)
Calculate the likelihood (and intermediate info) for a given abscissa.
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:354
Class for calculating 3-body kinematic quantities.
LauAbsRValue * sigmaR_
Sigma of right Gaussian.
virtual void calcPDFHeight(const LauKinematics *kinematics)
Calculate the PDF height.
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:218
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:287
File containing declaration of LauCruijffPdf class.
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:243