laura is hosted by Hepforge, IPPP Durham
Laura++  v3r4
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::cout;
48 using std::cerr;
49 using std::endl;
50 using std::vector;
51 
52 #include "TMath.h"
53 #include "TSystem.h"
54 
55 #include "LauCruijffPdf.hh"
56 #include "LauConstants.hh"
57 
59 
60 LauCruijffPdf::LauCruijffPdf(const TString& theVarName, const vector<LauAbsRValue*>& params, Double_t minAbscissa, 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) || (alphaL_ == 0) || (alphaR_ == 0)) {
82  cerr<<"ERROR in LauCruijffPdf constructor: LauCruijffPdf requires 5 parameters: \"mean\", \"sigmaL\", \"sigmaR\", \"alphaR\" and \"alphaL\"."<<endl;
83  gSystem->Exit(EXIT_FAILURE);
84  }
85 
86  // Cache the normalisation factor
87  this->calcNorm();
88 }
89 
91 {
92  // Destructor
93 }
94 
96 {
97 
98  // Check that the given abscissa is within the allowed range
99  if (!this->checkRange(abscissas)) {
100  gSystem->Exit(EXIT_FAILURE);
101  }
102 
103  // Get our abscissa
104  Double_t abscissa = abscissas[0];
105 
106  // Get the up to date parameter values
107  Double_t mean = mean_->unblindValue();
108  Double_t sigmaL = sigmaL_->unblindValue();
109  Double_t sigmaR = sigmaR_->unblindValue();
110  Double_t alphaL = alphaL_->unblindValue();
111  Double_t alphaR = alphaR_->unblindValue();
112 
113  // Evaluate the LauCruijff PDF value
114 
115 
116  Double_t arg = abscissa - mean;
117  Double_t coef(0.0);
118  Double_t value(0.0);
119 
120  if (arg < 0.0){
121  if (TMath::Abs(sigmaL) > 1e-30) {
122  coef = -1.0/(2.0*sigmaL*sigmaL + alphaL*arg*arg);
123  }
124  } else {
125  if (TMath::Abs(sigmaR) > 1e-30) {
126  coef = -1.0/(2.0*sigmaR*sigmaR+ alphaR*arg*arg);
127  }
128  }
129  value = TMath::Exp(coef*arg*arg);
130 
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 void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:383
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:131
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:278
ClassImp(LauAbsCoeffSet)
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:210
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:227
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)
Calculate the likelihood (and intermediate info) for a given abscissa.
virtual void calcPDFHeight(const LauKinematics *kinematics)
Calculate the PDF height.
virtual Bool_t withinNormCalc() const
Check whether the calcNorm method is running.
Definition: LauAbsPdf.hh:437
virtual Double_t unblindValue() const =0
The unblinded value of the parameter.
LauAbsRValue * mean_
Gaussian mean.
Class for defining a Cruijff PDF.
LauAbsRValue * alphaL_
Alpha of left Gaussian.
virtual Double_t getMaxAbscissa() const
Retrieve the maximum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:137
virtual void setMaxHeight(Double_t maxHeight)
Set the maximum height.
Definition: LauAbsPdf.hh:345
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:449
virtual Bool_t cachePDF() const
Check if the PDF is to be cached.
Definition: LauAbsPdf.hh:290
File containing LauConstants namespace.
LauAbsRValue * alphaR_
Alpha of right Gaussian.
LauAbsRValue * sigmaL_
Sigma of left Gaussian.
File containing declaration of LauCruijffPdf class.
virtual void calcNorm()
Calculate the normalisation factor of the PDF.
Definition: LauAbsPdf.cc:444
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:55
virtual ~LauCruijffPdf()
Destructor.
Class for calculating 3-body kinematic quantities.
Double_t value() const
The value of the parameter.
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:43
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:59
LauAbsRValue * sigmaR_
Sigma of right Gaussian.