laura is hosted by Hepforge, IPPP Durham
Laura++  v3r0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauLinearPdf.cc
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2006 - 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 #include <iostream>
16 #include <vector>
17 using std::cout;
18 using std::cerr;
19 using std::endl;
20 using std::vector;
21 
22 #include "TMath.h"
23 #include "TSystem.h"
24 
25 #include "LauConstants.hh"
26 #include "LauLinearPdf.hh"
27 
29 
30 
31  LauLinearPdf::LauLinearPdf(const TString& theVarName, const vector<LauAbsRValue*>& params, Double_t minAbscissa, Double_t maxAbscissa) :
32  LauAbsPdf(theVarName, params, minAbscissa, maxAbscissa),
33  slope_(0),posflag_(kTRUE)
34 {
35  // Constructor for the linear PDF.
36  //
37  // The parameters in params are the slope and y-intercept of the line.
38  // The last two arguments specify the range in which the PDF is defined, and the PDF
39  // will be normalised w.r.t. these limits.
40 
41  slope_ = this->findParameter("slope");
42 
43  if ((this->nParameters() != 1) || (slope_ == 0)) {
44  cerr<<"Warning. LauLinearPdf requires 1 parameter: \"slope\"."<<endl;
45  gSystem->Exit(EXIT_FAILURE);
46  }
47 
48  // Cache the normalisation factor.
49  this->calcNorm();
50 }
51 
53 {
54  // Destructor
55 }
56 
58 {
59  // Check that the given abscissa is within the allowed range
60  if (!this->checkRange(abscissas)) {
61  gSystem->Exit(EXIT_FAILURE);
62  }
63 
64  // Get our abscissa
65  Double_t abscissa = abscissas[0];
66 
67  // Get the up to date parameter values
68  Double_t slope = slope_->value();
69 
70  // Calculate the value of the straight line for the given value of the abscissa.
71  Double_t constVal = 1.0/(this->getMaxAbscissa() - this->getMinAbscissa());
72  constVal -= slope * (this->getMaxAbscissa() + this->getMinAbscissa()) * 0.5;
73 
74  Double_t value = slope*abscissa + constVal;
75 
76  // Make sure the PDF doesn't go negative
77  if ( value < 0.0 ) {
78  if ( posflag_ ) {
79  std::cerr << "WARNING in LauLinearPdf::calcLikelihoodInfo : The PDF is negative, setting to zero" << std::endl;
80  }
81  value = 0.0;
82  posflag_= kFALSE;
83  }
84 
85  this->setUnNormPDFVal(value);
86 }
87 
89 {
90  // Nothing to calculate here since the PDF is already normalised to 1
91  this->setNorm(1.0);
92 }
93 
94 void LauLinearPdf::calcPDFHeight( const LauKinematics* /*kinematics*/ )
95 {
96  if (this->heightUpToDate()) {
97  return;
98  }
99 
100  // Get the up to date parameter values
101  Double_t slope = slope_->value();
102 
103  // Calculate the PDF height for the straight line
104  LauAbscissas maxPoint(1);
105  if (slope>0.0) {
106  maxPoint[0] = this->getMaxAbscissa();
107  } else {
108  maxPoint[0] = this->getMinAbscissa();
109  }
110  this->calcLikelihoodInfo(maxPoint);
111 
112  Double_t height = this->getUnNormLikelihood();
113 
114  this->setMaxHeight(height);
115 }
Bool_t posflag_
Definition: LauLinearPdf.hh:75
virtual void setUnNormPDFVal(Double_t unNormPDFVal)
Set the unnormalised likelihood.
Definition: LauAbsPdf.hh:369
virtual ~LauLinearPdf()
Destructor.
Definition: LauLinearPdf.cc:52
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 void setNorm(Double_t norm)
Set the normalisation factor.
Definition: LauAbsPdf.hh:325
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:213
virtual void calcNorm()
Calculate the normalisation.
Definition: LauLinearPdf.cc:88
Class for defining a straight line PDF.
Definition: LauLinearPdf.hh:30
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
File containing declaration of LauLinearPdf class.
virtual void calcPDFHeight(const LauKinematics *kinematics)
Calculate the PDF height.
Definition: LauLinearPdf.cc:94
File containing LauConstants namespace.
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:41
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
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)
Calculate the likelihood (and intermediate info) for a given abscissa.
Definition: LauLinearPdf.cc:57