5 #include <boost/foreach.hpp>
6 #include <boost/regex.hpp>
7 #include <boost/lexical_cast.hpp>
8 #include <boost/algorithm/string/erase.hpp>
10 #include <TGraphErrors.h>
18 const TH1*
const h = book[
name];
19 const TH1*
const reco = book[base+
"_reconstruction"];
20 const TH1*
const field = book[base+
"_field"];
22 if(reco) p.
reco = std::make_pair<float,float>( reco->GetMean(), reco->GetMeanError());
23 if(field) p.
field = field->GetMean();
26 const TF1*
const f = h->GetFunction(
"LA_profile_fit");
if(!f)
break;
27 p.
measured = std::make_pair<float,float>(f->GetParameter(0),f->GetParError(0));
28 p.
chi2 = f->GetChisquare();
30 p.
entries = (unsigned)(h->GetEntries());
34 const TF1*
const f = h->GetFunction(
"SymmetryFit");
if(!f)
break;
35 p.
measured = std::make_pair<float,float>( p.
reco.first + f->GetParameter(0), f->GetParameter(1) );
36 p.
chi2 = f->GetParameter(2);
37 p.
ndof = (unsigned) (f->GetParameter(3));
39 (m&
PROB1) ? (
unsigned) book[base+
"_w1"]->GetEntries() :
52 std::map<uint32_t,Result>
results;
54 const uint32_t
detid = boost::lexical_cast<uint32_t>( boost::regex_replace( it->first,
55 boost::regex(
".*_module(\\d*)_.*"),
64 std::map<std::string,Result>
results;
74 std::map<std::string, std::vector<Result> >
results;
76 const std::string name = boost::regex_replace(it->first,boost::regex(
"sample\\d*_"),
"");
77 results[
name].push_back(
result(m,it->first,book));
84 typedef std::map<std::string, std::vector<Result> > results_t;
91 BOOST_FOREACH(
const Result p, group.second) {
95 book.
fill( p.
measured.second, name+
"_merr", 500, 0, 0.01);
99 TF1 gaus(
"mygaus",
"gaus");
100 book[name+
"_measure"]->Fit(&gaus,
"LLQ");
101 book[name+
"_merr"]->Fit(&gaus,
"LLQ");
102 book[name+
"_pull"]->Fit(&gaus,
"LLQ");
106 std::map<std::string, std::vector<LA_Filler_Fitter::EnsembleSummary> >
LA_Filler_Fitter::
108 std::map<std::string, std::vector<EnsembleSummary> >
summary;
110 const std::string base = boost::erase_all_copy(it->first,
"_ensembleReco");
112 const TH1*
const reco = it->second;
113 const TH1*
const measure = book[base+
"_measure"];
114 const TH1*
const merr = book[base+
"_merr"];
115 const TH1*
const pull = book[base+
"_pull"];
118 s.
samples = reco->GetEntries();
119 s.
truth = reco->GetMean();
120 s.
meanMeasured = std::make_pair<float,float>( measure->GetFunction(
"gaus")->GetParameter(1), measure->GetFunction(
"gaus")->GetParError(1) );
121 s.
sigmaMeasured = std::make_pair<float,float>( measure->GetFunction(
"gaus")->GetParameter(2), measure->GetFunction(
"gaus")->GetParError(2) );
122 s.
meanUncertainty = std::make_pair<float,float>( merr->GetFunction(
"gaus")->GetParameter(1), merr->GetFunction(
"gaus")->GetParError(1) );
123 s.
pull = std::make_pair<float,float>( pull->GetFunction(
"gaus")->GetParameter(2), pull->GetFunction(
"gaus")->GetParError(2) );
125 const std::string name = boost::regex_replace(base,boost::regex(
"ensembleBin\\d*_"),
"");
126 summary[
name].push_back(s);
132 offset_slope(
const std::vector<LA_Filler_Fitter::EnsembleSummary>& ensembles) {
134 std::vector<float>
x,
y,xerr,yerr;
136 x.push_back(ensemble.
truth);
141 TGraphErrors
graph(x.size(),&(x[0]),&(y[0]),&(xerr[0]),&(yerr[0]));
143 TF1 pol1(
"mypol1",
"pol1");
145 const TF1*
const fit =
graph.GetFunction(
"pol1");
147 return std::make_pair( std::make_pair(fit->GetParameter(0), fit->GetParError(0)),
148 std::make_pair(fit->GetParameter(1), fit->GetParError(1)) );
150 std::cerr <<
"Fitting Line Failed " << std::endl << e << std::endl;
151 return std::make_pair( std::make_pair(0,0), std::make_pair(0,0));
156 pull(
const std::vector<LA_Filler_Fitter::EnsembleSummary>& ensembles) {
159 const float unc2 =
pow(ensemble.
pull.second,2);
160 p+= ensemble.
pull.first / unc2;
168 return strm << r.
reco.first <<
"\t"<< r.
reco.second <<
"\t"
178 return strm << e.
truth <<
"\t"
182 << e.
pull.first <<
"\t"<< e.
pull.second <<
"\t"
std::pair< float, float > pull
static std::map< std::string, Result > layer_results(const Book &, const Method)
static void fit(Book &book)
std::pair< float, float > meanMeasured
std::pair< float, float > sigmaMeasured
static std::pair< std::pair< float, float >, std::pair< float, float > > offset_slope(const std::vector< EnsembleSummary > &)
static std::map< std::string, std::vector< EnsembleSummary > > ensemble_summary(const Book &)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
std::pair< float, float > measured
void summarize_ensembles(Book &) const
static Result result(Method, const std::string name, const Book &)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
iterator begin(string_t re=".*")
Container::value_type value_type
static std::string method(Method m, bool fit=true)
static std::map< std::string, std::vector< Result > > ensemble_results(const Book &, const Method)
void fill(double_t X, const char *name, uint_t NbinsX, double_t Xlow, double_t Xup, double_t W=1)
static std::map< uint32_t, Result > module_results(const Book &, const Method)
std::pair< float, float > meanUncertainty
boost::filter_iterator< match_name, book_t::const_iterator > const_iterator
std::pair< float, float > reco
static float pull(const std::vector< EnsembleSummary > &)
std::pair< float, float > calMeasured
const double ensembleLow_
Power< A, B >::type pow(const A &a, const B &b)
iterator end(string_t re=".*")