laura is hosted by Hepforge, IPPP Durham
Laura++  v3r0p1
A maximum likelihood fitting package for performing Dalitz-plot analysis.
LauAbsPdf.cc
Go to the documentation of this file.
1 
2 // Copyright University of Warwick 2004 - 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 <algorithm>
16 #include <iostream>
17 #include <map>
18 #include <vector>
19 
20 #include "TSystem.h"
21 
22 #include "LauAbsPdf.hh"
23 #include "LauRandom.hh"
24 #include "LauIntegrals.hh"
25 #include "LauKinematics.hh"
26 
28 
29 // Constructor for the abstract PDF class.
30 LauAbsPdf::LauAbsPdf(const TString& theVarName, const std::vector<LauAbsRValue*>& params,
31  Double_t minAbscissa, Double_t maxAbscissa) :
32  varNames_(),
33  param_(params),
34  norm_(0.0),
35  maxHeight_(0.0),
36  heightUpToDate_(kFALSE),
37  minAbscissas_(),
38  maxAbscissas_(),
39  randomFun_(LauRandom::randomFun()),
40  cachePDF_(kFALSE),
41  unNormPDFVal_(0.0),
42  nNormPoints_(50),
43  integMethod_(GaussLegendre),
44  withinNormCalc_(kFALSE),
45  withinGeneration_(kFALSE),
46  normWeightsDone_(kFALSE)
47 {
48  // Store the variable name
49  varNames_.insert( std::make_pair( 0, theVarName ) );
50 
51  // Store the min and max values
52  minAbscissas_.push_back( minAbscissa );
53  maxAbscissas_.push_back( maxAbscissa );
54 }
55 
56 LauAbsPdf::LauAbsPdf(const std::vector<TString>& theVarNames, const std::vector<LauAbsRValue*>& params,
57  const LauFitData& minAbscissas, const LauFitData& maxAbscissas) :
58  varNames_(),
59  param_(params),
60  norm_(0.0),
61  maxHeight_(0.0),
62  heightUpToDate_(kFALSE),
63  minAbscissas_(),
64  maxAbscissas_(),
65  randomFun_(LauRandom::randomFun()),
66  cachePDF_(kFALSE),
67  unNormPDFVal_(0.0),
68  nNormPoints_(50),
69  integMethod_(GaussLegendre),
70  withinNormCalc_(kFALSE),
71  withinGeneration_(kFALSE),
72  normWeightsDone_(kFALSE)
73 {
74  // Check that we have at least one variable
75  if ( theVarNames.empty() ) {
76  std::cerr << "ERROR in LauAbsPdf::LauAbsPdf : No variables supplied." << std::endl;
77  gSystem->Exit(EXIT_FAILURE);
78  }
79 
80  // Store the variable names
81  for ( UInt_t i(0); i < theVarNames.size(); ++i ) {
82  varNames_.insert( std::make_pair( i, theVarNames[i] ) );
83  }
84 
85  // Store the min and max abcissas for every variable
86  UInt_t nVars = varNames_.size();
87  minAbscissas_.resize( nVars );
88  maxAbscissas_.resize( nVars );
89  for ( std::map<UInt_t,TString>::const_iterator iter = varNames_.begin(); iter != varNames_.end(); ++iter ) {
90  UInt_t varIndex = iter->first;
91  const TString& theVarName = iter->second;
92  LauFitData::const_iterator min_iter = minAbscissas.find( theVarName );
93  LauFitData::const_iterator max_iter = maxAbscissas.find( theVarName );
94  if ( min_iter == minAbscissas.end() || max_iter == maxAbscissas.end() ) {
95  std::cerr << "ERROR in LauAbsPdf::LauAbsPdf : Either min or max abscissa not provided for variable \"" << theVarName << "\"." << std::endl;
96  gSystem->Exit(EXIT_FAILURE);
97  }
98  minAbscissas_[ varIndex ] = min_iter->second;
99  maxAbscissas_[ varIndex ] = max_iter->second;
100  }
101 }
102 
103 std::vector<TString> LauAbsPdf::varNames() const
104 {
105  std::vector<TString> theVarNames;
106  theVarNames.reserve( varNames_.size() );
107  for ( std::map<UInt_t,TString>::const_iterator iter = varNames_.begin(); iter != varNames_.end(); ++iter ) {
108  theVarNames.push_back( iter->second );
109  }
110  return theVarNames;
111 }
112 
114 {
115  LauParamFixed pred;
116  return std::count_if(param_.begin(),param_.end(),pred);
117 }
118 
119 Double_t LauAbsPdf::getMinAbscissa( const TString& theVarName ) const
120 {
121  for ( std::map<UInt_t,TString>::const_iterator iter = varNames_.begin(); iter != varNames_.end(); ++iter ) {
122  UInt_t index = iter->first;
123  const TString& name = iter->second;
124  if ( name == theVarName ) {
125  return minAbscissas_[ index ];
126  }
127  }
128 
129  std::cerr << "ERROR in LauAbsPdf::getMinAbscissa : Variable \"" << theVarName << "\" not found." << std::endl;
130  return 0.0;
131 }
132 
133 Double_t LauAbsPdf::getMaxAbscissa( const TString& theVarName ) const
134 {
135  for ( std::map<UInt_t,TString>::const_iterator iter = varNames_.begin(); iter != varNames_.end(); ++iter ) {
136  UInt_t index = iter->first;
137  const TString& name = iter->second;
138  if ( name == theVarName ) {
139  return maxAbscissas_[ index ];
140  }
141  }
142 
143  std::cerr << "ERROR in LauAbsPdf::getMaxAbscissa : Variable \"" << theVarName << "\" not found." << std::endl;
144  return 0.0;
145 }
146 
148 {
149  LauFitData minAbscissas;
150  for ( std::map<UInt_t,TString>::const_iterator iter = varNames_.begin(); iter != varNames_.end(); ++iter ) {
151  UInt_t varIndex = iter->first;
152  const TString& theVarName = iter->second;
153  minAbscissas[ theVarName ] = minAbscissas_[ varIndex ];
154  }
155  return minAbscissas;
156 }
157 
159 {
160  LauFitData maxAbscissas;
161  for ( std::map<UInt_t,TString>::const_iterator iter = varNames_.begin(); iter != varNames_.end(); ++iter ) {
162  UInt_t varIndex = iter->first;
163  const TString& theVarName = iter->second;
164  maxAbscissas[ theVarName ] = maxAbscissas_[ varIndex ];
165  }
166  return maxAbscissas;
167 }
168 
170 {
171  LauFitData minVals = this->getMinAbscissas();
172  LauFitData maxVals = this->getMaxAbscissas();
174 
175  for ( LauFitData::const_iterator iter = maxVals.begin(); iter != maxVals.end(); ++iter ) {
176  const TString& theVarName = iter->first;
177  Double_t maxVal = iter->second;
178  Double_t minVal = minVals.find(theVarName)->second;
179  range[theVarName] = maxVal - minVal;
180  }
181 
182  return range;
183 }
184 
185 void LauAbsPdf::setMinAbscissa(const TString& theVarName, Double_t minAbscissa)
186 {
187  for ( std::map<UInt_t,TString>::const_iterator iter = varNames_.begin(); iter != varNames_.end(); ++iter ) {
188  UInt_t index = iter->first;
189  const TString& name = iter->second;
190  if ( name == theVarName ) {
191  minAbscissas_[ index ] = minAbscissa;
192  return;
193  }
194  }
195 
196  std::cerr << "ERROR in LauAbsPdf::setMinAbscissa : Variable \"" << theVarName << "\" not found." << std::endl;
197 }
198 
199 void LauAbsPdf::setMaxAbscissa(const TString& theVarName, Double_t maxAbscissa)
200 {
201  for ( std::map<UInt_t,TString>::const_iterator iter = varNames_.begin(); iter != varNames_.end(); ++iter ) {
202  UInt_t index = iter->first;
203  const TString& name = iter->second;
204  if ( name == theVarName ) {
205  maxAbscissas_[ index ] = maxAbscissa;
206  return;
207  }
208  }
209 
210  std::cerr << "ERROR in LauAbsPdf::setMaxAbscissa : Variable \"" << theVarName << "\" not found." << std::endl;
211 }
212 
213 Bool_t LauAbsPdf::checkRange(const LauAbscissas& abscissas) const
214 {
215  // This method assumes the ordering of the abscissas provided match
216  // those of the min and max vectors
217 
218  // check that the size is correct
219  UInt_t nVars = abscissas.size();
220  if ( this->isDPDependent() ) {
221  nVars = abscissas.size() - 2; // if we depend on the DP we'll have been provided with the DP co-ordinates as well
222  }
223  if ( nVars != minAbscissas_.size() || nVars != maxAbscissas_.size() ) {
224  std::cerr << "ERROR in LauAbsPdf::checkRange : Unexpected number of absicssas: " << nVars << std::endl;
225  std::cerr << " : " << this->IsA()->GetName() << " expects " << minAbscissas_.size() << std::endl;
226  return kFALSE;
227  }
228 
229  for ( UInt_t i(0); i < nVars; ++i ) {
230  Double_t abscissa = abscissas[i];
231  Double_t minVal = minAbscissas_[i];
232  Double_t maxVal = maxAbscissas_[i];
233  if ( (abscissa < minVal) || (abscissa > maxVal) ) {
234  std::cerr << "ERROR in LauAbsPdf::checkRange : " << abscissa << " outside allowed range: [" << minVal << "," << maxVal << "]" << std::endl;
235  return kFALSE;
236  }
237  }
238  return kTRUE;
239 }
240 
241 void LauAbsPdf::cacheInfo(const LauFitDataTree& inputData)
242 {
243  Bool_t hasBranch(kTRUE);
244  for ( std::map<UInt_t,TString>::const_iterator iter = varNames_.begin(); iter != varNames_.end(); ++iter ) {
245  hasBranch &= inputData.haveBranch( iter->second );
246  if (!hasBranch) {
247  std::cerr << "ERROR in LauAbsPdf::cacheInfo : Input data does not contain variable \"" << iter->second << "\"." << std::endl;
248  return;
249  }
250  }
251 
252  // determine whether we are caching our PDF value
253  Bool_t doCaching( this->nFixedParameters() == this->nParameters() );
254  this->cachePDF( doCaching );
255 
256  // clear the vectors and reserve enough space
257  UInt_t nEvents = inputData.nEvents();
258  abscissas_.clear(); abscissas_.reserve(nEvents);
259  unNormPDFValues_.clear(); unNormPDFValues_.reserve(nEvents);
260 
261  for (UInt_t iEvt = 0; iEvt < nEvents; ++iEvt) {
262 
263  const LauFitData& dataValues = inputData.getData(iEvt);
264 
265  LauAbscissas myData;
266  // add all our variables into the data
267  for ( std::map<UInt_t,TString>::const_iterator var_iter = varNames_.begin(); var_iter != varNames_.end(); ++var_iter ) {
268  LauFitData::const_iterator iter = dataValues.find( var_iter->second );
269  myData.push_back( iter->second );
270  }
271  // if we're DP dependent then we'll need the DP co-ordinates as well
272  if ( this->isDPDependent() ) {
273  LauFitData::const_iterator iter = dataValues.find( "m13Sq" );
274  myData.push_back( iter->second );
275  iter = dataValues.find( "m23Sq" );
276  myData.push_back( iter->second );
277  }
278 
279  if (!this->checkRange(myData)) {
280  gSystem->Exit(EXIT_FAILURE);
281  }
282 
283  abscissas_.push_back( myData );
284 
285  if (this->cachePDF()) {
286  this->calcLikelihoodInfo( myData );
287  unNormPDFValues_.push_back( this->getUnNormLikelihood() );
288  }
289  }
290 
291  if (!this->cachePDF()) {
292  // in this case we seem to be doing a fit where the parameters are floating
293  // so need to mark that the PDF height is no longer up to date
294  this->heightUpToDate(kFALSE);
295  }
296 }
297 
299 {
300  this->withinGeneration(kTRUE);
301 
302  // Check that the PDF height is up to date
303  // N.B. this must now called every time (the method will simply
304  // return if there is nothing to do)
305  this->calcPDFHeight( kinematics );
306 
307  Bool_t gotAbscissa(kFALSE);
308  if (randomFun_ == 0) {
309  std::cerr << "ERROR in LauAbsPdf::generate : Please set the random number generator for this PDF by using the setRandomFun(TRandom*) function." << std::endl;
310  this->withinGeneration(kFALSE);
311  gSystem->Exit(EXIT_FAILURE);
312  }
313 
314  if ( this->isDPDependent() && !kinematics ) {
315  std::cerr << "ERROR in LauAbsPdf::generate : PDF depends on the DP and an invalid kinematics pointer has been provided." << std::endl;
316  this->withinGeneration(kFALSE);
317  gSystem->Exit(EXIT_FAILURE);
318  }
319 
320  // container for holding the generated abscissa(s)
321  LauAbscissas genAbscissa(1);
322 
323  // Generate the value of the abscissa.
324  Double_t genPDFVal(0.0);
325  Double_t PDFheight = this->getMaxHeight()*(1.0+1e-11);
326  while (!gotAbscissa) {
327 
328  if ( this->isDPDependent() ) {
329  genAbscissa.resize(3);
330  genAbscissa[1] = kinematics->getm13Sq();
331  genAbscissa[2] = kinematics->getm23Sq();
332  }
333  genAbscissa[0] = randomFun_->Rndm()*this->getRange() + this->getMinAbscissa();
334 
335  this->calcLikelihoodInfo(genAbscissa);
336  genPDFVal = this->getUnNormLikelihood();
337 
338  if (randomFun_->Rndm() <= genPDFVal/PDFheight) {gotAbscissa = kTRUE;}
339 
340  if (genPDFVal > PDFheight) {
341  std::cerr << "WARNING in LauAbsPdf::generate : genPDFVal = " << genPDFVal << " is larger than the maximum PDF height " << this->getMaxHeight() << " for the abscissa = " << genAbscissa[0] << "." << std::endl;
342  std::cerr << " : Need to reset height to be larger than " << genPDFVal << " by using the setMaxHeight(Double_t) function and re-run the Monte Carlo generation!" << std::endl;
343  }
344  }
345 
346  LauFitData genData;
347  genData[ this->varName() ] = genAbscissa[0];
348 
349  this->withinGeneration(kFALSE);
350 
351  return genData;
352 }
353 
354 Double_t LauAbsPdf::getLikelihood() const
355 {
356  if (TMath::Abs(norm_) > 1e-10) {
357  return unNormPDFVal_/norm_;
358  } else {
359  return 0.0;
360  }
361 }
362 
363 Double_t LauAbsPdf::getLikelihood( const TString& theVarName ) const
364 {
365  if ( theVarName != this->varName() ) {
366  std::cerr << "ERROR in LauAbsPdf::getLikelihood : Unrecognised variable name \"" << theVarName << "\", cannot determine likelihood." << std::endl;
367  return 0.0;
368  }
369  return this->getLikelihood();
370 }
371 
373 {
374  if (this->cachePDF() && (unNormPDFValues_.size() == abscissas_.size())) {
376  } else {
377  this->calcLikelihoodInfo( abscissas_[iEvt] );
378  }
379 }
380 
381 LauAbsRValue* LauAbsPdf::findParameter(const TString& parName)
382 {
383  for ( std::vector<LauAbsRValue*>::iterator iter = param_.begin(); iter != param_.end(); ++iter ) {
384  // std::vector<LauParameter*> params = (*iter)->getPars();
385  // for (std::vector<LauParameter*>::iterator params_iter = params.begin(); params_iter != params.end(); ++params_iter ) {
386  if ((*iter)->name().Contains(parName)) {
387  return (*iter);
388  }
389  // }
390  }
391 
392  std::cerr << "ERROR in LauAbsPdf::findParameter : Parameter \"" << parName << "\" not found." << std::endl;
393  return 0;
394 }
395 
396 const LauAbsRValue* LauAbsPdf::findParameter(const TString& parName) const
397 {
398  for ( std::vector<LauAbsRValue*>::const_iterator iter = param_.begin(); iter != param_.end(); ++iter ) {
399  // std::vector<LauParameter*> params = (*iter)->getPars();
400  // for (std::vector<LauParameter*>::iterator params_iter = params.begin(); params_iter != params.end(); ++params_iter ) {
401  if ((*iter)->name().Contains(parName)) {
402  return (*iter);
403  // }
404  }
405  }
406 
407  std::cerr << "ERROR in LauAbsPdf::findParameter : Parameter \"" << parName << "\" not found." << std::endl;
408  return 0;
409 }
410 
412 {
413  for ( std::vector<LauAbsRValue*>::iterator iter = param_.begin(); iter != param_.end(); ++iter ) {
414  std::vector<LauParameter*> params = (*iter)->getPars();
415  for (std::vector<LauParameter*>::iterator params_iter = params.begin(); params_iter != params.end(); ++params_iter ) {
416  if (!(*iter)->fixed()) {
417  (*params_iter)->updatePull();
418  }
419  }
420  }
421 }
422 
423 void LauAbsPdf::addParameters(std::vector<LauAbsRValue*>& params)
424 {
425  for ( std::vector<LauAbsRValue*>::iterator iter = params.begin(); iter != params.end(); ++iter ) {
426  param_.push_back(*iter);
427  }
428 }
429 
431 {
432  this->withinNormCalc(kTRUE);
433 
434  if ( this->nInputVars() > 1 ) {
435  std::cerr << "ERROR in LauAbsPdf::calcNorm : Numeric integration only works for 1D PDFs." << std::endl;
436  gSystem->Exit(EXIT_FAILURE);
437  }
438 
439  IntMethod sumMethod = this->integMethod();
440 
441  Double_t normFac = (sumMethod == GaussLegendre) ? this->integrGaussLegendre() : this->integTrapezoid();
442 
443  this->setNorm(normFac);
444 
445  this->withinNormCalc(kFALSE);
446 }
447 
449 {
450  if (!this->normWeightsDone()) {
451  this->getNormWeights();
452  }
453 
454  // Now compute the integral
455  Double_t norm(0.0);
456  for (UInt_t i = 0; i < normWeights_.size(); i++) {
458  Double_t fun = this->getUnNormLikelihood();
459  Double_t intFactor = 0.5 * this->getRange();
460  norm += normWeights_[i]*intFactor*fun;
461  }
462 
463  //std::cout<<"====================================================="<<std::endl;
464  //std::cout<<"NORM = "<<norm<<std::endl;
465 
466  //std::cout<<"====================================================="<<std::endl;
467  return norm;
468 }
469 
471 {
472  // Check whether we've already calculated the weights
473  if (this->normWeightsDone()) {
474  std::cerr << "WARNING in LauAbsPdf::getNormWeights : Already calculated weights, not doing it again." << std::endl;
475  return;
476  }
477 
478  // Avoid integral if we have no points in x space
479  if (nNormPoints_ == 0) {
480  std::cerr << "ERROR in LauAbsPdf::getNormWeights : Zero points specified, this is daft!" << std::endl;
481  return;
482  }
483 
484  // Calculate the normalisation weights and abscissas
485  Double_t precision(1e-6);
486 
487  Double_t intMean = 0.5*(this->getMaxAbscissa() + this->getMinAbscissa());
488  Double_t range = this->getMaxAbscissa() - this->getMinAbscissa();
489  Double_t halfRange = 0.5*range;
490 
491  std::vector<Double_t> abscissas;
492  LauIntegrals funIntegrals(precision);
493  funIntegrals.calcGaussLegendreWeights(nNormPoints_, abscissas, normWeights_);
494 
495  //std::cout<<"====================================================="<<std::endl;
496  //std::cout<<"NORM POINTS = "<<nNormPoints_<<std::endl;
497 
498  //std::cout<<"====================================================="<<std::endl;
499 
500  Int_t nWeights = static_cast<Int_t>(normWeights_.size());
501  normAbscissas_.resize(nWeights);
502 
503  // Use same number of abscissas for x and y co-ordinates
504  Int_t m = (nWeights + 1)/2;
505  for (Int_t i = 0; i < m; ++i) {
506 
507  Int_t ii = nWeights - 1 - i; // symmetric i index
508 
509  Double_t dx = halfRange*abscissas[i];
510  Double_t tmpVal = intMean - dx;
511  normAbscissas_[i].push_back( tmpVal );
512 
513  tmpVal = intMean + dx;
514  normAbscissas_[ii].push_back( tmpVal );
515 
516  }
517 
518  this->normWeightsDone(kTRUE);
519 }
520 
522 {
523  Double_t abscVal, tnm, sum, del;
524  Int_t it, j;
525 
526  static Double_t norm(0.0);
527  Double_t range = this->getRange();
528 
529  if (this->nNormPoints()==1){
530 
531  LauAbscissas abscissa(1);
532  abscissa[0] = this->getMinAbscissa();
533  this->calcLikelihoodInfo(abscissa);
534  Double_t funAbsMin = this->getUnNormLikelihood();
535 
536  abscissa[0] = this->getMinAbscissa();
537  this->calcLikelihoodInfo(abscissa);
538  Double_t funAbsMax = this->getUnNormLikelihood();
539 
540  norm = 0.5*range*(funAbsMin+funAbsMax);
541  return norm;
542 
543  } else {
544  for (it=1, j=1; j< this->nNormPoints()-1; j++) {it<<=1;}
545  tnm=it;
546  del=range/tnm;
547  abscVal= this->getMinAbscissa()+ 0.5*del;
548 
549  for (sum = 0.0, j=1; j<it; j++, abscVal+=del) {
550 
551  LauAbscissas abscissa(1);
552  abscissa[0] = abscVal;
553  this->calcLikelihoodInfo(abscissa);
554  Double_t funVal = this->getUnNormLikelihood();
555 
556  sum+=funVal;
557  }
558 
559  norm = 0.5*(norm + sum*range/tnm);
560  return norm;
561  }
562 }
563 
Double_t range() const
The range allowed for the parameter.
virtual Double_t integrGaussLegendre()
Integrate the PDF using the Gauss-Legendre method.
Definition: LauAbsPdf.cc:448
TRandom * randomFun()
Access the singleton random number generator with a particular seed.
Definition: LauRandom.cc:20
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:117
virtual Bool_t normWeightsDone() const
Check whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:447
Double_t unNormPDFVal_
The unnormalised liklihood value.
Definition: LauAbsPdf.hh:512
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:264
virtual const TString & varName() const
Retrieve the name of the abscissa.
Definition: LauAbsPdf.hh:80
ClassImp(LauAbsCoeffSet)
virtual LauAbsRValue * findParameter(const TString &parName)
Retrieve the specified parameter.
Definition: LauAbsPdf.cc:381
const TString & name() const
The parameter name.
virtual UInt_t nParameters() const
Retrieve the number of PDF parameters.
Definition: LauAbsPdf.hh:92
std::vector< LauAbscissas > normAbscissas_
The normalisation abscissas.
Definition: LauAbsPdf.hh:530
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:196
virtual void calcPDFHeight(const LauKinematics *kinematics)=0
Calculate the maximum height of the PDF.
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 Int_t nNormPoints() const
Retrieve the number of points to integrate over when normalising.
Definition: LauAbsPdf.hh:282
virtual void setMinAbscissa(const TString &theVarName, Double_t minAbscissa)
Set the minimum value of the specified abscissa.
Definition: LauAbsPdf.cc:185
Class for performing numerical integration routines.
Definition: LauIntegrals.hh:30
virtual LauFitData generate(const LauKinematics *kinematics)
Generate an event from the PDF.
Definition: LauAbsPdf.cc:298
std::map< TString, Double_t > LauFitData
Type for holding event data.
Double_t getm23Sq() const
Get the m23 invariant mass square.
TRandom * randomFun_
The random function used for MC generation.
Definition: LauAbsPdf.hh:499
virtual Bool_t withinNormCalc() const
Check whether the calcNorm method is running.
Definition: LauAbsPdf.hh:423
LauAbsPdf(const TString &theVarName, const std::vector< LauAbsRValue * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor for a 1D PDF.
Definition: LauAbsPdf.cc:30
File containing declaration of LauKinematics class.
virtual Double_t getMaxHeight() const
Retrieve the maximum height.
Definition: LauAbsPdf.hh:221
Int_t nNormPoints_
number of points to integrate over when normalising
Definition: LauAbsPdf.hh:515
LauAbscissas minAbscissas_
The minimum value(s) of the abscissa(s)
Definition: LauAbsPdf.hh:493
Double_t norm_
Normalisation factor of the PDF.
Definition: LauAbsPdf.hh:484
std::vector< LauAbsRValue * > param_
The parameters of the PDF (if any)
Definition: LauAbsPdf.hh:481
virtual void setMaxAbscissa(const TString &theVarName, Double_t maxAbscissa)
Set the maximum value of the specified abscissa.
Definition: LauAbsPdf.cc:199
std::vector< LauAbscissas > abscissas_
Cached values of the abscissas.
Definition: LauAbsPdf.hh:502
virtual LauFitData getMinAbscissas() const
Retrieve the minimum values of all the abscissas.
Definition: LauAbsPdf.cc:147
virtual LauFitData getRanges() const
Retrieve the ranges of all the abscissas.
Definition: LauAbsPdf.cc:169
virtual void updatePulls()
Update the pulls for all parameters.
Definition: LauAbsPdf.cc:411
void calcGaussLegendreWeights(const Int_t numPoints, std::vector< Double_t > &abscissas, std::vector< Double_t > &weights)
Calculate the Gauss-Legendre weights.
Definition: LauIntegrals.cc:50
std::vector< Double_t > normWeights_
The normalisation weights.
Definition: LauAbsPdf.hh:533
Predicate to allow counting of the number of fixed parameters.
virtual std::vector< TString > varNames() const
Retrieve the names of the abscissas.
Definition: LauAbsPdf.cc:103
virtual Double_t getMaxAbscissa() const
Retrieve the maximum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:123
virtual Bool_t isDPDependent() const
Specifies whether or not the PDF is DP dependent.
Definition: LauAbsPdf.hh:111
virtual void addParameters(std::vector< LauAbsRValue * > &params)
Add parameters to the PDF.
Definition: LauAbsPdf.cc:423
std::vector< Double_t > unNormPDFValues_
Cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:505
File containing declaration of LauAbsPdf class.
const LauFitData & getData(UInt_t iEvt) const
Retrieve the data for a given event.
virtual Bool_t withinGeneration() const
Check whether the generate method is running.
Definition: LauAbsPdf.hh:435
File containing LauRandom namespace.
virtual LauFitData getMaxAbscissas() const
Retrieve the maximum values of all the abscissas.
Definition: LauAbsPdf.cc:158
virtual Bool_t cachePDF() const
Check if the PDF is to be cached.
Definition: LauAbsPdf.hh:276
virtual Double_t getLikelihood() const
Retrieve the normalised likelihood value.
Definition: LauAbsPdf.cc:354
Double_t getm13Sq() const
Get the m13 invariant mass square.
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)=0
Calculate the likelihood (and all associated information) given value(s) of the abscissa(s) ...
virtual void getNormWeights()
Calculate the weights and abscissas used for normalisation.
Definition: LauAbsPdf.cc:470
Bool_t haveBranch(const TString &name) const
Check if the named branch is stored.
std::map< UInt_t, TString > varNames_
The names of the PDF variables.
Definition: LauAbsPdf.hh:478
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 IntMethod integMethod() const
Retrieve the integration method used to normalise the PDF.
Definition: LauAbsPdf.hh:294
File containing declaration of LauIntegrals class.
Class for calculating 3-body kinematic quantities.
virtual UInt_t nFixedParameters() const
Retrieve the number of fixed PDF parameters.
Definition: LauAbsPdf.cc:113
virtual void cacheInfo(const LauFitDataTree &inputData)
Cache information from data.
Definition: LauAbsPdf.cc:241
UInt_t nEvents() const
Retrieve the number of events.
LauAbscissas maxAbscissas_
The maximum value(s) of the abscissa(s)
Definition: LauAbsPdf.hh:496
virtual UInt_t nInputVars() const
Retrieve the number of abscissas.
Definition: LauAbsPdf.hh:104
virtual Double_t getRange() const
Retrieve the range of the (primary) abscissa.
Definition: LauAbsPdf.hh:129
IntMethod
The possible numerical intergration methods.
Definition: LauAbsPdf.hh:48
Pure abstract base class for defining a parameter containing an R value.
Definition: LauAbsRValue.hh:29
virtual Double_t integTrapezoid()
Integrate the PDF using the simple trapezoid method.
Definition: LauAbsPdf.cc:521
Class to store the input fit variables.
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:45