15 #include <TDirectory.h>
26 template <
typename hist_t>
28 hist->GetXaxis()->SetTitleSize(0.04);
29 hist->GetYaxis()->SetTitleSize(0.04);
30 hist->GetXaxis()->SetLabelSize(0.04);
31 hist->GetYaxis()->SetLabelSize(0.04);
32 hist->GetXaxis()->SetTitleOffset(1.0);
33 hist->GetYaxis()->SetTitleOffset(1.0);
34 hist->GetXaxis()->SetNdivisions(505);
35 hist->SetMarkerStyle(20);
36 hist->SetMarkerSize(0.8);
37 hist->SetLineWidth(2);
39 hist->SetLineColor(
color);
40 hist->SetMarkerColor(
color);
50 template <
typename eff_t>
52 eff->SetMarkerStyle(20);
53 eff->SetMarkerSize(0.8);
55 eff->SetLineColor(
color);
56 eff->SetMarkerColor(
color);
69 template <
typename hist_t>
71 float rwindow,
int n) {
73 float rel_good = (rgood - rmin) / (rmax - rmin);
74 float rel_window = rwindow / (rmax - rmin);
78 double red[number] = {0., 0., 0., 1., 1.};
79 double green[number] = {0., 1., 1., 1., 0.};
80 double blue[number] = {1., 1., 0., 0., 0.};
81 double stops[number] = {0., rel_good - rel_window, rel_good,
82 rel_good + rel_window, 1.};
85 TColor::CreateGradientColorTable(number, stops, red, green, blue, n);
97 template <
typename eff_t>
98 void adaptEffRange(eff_t* eff,
float minScale = 1,
float maxScale = 1.1) {
100 auto ymin = gPad->GetUymin();
101 auto ymax = gPad->GetUymax();
102 auto graph = eff->GetPaintedGraph();
132 std::array<float, 2>
range = {0., 0.};
136 std::function<float(ULong64_t)>
value;
139 std::function<float(ULong64_t)>
error;
182 std::array<float, 2>
range = {0., 0.};
186 std::function<float(ULong64_t)>
value;
209 std::function<bool(ULong64_t)>
one;
211 std::function<bool(ULong64_t)>
two;
227 std::vector<float>*
value =
nullptr;
229 std::array<float, 2>
range = {0., 0.};
234 if (
value !=
nullptr) {
235 float v =
value->at(entry);
246 template <
typename primitive_t>
248 std::vector<primitive_t>*
value =
nullptr;
255 primitive_t
v =
value->at(entry);
258 return std::numeric_limits<primitive_t>::max();
263 template <
typename primitive_one_t,
typename primitive_two_t>
265 std::vector<primitive_one_t>*
one =
nullptr;
267 std::vector<primitive_two_t>*
two =
nullptr;
274 primitive_one_t vo =
one->at(entry);
275 primitive_two_t vt = two->at(entry);
278 return std::numeric_limits<primitive_one_t>::max();
284 std::vector<float>*
value =
nullptr;
293 float v =
value->at(entry);
297 return std::numeric_limits<float>::infinity();
318 return (v - q_true / p_true);
320 return std::numeric_limits<float>::infinity();
338 float p = 1. / std::abs(
qop_value->at(entry));
341 return (p * sin(theta) - pt_true);
343 return std::numeric_limits<float>::infinity();
365 return std::cos(theta_v) / qop_v * theta_e -
366 std::sin(theta_v) / (qop_v * qop_v) * qop_e;
368 return std::numeric_limits<float>::infinity();
382 template <
typename dir_t,
typename tree_t>
384 tree_t&
tree,
unsigned long peakEntries,
385 unsigned int hBarcode) {
391 TString rangeHN =
"hrg_";
394 rangeHist += rangeHN;
398 tree.Draw(rangeHist.Data(), handle.
rangeCutStr.c_str(),
"", peakEntries);
399 handle.
rangeHist =
dynamic_cast<TH1F*
>(gDirectory->Get(rangeHN.Data()));
416 template <
typename dir_t,
typename tree_t>
418 unsigned long peakEntries,
unsigned int startBins,
419 unsigned int addBins,
unsigned int hBarcode) {
425 TString rangeHN =
"hrg_";
428 rangeHist += rangeHN;
430 rangeHist += startBins;
431 rangeHist +=
",-0.5,";
432 rangeHist +=
static_cast<float>(startBins - 0.5);
435 unsigned int nBins = startBins;
437 tree.Draw(rangeHist.Data(),
"",
"", peakEntries);
438 auto rhist =
dynamic_cast<TH1F*
>(gDirectory->Get(rangeHN.Data()));
439 if (rhist !=
nullptr) {
440 for (
unsigned int ib = 1;
ib <= startBins; ++
ib) {
441 if (rhist->GetBinContent(
ib) > 0.) {
445 handle.
bins = (nBins + addBins);
446 handle.
range = {-0.5,
static_cast<float>(handle.
bins - 0.5)};
449 handle.
bins = (startBins);
450 handle.
range = {-0.5,
static_cast<float>(handle.
bins - 0.5)};
460 unsigned int hBins,
unsigned int hBarcode) {
465 new TH1F(rName.Data(), handle.
tag.c_str(), hBins,
466 pullRange * handle.
range[0], pullRange * handle.
range[1]);
469 handle.
residualHist->GetXaxis()->SetTitle(xAxisTitle.c_str());
476 new TH1F(pName.Data(), (
std::string(
"pull ") + handle.
tag).c_str(), hBins,
477 -pullRange, pullRange);
480 handle.
pullHist->GetXaxis()->SetTitle(xAxisTitle.c_str());
481 handle.
pullHist->GetYaxis()->SetTitle(
"Entries");
492 template <
typename tree_t>
494 unsigned long configuredEntries) {
495 unsigned long entries =
static_cast<unsigned long>(tree.GetEntries());
496 if (configuredEntries > 0 and configuredEntries < entries) {
497 entries = configuredEntries;