5 #include <boost/regex.hpp> 6 #include <boost/lexical_cast.hpp> 7 #include <boost/algorithm/string/erase.hpp> 9 #include <TGraphErrors.h> 17 const TH1*
const h = book[
name];
18 const TH1*
const reco = book[base+
"_reconstruction"];
19 const TH1*
const field = book[base+
"_field"];
21 if(reco) p.
reco = std::make_pair<float,float>( reco->GetMean(), reco->GetMeanError());
22 if(field) p.
field = field->GetMean();
25 const TF1*
const f = h->GetFunction(
"LA_profile_fit");
if(!f)
break;
26 p.
measured = std::make_pair<float,float>(f->GetParameter(0),f->GetParError(0));
27 p.
chi2 = f->GetChisquare();
29 p.
entries = (unsigned)(h->GetEntries());
33 const TF1*
const f = h->GetFunction(
"SymmetryFit");
if(!f)
break;
34 p.
measured = std::make_pair<float,float>( p.
reco.first + f->GetParameter(0), f->GetParameter(1) );
35 p.
chi2 = f->GetParameter(2);
36 p.
ndof = (unsigned) (f->GetParameter(3));
38 (m&
PROB1) ? (
unsigned) book[base+
"_w1"]->GetEntries() :
51 std::map<uint32_t,Result>
results;
53 const uint32_t detid = boost::lexical_cast<uint32_t>( boost::regex_replace( it->first,
54 boost::regex(
".*_module(\\d*)_.*"),
56 results[detid] =
result(m,it->first,book);
63 std::map<std::string,Result>
results;
73 std::map<std::string, std::vector<Result> >
results;
75 const std::string name = boost::regex_replace(it->first,boost::regex(
"sample\\d*_"),
"");
76 results[
name].push_back(
result(m,it->first,book));
83 typedef std::map<std::string, std::vector<Result> > results_t;
88 for(
auto const&
group : results) {
90 for(
auto const&
p :
group.second) {
94 book.
fill(
p.measured.second, name+
"_merr", 500, 0, 0.01);
95 book.
fill( (
p.measured.first-
p.reco.first)/
p.measured.second, name+
"_pull", 500, -10,10);
98 TF1 gaus(
"mygaus",
"gaus");
99 book[name+
"_measure"]->Fit(&gaus,
"LLQ");
100 book[name+
"_merr"]->Fit(&gaus,
"LLQ");
101 book[name+
"_pull"]->Fit(&gaus,
"LLQ");
105 std::map<std::string, std::vector<LA_Filler_Fitter::EnsembleSummary> >
LA_Filler_Fitter:: 107 std::map<std::string, std::vector<EnsembleSummary> >
summary;
109 const std::string base = boost::erase_all_copy(it->first,
"_ensembleReco");
111 const TH1*
const reco = it->second;
112 const TH1*
const measure = book[base+
"_measure"];
113 const TH1*
const merr = book[base+
"_merr"];
114 const TH1*
const pull = book[base+
"_pull"];
117 s.
samples = reco->GetEntries();
118 s.
truth = reco->GetMean();
119 s.
meanMeasured = std::make_pair<float,float>( measure->GetFunction(
"gaus")->GetParameter(1), measure->GetFunction(
"gaus")->GetParError(1) );
120 s.
sigmaMeasured = std::make_pair<float,float>( measure->GetFunction(
"gaus")->GetParameter(2), measure->GetFunction(
"gaus")->GetParError(2) );
121 s.
meanUncertainty = std::make_pair<float,float>( merr->GetFunction(
"gaus")->GetParameter(1), merr->GetFunction(
"gaus")->GetParError(1) );
122 s.
pull = std::make_pair<float,float>( pull->GetFunction(
"gaus")->GetParameter(2), pull->GetFunction(
"gaus")->GetParError(2) );
124 const std::string name = boost::regex_replace(base,boost::regex(
"ensembleBin\\d*_"),
"");
125 summary[
name].push_back(s);
131 offset_slope(
const std::vector<LA_Filler_Fitter::EnsembleSummary>& ensembles) {
133 std::vector<float>
x,
y,xerr,yerr;
134 for(
auto const& ensemble : ensembles) {
135 x.push_back(ensemble.truth);
137 y.push_back(ensemble.meanMeasured.first);
138 yerr.push_back(ensemble.meanMeasured.second);
140 TGraphErrors graph(x.size(),&(x[0]),&(y[0]),&(xerr[0]),&(yerr[0]));
142 TF1 pol1(
"mypol1",
"pol1");
144 const TF1*
const fit = graph.GetFunction(
"pol1");
146 return std::make_pair( std::make_pair(fit->GetParameter(0), fit->GetParError(0)),
147 std::make_pair(fit->GetParameter(1), fit->GetParError(1)) );
149 std::cerr <<
"Fitting Line Failed " << std::endl << e << std::endl;
150 return std::make_pair( std::make_pair(0,0), std::make_pair(0,0));
155 pull(
const std::vector<LA_Filler_Fitter::EnsembleSummary>& ensembles) {
157 for(
auto const& ensemble : ensembles) {
158 const float unc2 =
pow(ensemble.pull.second,2);
159 p+= ensemble.pull.first / unc2;
167 return strm << r.
reco.first <<
"\t"<< r.
reco.second <<
"\t" 177 return strm << e.
truth <<
"\t" 181 << 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)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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 &)
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 &)
iterator begin(string_t re=".*")
base
Make Sure CMSSW is Setup ##.
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
std::ostream & operator<<(std::ostream &strm, const LA_Filler_Fitter::Result &r)
const double ensembleLow_
Power< A, B >::type pow(const A &a, const B &b)
iterator end(string_t re=".*")