-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpmt2sipm_draw.C
40 lines (39 loc) · 1022 Bytes
/
pmt2sipm_draw.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
void pmt2sipm_draw(const char *name)
{
int i;
char str[1024];
char strs[128];
TObjArray array;
gStyle->SetOptFit(1);
sprintf(str, "%s.root", name);
TFile *f = new TFile(str);
if (!f->IsOpen()) return;
TH2D *h = f->Get("hPmt2Sipm-diff");
if (!h) return;
TF1 *fGaus = new TF1("fGaus", "gaus", -1, 1);
h->FitSlicesY(fGaus, 0, -1, 0, "QN", &array);
TH1 *hpos = (TH1 *) array[1]->Clone();
hpos->SetLineWidth(4);
TCanvas *cv = new TCanvas("CV", "CV", 1200, 900);
h->SetStats(0);
hpos->SetStats(0);
h->Draw("colorz");
hpos->Draw("same");
cv->Update();
sprintf(str, "%s.pdf[", name);
cv->SaveAs(str);
sprintf(str, "%s.pdf", name);
cv->SaveAs(str);
cv->Clear();
hpos->SetTitle("Gaus fit mean; (Sipm+Pmt)/2, MeV;2*(Sipm-Pmt)/(Sipm+Pmt)");
hpos->Draw();
cv->SaveAs(str);
for (i = 0; i < h->GetNbinsX(); i++) {
sprintf(strs, "E=%4.2f-%4.2f", 1 + 0.25*i, 1.25+0.25*i);
h->ProjectionY(strs, i+1, i+1)->Fit("gaus");
cv->SaveAs(str);
}
sprintf(str, "%s.pdf]", name);
cv->SaveAs(str);
f->Close();
}