4 #include <TPaveStats.h>
18 file0_ =
new TFile(file0);
19 if (file0_->IsZombie())
21 dir0_ = file0_->GetDirectory(dir0);
25 file1_ =
new TFile(file1);
26 if (file1_->IsZombie())
28 dir1_ = file1_->GetDirectory(dir1);
38 legend_.AddEntry(s0_, leg0,
"mlf");
39 legend_.AddEntry(s1_, leg1,
"mlf");
46 out0 <<
"h0_2d_" <<
num;
48 out1 <<
"h1_2d_" <<
num;
51 string name0 = out0.str();
52 string name1 = out1.str();
54 TH1 *h0 = Histo(key, 0);
55 TH1 *h1 = Histo(key, 1);
57 TH2 *h0_2d =
dynamic_cast<TH2 *
>(h0);
58 TH2 *h1_2d =
dynamic_cast<TH2 *
>(h1);
60 if (h0_2d->GetNbinsY() == 1 || h1_2d->GetNbinsY() == 1) {
61 cerr << key <<
" is not 2D" << endl;
65 TH1::AddDirectory(
false);
67 TH1D *h0_slice = h0_2d->ProjectionY(name0.c_str(), binxmin, binxmax,
"");
68 TH1D *h1_slice = h1_2d->ProjectionY(name1.c_str(), binxmin, binxmax,
"");
69 TH1::AddDirectory(
true);
70 Draw(h0_slice, h1_slice, mode);
74 TDirectory *
dir = dir1_;
76 TH2D *h2 = (TH2D *)dir->Get(key);
82 TH2D *h2b = (TH2D *)dir->Get(key);
90 TDirectory *
dir = dir1_;
92 TH2D *h2 = (TH2D *)dir->Get(key);
94 TH1D *ha = TH2Ana.
RMS();
98 TH2D *h2b = (TH2D *)dir->Get(key);
100 TH1D *
hb = TH2Anab.
RMS();
106 TDirectory *
dir = dir1_;
108 TH2D *h2 = (TH2D *)dir->Get(key);
114 TH2D *h2b = (TH2D *)dir->Get(key);
122 const Double_t
value =
123 sqrt(par[0] * par[0] + par[1] * par[1] * (x[0] - par[3]) + par[2] * par[2] * (x[0] - par[3]) * (x[0] - par[3])) /
129 const char *
key,
const int rebinFactor,
const int binxmin,
const int binxmax,
const bool cst_binning,
Mode mode) {
130 TDirectory *
dir = dir1_;
132 TH2D *h2 = (TH2D *)dir->Get(key);
133 TH2Analyzer TH2Ana(h2, binxmin, binxmax, rebinFactor, cst_binning);
134 TH1D *hrms = TH2Ana.
RMS();
135 TF1 *fitfcndgssrms3 =
new TF1(
"fitfcndgssrms3",
137 hrms->GetXaxis()->GetBinLowEdge(1),
138 hrms->GetXaxis()->GetBinUpEdge(hrms->GetNbinsX()),
140 fitfcndgssrms3->SetNpx(500);
141 fitfcndgssrms3->SetLineWidth(3);
142 fitfcndgssrms3->SetLineStyle(2);
143 fitfcndgssrms3->SetLineColor(4);
144 hrms->Fit(fitfcndgssrms3,
"0R");
147 TF1 *fitfcndgsse3 =
new TF1(
"fitfcndgsse3",
149 hrms->GetXaxis()->GetBinLowEdge(1),
150 hrms->GetXaxis()->GetBinUpEdge(hrms->GetNbinsX()),
152 fitfcndgsse3->SetNpx(500);
153 fitfcndgsse3->SetLineWidth(3);
154 fitfcndgsse3->SetLineStyle(1);
155 fitfcndgsse3->SetLineColor(4);
156 ha->Fit(fitfcndgsse3,
"0R");
160 TH2D *h2b = (TH2D *)dir->Get(key);
161 TH2Analyzer TH2Anab(h2b, binxmin, binxmax, rebinFactor, cst_binning);
162 TH1D *hrmsb = TH2Anab.
RMS();
163 TF1 *fitfcndgssrmsb3 =
new TF1(
"fitfcndgssrmsb3",
165 hrms->GetXaxis()->GetBinLowEdge(1),
166 hrms->GetXaxis()->GetBinUpEdge(hrms->GetNbinsX()),
168 fitfcndgssrmsb3->SetNpx(500);
169 fitfcndgssrmsb3->SetLineWidth(3);
170 fitfcndgssrmsb3->SetLineStyle(2);
171 fitfcndgssrmsb3->SetLineColor(2);
172 hrmsb->Fit(fitfcndgssrmsb3,
"0R");
175 TF1 *fitfcndgsseb3 =
new TF1(
"fitfcndgsseb3",
177 hrms->GetXaxis()->GetBinLowEdge(1),
178 hrms->GetXaxis()->GetBinUpEdge(hrms->GetNbinsX()),
180 fitfcndgsseb3->SetNpx(500);
181 fitfcndgsseb3->SetLineWidth(3);
182 fitfcndgsseb3->SetLineStyle(1);
183 fitfcndgsseb3->SetLineColor(2);
184 hb->Fit(fitfcndgsseb3,
"0R");
189 fitfcndgssrms3->Draw(
"same");
190 fitfcndgsse3->Draw(
"same");
191 fitfcndgssrmsb3->Draw(
"same");
192 fitfcndgsseb3->Draw(
"same");
196 const char *
key,
const int rebinFactor,
const int binxmin,
const int binxmax,
const bool cst_binning,
Mode mode) {
197 TDirectory *
dir = dir1_;
199 TH2D *h2 = (TH2D *)dir->Get(key);
200 TH2Analyzer TH2Ana(h2, binxmin, binxmax, rebinFactor, cst_binning);
201 TH1D *hrms = TH2Ana.
RMS();
203 TH1D *meanXslice = TH2Ana.
MeanX();
211 hrms->Divide(meanXslice);
213 TF1 *fitXfcndgssrms3 =
new TF1(
"fitXfcndgssrms3",
215 hrms->GetXaxis()->GetBinLowEdge(1),
216 hrms->GetXaxis()->GetBinUpEdge(hrms->GetNbinsX()),
218 fitXfcndgssrms3->SetNpx(500);
219 fitXfcndgssrms3->SetLineWidth(3);
220 fitXfcndgssrms3->SetLineStyle(2);
221 fitXfcndgssrms3->SetLineColor(4);
222 hrms->Fit(fitXfcndgssrms3,
"0R");
225 ha->Divide(meanXslice);
226 TF1 *fitXfcndgsse3 =
new TF1(
"fitXfcndgsse3",
228 ha->GetXaxis()->GetBinLowEdge(1),
229 ha->GetXaxis()->GetBinUpEdge(ha->GetNbinsX()),
231 fitXfcndgsse3->SetNpx(500);
232 fitXfcndgsse3->SetLineWidth(3);
233 fitXfcndgsse3->SetLineStyle(1);
234 fitXfcndgsse3->SetLineColor(4);
235 ha->Fit(fitXfcndgsse3,
"0R");
239 TH2D *h2b = (TH2D *)dir->Get(key);
240 TH2Analyzer TH2Anab(h2b, binxmin, binxmax, rebinFactor, cst_binning);
241 TH1D *hrmsb = TH2Anab.
RMS();
242 hrmsb->Divide(meanXslice);
243 TF1 *fitXfcndgssrmsb3 =
new TF1(
"fitXfcndgssrmsb3",
245 hrmsb->GetXaxis()->GetBinLowEdge(1),
246 hrmsb->GetXaxis()->GetBinUpEdge(hrmsb->GetNbinsX()),
248 fitXfcndgssrmsb3->SetNpx(500);
249 fitXfcndgssrmsb3->SetLineWidth(3);
250 fitXfcndgssrmsb3->SetLineStyle(2);
251 fitXfcndgssrmsb3->SetLineColor(2);
252 hrmsb->Fit(fitXfcndgssrmsb3,
"0R");
255 hb->Divide(meanXslice);
256 TF1 *fitXfcndgsseb3 =
new TF1(
"fitXfcndgsseb3",
258 hb->GetXaxis()->GetBinLowEdge(1),
259 hb->GetXaxis()->GetBinUpEdge(hb->GetNbinsX()),
261 fitXfcndgsseb3->SetNpx(500);
262 fitXfcndgsseb3->SetLineWidth(3);
263 fitXfcndgsseb3->SetLineStyle(1);
264 fitXfcndgsseb3->SetLineColor(2);
265 hb->Fit(fitXfcndgsseb3,
"0R");
270 fitXfcndgssrms3->Draw(
"same");
271 fitXfcndgsse3->Draw(
"same");
272 fitXfcndgssrmsb3->Draw(
"same");
273 fitXfcndgsseb3->Draw(
"same");
277 TDirectory *
dir = dir1_;
280 TH2D *h2_b = (TH2D *)dir->Get(key2);
282 TH1D *meanslice = TH2Ana_b.
Average();
284 TH2D *h2 = (TH2D *)dir->Get(key);
288 ha->Divide(meanslice);
292 TH2D *h2b = (TH2D *)dir->Get(key);
295 TH2D *h2b_b = (TH2D *)dir->Get(key2);
297 TH1D *meansliceb = TH2Anab_b.
Average();
300 hb->Divide(meansliceb);
307 TH1::AddDirectory(
false);
308 TH1 *h0 = Histo(key, 0);
309 TH1 *h1 = (TH1 *)Histo(key, 1)->Clone(
"h1");
311 TH1::AddDirectory(
true);
323 TH1 *h0b = Histo(key1, 0);
325 TH1 *h1b = Histo(key1, 1);
333 h0->GetXaxis()->SetRangeUser(xMin_, xMax_);
334 h1->GetXaxis()->SetRangeUser(xMin_, xMax_);
335 h0b->GetXaxis()->SetRangeUser(xMin_, xMax_);
336 h1b->GetXaxis()->SetRangeUser(xMin_, xMax_);
341 h0->Divide(h0, h0b, 1., 1.,
"B");
344 h1->Divide(h1, h1b, 1., 1.,
"B");
351 cerr <<
"bad dir index: " << dirIndex << endl;
354 TDirectory *
dir =
nullptr;
363 TH1 *
h = (TH1 *)dir->Get(key);
365 cerr <<
"no key " << key <<
" in directory " << dir->GetName() << endl;
371 cerr <<
"invalid histo" << endl;
375 TH1::AddDirectory(
false);
376 h0_ = (TH1 *)h0->Clone(
"h0_");
377 h1_ = (TH1 *)h1->Clone(
"h1_");
378 TH1::AddDirectory(
true);
395 h0_->GetXaxis()->SetRangeUser(xMin_, xMax_);
396 h1_->GetXaxis()->SetRangeUser(xMin_, xMax_);
401 TPaveStats *ptstats =
new TPaveStats(0.7385057, 0.720339, 0.9396552, 0.8792373,
"brNDC");
402 ptstats->SetName(
"stats");
403 ptstats->SetBorderSize(1);
404 ptstats->SetLineColor(2);
405 ptstats->SetFillColor(10);
406 ptstats->SetTextAlign(12);
407 ptstats->SetTextColor(2);
408 ptstats->SetOptStat(1111);
409 ptstats->SetOptFit(0);
411 h0_->GetListOfFunctions()->Add(ptstats);
412 ptstats->SetParent(h0_->GetListOfFunctions());
419 TPaveStats *ptstats2 =
new TPaveStats(0.7399425, 0.529661, 0.941092, 0.6885593,
"brNDC");
420 ptstats2->SetName(
"stats");
421 ptstats2->SetBorderSize(1);
422 ptstats2->SetLineColor(4);
423 ptstats2->SetFillColor(10);
424 ptstats2->SetTextAlign(12);
425 ptstats2->SetTextColor(4);
426 TText *
text = ptstats2->AddText(
"h1_");
427 text->SetTextSize(0.03654661);
429 std::ostringstream oss3;
430 oss3 << h1_->GetEntries();
431 const std::string txt_entries =
"Entries = " + oss3.str();
432 text = ptstats2->AddText(txt_entries.c_str());
433 std::ostringstream oss;
434 oss << h1_->GetMean();
435 const std::string txt_mean =
"Mean = " + oss.str();
436 text = ptstats2->AddText(txt_mean.c_str());
437 std::ostringstream oss2;
438 oss2 << h1_->GetRMS();
440 text = ptstats2->AddText(txt_rms.c_str());
441 ptstats2->SetOptStat(1111);
442 ptstats2->SetOptFit(0);
444 h1_->GetListOfFunctions()->Add(ptstats2);
445 ptstats2->SetParent(h1_->GetListOfFunctions());
447 TPaveStats *ptstats =
new TPaveStats(0.0, 0.0, 0.0, 0.0,
"brNDC");
449 h0_->GetListOfFunctions()->Add(ptstats);
450 ptstats->SetParent(h0_->GetListOfFunctions());
457 h1_->Scale(h0_->GetEntries() / h1_->GetEntries());
465 if (h1_->GetMaximum() > h0_->GetMaximum()) {
466 h0_->SetMaximum(h1_->GetMaximum() * 1.15);
480 max = h0_->GetMaximum();
481 if (h1_->GetMaximum() >
max)
482 max = h1_->GetMaximum();
488 min = h0_->GetMinimum();
489 if (h1_->GetMinimum() <
min)
490 min = h1_->GetMinimum();
495 h0_->SetMaximum(max);
496 h0_->SetMinimum(min);
507 if (h1_->GetMaximum() > h0_->GetMaximum()) {
508 h0_->SetMaximum(h1_->GetMaximum() * 1.15);
510 if (h1_->GetMinimum() < h0_->GetMinimum()) {
511 h0_->SetMinimum(h1_->GetMinimum() * 1.15);
513 h0_->SetMarkerStyle(21);
514 h0_->SetMarkerColor(2);
515 h1_->SetMarkerStyle(21);
516 h1_->SetMarkerColor(4);
void SetStyles(Style *s0, Style *s1, const char *leg0, const char *leg1)
static void FormatHisto(TH1 *h, const Style *s)
void DrawSigmaSlice(const char *key, const int rebinFactor, Mode mode)
void Draw(const char *key, Mode mode)
void DrawGaussSigmaOverMeanXSlice(const char *key, const int rebinFactor, const int binxmin, const int binxmax, const bool cst_binning, Mode mode)
void DrawMeanSlice(const char *key, const int rebinFactor, Mode mode)
void SetDirs(const char *file0, const char *dir0, const char *file1, const char *dir1)
tuple key
prepare the HTCondor submission files and eventually submit them
TH1 * Histo(const char *key, unsigned dirIndex)
Double_t fitFunction_f(Double_t *x, Double_t *par)
void DrawSlice(const char *key, int binxmin, int binxmax, Mode mode)
void DrawGaussSigmaOverMeanSlice(const char *key, const char *key2, const int rebinFactor, Mode mode)
void DrawGaussSigmaSlice(const char *key, const int rebinFactor, Mode mode)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.