]>
Commit | Line | Data |
---|---|---|
2845593c | 1 | /****************************************************************************************************************************************** |
2 | Contact person: Marco Leoncino (leoncino@to.infn.it) | |
3 | Macro to draw the ZDC QA trending plots by accessing the std tree. To be mainly used with the automatic scripts to fill the QA repository. | |
4 | Launch with aliroot -x -b -q "DrawTrendingZDCQA.C" The macro produces one png file for trending variables and a file with the histograms. | |
5 | ******************************************************************************************************************************************/ | |
6 | #if !defined(__CINT__) || defined(__MAKECINT__) | |
7 | ||
8 | #include <stdio.h> | |
9 | #include <stdlib.h> | |
10 | #include <TROOT.h> | |
11 | #include <Riostream.h> | |
12 | #include <TClassTable.h> | |
13 | #include <TStyle.h> | |
14 | #include <TMath.h> | |
15 | #include <TFile.h> | |
16 | #include <TCanvas.h> | |
17 | #include <TH1.h> | |
18 | #include <TH2.h> | |
19 | #include <TProfile.h> | |
20 | #include <TLine.h> | |
21 | #include <TGrid.h> | |
22 | #include <TBits.h> | |
23 | #include <TChain.h> | |
24 | #include <TNtuple.h> | |
25 | #include <TTree.h> | |
26 | #include <TBranch.h> | |
27 | #include <TFileMerger.h> | |
28 | #include <TGridResult.h> | |
29 | #include <TSystem.h> | |
30 | #include <TGaxis.h> | |
31 | #include <TRandom.h> | |
32 | #include <TLegend.h> | |
33 | ||
34 | #endif | |
35 | ||
36 | Int_t DrawTrendingZDCQA(TString mergedTrendFile = "trending.root", // trending tree file | |
37 | Bool_t displayAll = kFALSE) // set to kTRUE to display trending for expert plots | |
38 | { | |
39 | // | |
40 | //reads merged trending.root file and draws trending plots from tree | |
41 | // | |
42 | if (!mergedTrendFile) { | |
43 | Printf("Cannot open merged trend file with ZDC QA"); | |
44 | return 1; | |
45 | } | |
46 | ||
47 | /*set graphic style*/ | |
48 | gStyle->SetCanvasColor(kWhite); | |
49 | gStyle->SetFrameFillColor(kWhite); | |
50 | gStyle->SetFrameBorderMode(0); | |
51 | gStyle->SetCanvasBorderMode(0); | |
52 | gStyle->SetTitleFillColor(kWhite); | |
53 | gStyle->SetTitleBorderSize(0); | |
54 | gStyle->SetTitleFont(42); | |
55 | gStyle->SetTextFont(42); | |
56 | gStyle->SetStatColor(kWhite); | |
57 | gStyle->SetStatBorderSize(1); | |
58 | gStyle->SetOptStat(0); | |
59 | TGaxis::SetMaxDigits(3); | |
60 | ||
61 | char outfilename[200]= "ProductionQA.hist.root"; | |
62 | TString plotDir("."); | |
63 | //TString plotDir(Form("PlotsTrending")); | |
64 | //gSystem->Exec(Form("mkdir %s",plotDir.Data())); | |
65 | ||
66 | legend = new TLegend(0.9,0.1,1.0,0.9); | |
67 | legend->SetFillColor(kWhite); | |
68 | ||
69 | Int_t runNumber=0; | |
70 | Double_t ZNC_mean=0; | |
71 | Double_t ZNA_mean=0; | |
72 | Double_t ZPA_mean=0; | |
73 | Double_t ZPC_mean=0; | |
74 | Double_t ZEM1_mean=0; | |
75 | Double_t ZEM2_mean=0; | |
76 | Double_t ZNC_XCent=0; | |
77 | Double_t ZNC_YCent=0; | |
78 | Double_t ZNA_XCent=0; | |
79 | Double_t ZNA_YCent=0; | |
80 | Double_t ZNC_XCent_err=0; | |
81 | Double_t ZNC_YCent_err=0; | |
82 | Double_t ZNA_XCent_err=0; | |
83 | Double_t ZNA_YCent_err=0; | |
84 | Double_t ZN_TDC_Sum=0; | |
85 | Double_t ZN_TDC_Diff=0; | |
86 | Double_t ZN_TDC_Sum_err=0; | |
87 | Double_t ZN_TDC_Diff_err=0; | |
88 | ||
89 | TFile * fin = TFile::Open(mergedTrendFile.Data()); | |
90 | TTree * ttree = (TTree*) fin->Get("trending"); | |
91 | if (!ttree){ | |
92 | Printf("Invalid trending tree."); | |
93 | return 2; | |
94 | } | |
95 | ||
96 | Int_t nRuns=ttree->GetEntries(); | |
97 | printf("Number of runs to be analyzed:%d\n",nRuns); | |
98 | TList list; | |
99 | ||
100 | TH1D *hZNCpmcSpectrum = new TH1D("hZNCpmcSpectrum","ZNC common tower mean ADC channel vs Run",200.,0.,2000.); | |
101 | TH1D *hZNApmcSpectrum = new TH1D("hZNApmcSpectrum","ZNA common tower mean ADC channel vs Run",200.,0.,2000.); | |
102 | TH1D *hZPCpmcSpectrum = new TH1D("hZPCpmcSpectrum","ZPC common tower mean ADC channel vs Run",200.,0.,2000.); | |
103 | TH1D *hZPApmcSpectrum = new TH1D("hZPApmcSpectrum","ZPA common tower mean ADC channel vs Run",200.,0.,2000.); | |
104 | TH1D *hZEM1Spectrum = new TH1D("hZEM1Spectrum","ZEM1 mean ADC channel vs Run",200.,0.,2000.); | |
105 | TH1D *hZEM2Spectrum = new TH1D("hZEM2Spectrum","ZEM2 mean ADC channel vs Run",200.,0.,2000.); | |
106 | ||
107 | ttree->SetBranchAddress("run",&runNumber); | |
108 | ttree->SetBranchAddress("ZNC_mean_value",&ZNC_mean); | |
109 | ttree->SetBranchAddress("ZNA_mean_value",&ZNA_mean); | |
110 | ttree->SetBranchAddress("ZPC_mean_value",&ZPC_mean); | |
111 | ttree->SetBranchAddress("ZPA_mean_value",&ZPA_mean); | |
112 | ttree->SetBranchAddress("ZEM1_mean_value",&ZEM1_mean); | |
113 | ttree->SetBranchAddress("ZEM2_mean_value",&ZEM2_mean); | |
114 | ttree->SetBranchAddress("ZNC_X_Centroid",&ZNC_XCent); | |
115 | ttree->SetBranchAddress("ZNC_Y_Centroid",&ZNC_YCent); | |
116 | ttree->SetBranchAddress("ZNA_X_Centroid",&ZNA_XCent); | |
117 | ttree->SetBranchAddress("ZNA_Y_Centroid",&ZNA_YCent); | |
118 | ttree->SetBranchAddress("ZNC_X_Centroid_Err",&ZNC_XCent_err); | |
119 | ttree->SetBranchAddress("ZNC_Y_Centroid_Err",&ZNC_YCent_err); | |
120 | ttree->SetBranchAddress("ZNA_X_Centroid_Err",&ZNA_XCent_err); | |
121 | ttree->SetBranchAddress("ZNA_Y_Centroid_Err",&ZNA_YCent_err); | |
122 | ttree->SetBranchAddress("ZN_TDC_Sum",&ZN_TDC_Sum); | |
123 | ttree->SetBranchAddress("ZN_TDC_Diff",&ZN_TDC_Diff); | |
124 | ttree->SetBranchAddress("ZN_TDC_Sum_Err",&ZN_TDC_Sum_err); | |
125 | ttree->SetBranchAddress("ZN_TDC_Diff_Err",&ZN_TDC_Diff_err); | |
126 | ||
127 | TH1D *hznc = new TH1D("hznc","ZNC common tower mean ADC channel vs Run",nRuns,0.,nRuns); | |
128 | hznc->SetDrawOption("E"); | |
129 | hznc->SetDrawOption("E"); | |
130 | ||
131 | TH1D *hzna = new TH1D("hzna","ZNA common tower mean ADC channel vs Run",nRuns,0.,nRuns); | |
132 | hzna->SetDrawOption("E"); | |
133 | hzna->SetMarkerStyle(20); | |
134 | ||
135 | TH1D *hzpc = new TH1D("hzpc","ZPC common tower mean ADC channel vs Run",nRuns,0.,nRuns); | |
136 | hzpc->SetDrawOption("E"); | |
137 | hzpc->SetMarkerStyle(20); | |
138 | ||
139 | TH1D *hzpa = new TH1D("hzpa","ZPA common tower mean ADC channel vs Run",nRuns,0.,nRuns); | |
140 | hzpa->SetDrawOption("E"); | |
141 | hzpa->SetMarkerStyle(20); | |
142 | ||
143 | TH1D *hzem1 = new TH1D("hzem1","ZEM1 mean ADC channel vs Run",nRuns,0.,nRuns); | |
144 | hzem1->SetDrawOption("E"); | |
145 | hzem1->SetMarkerStyle(20); | |
146 | ||
147 | TH1D *hzem2 = new TH1D("hzem2","ZEM2 mean ADC channel vs Run",nRuns,0.,nRuns); | |
148 | hzem2->SetDrawOption("E"); | |
149 | hzem2->SetMarkerStyle(20); | |
150 | ||
151 | TH1D *hzna_Xcentroid = new TH1D("hzna_Xcentroid","ZNA X centroid vs Run",nRuns,0.,nRuns); | |
152 | hzna_Xcentroid->SetDrawOption("E"); | |
153 | hzna_Xcentroid->SetMarkerStyle(20); | |
154 | ||
155 | TH1D *hzna_Ycentroid = new TH1D("hzna_Ycentroid","ZNA Y centroid vs Run",nRuns,0.,nRuns); | |
156 | hzna_Ycentroid->SetDrawOption("E"); | |
157 | hzna_Ycentroid->SetMarkerStyle(20); | |
158 | ||
159 | TH1D *hznc_Xcentroid = new TH1D("hznc_Xcentroid","ZNC X centroid vs Run",nRuns,0.,nRuns); | |
160 | hznc_Xcentroid->SetDrawOption("E"); | |
161 | hznc_Xcentroid->SetMarkerStyle(20); | |
162 | ||
163 | TH1D *hznc_Ycentroid = new TH1D("hznc_Ycentroid","ZNC Y centroid vs Run",nRuns,0.,nRuns); | |
164 | hznc_Ycentroid->SetDrawOption("E"); | |
165 | hznc_Ycentroid->SetMarkerStyle(20); | |
166 | ||
167 | TH1D *hzn_TDC_Sum = new TH1D("hzn_TDC_Sum","ZNC TDC + ZNA TDC",nRuns,0.,nRuns); | |
168 | hzn_TDC_Sum->SetDrawOption("E"); | |
169 | hzn_TDC_Sum->SetMarkerStyle(20); | |
170 | ||
171 | TH1D *hzn_TDC_Diff = new TH1D("hzn_TDC_Diff","ZNC TDC - ZNA TDC",nRuns,0.,nRuns); | |
172 | hzn_TDC_Diff->SetDrawOption("E"); | |
173 | hzn_TDC_Diff->SetMarkerStyle(20); | |
174 | ||
175 | char runlabel[10]; | |
176 | int icol = 0; | |
177 | ||
178 | for (Int_t irun=0;irun<nRuns;irun++){ | |
179 | ||
180 | ttree->GetEntry(irun); | |
181 | sprintf(runlabel,"%i",runNumber); | |
182 | icol = 99*gRandom->Rndm(); | |
183 | ||
184 | //---------------------------------------------------------------------- | |
185 | //spectra vs run | |
186 | //---------------------------------------------------------------------- | |
187 | ||
188 | hZNCpmcSpectrum = dynamic_cast<TH1D*> (fin->Get("fhZNCpmc")); | |
189 | hZNCpmcSpectrum->Scale(1./hZNCpmcSpectrum->GetEntries()); | |
190 | hZNCpmcSpectrum->SetLineColor(icol); | |
191 | hZNCpmcSpectrum->SetTitle("ZNC spectra as a function of Run Number"); | |
192 | hZNCpmcSpectrum->SetXTitle("ZNC signal (ADC ch.)"); | |
193 | ||
194 | hZNApmcSpectrum = dynamic_cast<TH1D*> (fin->Get("fhZNApmc")); | |
195 | hZNApmcSpectrum->Scale(1./hZNApmcSpectrum->GetEntries()); | |
196 | hZNApmcSpectrum->SetLineColor(icol); | |
197 | hZNApmcSpectrum->SetTitle("ZNA spectra as a function of Run Number"); | |
198 | hZNApmcSpectrum->SetXTitle("ZNA signal (ADC ch.)"); | |
199 | ||
200 | hZPCpmcSpectrum = dynamic_cast<TH1D*> (fin->Get("fhZPCpmc")); | |
201 | hZPCpmcSpectrum->Scale(1./hZPCpmcSpectrum->GetEntries()); | |
202 | hZPCpmcSpectrum->SetLineColor(icol); | |
203 | hZPCpmcSpectrum->SetTitle("ZPC spectra as a function of Run Number"); | |
204 | hZPCpmcSpectrum->SetXTitle("ZPC signal (ADC ch.)"); | |
205 | ||
206 | hZPApmcSpectrum = dynamic_cast<TH1D*> (fin->Get("fhZPApmc")); | |
207 | hZPApmcSpectrum->Scale(1./hZPApmcSpectrum->GetEntries()); | |
208 | hZPApmcSpectrum->SetLineColor(icol); | |
209 | hZPApmcSpectrum->SetTitle("ZPA spectra as a function of Run Number"); | |
210 | hZPApmcSpectrum->SetXTitle("ZPA signal (ADC ch.)"); | |
211 | ||
212 | hZEM1Spectrum = dynamic_cast<TH1D*> (fin->Get("fhZEM1Spectrum")); | |
213 | hZEM1Spectrum->Scale(1./hZEM1Spectrum->GetEntries()); | |
214 | hZEM1Spectrum->SetLineColor(icol); | |
215 | hZEM1Spectrum->SetTitle("ZEM1 spectra as a function of Run Number"); | |
216 | hZEM1Spectrum->SetXTitle("ZEM1 signal (ADC ch.)"); | |
217 | ||
218 | hZEM2Spectrum = dynamic_cast<TH1D*> (fin->Get("fhZEM2Spectrum")); | |
219 | hZEM2Spectrum->Scale(1./hZEM2Spectrum->GetEntries()); | |
220 | hZEM2Spectrum->SetLineColor(icol); | |
221 | hZEM2Spectrum->SetTitle("ZEM2 spectra as a function of Run Number"); | |
222 | hZEM2Spectrum->SetXTitle("ZEM2 signal (ADC ch.)"); | |
223 | ||
224 | legend->AddEntry(hZPApmcSpectrum, runlabel, "l"); | |
225 | ||
226 | //---------------------------------------------------------------------- | |
227 | //variables vs run | |
228 | //---------------------------------------------------------------------- | |
229 | ||
230 | hznc->SetBinContent(irun+1, ZNC_mean); | |
231 | hznc->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
232 | ||
233 | hzna->SetBinContent(irun+1, ZNA_mean); | |
234 | hzna->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
235 | ||
236 | hzpc->SetBinContent(irun+1, ZPC_mean); | |
237 | hzpc->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
238 | ||
239 | hzpa->SetBinContent(irun+1, ZPA_mean); | |
240 | hzpa->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
241 | ||
242 | hzem1->SetBinContent(irun+1, ZEM1_mean); | |
243 | hzem1->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
244 | ||
245 | hzem2->SetBinContent(irun+1, ZEM2_mean); | |
246 | hzem2->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
247 | ||
248 | hzna_Xcentroid->SetBinContent(irun+1, ZNA_XCent); | |
249 | hzna_Xcentroid->SetBinError(irun+1, ZNA_XCent_err); | |
250 | hzna_Xcentroid->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
251 | ||
252 | hzna_Ycentroid->SetBinContent(irun+1, ZNA_YCent); | |
253 | hzna_Ycentroid->SetBinError(irun+1, ZNA_YCent_err); | |
254 | hzna_Ycentroid->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
255 | ||
256 | hznc_Xcentroid->SetBinContent(irun+1, ZNC_XCent); | |
257 | hznc_Xcentroid->SetBinError(irun+1, ZNC_XCent_err); | |
258 | hznc_Xcentroid->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
259 | ||
260 | hznc_Ycentroid->SetBinContent(irun+1, ZNC_YCent); | |
261 | hznc_Ycentroid->SetBinError(irun+1, ZNC_YCent_err); | |
262 | hznc_Ycentroid->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
263 | ||
264 | hzn_TDC_Sum->SetBinContent(irun+1, ZN_TDC_Sum); | |
265 | hzn_TDC_Sum->SetBinError(irun+1, ZN_TDC_Sum_err); | |
266 | hzn_TDC_Sum->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
267 | ||
268 | hzn_TDC_Diff->SetBinContent(irun+1, ZN_TDC_Diff); | |
269 | hzn_TDC_Diff->SetBinError(irun+1, ZN_TDC_Diff_err); | |
270 | hzn_TDC_Diff->GetXaxis()->SetBinLabel(irun+1,runlabel); | |
271 | } | |
272 | ||
273 | //---------------------------------------------------------------------- | |
274 | //spectra vs run | |
275 | //---------------------------------------------------------------------- | |
276 | ||
277 | TCanvas* cZNC_Spectra = new TCanvas("cZNC_Spectra","cZNC_Spectra",50,50,1200,900); | |
278 | hZNCpmcSpectrum->Draw(); | |
279 | cZNC_Spectra->Print(Form("%s/cZNC_Spectra.png",plotDir.Data())); | |
280 | gPad->SetLogy(); | |
281 | legend->Draw("same"); | |
282 | ||
283 | TCanvas* cZNA_Spectra = new TCanvas("cZNA_Spectra","cZNA_Spectra",50,50,1200,900); | |
284 | hZNApmcSpectrum->Draw(); | |
285 | cZNA_Spectra->Print(Form("%s/cZNA_Spectra.png",plotDir.Data())); | |
286 | gPad->SetLogy(); | |
287 | legend->Draw("same"); | |
288 | ||
289 | TCanvas* cZPC_Spectra = new TCanvas("cZPC_Spectra","cZPC_Spectra",50,50,1200,900); | |
290 | hZPCpmcSpectrum->Draw(); | |
291 | cZPC_Spectra->Print(Form("%s/cZPC_Spectra.png",plotDir.Data())); | |
292 | gPad->SetLogy(); | |
293 | legend->Draw("same"); | |
294 | ||
295 | TCanvas* cZPA_Spectra = new TCanvas("cZPA_Spectra","cZPA_Spectra",50,50,1200,900); | |
296 | hZPApmcSpectrum->Draw(); | |
297 | cZPA_Spectra->Print(Form("%s/cZPA_Spectra.png",plotDir.Data())); | |
298 | gPad->SetLogy(); | |
299 | legend->Draw("same"); | |
300 | ||
301 | TCanvas* cZEM1_Spectra = new TCanvas("cZEM1_Spectra","cZEM1_Spectra",50,50,1200,900); | |
302 | hZEM1Spectrum->Draw(); | |
303 | cZEM1_Spectra->Print(Form("%s/cZEM1_Spectra.png",plotDir.Data())); | |
304 | gPad->SetLogy(); | |
305 | legend->Draw("same"); | |
306 | ||
307 | TCanvas* cZEM2_Spectra = new TCanvas("cZEM2_Spectra","cZEM2_Spectra",50,50,1200,900); | |
308 | hZEM2Spectrum->Draw(); | |
309 | cZEM2_Spectra->Print(Form("%s/cZEM2_Spectra.png",plotDir.Data())); | |
310 | gPad->SetLogy(); | |
311 | legend->Draw("same"); | |
312 | ||
313 | //---------------------------------------------------------------------- | |
314 | //variables vs run | |
315 | //---------------------------------------------------------------------- | |
316 | TCanvas* cZNC_mean_values = new TCanvas("cZNC_mean_values","cZNC_mean_values", 50,50,750,550); | |
317 | hznc->Draw(); | |
318 | cZNC_mean_values->Print(Form("%s/cZNC_mean_values.png",plotDir.Data())); | |
319 | ||
320 | TCanvas* cZNA_mean_values = new TCanvas("cZNA_mean_values","cZNA_mean_values", 50,50,750,550); | |
321 | hzna->Draw(); | |
322 | cZNA_mean_values->Print(Form("%s/cZNA_mean_values.png",plotDir.Data())); | |
323 | ||
324 | TCanvas* cZPC_mean_values = new TCanvas("cZPC_mean_values","cZPC_mean_values", 50,50,750,550); | |
325 | hzpc->Draw(); | |
326 | cZPC_mean_values->Print(Form("%s/cZNP_mean_values.png",plotDir.Data())); | |
327 | ||
328 | TCanvas* cZPA_mean_values = new TCanvas("cZPA_mean_values","cZPA_mean_values", 50,50,750,550); | |
329 | hzpa->Draw(); | |
330 | cZPA_mean_values->Print(Form("%s/cZPA_mean_values.png",plotDir.Data())); | |
331 | ||
332 | TCanvas* cZNA_X_centroid = new TCanvas("cZNA_X_centroid","cZNA_X_centroid", 50,50,750,550); | |
333 | hzna_Xcentroid->Draw(); | |
334 | cZNA_X_centroid->Print(Form("%s/cZNA_X_centroid.png",plotDir.Data())); | |
335 | ||
336 | TCanvas* cZNA_Y_centroid = new TCanvas("cZNA_Y_centroid","cZNA_Y_centroid", 50,50,750,550); | |
337 | hzna_Ycentroid->Draw(); | |
338 | cZNA_Y_centroid->Print(Form("%s/cZNA_Y_centroid.png",plotDir.Data())); | |
339 | ||
340 | TCanvas* cZNC_X_centroid = new TCanvas("cZNC_X_centroid","cZNC_X_centroid", 50,50,750,550); | |
341 | hznc_Xcentroid->Draw(); | |
342 | cZNC_X_centroid->Print(Form("%s/cZNC_X_centroid.png",plotDir.Data())); | |
343 | ||
344 | TCanvas* cZNC_Y_centroid = new TCanvas("cZNC_Y_centroid","cZNC_Y_centroid", 50,50,750,550); | |
345 | hznc_Ycentroid->Draw(); | |
346 | cZNC_Y_centroid->Print(Form("%s/cZNC_Y_centroid.png",plotDir.Data())); | |
347 | ||
348 | list.Add(cZNC_Spectra); | |
349 | list.Add(cZNA_Spectra); | |
350 | list.Add(cZPC_Spectra); | |
351 | list.Add(cZPA_Spectra); | |
352 | list.Add(cZEM1_Spectra); | |
353 | list.Add(cZEM2_Spectra); | |
354 | list.Add(hznc); | |
355 | list.Add(hzna); | |
356 | list.Add(hzpc); | |
357 | list.Add(hzpa); | |
358 | list.Add(hzem1); | |
359 | list.Add(hzem2); | |
360 | list.Add(hzna_Xcentroid); | |
361 | list.Add(hzna_Ycentroid); | |
362 | list.Add(hznc_Xcentroid); | |
363 | list.Add(hznc_Ycentroid); | |
364 | list.Add(hzn_TDC_Sum); | |
365 | list.Add(hzn_TDC_Diff); | |
366 | ||
367 | TFile * fout=new TFile(outfilename,"recreate"); | |
368 | fout->cd(); | |
369 | list.Write(); | |
370 | fout->Close(); | |
371 | ||
372 | return 0; | |
373 | ||
374 | } |