22 for (
int i=ilow ;
i<=ihi ;
i++ )
sum +=
h->GetBinContent(
i);
33 int& lowerbin,
int& upperbin,
double& lowerfrac,
double& upperfrac ) {
45 double sumn =
s->GetBinContent(
imax);
46 double tsum =
s->GetBinContent(
imax);
51 const int upperbin_i =
imax+
i;
52 const int lowerbin_i =
imax-
i;
54 if ( upperbin_i>
s->GetNbinsX() || lowerbin_i<1 )
break;
56 tsum +=
s->GetBinContent(upperbin_i) +
s->GetBinContent(lowerbin_i);
71 upperbin = upperbin_i;
72 lowerbin = lowerbin_i;
86 const bool interpolate_flag =
true;
89 double entries =
s->GetEffectiveEntries();
98 s->GetXaxis()->SetRange(1,
s->GetNbinsX());
100 double mean =
s->GetMean();
101 double meane =
s->GetMeanError();
106 double upperfrac = 0;
107 double lowerfrac = 0;
112 constexpr
int it_max=20;
113 constexpr
int it_max_report=20;
115 for ( ;
it<it_max ;
it++ ) {
130 s->GetXaxis()->SetRange(lowerbin, upperbin);
132 double m =
s->GetMean();
133 double me =
s->GetMeanError();
137 std::fabs(
mean-
m)<me*1
e-5 ||
138 std::fabs(
mean-
m)<meane*1
e-5 ) {
146 if (
it>=it_max_report ) {
147 std::cerr <<
s->GetName() <<
"\tMax iterations " <<
it <<
" reached" << std::endl;
157 if ( interpolate_flag ) {
159 s->GetXaxis()->SetRange(lowerbin-1, upperbin+1);
161 double m =
s->GetMean();
164 s->GetXaxis()->SetRange(1,
s->GetNbinsX());
166 if ( upperfrac==lowerfrac )
return 0;
168 double inter_mean =
mean + (
frac-lowerfrac)*(
m-
mean)/(upperfrac-lowerfrac);
173 s->GetXaxis()->SetRange(1,
s->GetNbinsX());
183 for (
int i=2 ;
i<=
s->GetNbinsX() ;
i++ ) {
185 if (
s->GetBinContent(
i)>
s->GetBinContent(
imax) )
imax =
i;
198 const bool interpolate_flag =
true;
200 if (
s==0 ) { std::cerr <<
"rmsFrac() histogram s = " <<
s << std::endl;
return 0; }
201 if (
s->GetXaxis()==0) { std::cerr <<
"rmsFrac() histogram s->GetXaxis() not definied for histogram " <<
s->GetName() << std::endl;
return 0; }
206 double entries =
s->GetEffectiveEntries();
213 s->GetXaxis()->SetRange(1,
s->GetNbinsX());
217 int imax =
s->GetXaxis()->FindBin(
m);
225 double upperfrac = 0;
226 double lowerfrac = 0;
237 std::vector<double>
stats;
241 if ( interpolate_flag ) {
245 s->GetXaxis()->SetRange(lowerbin, upperbin);
246 rlower =
s->GetRMS();
251 s->GetXaxis()->SetRange(lowerbin-1, upperbin+1);
252 rupper =
s->GetRMS();
257 if ( upperfrac!=lowerfrac ) {
258 rms = rlower + (
frac-lowerfrac)*(rupper-rlower)/(upperfrac-lowerfrac);
259 erms = erlower + (
frac-lowerfrac)*(erupper-erlower)/(upperfrac-lowerfrac);
267 s->GetXaxis()->SetRange(lowerbin, upperbin);
273 s->GetXaxis()->SetRange(1,
s->GetNbinsX());
289 s->GetXaxis()->SetRange(1,
s->GetNbinsX());
297 s->GetXaxis()->SetRange(1,
s->GetNbinsX());