4 #pragma warning(disable:1572) 17 #include "AIDA/IHistogram1D.h" 18 #include "AIDA/IAxis.h" 48 (
const AIDA::IHistogram1D* histo ,
49 const unsigned int order ,
52 if ( !histo ) {
return s_bad ; }
53 if ( 0 == order ) {
return 1.0 ; }
54 if ( 1 == order ) {
return mean( histo ) - value ; }
57 const auto _r =
rms ( histo ) ;
58 const auto _d = value -
mean ( histo ) ;
61 const auto n =
nEff ( histo ) ;
62 if ( 0 >=
n ) {
return 0.0 ; }
65 const auto & axis = histo -> axis () ;
67 const auto nBins = axis.bins() ;
68 double result{0}, weight{0};
70 for (
int i = 0 ; i < nBins ; ++i )
72 const auto lE = axis . binLowerEdge ( i ) ;
73 const auto uE = axis . binUpperEdge ( i ) ;
75 const auto yBin = histo -> binHeight ( i ) ;
76 const double xBin = 0.5 * ( lE + uE ) ;
79 result += yBin *
std::pow ( xBin - value , order ) ;
81 if ( 0 != weight ) { result /= weight ; }
93 (
const AIDA::IHistogram1D* histo ,
94 const unsigned int order )
96 if ( !histo ) {
return s_bad ; }
97 const auto n =
nEff ( histo ) ;
98 if ( 0 >=
n ) {
return 0.0 ; }
99 const auto a2o =
moment ( histo , 2 * order ) ;
100 const auto ao =
moment ( histo , order ) ;
113 (
const AIDA::IHistogram1D* histo ,
114 const unsigned int order )
116 if ( !histo ) {
return s_bad ; }
117 if ( 0 == order ) {
return 1.0 ; }
118 if ( 1 == order ) {
return 0.0 ; }
124 return moment ( histo , order ,
mean ( histo ) ) ;
137 (
const AIDA::IHistogram1D* histo ,
138 const unsigned int order )
140 if ( !histo ) {
return s_bad ; }
141 const auto n =
nEff ( histo ) ;
142 if ( 0 >=
n ) {
return 0.0 ; }
148 const auto result = ( mu2o
149 - ( 2.0 * order * muom * muop )
151 + ( order * order * mu2 * muom * muom ) ) /
n ;
158 (
const AIDA::IHistogram1D* histo )
160 if ( !histo ) {
return s_bad ; }
163 return (
std::fabs(s3)>0 ? mu3/s3 : 0.0 );
169 (
const AIDA::IHistogram1D* histo )
171 if ( !histo ) {
return s_bad ; }
172 const auto n =
nEff ( histo ) ;
173 if ( 2 >
n ) {
return 0.0 ; }
174 const auto result = 6.0 * (
n - 2 ) / ( (
n + 1 ) * (
n + 3 ) );
181 (
const AIDA::IHistogram1D* histo )
183 if ( !histo ) {
return s_bad ; }
186 return (
std::fabs(s4)>0 ? mu4/s4 - 3.0 : 0.0 );
192 (
const AIDA::IHistogram1D* histo )
194 if ( !histo ) {
return s_bad ; }
195 const auto n =
nEff ( histo ) ;
196 if ( 3 >
n ) {
return 0.0 ; }
197 auto result = 24.0 *
n ;
198 result *= (
n - 2 ) * (
n - 3 ) ;
199 result /= (
n + 1 ) * (
n + 1 ) ;
200 result /= (
n + 3 ) * (
n + 5 ) ;
207 (
const AIDA::IHistogram1D* histo )
209 return ( histo ? histo->equivalentBinEntries() : s_bad );
215 (
const AIDA::IHistogram1D* histo )
217 return ( histo ? histo ->
mean() : s_bad );
223 (
const AIDA::IHistogram1D* histo )
225 if ( !histo ) {
return s_bad ; }
226 const auto n =
nEff ( histo ) ;
233 (
const AIDA::IHistogram1D* histo )
235 return ( histo ? histo ->
rms () : s_bad );
241 (
const AIDA::IHistogram1D* histo )
243 if ( !histo ) {
return s_bad ; }
244 const auto n =
nEff ( histo ) ;
245 if ( 1 >=
n ) {
return 0.0 ; }
246 auto result = 2.0 +
kurtosis ( histo ) ;
247 result += 2.0 / (
n - 1 ) ;
255 (
const AIDA::IHistogram1D* histo )
257 if ( !histo ) {
return s_bad ; }
261 const auto & axis = histo -> axis () ;
263 const auto nBins = axis.bins() ;
265 for (
int i = 0 ; i < nBins ; ++i )
268 error2 +=
std::pow( histo->binError(i), 2 ) ;
276 (
const AIDA::IHistogram1D* histo )
278 if ( !histo ) {
return s_bad ; }
280 const auto error = sumBinHeightErr( histo ) ;
281 if ( 0 > error ) {
return s_bad ; }
283 const auto err1 = histo->binError ( AIDA::IAxis::UNDERFLOW_BIN ) ;
284 const auto err2 = histo->binError ( AIDA::IAxis::OVERFLOW_BIN ) ;
292 (
const AIDA::IHistogram1D* histo )
294 if ( !histo ) {
return s_bad ; }
295 const auto overflow = histo -> binEntries ( AIDA::IAxis::OVERFLOW_BIN ) ;
296 if ( 0 == overflow ) {
return 0 ; }
297 const auto all = histo->allEntries() ;
298 if ( 0 == all ) {
return 0 ; }
299 if ( 0 > all ) {
return s_bad ; }
301 return (
double) overflow / (double) all;
307 (
const AIDA::IHistogram1D* histo )
309 if ( !histo ) {
return s_bad ; }
310 const auto underflow = histo -> binEntries ( AIDA::IAxis::UNDERFLOW_BIN ) ;
311 if ( 0 == underflow ) {
return 0 ; }
312 const auto all = histo->allEntries() ;
313 if ( 0 == all ) {
return 0 ; }
314 if ( 0 > all ) {
return s_bad ; }
316 return (
double) underflow / (double) all;
322 (
const AIDA::IHistogram1D* histo )
324 if ( !histo ) {
return s_bad ; }
325 const auto overflow = histo -> binHeight ( AIDA::IAxis::OVERFLOW_BIN ) ;
326 if ( 0 == overflow ) {
return 0 ; }
327 const auto all = histo -> sumAllBinHeights() ;
328 if ( 0 == all ) {
return 0 ; }
330 return (
double)overflow / (double)all ;
336 (
const AIDA::IHistogram1D* histo )
338 if ( !histo ) {
return s_bad ; }
339 const auto underflow = histo -> binHeight ( AIDA::IAxis::UNDERFLOW_BIN ) ;
340 if ( 0 == underflow ) {
return 0 ; }
341 const auto all = histo -> sumAllBinHeights() ;
342 if ( 0 == all ) {
return 0 ; }
344 return (
double)underflow / (double)all ;
350 (
const AIDA::IHistogram1D* histo )
352 if ( !histo ) {
return s_bad ; }
354 const auto overflow = histo -> binEntries ( AIDA::IAxis::OVERFLOW_BIN );
355 const auto all = histo -> allEntries () ;
357 if ( 0 > overflow || 0 >= all || overflow > all ) {
return s_bad ; }
359 const double n =
std::max ( (
double)overflow , 1.0 ) ;
360 const double N = all ;
361 const double n1 =
std::max ( N - n , 1.0 ) ;
369 (
const AIDA::IHistogram1D* histo )
371 if ( !histo ) {
return s_bad ; }
373 const auto underflow = histo -> binEntries ( AIDA::IAxis::UNDERFLOW_BIN );
374 const auto all = histo -> allEntries () ;
376 if ( 0 > underflow || 0 >= all || underflow > all ) {
return s_bad ; }
378 const double n =
std::max ( (
double)underflow , 1.0 ) ;
379 const double N = all ;
380 const double n1 =
std::max ( N - n , 1.0 ) ;
388 (
const AIDA::IHistogram1D* histo )
390 if ( !histo ) {
return s_bad ; }
392 const auto all = histo -> sumAllBinHeights () ;
393 if ( 0 == all ) {
return s_bad ; }
394 const auto overflow = histo -> binHeight ( AIDA::IAxis::OVERFLOW_BIN ) ;
395 const auto oErr = histo -> binError ( AIDA::IAxis::OVERFLOW_BIN ) ;
396 if ( 0 > oErr ) {
return s_bad ; }
397 const auto aErr = sumAllBinHeightErr ( histo ) ;
398 if ( 0 > aErr ) {
return s_bad ; }
400 double error2 =
std::pow((
double)oErr,2) ;
401 error2 += (
std::pow((
double)aErr,2) *
411 (
const AIDA::IHistogram1D* histo )
413 if ( !histo ) {
return s_bad ; }
415 const auto all = histo -> sumAllBinHeights () ;
416 if ( 0 == all ) {
return s_bad ; }
417 const auto underflow = histo -> binHeight ( AIDA::IAxis::UNDERFLOW_BIN ) ;
418 const auto oErr = histo -> binError ( AIDA::IAxis::UNDERFLOW_BIN ) ;
419 if ( 0 > oErr ) {
return s_bad ; }
420 const auto aErr = sumAllBinHeightErr ( histo ) ;
421 if ( 0 > aErr ) {
return s_bad ; }
423 double error2 =
std::pow((
double)oErr,2) ;
424 error2 += (
std::pow((
double)aErr,2) *
440 (
const AIDA::IHistogram1D* histo ,
443 if ( !histo ) {
return s_long_bad ; }
444 if ( 0 > imax ) {
return 0 ; }
445 long result = histo -> binEntries( AIDA::IAxis::UNDERFLOW_BIN ) ;
448 const auto& axis = histo -> axis () ;
450 const auto nBins = axis.bins() ;
452 for (
int i = 0 ; i < nBins ; ++i )
453 {
if ( i < imax ) { result += histo->binEntries ( i ) ; } }
456 { result += histo -> binEntries( AIDA::IAxis::OVERFLOW_BIN ) ; }
470 (
const AIDA::IHistogram1D* histo ,
474 if ( !histo ) {
return s_long_bad ; }
475 if ( imin == imax ) {
return 0 ; }
476 if ( imax < imin ) {
return nEntries ( histo , imax ,imin ) ; }
480 { result += histo -> binEntries( AIDA::IAxis::UNDERFLOW_BIN ) ; }
482 const auto& axis = histo -> axis () ;
484 const auto nBins = axis.bins() ;
485 if ( nBins < imin ) {
return 0 ; }
487 for (
int i = 0 ; i < nBins ; ++i )
488 {
if ( imin <= i && i < imax ) { result += histo->binEntries ( i ) ; } }
491 { result += histo -> binEntries( AIDA::IAxis::OVERFLOW_BIN ) ; }
505 (
const AIDA::IHistogram1D* histo ,
508 if ( !histo ) {
return s_bad ; }
510 const auto N = histo->allEntries () ;
511 if ( 0 >=
N ) {
return s_bad ; }
512 const auto n =
nEntries ( histo , imax ) ;
513 if ( 0 >
n ) {
return s_bad ; }
514 if (
n >
N ) {
return s_bad ; }
516 return (
double)
n / (double)
N ;
528 (
const AIDA::IHistogram1D* histo ,
532 if ( !histo ) {
return s_bad ; }
533 const auto N = histo->allEntries () ;
534 if ( 0 >=
N ) {
return s_bad ; }
535 const auto n =
nEntries ( histo , imin , imax ) ;
536 if ( 0 >
n ) {
return s_bad ; }
537 if (
n >
N ) {
return s_bad ; }
539 return (
double)
n / (double)
N ;
551 (
const AIDA::IHistogram1D* histo ,
554 if ( !histo ) {
return s_bad ; }
556 const auto N = histo->allEntries () ;
557 if ( 0 >=
N ) {
return s_bad ; }
558 const auto n =
nEntries ( histo , imax ) ;
559 if ( 0 >
n ) {
return s_bad ; }
560 if (
n >
N ) {
return s_bad ; }
562 const double _n1 =
std::max ( (
double)
n , 1.0 ) ;
563 const double _n2 =
std::max ( (
double) (
N - n ) , 1.0 ) ;
577 (
const AIDA::IHistogram1D* histo ,
581 if ( !histo ) {
return s_bad ; }
583 const auto N = histo->allEntries () ;
584 if ( 0 >=
N ) {
return s_bad ; }
585 const auto n =
nEntries ( histo , imin , imax ) ;
586 if ( 0 >
n ) {
return s_bad ; }
587 if (
n >
N ) {
return s_bad ; }
589 const double _n1 =
std::max ( (
double)
n , 1.0 ) ;
590 const double _n2 =
std::max ( (
double) (
N - n ) , 1.0 ) ;
static double underflowIntegralFracErr(const AIDA::IHistogram1D *histo)
the error on fraction of underflow integral
static double overflowIntegralFracErr(const AIDA::IHistogram1D *histo)
the error on fraction of overflow intergal
static double momentErr(const AIDA::IHistogram1D *histo, const unsigned int order)
evaluate the uncertanty for 'bin-by-bin'-moment
static double underflowEntriesFrac(const AIDA::IHistogram1D *histo)
the fraction of underflow entries (useful for shape comparison)
static long nEntries(const AIDA::IHistogram1D *histo, const int imax)
get number of entries in histogram up to the certain bin (not-included)
static double rmsErr(const AIDA::IHistogram1D *histo)
get an error in the rms value
static double underflowIntegralFrac(const AIDA::IHistogram1D *histo)
the fraction of underflow integral (useful for shape comparison)
static double moment(const AIDA::IHistogram1D *histo, const unsigned int order, const double value=0)
get the "bin-by-bin"-moment around the specified "value"
static double meanErr(const AIDA::IHistogram1D *histo)
get an error in the mean value
static double nEntriesFrac(const AIDA::IHistogram1D *histo, const int imax)
get the fraction of entries in histogram up to the certain bin (not-included)
static double overflowIntegralFrac(const AIDA::IHistogram1D *histo)
the fraction of overflow intergal (useful for shape comparison)
static double centralMoment(const AIDA::IHistogram1D *histo, const unsigned int order)
evaluate the 'bin-by-bin'-central moment (around the mean value)
static double centralMomentErr(const AIDA::IHistogram1D *histo, const unsigned int order)
evaluate the uncertanty for 'bin-by-bin'-central moment (around the mean value) ( the uncertanty is c...
static double rms(const AIDA::IHistogram1D *histo)
get the rms value for the histogram (just for completeness)
static double overflowEntriesFrac(const AIDA::IHistogram1D *histo)
the fraction of overflow entries (useful for shape comparison)
static double nEntriesFracErr(const AIDA::IHistogram1D *histo, const int imax)
get the (binominal) error for the fraction of entries in histogram up to the certain bin (not-include...
static double sumBinHeightErr(const AIDA::IHistogram1D *histo)
get an error in the sum bin height ("in-range integral")
static double overflowEntriesFracErr(const AIDA::IHistogram1D *histo)
error on fraction of overflow entries (useful for shape comparison)
static double sumAllBinHeightErr(const AIDA::IHistogram1D *histo)
get an error in the sum of all bin height ("integral")
static double kurtosisErr(const AIDA::IHistogram1D *histo)
get the error in kurtosis for the histogram
static double mean(const AIDA::IHistogram1D *histo)
get the mean value for the histogram (just for completeness)
static double skewnessErr(const AIDA::IHistogram1D *histo)
get the error in skewness for the histogram
static double underflowEntriesFracErr(const AIDA::IHistogram1D *histo)
the error on fraction of underflow entries (useful for shape comparison)
static double kurtosis(const AIDA::IHistogram1D *histo)
get the kurtosis for the histogram
static double nEff(const AIDA::IHistogram1D *histo)
get the effective entries (just for completeness)
static double skewness(const AIDA::IHistogram1D *histo)
get the skewness for the histogram