laura is hosted by Hepforge, IPPP Durham
Laura++  v2r0
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 
27 ClassImp(LauAbsPdf)
28 
29 // Constructor for the abstract PDF class.
30 LauAbsPdf::LauAbsPdf(const TString& theVarName, const std::vector<LauParameter*>& 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<LauParameter*>& 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 LauParameter* LauAbsPdf::findParameter(const TString& parName)
382 {
383  for ( std::vector<LauParameter*>::iterator iter = param_.begin(); iter != param_.end(); ++iter ) {
384  if ((*iter)->name().Contains(parName)) {
385  return (*iter);
386  }
387  }
388 
389  std::cerr << "ERROR in LauAbsPdf::findParameter : Parameter \"" << parName << "\" not found." << std::endl;
390  return 0;
391 }
392 
393 const LauParameter* LauAbsPdf::findParameter(const TString& parName) const
394 {
395  for ( std::vector<LauParameter*>::const_iterator iter = param_.begin(); iter != param_.end(); ++iter ) {
396  if ((*iter)->name().Contains(parName)) {
397  return (*iter);
398  }
399  }
400 
401  std::cerr << "ERROR in LauAbsPdf::findParameter : Parameter \"" << parName << "\" not found." << std::endl;
402  return 0;
403 }
404 
405 Double_t LauAbsPdf::getParValue(const TString& parName) const
406 {
407  const LauParameter* par = this->findParameter(parName);
408  if (par != 0) {
409  return par->value();
410  } else {
411  return 0.0;
412  }
413 }
414 
415 Double_t LauAbsPdf::getParMin(const TString& parName) const
416 {
417  const LauParameter* par = this->findParameter(parName);
418  if (par != 0) {
419  return par->minValue();
420  } else {
421  return 0.0;
422  }
423 }
424 
425 Double_t LauAbsPdf::getParMax(const TString& parName) const
426 {
427  const LauParameter* par = this->findParameter(parName);
428  if (par != 0) {
429  return par->maxValue();
430  } else {
431  return 0.0;
432  }
433 }
434 
435 Double_t LauAbsPdf::getParRange(const TString& parName) const
436 {
437  const LauParameter* par = this->findParameter(parName);
438  if (par != 0) {
439  return (par->maxValue() - par->minValue());
440  } else {
441  return 0.0;
442  }
443 }
444 
445 Bool_t LauAbsPdf::parFixed(const TString& parName) const
446 {
447  const LauParameter* par = this->findParameter(parName);
448  if (par != 0) {
449  return par->fixed();
450  } else {
451  return kTRUE;
452  }
453 }
454 
455 Bool_t LauAbsPdf::parClone(const TString& parName) const
456 {
457  const LauParameter* par = this->findParameter(parName);
458  if (par != 0) {
459  return par->clone();
460  } else {
461  return kTRUE;
462  }
463 }
464 
465 void LauAbsPdf::setParValue(const TString& parName, Double_t value)
466 {
467  LauParameter* par = this->findParameter(parName);
468  if (par != 0) {
469  par->value(value);
470  }
471 }
472 
473 void LauAbsPdf::setParMin(const TString& parName, Double_t minValue)
474 {
475  LauParameter* par = this->findParameter(parName);
476  if (par != 0) {
477  par->minValue(minValue);
478  }
479 }
480 
481 void LauAbsPdf::setParMax(const TString& parName, Double_t maxValue)
482 {
483  LauParameter* par = this->findParameter(parName);
484  if (par != 0) {
485  par->maxValue(maxValue);
486  }
487 }
488 
489 void LauAbsPdf::setParRange(const TString& parName, Double_t minValue, Double_t maxValue)
490 {
491  LauParameter* par = this->findParameter(parName);
492  if (par != 0) {
493  par->range(minValue, maxValue);
494  }
495 }
496 
497 void LauAbsPdf::fixPar(const TString& parName)
498 {
499  LauParameter* par = this->findParameter(parName);
500  if (par != 0) {
501  par->fixed(kTRUE);
502  }
503 }
504 
505 void LauAbsPdf::floatPar(const TString& parName)
506 {
507  LauParameter* par = this->findParameter(parName);
508  if (par != 0) {
509  par->fixed(kFALSE);
510  }
511 }
512 
514 {
515  for ( std::vector<LauParameter*>::iterator iter = param_.begin(); iter != param_.end(); ++iter ) {
516  if (!(*iter)->fixed()) {
517  (*iter)->updatePull();
518  }
519  }
520 }
521 
522 void LauAbsPdf::addParameters(std::vector<LauParameter*>& params)
523 {
524  for ( std::vector<LauParameter*>::iterator iter = params.begin(); iter != params.end(); ++iter ) {
525  param_.push_back(*iter);
526  }
527 }
528 
530 {
531  this->withinNormCalc(kTRUE);
532 
533  if ( this->nInputVars() > 1 ) {
534  std::cerr << "ERROR in LauAbsPdf::calcNorm : Numeric integration only works for 1D PDFs." << std::endl;
535  gSystem->Exit(EXIT_FAILURE);
536  }
537 
538  IntMethod sumMethod = this->integMethod();
539 
540  Double_t normFac = (sumMethod == GaussLegendre) ? this->integrGaussLegendre() : this->integTrapezoid();
541 
542  this->setNorm(normFac);
543 
544  this->withinNormCalc(kFALSE);
545 }
546 
548 {
549  if (!this->normWeightsDone()) {
550  this->getNormWeights();
551  }
552 
553  // Now compute the integral
554  Double_t norm(0.0);
555  for (UInt_t i = 0; i < normWeights_.size(); i++) {
557  Double_t fun = this->getUnNormLikelihood();
558  Double_t intFactor = 0.5 * this->getRange();
559  norm += normWeights_[i]*intFactor*fun;
560  }
561 
562  //std::cout<<"====================================================="<<std::endl;
563  //std::cout<<"NORM = "<<norm<<std::endl;
564 
565  //std::cout<<"====================================================="<<std::endl;
566  return norm;
567 }
568 
570 {
571  // Check whether we've already calculated the weights
572  if (this->normWeightsDone()) {
573  std::cerr << "WARNING in LauAbsPdf::getNormWeights : Already calculated weights, not doing it again." << std::endl;
574  return;
575  }
576 
577  // Avoid integral if we have no points in x space
578  if (nNormPoints_ == 0) {
579  std::cerr << "ERROR in LauAbsPdf::getNormWeights : Zero points specified, this is daft!" << std::endl;
580  return;
581  }
582 
583  // Calculate the normalisation weights and abscissas
584  Double_t precision(1e-6);
585 
586  Double_t intMean = 0.5*(this->getMaxAbscissa() + this->getMinAbscissa());
587  Double_t range = this->getMaxAbscissa() - this->getMinAbscissa();
588  Double_t halfRange = 0.5*range;
589 
590  std::vector<Double_t> abscissas;
591  LauIntegrals funIntegrals(precision);
592  funIntegrals.calcGaussLegendreWeights(nNormPoints_, abscissas, normWeights_);
593 
594  //std::cout<<"====================================================="<<std::endl;
595  //std::cout<<"NORM POINTS = "<<nNormPoints_<<std::endl;
596 
597  //std::cout<<"====================================================="<<std::endl;
598 
599  Int_t nWeights = static_cast<Int_t>(normWeights_.size());
600  normAbscissas_.resize(nWeights);
601 
602  // Use same number of abscissas for x and y co-ordinates
603  Int_t m = (nWeights + 1)/2;
604  for (Int_t i = 0; i < m; ++i) {
605 
606  Int_t ii = nWeights - 1 - i; // symmetric i index
607 
608  Double_t dx = halfRange*abscissas[i];
609  Double_t tmpVal = intMean - dx;
610  normAbscissas_[i].push_back( tmpVal );
611 
612  tmpVal = intMean + dx;
613  normAbscissas_[ii].push_back( tmpVal );
614 
615  }
616 
617  this->normWeightsDone(kTRUE);
618 }
619 
621 {
622  Double_t abscVal, tnm, sum, del;
623  Int_t it, j;
624 
625  static Double_t norm(0.0);
626  Double_t range = this->getRange();
627 
628  if (this->nNormPoints()==1){
629 
630  LauAbscissas abscissa(1);
631  abscissa[0] = this->getMinAbscissa();
632  this->calcLikelihoodInfo(abscissa);
633  Double_t funAbsMin = this->getUnNormLikelihood();
634 
635  abscissa[0] = this->getMinAbscissa();
636  this->calcLikelihoodInfo(abscissa);
637  Double_t funAbsMax = this->getUnNormLikelihood();
638 
639  norm = 0.5*range*(funAbsMin+funAbsMax);
640  return norm;
641 
642  } else {
643  for (it=1, j=1; j< this->nNormPoints()-1; j++) {it<<=1;}
644  tnm=it;
645  del=range/tnm;
646  abscVal= this->getMinAbscissa()+ 0.5*del;
647 
648  for (sum = 0.0, j=1; j<it; j++, abscVal+=del) {
649 
650  LauAbscissas abscissa(1);
651  abscissa[0] = abscVal;
652  this->calcLikelihoodInfo(abscissa);
653  Double_t funVal = this->getUnNormLikelihood();
654 
655  sum+=funVal;
656  }
657 
658  norm = 0.5*(norm + sum*range/tnm);
659  return norm;
660  }
661 }
662 
Double_t range() const
The range allowed for the parameter.
std::vector< LauParameter * > param_
The parameters of the PDF (if any)
Definition: LauAbsPdf.hh:560
virtual Double_t integrGaussLegendre()
Integrate the PDF using the Gauss-Legendre method.
Definition: LauAbsPdf.cc:547
virtual void setParMax(const TString &parName, Double_t maxValue)
Change the maximum value of the specified parameter.
Definition: LauAbsPdf.cc:481
TRandom * randomFun()
Access the singleton random number generator with a particular seed.
Definition: LauRandom.cc:20
Bool_t fixed() const
Check whether the parameter is fixed or floated.
virtual Double_t getMinAbscissa() const
Retrieve the minimum value of the (primary) abscissa.
Definition: LauAbsPdf.hh:158
virtual Bool_t normWeightsDone() const
Check whether the normalisation weights have been calculated.
Definition: LauAbsPdf.hh:532
Double_t unNormPDFVal_
The unnormalised liklihood value.
Definition: LauAbsPdf.hh:591
virtual Bool_t heightUpToDate() const
Check if the maximum height of the PDF is up to date.
Definition: LauAbsPdf.hh:349
Double_t maxValue() const
The maximum value allowed for the parameter.
virtual const TString & varName() const
Retrieve the name of the abscissa.
Definition: LauAbsPdf.hh:79
virtual void addParameters(std::vector< LauParameter * > &params)
Add parameters to the PDF.
Definition: LauAbsPdf.cc:522
const TString & name() const
The parameter name.
virtual UInt_t nParameters() const
Retrieve the number of PDF parameters.
Definition: LauAbsPdf.hh:91
std::vector< LauAbscissas > normAbscissas_
The normalisation abscissas.
Definition: LauAbsPdf.hh:609
virtual Double_t getUnNormLikelihood() const
Retrieve the unnormalised likelihood value.
Definition: LauAbsPdf.hh:278
virtual void calcPDFHeight(const LauKinematics *kinematics)=0
Calculate the maximum height of the PDF.
Double_t minValue() const
The minimum value allowed for the parameter.
virtual void setNorm(Double_t norm)
Set the normalisation factor.
Definition: LauAbsPdf.hh:410
virtual Bool_t checkRange(const LauAbscissas &abscissas) const
Check that all abscissas are within their allowed ranges.
Definition: LauAbsPdf.cc:213
virtual Double_t getParMin(const TString &parName) const
Retrieve the minimum value of the specified parameter.
Definition: LauAbsPdf.cc:415
virtual void setParMin(const TString &parName, Double_t minValue)
Change the minimum value of the specified parameter.
Definition: LauAbsPdf.cc:473
virtual Int_t nNormPoints() const
Retrieve the number of points to integrate over when normalising.
Definition: LauAbsPdf.hh:361
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:578
virtual Bool_t withinNormCalc() const
Check whether the calcNorm method is running.
Definition: LauAbsPdf.hh:508
File containing declaration of LauKinematics class.
virtual Double_t getMaxHeight() const
Retrieve the maximum height.
Definition: LauAbsPdf.hh:303
Int_t nNormPoints_
number of points to integrate over when normalising
Definition: LauAbsPdf.hh:594
virtual void setParRange(const TString &parName, Double_t minValue, Double_t maxValue)
Change the range of the specified parameter.
Definition: LauAbsPdf.cc:489
LauAbscissas minAbscissas_
The minimum value(s) of the abscissa(s)
Definition: LauAbsPdf.hh:572
Double_t norm_
Normalisation factor of the PDF.
Definition: LauAbsPdf.hh:563
virtual void setMaxAbscissa(const TString &theVarName, Double_t maxAbscissa)
Set the maximum value of the specified abscissa.
Definition: LauAbsPdf.cc:199
virtual void setParValue(const TString &parName, Double_t value)
Change the value of the specified parameter.
Definition: LauAbsPdf.cc:465
std::vector< LauAbscissas > abscissas_
Cached values of the abscissas.
Definition: LauAbsPdf.hh:581
virtual void fixPar(const TString &parName)
Fix the specified parameter.
Definition: LauAbsPdf.cc:497
virtual LauFitData getMinAbscissas() const
Retrieve the minimum values of all the abscissas.
Definition: LauAbsPdf.cc:147
Bool_t clone() const
Check whether is a clone or not.
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:513
void calcGaussLegendreWeights(const Int_t numPoints, std::vector< Double_t > &abscissas, std::vector< Double_t > &weights)
Calculate the Gauss-Legendre weights.
Definition: LauIntegrals.cc:37
std::vector< Double_t > normWeights_
The normalisation weights.
Definition: LauAbsPdf.hh:612
virtual Bool_t parFixed(const TString &parName) const
Retrieve whether the specified parameter is fixed.
Definition: LauAbsPdf.cc:445
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:164
virtual Bool_t isDPDependent() const
Specifies whether or not the PDF is DP dependent.
Definition: LauAbsPdf.hh:110
Class for defining the fit parameter objects.
Definition: LauParameter.hh:32
std::vector< Double_t > unNormPDFValues_
Cached unnormalised likelihood values.
Definition: LauAbsPdf.hh:584
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:520
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:355
virtual Double_t getLikelihood() const
Retrieve the normalised likelihood value.
Definition: LauAbsPdf.cc:354
virtual Bool_t parClone(const TString &parName) const
Retrieve whether the specified parameter is a clone.
Definition: LauAbsPdf.cc:455
LauAbsPdf(const TString &theVarName, const std::vector< LauParameter * > &params, Double_t minAbscissa, Double_t maxAbscissa)
Constructor for a 1D PDF.
Definition: LauAbsPdf.cc:30
Double_t getm13Sq() const
Get the m13 invariant mass square.
virtual Double_t getParMax(const TString &parName) const
Retrieve the maximum value of the specified parameter.
Definition: LauAbsPdf.cc:425
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:569
virtual LauParameter * findParameter(const TString &parName)
Retrieve the specified parameter.
Definition: LauAbsPdf.cc:381
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:557
virtual void calcNorm()
Calculate the normalisation factor of the PDF.
Definition: LauAbsPdf.cc:529
Class for defining the abstract interface for PDF classes.
Definition: LauAbsPdf.hh:40
virtual Double_t getParRange(const TString &parName) const
Retrieve the range of the specified parameter.
Definition: LauAbsPdf.cc:435
virtual IntMethod integMethod() const
Retrieve the integration method used to normalise the PDF.
Definition: LauAbsPdf.hh:373
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
Double_t value() const
The value of the parameter.
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:575
virtual void floatPar(const TString &parName)
Float the specified parameter.
Definition: LauAbsPdf.cc:505
virtual UInt_t nInputVars() const
Retrieve the number of abscissas.
Definition: LauAbsPdf.hh:103
virtual Double_t getRange() const
Retrieve the range of the (primary) abscissa.
Definition: LauAbsPdf.hh:170
IntMethod
The possible numerical intergration methods.
Definition: LauAbsPdf.hh:47
virtual Double_t getParValue(const TString &parName) const
Retrieve the value of the specified parameter.
Definition: LauAbsPdf.cc:405
virtual Double_t integTrapezoid()
Integrate the PDF using the simple trapezoid method.
Definition: LauAbsPdf.cc:620
Class to store the input fit variables.
std::vector< Double_t > LauAbscissas
The type used for containing multiple abscissa values.
Definition: LauAbsPdf.hh:44