21 if ( data == 0 )
return mc;
26 else if ( data >= mc )
return 0.;
31 return ( mc - data + data * std::log( data / mc ) );
55 else if ( data >= mc )
return 0.;
59 const double fractional = std::sqrt( w2 ) / newmc;
61 const double fractional2 = fractional * fractional;
63 const double temp = newmc * fractional2 - 1;
65 const double temp2 = temp * temp + 4 * data * fractional2;
67 MACH3LOG_ERROR(
"Negative square root in Barlow Beeston coefficient calculation!");
71 const double beta = ( -1 * temp + sqrt( temp2 ) ) / 2.;
74 double stat = mc * beta;
78 stat = newmc - data + data * std::log( data / newmc );
84 if ( fractional > 0 ) penalty = ( beta - 1 ) * ( beta - 1 ) / ( 2 * fractional2 );
105 else if ( data >= mc )
return 0.;
109 const double k = newmc * newmc / w2;
111 const double beta = ( data + k ) / ( newmc + k );
116 const double penalty = k * beta - k + k * std::log( k / ( k * beta ) );
122 if ( data > 0 ) stat = newmc - data + data * std::log( data / newmc );
144 const long double b = mc / w2;
145 const long double a = mc * b + 1;
148 const double stat = double( -1 * ( a * logl( b ) + lgammal( data + a ) - lgammal( data + 1 ) - ( ( data + a ) * log1pl( b ) ) - lgammal( a ) ) );
155 if ( stat > poisson )
return poisson;
167 if ( data == 0 )
return mc/2.;
172 else if ( data >= mc )
return 0.;
176 return ( data - mc ) * ( data - mc ) / ( 2 * mc );
186 case TestStatistic::kNTestStatistics:
202 buf = std::cout.rdbuf();
203 errbuf = std::cerr.rdbuf();
204 std::cout.rdbuf(
nullptr );
205 std::cerr.rdbuf(
nullptr );
216 std::cout.rdbuf(
buf);
@ kPearson
Standard Pearson likelihood .
@ kBarlowBeeston
Barlow-Beeston () following Conway approximation ()
@ kDembinskiAbdelmotteleb
Based on .
@ kPoisson
Standard Poisson likelihood .
Custom exception class for MaCh3 errors.
virtual ~SampleHandlerBase()
destructor
void NowTalk()
CW: Redirect std::cout to silence some experiment specific libraries.
std::streambuf * buf
Keep the cout buffer.
SampleHandlerBase()
The main constructor.
std::streambuf * errbuf
Keep the cerr buffer.
TestStatistic fTestStatistic
Test statistic tells what kind of likelihood sample is using.
M3::int_t nSamples
Contains how many samples we've got.
unsigned int nEvents
Number of MC events are there.
void QuietPlease()
CW: Redirect std::cout to silence some experiment specific libraries.
double GetTestStatLLH(double data, double mc) const
Calculate test statistic for a single bin using Poisson.
static constexpr const double _LOW_MC_BOUND_
MC prediction lower bound in bin to identify problematic binning definitions and handle LogL calculat...