given a histogram, get a generator for the distribution in that histogram, then run some pseudo-experiments and collect the mean and rms
More...
#include <generate.h>
given a histogram, get a generator for the distribution in that histogram, then run some pseudo-experiments and collect the mean and rms
Definition at line 132 of file generate.h.
◆ experiment() [1/2]
generate::experiment::experiment |
( |
TH1D * |
h, |
|
|
int |
Nexperiments = 10 , |
|
|
int |
fevents = 0 |
|
) |
| |
given a distribution, gnerate some number of pseudo experiments to estimate the uncertainties in the mean and rms more appropriately (root errors assume a gaussian approximation)
NB: Here we need to keep track of the number of events in the histogram. To correctly estimate the uncertainty on the rms, we should use the same number of entries N, for each pseudo-experiment but this can be computaionally very expensive and time consuming, so we generate in this case with fewer events, n, and estimate the uncertainty by scaling by sqrt( n/N )
std::cout << "generate() " << h->GetName() << " requested " << Nevents << " using default max of " << Nevent_max << std::endl;
set the correct error scaling to the correct number of events
loop over the pseudo experiments
Definition at line 302 of file generate.cxx.
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());
331 m_gen =
new hist_generator(
h );
332 generator_base&
g = *
m_gen;
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" )
◆ experiment() [2/2]
◆ gen()
◆ hmean()
double generate::experiment::hmean |
( |
| ) |
const |
|
inline |
◆ hrms()
double generate::experiment::hrms |
( |
| ) |
const |
|
inline |
◆ mean()
double generate::experiment::mean |
( |
| ) |
const |
|
inline |
◆ mean_error()
double generate::experiment::mean_error |
( |
| ) |
const |
|
inline |
◆ operator=()
◆ rms()
double generate::experiment::rms |
( |
| ) |
const |
|
inline |
◆ rms_error()
double generate::experiment::rms_error |
( |
| ) |
const |
|
inline |
◆ rmshisto()
TH1D* generate::experiment::rmshisto |
( |
| ) |
|
|
inline |
◆ m_gen
◆ m_global_mean
double generate::experiment::m_global_mean |
|
private |
actual histogram rms95
overall mean and rms from the pseudo experiments
Definition at line 164 of file generate.h.
◆ m_global_mean_error
double generate::experiment::m_global_mean_error |
|
private |
◆ m_global_rms
double generate::experiment::m_global_rms |
|
private |
◆ m_global_rms_error
double generate::experiment::m_global_rms_error |
|
private |
◆ m_hmean
double generate::experiment::m_hmean |
|
private |
rms from each experiment
Definition at line 160 of file generate.h.
◆ m_hrms
double generate::experiment::m_hrms |
|
private |
actual histogram mean95
Definition at line 161 of file generate.h.
◆ m_mean
std::vector<double> generate::experiment::m_mean |
|
private |
◆ m_N
int generate::experiment::m_N |
|
private |
◆ m_rms
std::vector<double> generate::experiment::m_rms |
|
private |
means from each experiment
Definition at line 158 of file generate.h.
◆ m_THrms
TH1D* generate::experiment::m_THrms |
|
private |
The documentation for this class was generated from the following files: