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