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