6 #include <boost/lexical_cast.hpp>
7 #include <boost/algorithm/string/erase.hpp>
9 #include <TGraphErrors.h>
16 const TH1*
const h = book[
name];
17 const TH1*
const reco = book[
base +
"_reconstruction"];
18 const TH1*
const field = book[
base +
"_field"];
21 p.reco = std::make_pair<float, float>(
reco->GetMean(),
reco->GetMeanError());
23 p.field = field->GetMean();
27 const TF1*
const f =
h->GetFunction(
"LA_profile_fit");
30 p.measured = std::make_pair<float, float>(
f->GetParameter(0),
f->GetParError(0));
31 p.chi2 =
f->GetChisquare();
33 p.entries = (unsigned)(
h->GetEntries());
41 const TF1*
const f =
h->GetFunction(
"SymmetryFit");
44 p.measured = std::make_pair<float, float>(
p.reco.first +
f->GetParameter(0),
f->GetParameter(1));
45 p.chi2 =
f->GetParameter(2);
46 p.ndof = (unsigned)(
f->GetParameter(3));
47 p.entries = (
m &
PROB1) ? (
unsigned)book[
base +
"_w1"]->GetEntries()
61 std::map<uint32_t, Result>
results;
63 const uint32_t detid = boost::lexical_cast<uint32_t>(
64 std::regex_replace(it->first, std::regex(
".*_module(\\d*)_.*"),
std::string(
"\\1")));
71 std::map<std::string, Result>
results;
81 std::map<std::string, std::vector<Result> >
results;
83 const std::string name = std::regex_replace(it->first, std::regex(
"sample\\d*_"),
"");
90 typedef std::map<std::string, std::vector<Result> > results_t;
100 for (
auto const&
p :
group.second) {
104 book.
fill(
p.measured.second,
name +
"_merr", 500, 0, 0.01);
105 book.
fill((
p.measured.first -
p.reco.first) /
p.measured.second,
name +
"_pull", 500, -10, 10);
108 TF1 gaus(
"mygaus",
"gaus");
109 book[
name +
"_measure"]->Fit(&gaus,
"LLQ");
110 book[
name +
"_merr"]->Fit(&gaus,
"LLQ");
111 book[
name +
"_pull"]->Fit(&gaus,
"LLQ");
117 std::map<std::string, std::vector<EnsembleSummary> >
summary;
119 const std::string base = boost::erase_all_copy(it->first,
"_ensembleReco");
121 const TH1*
const reco = it->second;
122 const TH1*
const measure = book[
base +
"_measure"];
123 const TH1*
const merr = book[
base +
"_merr"];
124 const TH1*
const pull = book[
base +
"_pull"];
127 s.samples =
reco->GetEntries();
128 s.truth =
reco->GetMean();
129 s.meanMeasured = std::make_pair<float, float>(measure->GetFunction(
"gaus")->GetParameter(1),
130 measure->GetFunction(
"gaus")->GetParError(1));
131 s.sigmaMeasured = std::make_pair<float, float>(measure->GetFunction(
"gaus")->GetParameter(2),
132 measure->GetFunction(
"gaus")->GetParError(2));
133 s.meanUncertainty = std::make_pair<float, float>(merr->GetFunction(
"gaus")->GetParameter(1),
134 merr->GetFunction(
"gaus")->GetParError(1));
135 s.pull = std::make_pair<float, float>(
pull->GetFunction(
"gaus")->GetParameter(2),
136 pull->GetFunction(
"gaus")->GetParError(2));
145 const std::vector<LA_Filler_Fitter::EnsembleSummary>& ensembles) {
147 std::vector<float>
x,
y, xerr, yerr;
148 for (
auto const& ensemble : ensembles) {
149 x.push_back(ensemble.truth);
151 y.push_back(ensemble.meanMeasured.first);
152 yerr.push_back(ensemble.meanMeasured.second);
154 TGraphErrors graph(
x.size(), &(
x[0]), &(
y[0]), &(xerr[0]), &(yerr[0]));
156 TF1 pol1(
"mypol1",
"pol1");
158 const TF1*
const fit = graph.GetFunction(
"pol1");
160 return std::make_pair(std::make_pair(
fit->GetParameter(0),
fit->GetParError(0)),
161 std::make_pair(
fit->GetParameter(1),
fit->GetParError(1)));
163 std::cerr <<
"Fitting Line Failed " << std::endl <<
e << std::endl;
164 return std::make_pair(std::make_pair(0, 0), std::make_pair(0, 0));
170 for (
auto const& ensemble : ensembles) {
171 const float unc2 =
pow(ensemble.pull.second, 2);
172 p += ensemble.pull.first / unc2;
179 return strm <<
r.reco.first <<
"\t" <<
r.reco.second <<
"\t" <<
r.measured.first <<
"\t" <<
r.measured.second <<
"\t"
180 <<
r.calMeasured.first <<
"\t" <<
r.calMeasured.second <<
"\t" <<
r.field <<
"\t" <<
r.chi2 <<
"\t"
181 <<
r.ndof <<
"\t" <<
r.entries;
185 return strm <<
e.truth <<
"\t" <<
e.meanMeasured.first <<
"\t" <<
e.meanMeasured.second <<
"\t"
186 <<
e.sigmaMeasured.first <<
"\t" <<
e.sigmaMeasured.second <<
"\t" <<
e.meanUncertainty.first <<
"\t"
187 <<
e.meanUncertainty.second <<
"\t" <<
e.pull.first <<
"\t" <<
e.pull.second <<
"\t" <<
e.samples;