Skip to content

Fix bin value determination when computing stats for int type histograms

Addresses a small bias in the bin values computed for integer like histograms.

For floating point based histograms, the correct bin value to use is the mid point of the bin, as this is the best guess (average) for the values saved in that bin. For int-based histograms this is not correct, and the better estimate is the lower bin value. e.g. for an int histogram with 10 bins from 0 to 10, the bins represent the values (0,1,2...,9).

This MR updates the stat calculations to determine the type (floating point or int) and adapt accordingly.

FYI @clemenci @sponce

Tested with lhcb/LHCb!4855 (merged) - e.g.

Normal_H1DD          INFO 1D=1 2D=0 H=1 P=0 W=0 NW=1
Normal_H1DD          INFO Generating Normal Mean=25 StdDev=15 Skewness=0 Kurtosis=0
Normal_H1DD          INFO Hist Min/Max/Bins -50/100/200
Normal_H1DI          INFO 1D=1 2D=0 H=1 P=0 W=0 NW=1
Normal_H1DI          INFO Generating Normal Mean=25 StdDev=15 Skewness=0 Kurtosis=0
Normal_H1DI          INFO Hist Min/Max/Bins -50/100/150
Exponential_H1DD     INFO 1D=1 2D=0 H=1 P=0 W=0 NW=1
Exponential_H1DD     INFO Generating Exponential Mean=13.3333 StdDev=13.3333 Skewness=2 Kurtosis=6
Exponential_H1DD     INFO Hist Min/Max/Bins 0/200/200
Exponential_H1DI     INFO 1D=1 2D=0 H=1 P=0 W=0 NW=1
Exponential_H1DI     INFO Generating Exponential Mean=13.3333 StdDev=13.3333 Skewness=2 Kurtosis=6
Exponential_H1DI     INFO Hist Min/Max/Bins 0/200/200
FlatTop_H1DD         INFO 1D=1 2D=0 H=1 P=0 W=0 NW=1
FlatTop_H1DD         INFO Generating FlatTop Mean=50 StdDev=27.7128 Skewness=0 Kurtosis=-1.2
FlatTop_H1DD         INFO Hist Min/Max/Bins 0/100/200
FlatTop_H1DI         INFO 1D=1 2D=0 H=1 P=0 W=0 NW=1
FlatTop_H1DI         INFO Generating FlatTop Mean=50 StdDev=27.7128 Skewness=0 Kurtosis=-1.2
FlatTop_H1DI         INFO Hist Min/Max/Bins 0/100/100
Exponential_H1DD     INFO Booked 2 Histogram(s) : 1D=2 2D=0 3D=0 1DProf=0 2DProf=0 3DProf=0
Exponential_H1DD     INFO 1D histograms in directory "Exponential_H1DD" : 2
 | ID                                            | Title                                         |      #     |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
 | /RICH/Exponential_H1DD/testH1D0               | "Exponential;X;Entries"                       |    1000000 |     13.322 | 13.325     |     2.0004 |     5.9701 |
 | /RICH/Exponential_H1DD/testH1D1               | "Exponential;X;Entries"                       |    1000000 |     13.322 | 13.325     |     2.0004 |     5.9701 |
Exponential_H1DI     INFO Booked 2 Histogram(s) : 1D=2 2D=0 3D=0 1DProf=0 2DProf=0 3DProf=0
Exponential_H1DI     INFO 1D histograms in directory "Exponential_H1DI" : 2
 | ID                                            | Title                                         |      #     |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
 | /RICH/Exponential_H1DI/testH1D0               | "Exponential;X;Entries"                       |    1000000 |     13.336 | 13.352     |     1.9955 |     5.9292 |
 | /RICH/Exponential_H1DI/testH1D1               | "Exponential;X;Entries"                       |    1000000 |     13.336 | 13.352     |     1.9955 |     5.9292 |
FlatTop_H1DD         INFO Booked 2 Histogram(s) : 1D=2 2D=0 3D=0 1DProf=0 2DProf=0 3DProf=0
FlatTop_H1DD         INFO 1D histograms in directory "FlatTop_H1DD" : 2
 | ID                                            | Title                                         |      #     |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
 | /RICH/FlatTop_H1DD/testH1D0                   | "FlatTop;X;Entries"                           |    1000000 |     49.981 | 27.713     | 0.00040877 |    -1.1998 |
 | /RICH/FlatTop_H1DD/testH1D1                   | "FlatTop;X;Entries"                           |    1000000 |     49.981 | 27.713     | 0.00040877 |    -1.1998 |
FlatTop_H1DI         INFO Booked 2 Histogram(s) : 1D=2 2D=0 3D=0 1DProf=0 2DProf=0 3DProf=0
FlatTop_H1DI         INFO 1D histograms in directory "FlatTop_H1DI" : 2
 | ID                                            | Title                                         |      #     |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
 | /RICH/FlatTop_H1DI/testH1D0                   | "FlatTop;X;Entries"                           |    1000000 |     49.979 | 27.711     |   0.001086 |    -1.1989 |
 | /RICH/FlatTop_H1DI/testH1D1                   | "FlatTop;X;Entries"                           |    1000000 |     49.979 | 27.711     |   0.001086 |    -1.1989 |
Normal_H1DD          INFO Booked 2 Histogram(s) : 1D=2 2D=0 3D=0 1DProf=0 2DProf=0 3DProf=0
Normal_H1DD          INFO 1D histograms in directory "Normal_H1DD" : 2
 | ID                                            | Title                                         |      #     |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
 | /RICH/Normal_H1DD/testH1D0                    | "Normal;X;Entries"                            |    1000000 |     24.972 | 15.021     | 0.00041311 |  0.0098636 |
 | /RICH/Normal_H1DD/testH1D1                    | "Normal;X;Entries"                            |    1000000 |     24.972 | 15.021     | 0.00041311 |  0.0098636 |
Normal_H1DI          INFO Booked 2 Histogram(s) : 1D=2 2D=0 3D=0 1DProf=0 2DProf=0 3DProf=0
Normal_H1DI          INFO 1D histograms in directory "Normal_H1DI" : 2
 | ID                                            | Title                                         |      #     |     Mean   |    RMS     |  Skewness  |  Kurtosis  |
 | /RICH/Normal_H1DI/testH1D0                    | "Normal;X;Entries"                            |    1000000 |     24.996 | 14.989     |  0.0002025 | -0.0042996 |
 | /RICH/Normal_H1DI/testH1D1                    | "Normal;X;Entries"                            |    1000000 |     24.996 | 14.989     |  0.0002025 | -0.0042996 |
Edited by Christopher Rob Jones

Merge request reports

Loading