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));
48 ? (
unsigned)book[
base +
"_w1"]->GetEntries()
62 std::map<uint32_t, Result>
results;
64 const uint32_t detid = boost::lexical_cast<uint32_t>(
65 std::regex_replace(it->first, std::regex(
".*_module(\\d*)_.*"),
std::string(
"\\1")));
72 std::map<std::string, Result>
results;
82 std::map<std::string, std::vector<Result> >
results;
84 const std::string name = std::regex_replace(it->first, std::regex(
"sample\\d*_"),
"");
91 typedef std::map<std::string, std::vector<Result> > results_t;
101 for (
auto const&
p :
group.second) {
105 book.
fill(
p.measured.second,
name +
"_merr", 500, 0, 0.01);
106 book.
fill((
p.measured.first -
p.reco.first) /
p.measured.second,
name +
"_pull", 500, -10, 10);
109 TF1 gaus(
"mygaus",
"gaus");
110 book[
name +
"_measure"]->Fit(&gaus,
"LLQ");
111 book[
name +
"_merr"]->Fit(&gaus,
"LLQ");
112 book[
name +
"_pull"]->Fit(&gaus,
"LLQ");
118 std::map<std::string, std::vector<EnsembleSummary> >
summary;
120 const std::string base = boost::erase_all_copy(it->first,
"_ensembleReco");
122 const TH1*
const reco = it->second;
123 const TH1*
const measure = book[
base +
"_measure"];
124 const TH1*
const merr = book[
base +
"_merr"];
125 const TH1*
const pull = book[
base +
"_pull"];
128 s.samples =
reco->GetEntries();
129 s.truth =
reco->GetMean();
130 s.meanMeasured = std::make_pair<float, float>(measure->GetFunction(
"gaus")->GetParameter(1),
131 measure->GetFunction(
"gaus")->GetParError(1));
132 s.sigmaMeasured = std::make_pair<float, float>(measure->GetFunction(
"gaus")->GetParameter(2),
133 measure->GetFunction(
"gaus")->GetParError(2));
134 s.meanUncertainty = std::make_pair<float, float>(merr->GetFunction(
"gaus")->GetParameter(1),
135 merr->GetFunction(
"gaus")->GetParError(1));
136 s.pull = std::make_pair<float, float>(
pull->GetFunction(
"gaus")->GetParameter(2),
137 pull->GetFunction(
"gaus")->GetParError(2));
146 const std::vector<LA_Filler_Fitter::EnsembleSummary>& ensembles) {
148 std::vector<float>
x,
y, xerr, yerr;
149 for (
auto const& ensemble : ensembles) {
150 x.push_back(ensemble.truth);
152 y.push_back(ensemble.meanMeasured.first);
153 yerr.push_back(ensemble.meanMeasured.second);
155 TGraphErrors graph(
x.size(), &(
x[0]), &(
y[0]), &(xerr[0]), &(yerr[0]));
157 TF1 pol1(
"mypol1",
"pol1");
159 const TF1*
const fit = graph.GetFunction(
"pol1");
161 return std::make_pair(std::make_pair(
fit->GetParameter(0),
fit->GetParError(0)),
162 std::make_pair(
fit->GetParameter(1),
fit->GetParError(1)));
164 std::cerr <<
"Fitting Line Failed " << std::endl <<
e << std::endl;
165 return std::make_pair(std::make_pair(0, 0), std::make_pair(0, 0));
171 for (
auto const& ensemble : ensembles) {
172 const float unc2 =
pow(ensemble.pull.second, 2);
173 p += ensemble.pull.first / unc2;
180 return strm <<
r.reco.first <<
"\t" <<
r.reco.second <<
"\t" <<
r.measured.first <<
"\t" <<
r.measured.second <<
"\t"
181 <<
r.calMeasured.first <<
"\t" <<
r.calMeasured.second <<
"\t" <<
r.field <<
"\t" <<
r.chi2 <<
"\t"
182 <<
r.ndof <<
"\t" <<
r.entries;
186 return strm <<
e.truth <<
"\t" <<
e.meanMeasured.first <<
"\t" <<
e.meanMeasured.second <<
"\t"
187 <<
e.sigmaMeasured.first <<
"\t" <<
e.sigmaMeasured.second <<
"\t" <<
e.meanUncertainty.first <<
"\t"
188 <<
e.meanUncertainty.second <<
"\t" <<
e.pull.first <<
"\t" <<
e.pull.second <<
"\t" <<
e.samples;