laura is hosted by Hepforge, IPPP Durham
Laura++  v2r1
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 
81 LauCruijffPdf::LauCruijffPdf(const LauCruijffPdf& other) : LauAbsPdf(other.varName(), other.getParameters(), other.getMinAbscissa(), other.getMaxAbscissa())
82 {
83  // Copy constructor
84  this->setRandomFun(other.getRandomFun());
85  this->calcNorm();
86 }
87 
89 {
90 
91  // Check that the given abscissa is within the allowed range
92  if (!this->checkRange(abscissas)) {
93  gSystem->Exit(EXIT_FAILURE);
94  }
95 
96  // Get our abscissa
97  Double_t abscissa = abscissas[0];
98 
99  // Get the up to date parameter values
100  Double_t mean = mean_->value();
101  Double_t sigmaL = sigmaL_->value();
102  Double_t sigmaR = sigmaR_->value();
103  Double_t alphaL = alphaL_->value();
104  Double_t alphaR = alphaR_->value();
105 
106  // Evaluate the LauCruijff PDF value
107 
108 
109  Double_t arg = abscissa - mean;
110  Double_t coef(0.0);
111  Double_t value(0.0);
112 
113  if (arg < 0.0){
114  if (TMath::Abs(sigmaL) > 1e-30) {
115  coef = -1.0/(2.0*sigmaL*sigmaL + alphaL*arg*arg);
116  }
117  } else {
118  if (TMath::Abs(sigmaR) > 1e-30) {
119  coef = -1.0/(2.0*sigmaR*sigmaR+ alphaR*arg*arg);
120  }
121  }
122  value = TMath::Exp(coef*arg*arg);
123 
124 
125  // if the parameters are floating then we
126  // need to recalculate the normalisation
127  if (!this->cachePDF() && !this->withinNormCalc() && !this->withinGeneration()) {
128  this->calcNorm();
129  }
130 
131  this->setUnNormPDFVal(value);
132 }
133 
134 void LauCruijffPdf::calcPDFHeight( const LauKinematics* /*kinematics*/ )
135 {
136  if (this->heightUpToDate()) {
137  return;
138  }
139 
140  // Get the up to date parameter values
141  Double_t mean = mean_->value();
142 
143  LauAbscissas maxPoint(1);
144  maxPoint[0] = mean;
145 
146  // Calculate the PDF height
147 
148  if (mean < this->getMinAbscissa()) {
149  maxPoint[0] = this->getMinAbscissa();
150  } else if (mean > this->getMaxAbscissa()) {
151  maxPoint[0] = this->getMaxAbscissa();
152  }
153 
154  this->calcLikelihoodInfo(maxPoint);
155  Double_t height = this->getUnNormLikelihood();
156 
157  // Multiply by a small factor to avoid problems from rounding errors
158  height *= (1.0 + 1e-1);
159 
160  this->setMaxHeight(height);
161 }
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 TRandom * getRandomFun() const
Retrieve the random function used for MC generation.
Definition: LauAbsPdf.hh:387
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:270
File containing LauConstants namespace.
LauAbsRValue * alphaR_
Alpha of right Gaussian.
LauAbsRValue * sigmaL_
Sigma of left Gaussian.
virtual Double_t value() const =0
Return the value of the parameter.
LauCruijffPdf(const TString &theVarName, const vector< LauAbsRValue * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor.
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.
virtual void setRandomFun(TRandom *randomFun)
Set the random function used for toy MC generation.
Definition: LauAbsPdf.hh:233
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.