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