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