20 fpSIG = TFile::Open(
"dimuon_signal_hist.root");
21 fpBKG = TFile::Open(
"dimuon_background_hist.root");
36 TCanvas*
canvas(
const char*
nm,
const char* ti,
const char*
a)
38 if (a == TString(
"square"))
return new TCanvas(nm, nm, 600,600);
39 if (a == TString(
"portrait"))
return new TCanvas(nm, nm, 500,700);
40 if (a == TString(
"landscape"))
return new TCanvas(nm, nm, 700,500);
45 h2->Scale(h1->GetEntries()/h2->GetEntries());
49 float m1 = h1->GetMaximum();
50 float m2 = h2->GetMaximum();
59 if (islog) mx =
pow(10.0, mx);
65 m1 = h1->GetMinimum();
66 m2 = h2->GetMinimum();
67 if (m1<=1 || m2<=1) h1->SetMinimum(0.1);
68 else h1->SetMinimum(1.0);
78 TLine*
l =
new TLine(x, y1, x, y2);
79 l->SetLineColor(kBlack);
83 double y = y1 + fy*(y2-
y1);
84 TArrow*
a =
new TArrow(x, y, x+dx, y, 0.02);
86 a->SetLineColor(kBlack);
91 h->SetFillColor(kAzure-9);
92 h->GetXaxis()->SetNdivisions(505);
93 h->GetYaxis()->SetNdivisions(505);
97 h->SetLineColor(
kRed);
108 const char* base_name,
118 sprintf(sig_name,
"sig%s", base_name);
119 sprintf(bkg_name,
"bkg%s", base_name);
121 TH1F* sig =
new TH1F(sig_name, title, n, x1, x2);
122 TH1F*
bkg =
new TH1F(bkg_name, title, n, x1, x2);
126 ntSIG->Project(sig_name, var, cut);
127 ntBKG->Project(bkg_name, var, cut);
130 << base_name <<
" & " 131 << sig->GetEntries() <<
" & " 132 << bkg->GetEntries() <<
" & " 151 sprintf(ti,
"%s_%s",
gPrefix, title);
152 TCanvas*
c =
canvas(ti, 0, aspect);
153 if (islogy==1) c->SetLogy();
155 float mx =
plot_max(h1, h2, r, islogy);
160 float xlo = h1->GetXaxis()->GetXmin();
161 float xhi = h1->GetXaxis()->GetXmax();
162 if (
fabs((xlo+xhi)/(xhi-xlo))<0.05) {
163 h1->GetXaxis()->CenterTitle();
166 h2->Draw(
"hist,same");
168 float dx = 0.05*(xhi-
xlo);
169 if (cut_left !=-99) {
show_x_cut(cut_left, dx, 0, mx); }
170 if (cut_right!=-99) {
show_x_cut(cut_right, -dx, 0, mx); }
174 sprintf(fname,
"%s.pdf",c->GetName());
225 TCut cutNONE = TCut(
"1");
229 proj_1D(&sigNpl, &bkgNpl,
"Nplane",
";number of hit planes;slice counts/5 planes", 44, 0, 220,
"np", cutNONE);
230 plot_1D( sigNpl, bkgNpl,
"01_Nplane",
"portrait", logy, 0.5, 20, 200);
232 TCut cutNp(
"np>=20&&np<=200");
237 proj_1D(&sigNhit, &bkgNhit,
"Nhit",
";number of hit cells;slice counts/5 hits", 80, 0, 400,
"(nhitx+nhity)", cutNONE);
238 plot_1D( sigNhit, bkgNhit,
"01_Nhit",
"portrait", logy, 0.5, 30, -99);
240 TCut cutNhit(
"(nhitx+nhity)>=30");
245 proj_1D(&sigAnhit, &bkgAnhit,
"Anhit",
";(N_{x}-N_{y})/(N_{x}+N_{y});slice counts/0.05", 20, -1, 1,
"(nhitx-nhity)/(nhitx+nhity)", cutNp&&cutNhit);
246 plot_1D( sigAnhit, bkgAnhit,
"01_Anhit",
"portrait", logy, 0.5, -0.5, 0.5);
248 TCut cutAnhit(
"fabs(nhitx-nhity)/(nhitx+nhity)<=0.5");
253 proj_1D(&sigN2p, &bkgN2p,
"N2p",
";number of planes with 2 hits;slice counts", 100, 0, 100,
"n2p", cutNp&&cutNhit&&cutAnhit);
254 plot_1D( sigN2p, bkgN2p,
"01_N2p",
"portrait", liny, 20, 8, -99);
256 TCut cutN2p(
"n2p>=8");
261 proj_1D(&sigN3p, &bkgN3p,
"N3p",
";number of planes with 3+ hits;slice counts", 100, 0, 100,
"n3p", cutNp&&cutNhit&&cutAnhit);
262 plot_1D( sigN3p, bkgN3p,
"01_N3p",
"portrait", logy, 0.5, -99, 40);
264 TCut cutN3p(
"n3p<=40");
269 gCutNHIT = TCut(cutNp&&cutNhit&&cutAnhit&&cutN2p&&cutN3p);
282 proj_1D(&sigNp5, &bkgNp5,
"Np5",
";number of hits on front face;slice counts/hit", 51, -0.5, 50.5,
"np5",
gCutNHIT);
283 plot_1D( sigNp5, bkgNp5,
"02_Np5",
"portrait", logy, 0.5, -99, 1.5);
285 TCut cutNp5(
"np5<=1");
290 proj_1D(&sigNwall, &bkgNwall,
"Nwall",
";number of side walls hit;slice counts", 5, -0.5, 4.5,
"(nc5t>1)+(nc5b>1)+(nc5l>1)+(nc5r>1)",
gCutNHIT);
291 plot_1D( sigNwall, bkgNwall,
"02_Nwall",
"portrait", logy, 1.0, -99, 2.5);
293 TCut cutNwall(
"((nc5t>1)+(nc5b>1)+(nc5l>1)+(nc5r>1))<=2");
308 plot_1D( sigVx, bkgVx,
"03_Vx",
"portrait", liny, 20, -160, 160);
313 plot_1D( sigVy, bkgVy,
"03_Vy",
"portrait", liny, 20, -160, 160);
318 plot_1D( sigVz, bkgVz,
"03_Vz",
"landscape", liny, 20, 50, 1000);
323 gCutVTX = TCut(
"abs(x)<=160&&abs(y)<=160&&z>=50&&z<=1000");
336 plot_1D( sigHperP, bkgHperP,
"04_HperP",
"portrait", liny, 450, -99, 2.5);
338 TCut cutHperP(
"(nhitx+nhity)/np<=2.5");
343 proj_1D(&sigNc, &bkgNc,
"NcNp",
";(N^{2}_{cx}+N^{2}_{cy})^{1/2}/N_{planes};slice counts/0.1", 25, 0, 2.5,
"sqrt(ncx**2+ncy**2)/np",
gCutNHIT&&
gCutVETO&&
gCutVTX);
344 plot_1D( sigNc, bkgNc,
"04_NcNp",
"portrait", logy, 0.5, -99, 1.2);
346 TCut cutNcNp(
"sqrt(ncx**2+ncy**2)/np<=1.2");
352 plot_1D( sigN10, bkgN10,
"04_N10",
"portrait", logy, 0.5, -99, 25.5);
354 TCut cutN10(
"n10<=25");
360 plot_1D( sigPks, bkgPks,
"04_Pks",
"portrait", logy, 0.5, -4.5, -99);
362 TCut cutPks(
"log10(pks)>=-4.5");
366 gCutSHAPE = TCut(cutHperP&&cutNcNp&&cutN3p&&cutN2p&&cutN10&&cutPks);
375 TH1F* sigNpFinal = 0;
376 TH1F* bkgNpFinal = 0;
377 proj_1D(&sigNpFinal, &bkgNpFinal,
"NpFinal",
";number of hit planes;slice counts/5 planes", 44, 0, 220,
"np",
gCutPASS1);
378 plot_1D( sigNpFinal, bkgNpFinal,
"05_NpFinal",
"portrait", logy, 1.0, 20, 200);
390 const char* cut_name,
405 nt->Scan(var, c&&s,
"", n1, n0);
408 nt->Scan(var, c&&!s,
"", n2, n0);
414 scan(
"SIGNAL",
"NHIT",
ntSIG, 0, 50, 50,
"run:event:slice:np:nhitx:nhity:n2p:n3p", noCut,
gCutNHIT);
415 scan(
"BACKGROUND",
"NHIT",
ntBKG, 0, 50, 50,
"run:event:slice:np:nhitx:nhity:n2p:n3p", noCut,
gCutNHIT);
431 gStyle->SetOptStat(0);
fvar< T > fabs(const fvar< T > &x)
Float_t y1[n_points_granero]
Float_t x1[n_points_granero]
static constexpr Double_t nm
TCanvas * canvas(const char *nm, const char *ti, const char *a)
void proj_1D(TH1F **h1, TH1F **h2, const char *base_name, const char *title, int n, float x1, float x2, const char *var, TCut cut)
float plot_max(TH1F *h1, TH1F *h2, float r, int islog=0)
void area_normalize(TH1F *h1, TH1F *h2)
static constexpr Double_t m2
fvar< T > floor(const fvar< T > &x)
void scan(const char *sample, const char *cut_name, TTree *nt, int n0, int n1, int n2, const char *var, TCut c, TCut s)
void plot_1D(TH1F *h1, TH1F *h2, const char *title, const char *aspect, int islogy, float r, float cut_left=-99, float cut_right=-99)
void show_x_cut(float x, float dx, float y1, float y2, float fy=0.82)