|
ATLAS Offline Software
|
Go to the documentation of this file.
30 static const bool printPad =
false;
33 for (
int i=0 ;
i<=hin->GetNbinsX()+1 ;
i++ ) {
34 hin->SetBinContent(
i, 0);
35 hin->SetBinError(
i, 0);
42 for (
int i=1 ;
i<=hin->GetNbinsX() ;
i++ )
N += hin->GetBinContent(
i);
49 for (
unsigned i=0 ;
i<
m.size() ;
i++ )
mean +=
m[
i];
54 double get_rms(
const std::vector<double>&
m ) {
57 for (
unsigned i=0 ;
i<
m.size() ;
i++ ) {
61 return std::sqrt(
rms/
m.size() );
70 TH1D* hint = (TH1D*)hin->Clone( (std::string(hin->GetName())+
"-cumulative").c_str() );
74 hint->SetBinContent(0,0);
75 hint->SetBinContent(hin->GetNbinsX()+1,0);
77 for (
int i=1 ;
i<=hin->GetNbinsX()+1 ;
i++ ) {
78 double c = hin->GetBinContent(
i) + hint->GetBinContent(
i-1);
79 hint->SetBinContent(
i,
c);
80 hint->SetBinError(
i, std::sqrt(
c) );
83 hint->SetBinContent(hin->GetNbinsX()+1, hint->GetBinContent(hin->GetNbinsX()) );
94 double N = hin->GetBinContent(hin->GetNbinsX());
96 for (
int i=0 ;
i<=hin->GetNbinsX()+1 ;
i++ ) {
98 double n = hin->GetBinContent(
i);
102 double ee = std::sqrt(
e*(1-
e)/
N);
104 hin->SetBinContent(
i,
e);
105 hin->SetBinError(
i, ee);
124 for (
int i=2 ;
i<hin->GetNbinsX() ;
i++ ) {
125 double g = hin->GetBinContent(
i+1)-hin->GetBinContent(
i-1);
126 if ( std::fabs(gmax)<std::fabs(
g) ) {
131 return gmax/hin->GetBinError(
imax);
139 for (
int i=2 ;
i<hin->GetNbinsX() ;
i++ ) {
140 double g = hin->GetBinContent(
i+1)-hin->GetBinContent(
i-1);
141 if ( std::fabs(gmax)<std::fabs(
g) ) {
160 TH1D* hsmooth = (TH1D*)hin->Clone( (std::string(hin->GetName())+
"-smooth").c_str() );
161 hsmooth->SetDirectory(0);
176 hint->SetDirectory(0);
178 for (
int i=2 ;
i<hsmooth->GetNbinsX() ;
i++ ) {
179 double gradient = std::fabs(0.5*(hint->GetBinContent(
i+1) - hint->GetBinContent(
i-1)));
191 const double sfac = 0.1;
195 for (
int i=1 ;
i<=hsmooth->GetNbinsX() ;
i++ ) {
198 int Nbins = 2*sfac*std::fabs(
i-img );
207 for (
int j=
i-Nbins ; j<=
i+Nbins ; j++ ) {
209 if ( j>hin->GetNbinsX() )
break;
210 sum += hin->GetBinContent(j);
214 if ( wsum>0 )
sum /= wsum;
218 hsmooth->SetBinContent(
i,
sum);
219 hsmooth->SetBinError(
i, 0 );
242 m_smooth = (TH1D*)
h->Clone( (std::string(
h->GetName())+
"-smooth").c_str() );
255 m_x.push_back(
m_s->GetBinLowEdge(1) );
258 for (
int i=1 ;
i<=
m_s->GetNbinsX() ;
i++ ) {
259 m_x.push_back(
m_s->GetBinLowEdge(
i+1) );
260 m_y.push_back(
m_s->GetBinContent(
i) );
269 for (
unsigned i=0 ;
i<
m_y.size()-1 ;
i++ ) {
303 : m_N(Nexperiments) {
314 std::cout <<
"mean " <<
h->GetMean() <<
" +- " <<
h->GetMeanError() <<
" (" <<
findMean(
h,0.95) <<
")"
315 <<
"\trms " <<
h->GetRMS() <<
" +- " <<
h->GetRMSError() <<
" (" <<
rms95(
h) <<
")"
316 <<
"\thistogram" << std::endl;
329 h->GetXaxis()->SetRange(1,
h->GetNbinsX());
337 int Nevents =
h->GetEffectiveEntries()+0.5;
341 if ( fevents!=0 )
Nevents = fevents;
364 fnscale = std::sqrt(
Nevents/_Nevents );
372 gStyle->SetOptStat(1111);
373 hmean =
new TH1D(
"mean",
"", 500, -0.001, 0.001);
374 hrms =
new TH1D(
"rms",
"", 500, 0.001, 0.01);
375 hmean->SetDirectory(0);
376 hrms->SetDirectory(0);
383 m_THrms =
new TH1D(
"rms95",
"", 50, 0.0006, 0.0009 );
386 for (
int j=0 ; j<
m_N ; j++ ) {
388 TH1D* h3 = (TH1D*)
h->Clone();
391 for (
int i=
Nevents ;
i-- ; ) h3->Fill(
g.generate() );
399 std::cout << j <<
"\texpt mean " << _mean95 <<
"\trms95 " << _rms95 << std::endl;
401 if ( std::string(
h->GetTitle()).find(
"[ 34.4747 - 42.1697 ]")!=std::string::npos ) {
403 std::cout <<
"mean " << h3->GetMean() <<
" +- " << h3->GetMeanError()
404 <<
" (" << _mean95 <<
") "
405 <<
"\trms " << h3->GetRMS() <<
" +- " << h3->GetRMSError()
406 <<
" (" << _rms95 <<
") "
407 <<
"\t pseudo data (" <<
Nevents <<
" events)"
415 mean.push_back( _mean95 );
416 rms.push_back( _rms95 );
426 if ( std::string(
h->GetTitle()).find(
"[ 34.4747 - 42.1697 ]")!=std::string::npos ) {
428 std::cout <<
"mean " <<
h->GetMean() <<
" +- " <<
h->GetMeanError() <<
" (" <<
findMean(
h,0.95) <<
")"
429 <<
"\trms " <<
h->GetRMS() <<
" +- " <<
h->GetRMSError() <<
" (" <<
rms95(
h) <<
")"
430 <<
"\thistogram" << std::endl;
435 <<
" after " << Nexperiments <<
" experiment" << ( Nexperiments==1 ?
"" :
"s" )
double Entries(TH1D *hin)
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
double m_global_mean
actual histogram rms95
double Gradient(TH1D *hin)
double m_global_rms_error
std::vector< double > m_dx
double rms95(TH1D *s, double mean)
get the fraction of the rms95 value with respect to the rms95 value of a gaussian
double get_mean(const std::vector< double > &m)
mean and rms
double m_hmean
rms from each experiment
std::vector< double > m_mean
number of experiments
TH1D * PDF(TH1D *hin)
generate a (normalised) pdf from a distribution
TH1D * smooth(TH1D *hin, bool sym)
smooth a distribution about the maximum NB: maximum is not smoothed
void ScaleIntegral(TH1D *hin)
scale a distribution by the integral
double m_hrms
actual histogram mean95
double get_rms(const std::vector< double > &m)
experiment(TH1D *h, int Nexperiments=10, int fevents=0)
given a distribution, gnerate some number of pseudo experiments to estimate the uncertainties in the ...
std::vector< double > m_dy
TH1D * integrate(TH1D *hin)
generate an integrated distribution
generate a distribution according to an input histogram (after smoothing)
std::vector< double > m_x
double m_global_mean_error
std::vector< double > m_rms
means from each experiment
std::vector< double > m_y
hist_generator(TH1D *h, bool _smooth=true)
double rmsFrac(TH1D *s, double frac, double mean)
base class for a "generator" class
double findMean(TH1D *s, double frac=0.95)
std::vector< double > m_dxdy