Laura++
3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
|
Go to the documentation of this file.
49 Bool_t useInterpolation,
50 Bool_t fluctuateBins ) :
52 hist_( hist ? dynamic_cast<TH2*>( hist->Clone() ) : 0 ),
71 useInterpolation_( useInterpolation ),
72 fluctuateBins_( fluctuateBins )
78 std::cerr << "ERROR in Lau2DHistPdf::Lau2DHistPdf : Have not been provided with exactly two variables."
80 gSystem->Exit( EXIT_FAILURE );
97 std::cerr << "ERROR in Lau2DHistPdf::Lau2DHistPdf : Histogram pointer is null." << std::endl;
98 gSystem->Exit( EXIT_FAILURE );
102 hist_->SetDirectory( 0 );
108 TAxis* xAxis = hist_->GetXaxis();
109 Double_t xAxisMin = xAxis->GetXmin();
110 Double_t xAxisMax = xAxis->GetXmax();
112 TAxis* yAxis = hist_->GetYaxis();
113 Double_t yAxisMin = yAxis->GetXmin();
114 Double_t yAxisMax = yAxis->GetXmax();
117 if ( TMath::Abs( minX_ - xAxisMin ) > 1e-6 ) {
118 std::cerr << "ERROR in Lau2DHistPdf::Lau2DHistPdf : Histogram x-axis minimum: " << xAxisMin
119 << " does not correspond to " << xName_ << " minimum: " << minX_ << "."
121 gSystem->Exit( EXIT_FAILURE );
123 if ( TMath::Abs( maxX_ - xAxisMax ) > 1e-6 ) {
124 std::cerr << "ERROR in Lau2DHistPdf::Lau2DHistPdf : Histogram x-axis maximum: " << xAxisMax
125 << " does not correspond to " << xName_ << " maximum: " << maxX_ << "."
127 gSystem->Exit( EXIT_FAILURE );
129 if ( TMath::Abs( minY_ - yAxisMin ) > 1e-6 ) {
130 std::cerr << "ERROR in Lau2DHistPdf::Lau2DHistPdf : Histogram y-axis minimum: " << yAxisMin
131 << " does not correspond to " << yName_ << " minimum: " << minY_ << "."
133 gSystem->Exit( EXIT_FAILURE );
135 if ( TMath::Abs( maxY_ - yAxisMax ) > 1e-6 ) {
136 std::cerr << "ERROR in Lau2DHistPdf::Lau2DHistPdf : Histogram y-axis maximum: " << yAxisMax
137 << " does not correspond to " << yName_ << " maximum: " << maxY_ << "."
139 gSystem->Exit( EXIT_FAILURE );
154 if ( fluctuateBins ) {
162 std::cerr << "ERROR in Lau2DHistPdf::Lau2DHistPdf : Can't get X or Y projection from 2D histogram."
164 gSystem->Exit( EXIT_FAILURE );
198 Int_t maxBin = hist_->GetMaximumBin();
199 Double_t height = hist_->GetBinContent( maxBin );
212 Double_t area( 0.0 );
214 Double_t x( minX_ + dx / 2.0 );
216 Double_t y( minY_ + dy / 2.0 );
224 Double_t norm = area * dx * dy;
231 Double_t area( 0.0 );
232 Double_t areaNoNorm( 0.0 );
237 Double_t x( minX_ + dx / 2.0 );
239 Double_t y( minY_ + dy / 2.0 );
249 Double_t norm = area * dx * dy;
253 std::cout << "INFO in Lau2DHistPdf::checkNormalisation : Area = " << area << ", dx = " << dx
254 << ", dy = " << dy << ", dx*dy = " << dx * dy << std::endl;
255 std::cout << " : Area with no norm = " << areaNoNorm
256 << "*dx*dy = " << areaNoNorm * dx * dy << std::endl;
257 std::cout << " : The total area of the normalised histogram PDF is "
258 << norm << std::endl;
264 if ( ( i < 1 ) || ( i > nBinsX_ ) ) {
268 if ( ( j < 1 ) || ( j > nBinsY_ ) ) {
271 Double_t value = hist_->GetBinContent( i, j );
274 std::cerr << "WARNING in Lau2DHistPdf::getBinHistValue : Negative bin content set to zero!"
285 Double_t norm = this-> getNorm();
314 Double_t cbinx = static_cast<Double_t >( i - 0.5 ) * binXWidth_ + minX_;
315 Double_t cbiny = static_cast<Double_t >( j - 0.5 ) * binYWidth_ + minY_;
318 Double_t deltax = x - cbinx;
319 Double_t deltay = y - cbiny;
321 Int_t i_adj( 0 ), j_adj( 0 );
322 if ( deltax > 0.0 ) {
327 if ( deltay > 0.0 ) {
333 Bool_t isXBoundary( kFALSE ), isYBoundary( kFALSE );
335 Double_t value( 0.0 );
337 if ( i_adj > nBinsX_ || i_adj < 1 ) {
340 if ( j_adj > nBinsY_ || j_adj < 1 ) {
345 if ( isXBoundary == kTRUE && isYBoundary == kTRUE ) {
349 } else if ( isXBoundary == kTRUE && isYBoundary == kFALSE ) {
352 Double_t cbinx_adj = static_cast<Double_t >( i_adj - 0.5 ) * binXWidth_ + minX_;
354 Double_t dx0 = TMath::Abs( x - cbinx );
355 Double_t dx1 = TMath::Abs( cbinx_adj - x );
356 Double_t inter_denom = dx0 + dx1;
361 value = ( value1 * dx1 + value2 * dx0 ) / inter_denom;
363 } else if ( isYBoundary == kTRUE && isXBoundary == kFALSE ) {
366 Double_t cbiny_adj = static_cast<Double_t >( j_adj - 0.5 ) * binYWidth_ + minY_;
368 Double_t dy0 = TMath::Abs( y - cbiny );
369 Double_t dy1 = TMath::Abs( cbiny_adj - y );
370 Double_t inter_denom = dy0 + dy1;
375 value = ( value1 * dy1 + value2 * dy0 ) / inter_denom;
381 Double_t cbinx_adj = static_cast<Double_t >( i_adj - 0.5 ) * binXWidth_ + minX_;
382 Double_t cbiny_adj = static_cast<Double_t >( j_adj - 0.5 ) * binYWidth_ + minY_;
384 Double_t dx0 = TMath::Abs( x - cbinx );
385 Double_t dx1 = TMath::Abs( cbinx_adj - x );
386 Double_t dy0 = TMath::Abs( y - cbiny );
387 Double_t dy1 = TMath::Abs( cbiny_adj - y );
389 Double_t inter_denom = ( dx0 + dx1 ) * ( dy0 + dy1 );
396 value = value1 * dx1 * dy1 + value2 * dx0 * dy1 + value3 * dx1 * dy0 + value4 * dx0 * dy0;
397 value /= inter_denom;
407 gSystem->Exit( EXIT_FAILURE );
411 Double_t x = abscissas[0];
412 Double_t y = abscissas[1];
434 if ( theVarName == xName_ ) {
436 } else if ( theVarName == yName_ ) {
439 std::cerr << "ERROR in Lau2DHistPdf::getLikelihood : Unrecognised variable name \""
440 << theVarName << "\", cannot determine likelihood." << std::endl;
458 for ( Int_t i( 0 ); i < nBinsX_; i++ ) {
459 for ( Int_t j( 0 ); j < nBinsY_; j++ ) {
460 Double_t currentContent = hist_->GetBinContent( i + 1, j + 1 );
461 Double_t currentError = hist_->GetBinError( i + 1, j + 1 );
462 Double_t newContent = random->Gaus( currentContent, currentError );
463 if ( newContent < 0.0 ) {
464 hist_->SetBinContent( i + 1, j + 1, 0.0 );
466 hist_->SetBinContent( i + 1, j + 1, newContent );
480 Bool_t gotAbscissa( kFALSE );
482 std::cerr << "ERROR in Lau2DHistPdf::generate : Please set the random number generator for this PDF by using the setRandomFun(TRandom*) function."
485 gSystem->Exit( EXIT_FAILURE );
488 Double_t genPDFVal( 0.0 );
491 Double_t PDFheight = this-> getMaxHeight() * ( 1.0 + 1e-11 );
492 while ( ! gotAbscissa ) {
502 if ( this-> getRandomFun()->Rndm() <= genPDFVal / PDFheight ) {
506 if ( genPDFVal > PDFheight ) {
507 std::cerr << "WARNING in LauAbsPdf::generate : genPDFVal = " << genPDFVal
508 << " is larger than the specified PDF height " << this-> getMaxHeight()
509 << " for (x,y) = (" << genAbscissas[0] << "," << genAbscissas[1] << ")."
511 std::cerr << " : Need to reset height to be larger than "
513 << " by using the setMaxHeight(Double_t) function and re-run the Monte Carlo generation!"
519 genData[ xName_] = genAbscissas[0];
520 genData[ yName_] = genAbscissas[1];
Class for defining a 1D histogram PDF.
void checkNormalisation() Check the normalisation calculation.
Int_t nBinsX_ The number of bins on the x-axis of the histogram.
File containing LauRandom namespace.
Class for defining the fit parameter objects.
virtual Double_t getMaxAbscissa() const Retrieve the maximum value of the (primary) abscissa.
virtual Double_t getMaxHeight() const Retrieve the maximum height.
Double_t value() const The value of the parameter.
Double_t binYWidth_ The histogram y-axis bin width.
virtual Double_t getMinAbscissa() const Retrieve the minimum value of the (primary) abscissa.
virtual void calcPDFHeight(const LauKinematics *kinematics) Calculate the PDF height.
virtual void calcNorm() Calculate the normalisation.
Double_t minY_ The histogram y-axis minimum.
Lau1DHistPdf * xVarPdf_ 1D PDF for x variable
std::vector< Double_t > LauAbscissas The type used for containing multiple abscissa values.
virtual LauFitData generate(const LauKinematics *kinematics) Generate an event from the PDF.
virtual Double_t getRange() const Retrieve the range of the (primary) abscissa.
Double_t minX_ The histogram x-axis minimum.
Double_t interpolateXYNorm(Double_t x, Double_t y) const Perform the interpolation and divide by the normalisation.
Double_t invBinXWidth_ The histogram x-axis inverse bin width.
virtual void cacheInfo(const LauFitDataTree &inputData) Cache information from data.
Double_t rangeX_ The histogram x-axis range.
Double_t maxY_ The histogram y-axis maximum.
Class to store the input fit variables.
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas) Calculate the likelihood (and intermediate info) for a given value of the abscissas.
virtual void setNorm(Double_t norm) Set the normalisation factor.
TString yName_ y variable name
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas) Calculate the likelihood (and intermediate info) for a given abscissa.
Int_t nBinsY_ The number of bins on the y-axis of the histogram.
TH1 * xProj_ Projection of histogram x-axis.
virtual std::vector< TString > varNames() const Retrieve the names of the abscissas.
virtual ~Lau2DHistPdf() Destructor.
virtual TRandom * getRandomFun() const Retrieve the random function used for MC generation.
virtual UInt_t nInputVars() const Retrieve the number of abscissas.
virtual void setUnNormPDFVal(Double_t unNormPDFVal) Set the unnormalised likelihood.
Double_t rangeY_ The histogram y-axis range.
TRandom * randomFun() Access the singleton random number generator with a particular seed.
Double_t binXWidth_ The histogram x-axis bin width.
virtual void calcLikelihoodInfo(const LauAbscissas &abscissas)=0 Calculate the likelihood (and all associated information) given value(s) of the abscissa(s)
Class for defining the abstract interface for PDF classes.
virtual void cacheInfo(const LauFitDataTree &inputData) Cache information from data.
virtual Double_t getLikelihood() const Retrieve the normalised likelihood value.
virtual Bool_t withinGeneration() const Check whether the generate method is running.
Pure abstract base class for defining a parameter containing an R value.
Bool_t useInterpolation_ Control boolean for using the linear interpolation.
Bool_t fluctuateBins_ Control boolean for performing the fluctuation of the histogram bin contents.
Lau1DHistPdf * yVarPdf_ 1D PDF for y variable
File containing declaration of Lau1DHistPdf class.
std::map< TString, Double_t > LauFitData Type for holding event data.
Double_t maxX_ The histogram x-axis maximum.
virtual void setMaxHeight(Double_t maxHeight) Set the maximum height.
virtual Double_t getNorm() const Retrieve the normalisation factor.
TH2 * hist_ The underlying histogram.
Lau2DHistPdf(const std::vector< TString > &theVarNames, const TH2 *hist, const LauFitData &minVals, const LauFitData &maxVals, Bool_t useInterpolation=kTRUE, Bool_t fluctuateBins=kFALSE) Constructor.
Class for calculating 3-body kinematic quantities.
Double_t interpolateXY(Double_t x, Double_t y) const Perform the interpolation (unnormalised)
Double_t getBinHistValue(Int_t i, Int_t j) const Get the bin content from the histogram.
Double_t invBinYWidth_ The histogram y-axis inverse bin width.
void doBinFluctuation() Fluctuate the histogram bin contents in accordance with their errors.
virtual Double_t getUnNormLikelihood() const Retrieve the unnormalised likelihood value.
TString xName_ x variable name
virtual Bool_t heightUpToDate() const Check if the maximum height of the PDF is up to date.
File containing declaration of Lau2DHistPdf class.
TH1 * yProj_ Projection of histogram y-axis.
virtual Bool_t checkRange(const LauAbscissas &abscissas) const Check that all abscissas are within their allowed ranges.
|