TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGPP / ZDC / macros / DrawPerformanceZDCQAMatch.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <TROOT.h>
5 #include <Riostream.h>
6 #include <TClassTable.h>
7 #include <TStyle.h>
8 #include <TMath.h>
9 #include <TFile.h>
10 #include <TCanvas.h>
11 #include <TH1.h>
12 #include <TH2.h>
13 #include <TProfile.h>
14 #include <TLine.h>
15 #include <TGrid.h>
16 #include <TBits.h>
17 #include <TChain.h>
18 #include <TNtuple.h>
19 #include <TTree.h>
20 #include <TBranch.h>
21 #include <TFileMerger.h>
22 #include <TGridResult.h>
23 #include <TSystem.h>
24 #include <TGaxis.h>
25 #include <TRandom.h>
26 #include <TLegend.h>
27 #endif
28
29 Int_t DrawPerformanceZDCQAMatch(const char* inFile){
30   
31 // Draw control histograms and generate output pictures
32
33 gSystem->Load("libSTAT");
34 gSystem->Load("libANALYSIS");
35 gSystem->Load("libANALYSISalice");
36 gSystem->Load("libANALYSIScalib");
37 gSystem->Load("libCORRFW");
38 gSystem->Load("libANALYSISalice.so");
39 gSystem->Load("libANALYSIScalib.so");
40 gSystem->Load("libTender.so");
41 gSystem->Load("libPWGPP.so");
42
43 gROOT->Reset();
44 gROOT->SetStyle("Plain");
45 gStyle->SetPalette(1);
46 gStyle->SetOptStat(0);    
47 gStyle->SetTitleSize(0.025);
48 TH1::AddDirectory(kFALSE);
49
50 TFile * fin = TFile::Open(inFile);
51 TTree * ttree = (TTree*) fin->Get("trending");  //in
52 TTree * tree = new TTree("tree","tree");        //out (to be summed)
53
54 if (!ttree){
55   Printf("Invalid trending tree.");
56   return 2;
57 }
58
59 Int_t nRuns=ttree->GetEntries();
60 TList list;
61   
62 /*set graphic style*/
63 gStyle->SetCanvasColor(kWhite);
64 gStyle->SetFrameFillColor(kWhite);
65 gStyle->SetFrameBorderMode(0);
66 gStyle->SetCanvasBorderMode(0);
67 gStyle->SetTitleFillColor(kWhite);
68 gStyle->SetTitleBorderSize(0);
69 gStyle->SetTitleFont(42);
70 gStyle->SetTitleX(0.5);
71 gStyle->SetTitleAlign(23); 
72 gStyle->SetTextFont(42);
73 gStyle->SetStatColor(kWhite); 
74 gStyle->SetStatBorderSize(1);
75 gStyle->SetOptStat(0);  
76 gStyle->SetTickLength(0.02,"y");
77 gStyle->SetLabelSize(0.02,"xyz");
78 gStyle->SetLabelOffset(0.03,"xyz");
79
80 char  outfilename[200]= "trending.root";
81 TString plotDir(".");
82
83 legend = new TLegend(0.9,0.1,1.0,0.9);
84 legend->SetFillColor(kWhite);
85
86 Int_t runNumber=0;
87 Double_t ZNC_mean=0;
88 Double_t ZNA_mean=0;
89 Double_t ZPA_mean=0;
90 Double_t ZPC_mean=0;
91 Double_t ZEM1_mean=0;
92 Double_t ZEM2_mean=0; 
93 Double_t ZNC_XCent=0;
94 Double_t ZNC_YCent=0;
95 Double_t ZNA_XCent=0;
96 Double_t ZNA_YCent=0;  
97 Double_t ZNC_XCent_err=0;
98 Double_t ZNC_YCent_err=0;
99 Double_t ZNA_XCent_err=0;
100 Double_t ZNA_YCent_err=0; 
101 Double_t ZN_TDC_Sum=0;
102 Double_t ZN_TDC_Diff=0;
103 Double_t ZN_TDC_Sum_err=0;
104 Double_t ZN_TDC_Diff_err=0;
105
106 TH1D *hZNCpmcSpectrum = new TH1D("hZNCpmcSpectrum","hZNCpmcSpectrum",200.,0.,2000.);
107 TH1D *hZNApmcSpectrum = new TH1D("hZNApmcSpectrum","hZNApmcSpectrum",200.,0.,2000.);
108 TH1D *hZPCpmcSpectrum = new TH1D("hZPCpmcSpectrum","hZPCpmcSpectrum",200.,0.,2000.);  
109 TH1D *hZPApmcSpectrum = new TH1D("hZPApmcSpectrum","hZPApmcSpectrum",200.,0.,2000.);
110 TH1D *hZEM1Spectrum = new TH1D("hZEM1Spectrum","hZEM1Spectrum",200.,0.,2000.);  
111 TH1D *hZEM2Spectrum = new TH1D("hZEM2Spectrum","hZEM2Spectrum",200.,0.,2000.);  
112
113 ttree->SetBranchAddress("run",&runNumber);
114 ttree->SetBranchAddress("ZNC_mean_value",&ZNC_mean);
115 ttree->SetBranchAddress("ZNA_mean_value",&ZNA_mean);
116 ttree->SetBranchAddress("ZPC_mean_value",&ZPC_mean);
117 ttree->SetBranchAddress("ZPA_mean_value",&ZPA_mean); 
118 ttree->SetBranchAddress("ZEM1_mean_value",&ZEM1_mean);
119 ttree->SetBranchAddress("ZEM2_mean_value",&ZEM2_mean);  
120 ttree->SetBranchAddress("ZNC_X_Centroid",&ZNC_XCent);
121 ttree->SetBranchAddress("ZNC_Y_Centroid",&ZNC_YCent);   
122 ttree->SetBranchAddress("ZNA_X_Centroid",&ZNA_XCent);
123 ttree->SetBranchAddress("ZNA_Y_Centroid",&ZNA_YCent);  
124 ttree->SetBranchAddress("ZNC_X_Centroid_Err",&ZNC_XCent_err);
125 ttree->SetBranchAddress("ZNC_Y_Centroid_Err",&ZNC_YCent_err);   
126 ttree->SetBranchAddress("ZNA_X_Centroid_Err",&ZNA_XCent_err);
127 ttree->SetBranchAddress("ZNA_Y_Centroid_Err",&ZNA_YCent_err);    
128 ttree->SetBranchAddress("ZN_TDC_Sum",&ZN_TDC_Sum);
129 ttree->SetBranchAddress("ZN_TDC_Diff",&ZN_TDC_Diff);    
130 ttree->SetBranchAddress("ZN_TDC_Sum_Err",&ZN_TDC_Sum_err);
131 ttree->SetBranchAddress("ZN_TDC_Diff_Err",&ZN_TDC_Diff_err);
132
133 TH1D *hznc = new TH1D("hznc","ZNC TC mean signal",3,-1,1);
134 hznc->GetXaxis()->SetRangeUser(-1.,1.);
135 hznc->SetDrawOption("EP");
136 hznc->SetMarkerStyle(20);
137 hznc->SetMarkerColor(kRed);
138 hznc->SetLineColor(kRed);   
139
140 TH1D *hzna = new TH1D("hzna","ZNA TC mean signal",3,-1,1);
141 hzna->GetXaxis()->SetRangeUser(-1.,1.);  
142 hzna->SetDrawOption("EP");
143 hzna->SetMarkerStyle(20);
144 hzna->SetMarkerColor(kRed);
145 hzna->SetLineColor(kRed);   
146
147 TH1D *hzpc = new TH1D("hzpc","ZPC TC mean signal",3,-1,1);
148 hzpc->GetXaxis()->SetRangeUser(-1.,1.); 
149 hzpc->SetDrawOption("EP");
150 hzpc->SetMarkerStyle(20);
151 hzpc->SetMarkerColor(kRed);
152 hzpc->SetLineColor(kRed);   
153
154 TH1D *hzpa = new TH1D("hzpa","ZPA TC mean signal",3,-1,1);
155 hzpa->GetXaxis()->SetRangeUser(-1.,1.);   
156 hzpa->SetDrawOption("EP");
157 hzpa->SetMarkerStyle(20);
158 hzpa->SetMarkerColor(kRed);
159 hzpa->SetLineColor(kRed);   
160
161 TH1D *hzem1 = new TH1D("hzem1","ZEM1 mean signal",3,-1,1);
162 hzem1->GetXaxis()->SetRangeUser(-1.,1.);   
163 hzem1->SetDrawOption("EP");
164 hzem1->SetMarkerStyle(20);
165 hzem1->SetMarkerColor(kRed);  
166 hzem1->SetLineColor(kRed); 
167
168 TH1D *hzem2 = new TH1D("hzem2","ZEM2 mean signal",3,-1,1);
169 hzem2->GetXaxis()->SetRangeUser(-1.,1.);     
170 hzem2->SetDrawOption("EP");
171 hzem2->SetMarkerStyle(20);
172 hzem2->SetMarkerColor(kRed);
173 hzem2->SetLineColor(kRed);   
174
175 TH1D *hzna_Xcentroid = new TH1D("hzna_Xcentroid","ZNA X centroid",3,-1,1);
176 hzna_Xcentroid->GetXaxis()->SetRangeUser(-1.,1.);       
177 hzna_Xcentroid->SetDrawOption("EP");
178 hzna_Xcentroid->SetMarkerStyle(20);
179 hzna_Xcentroid->SetMarkerColor(kRed);
180 hzna_Xcentroid->SetLineColor(kRed);     
181
182 TH1D *hzna_Ycentroid = new TH1D("hzna_Ycentroid","ZNA Y centroid",3,-1,1);
183 hzna_Ycentroid->GetXaxis()->SetRangeUser(-1.,1.);    
184 hzna_Ycentroid->SetDrawOption("EP");
185 hzna_Ycentroid->SetMarkerStyle(20);
186 hzna_Ycentroid->SetMarkerColor(kRed);
187 hzna_Ycentroid->SetLineColor(kRed);      
188
189 TH1D *hznc_Xcentroid = new TH1D("hznc_Xcentroid","ZNC X centroid",3,-1,1);
190 hznc_Xcentroid->GetXaxis()->SetRangeUser(-1.,1.);     
191 hznc_Xcentroid->SetDrawOption("EP");
192 hznc_Xcentroid->SetMarkerStyle(20);
193 hznc_Xcentroid->SetMarkerColor(kRed);
194 hznc_Xcentroid->SetLineColor(kRed); 
195
196 TH1D *hznc_Ycentroid = new TH1D("hznc_Ycentroid","ZNC Y centroid",3,-1,1);
197 hznc_Ycentroid->GetXaxis()->SetRangeUser(-1.,1.);     
198 hznc_Ycentroid->SetDrawOption("EP");
199 hznc_Ycentroid->SetMarkerStyle(20);
200 hznc_Ycentroid->SetMarkerColor(kRed);
201 hznc_Ycentroid->SetLineColor(kRed); 
202
203 TH1D *hzn_TDC_Sum = new TH1D("hzn_TDC_Sum","ZNC TDC + ZNA TDC",3,-1,1);
204 hzn_TDC_Sum->GetXaxis()->SetRangeUser(-1.,1.);   
205 hzn_TDC_Sum->SetDrawOption("EP");
206 hzn_TDC_Sum->SetMarkerStyle(20);
207 hzn_TDC_Sum->SetMarkerColor(kRed);
208 hzn_TDC_Sum->SetLineColor(kRed);   
209
210 TH1D *hzn_TDC_Diff = new TH1D("hzn_TDC_Diff","ZNC TDC - ZNA TDC",3,-1,1);
211 hzn_TDC_Diff->GetXaxis()->SetRangeUser(-1.,1.);    
212 hzn_TDC_Diff->SetDrawOption("EP");
213 hzn_TDC_Diff->SetMarkerStyle(20);
214 hzn_TDC_Diff->SetMarkerColor(kRed);
215 hzn_TDC_Diff->SetLineColor(kRed);   
216   
217 char runlabel[10];
218
219 for (Int_t irun=0;irun<nRuns;irun++){  
220   ttree->GetEntry(irun);
221  }
222     
223 sprintf(runlabel,"%i",runNumber);
224     
225 //----------------------------------------------------------------------
226 //spectrum vs run
227 //----------------------------------------------------------------------
228
229 hZNCpmcSpectrum = dynamic_cast<TH1D*> (fin->Get("fhZNCpmc"));
230 hZNCpmcSpectrum->GetXaxis()->SetRangeUser(0.,2000);   
231 hZNCpmcSpectrum->Scale(1./hZNCpmcSpectrum->GetEntries());
232 hZNCpmcSpectrum->SetLineColor(kRed);
233 hZNCpmcSpectrum->SetLineWidth(2);    
234 hZNCpmcSpectrum->SetTitle("ZNC spectrum");
235 hZNCpmcSpectrum->SetXTitle("ZNC signal (ADC ch.)");
236
237 hZNApmcSpectrum = dynamic_cast<TH1D*> (fin->Get("fhZNApmc"));
238 hZNApmcSpectrum->GetXaxis()->SetRangeUser(0.,2000);     
239 hZNApmcSpectrum->Scale(1./hZNApmcSpectrum->GetEntries());
240 hZNApmcSpectrum->SetLineColor(kRed);
241 hZNApmcSpectrum->SetLineWidth(2);        
242 hZNApmcSpectrum->SetTitle("ZNA spectrum");
243 hZNApmcSpectrum->SetXTitle("ZNA signal (ADC ch.)");
244
245 hZPCpmcSpectrum = dynamic_cast<TH1D*> (fin->Get("fhZPCpmc"));
246 hZPCpmcSpectrum->GetXaxis()->SetRangeUser(0.,2000);       
247 hZPCpmcSpectrum->Scale(1./hZPCpmcSpectrum->GetEntries());
248 hZPCpmcSpectrum->SetLineColor(kRed);
249 hZPCpmcSpectrum->SetLineWidth(2); 
250 hZPCpmcSpectrum->SetTitle("ZPC spectrum");
251 hZPCpmcSpectrum->SetXTitle("ZPC signal (ADC ch.)");
252
253 hZPApmcSpectrum = dynamic_cast<TH1D*> (fin->Get("fhZPApmc"));
254 hZPApmcSpectrum->GetXaxis()->SetRangeUser(0.,2000);        
255 hZPApmcSpectrum->Scale(1./hZPApmcSpectrum->GetEntries());
256 hZPApmcSpectrum->SetLineColor(kRed);
257 hZPApmcSpectrum->SetLineWidth(2); 
258 hZPApmcSpectrum->SetTitle("ZPA spectrum");
259 hZPApmcSpectrum->SetXTitle("ZPA signal (ADC ch.)");    
260
261 hZEM1Spectrum = dynamic_cast<TH1D*> (fin->Get("fhZEM1Spectrum"));
262 hZEM1Spectrum->GetXaxis()->SetRangeUser(0.,2000);           
263 hZEM1Spectrum->Scale(1./hZEM1Spectrum->GetEntries());
264 hZEM1Spectrum->SetLineColor(kRed);
265 hZEM1Spectrum->SetLineWidth(2);     
266 hZEM1Spectrum->SetTitle("ZEM1 spectrum");
267 hZEM1Spectrum->SetXTitle("ZEM1 signal (ADC ch.)");    
268
269 hZEM2Spectrum = dynamic_cast<TH1D*> (fin->Get("fhZEM2Spectrum"));
270 hZEM2Spectrum->GetXaxis()->SetRangeUser(0.,2000);      
271 hZEM2Spectrum->Scale(1./hZEM2Spectrum->GetEntries());
272 hZEM2Spectrum->SetLineColor(kRed);
273 hZEM2Spectrum->SetLineWidth(2);      
274 hZEM2Spectrum->SetTitle("ZEM2 spectrum");
275 hZEM2Spectrum->SetXTitle("ZEM2 signal (ADC ch.)");    
276           
277 //----------------------------------------------------------------------    
278 //variables vs run
279 //----------------------------------------------------------------------
280 hzna->SetBinContent(2,ZNA_mean);
281 hzna->GetXaxis()->SetBinLabel(2,runlabel);
282 hzna->GetXaxis()->SetLabelSize(0.05);
283
284 hzpc->SetBinContent(2,ZPC_mean);
285 hzpc->GetXaxis()->SetBinLabel(2,runlabel);
286 hzpc->GetXaxis()->SetLabelSize(0.05);    
287
288 hzpa->SetBinContent(2,ZPA_mean);
289 hzpa->GetXaxis()->SetBinLabel(2,runlabel);
290 hzpa->GetXaxis()->SetLabelSize(0.05);      
291
292 hzem1->SetBinContent(2,ZEM1_mean);
293 hzem1->GetXaxis()->SetBinLabel(2,runlabel);
294 hzem1->GetXaxis()->SetLabelSize(0.05);      
295
296 hzem2->SetBinContent(2,ZEM2_mean);
297 hzem2->GetXaxis()->SetBinLabel(2,runlabel);
298 hzem2->GetXaxis()->SetLabelSize(0.05);    
299
300 hzna_Xcentroid->SetBinContent(2,ZNA_XCent);
301 hzna_Xcentroid->SetBinError(2,ZNA_XCent_err);
302 hzna_Xcentroid->GetXaxis()->SetBinLabel(2,runlabel);
303 hzna_Xcentroid->GetXaxis()->SetLabelSize(0.05);
304 hzna_Xcentroid->GetYaxis()->SetTitle("(cm)");    
305    
306 hzna_Ycentroid->SetBinContent(2,ZNA_YCent);
307 hzna_Ycentroid->SetBinError(2,ZNA_YCent_err); 
308 hzna_Ycentroid->GetXaxis()->SetBinLabel(2,runlabel); 
309 hzna_Ycentroid->GetXaxis()->SetLabelSize(0.05);
310 hzna_Ycentroid->GetYaxis()->SetTitle("(cm)");       
311
312 hznc_Xcentroid->SetBinContent(2,ZNC_XCent);
313 hznc_Xcentroid->SetBinError(2,ZNC_XCent_err);
314 hznc_Xcentroid->GetXaxis()->SetBinLabel(2,runlabel);
315 hznc_Xcentroid->GetXaxis()->SetLabelSize(0.05);
316 hznc_Xcentroid->GetYaxis()->SetTitle("(cm)");     
317
318 hznc_Ycentroid->SetBinContent(2,ZNC_YCent);
319 hznc_Ycentroid->SetBinError(2,ZNC_YCent_err);
320 hznc_Ycentroid->GetXaxis()->SetBinLabel(2,runlabel);
321 hznc_Ycentroid->GetXaxis()->SetLabelSize(0.05);
322 hznc_Ycentroid->GetYaxis()->SetTitle("(cm)");   
323
324 hzn_TDC_Sum->SetBinContent(2,ZN_TDC_Sum);
325 hzn_TDC_Sum->SetBinError(2,ZN_TDC_Sum_err);
326 hzn_TDC_Sum->GetXaxis()->SetBinLabel(2,runlabel);
327 hzn_TDC_Sum->GetXaxis()->SetLabelSize(0.05);
328 hzn_TDC_Sum->GetYaxis()->SetTitle("(ns)");     
329
330 hzn_TDC_Diff->SetBinContent(2,ZN_TDC_Diff);
331 hzn_TDC_Diff->SetBinError(2,ZN_TDC_Diff_err); 
332 hzn_TDC_Diff->GetXaxis()->SetBinLabel(2,runlabel);
333 hzn_TDC_Diff->GetXaxis()->SetLabelSize(0.05);
334 hzn_TDC_Diff->GetYaxis()->SetTitle("(ns)");     
335     
336 //----------------------------------------------------------------------
337 //spectra
338 //----------------------------------------------------------------------  
339   
340 TCanvas* cZNC_Spectra = new TCanvas("cZNC_Spectra","cZNC_Spectra",50,50,1200,900); gPad->SetLogy();
341 hZNCpmcSpectrum->Draw();
342 cZNC_Spectra->Print(Form("%s/cZNC_Spectra.png",plotDir.Data()));
343
344 TCanvas* cZNA_Spectra = new TCanvas("cZNA_Spectra","cZNA_Spectra",50,50,1200,900); gPad->SetLogy();
345 hZNApmcSpectrum->Draw();
346 cZNA_Spectra->Print(Form("%s/cZNA_Spectra.png",plotDir.Data()));
347
348 TCanvas* cZPC_Spectra = new TCanvas("cZPC_Spectra","cZPC_Spectra",50,50,1200,900); gPad->SetLogy();
349 hZPCpmcSpectrum->Draw();
350 cZPC_Spectra->Print(Form("%s/cZPC_Spectra.png",plotDir.Data()));
351
352 TCanvas* cZPA_Spectra = new TCanvas("cZPA_Spectra","cZPA_Spectra",50,50,1200,900); gPad->SetLogy();
353 hZPApmcSpectrum->Draw();
354 cZPA_Spectra->Print(Form("%s/cZPA_Spectra.png",plotDir.Data()));
355
356 TCanvas* cZEM1_Spectra = new TCanvas("cZEM1_Spectra","cZEM1_Spectra",50,50,1200,900); gPad->SetLogy();
357 hZEM1Spectrum->Draw();
358 cZEM1_Spectra->Print(Form("%s/cZEM1_Spectra.png",plotDir.Data()));
359
360 TCanvas* cZEM2_Spectra = new TCanvas("cZEM2_Spectra","cZEM2_Spectra",50,50,1200,900); gPad->SetLogy();
361 hZEM2Spectrum->Draw();
362 cZEM2_Spectra->Print(Form("%s/cZEM2_Spectra.png",plotDir.Data()));
363
364
365 //---------------------------------------------------------------------------------------------------
366 //variables
367 //---------------------------------------------------------------------------------------------------
368
369 //---------------------------------------------------------------------------------------------------
370 //means
371 //---------------------------------------------------------------------------------------------------
372 TCanvas* cZNC_Mean_Values = new TCanvas("cZNC_Mean_Values","cZNC_Mean_Values", 50,50,750,550);
373 hznc->Draw("ep");
374 hznc->SetBinContent(2,ZNC_mean);
375 hznc->GetXaxis()->SetBinLabel(2,runlabel);  
376 hznc->GetXaxis()->SetLabelSize(0.05);
377 cZNC_Mean_Values->Print(Form("%s/cZNC_Mean_Values.png",plotDir.Data()));
378   
379 TCanvas* cZNA_Mean_Values = new TCanvas("cZNA_Mean_Values","cZNA_Mean_Values", 50,50,750,550);
380 hzna->Draw("ep");
381 cZNA_Mean_Values->Print(Form("%s/cZNA_Mean_Values.png",plotDir.Data()));
382
383 TCanvas* cZPC_Mean_Values = new TCanvas("cZPC_Mean_Values","cZPC_Mean_Values", 50,50,750,550);
384 hzpc->Draw("ep");
385 cZPC_Mean_Values->Print(Form("%s/cZPC_Mean_Values.png",plotDir.Data()));
386
387 TCanvas* cZPA_Mean_Values = new TCanvas("cZPA_Mean_Values","cZPA_Mean_Values", 50,50,750,550);
388 hzpa->Draw("ep");
389 cZPA_Mean_Values->Print(Form("%s/cZPA_Mean_Values.png",plotDir.Data()));
390
391 TCanvas* cZEM1_Mean_Values = new TCanvas("cZEM1_Mean_Values","cZEM1_Mean_Values", 50,50,750,550);
392 hzem1->Draw("ep");
393 cZEM1_Mean_Values->Print(Form("%s/cZEM1_Mean_Values.png",plotDir.Data()));
394
395 TCanvas* cZEM2_Mean_Values = new TCanvas("cZEM2_Mean_Values","cZEM2_Mean_Values", 50,50,750,550);
396 hzem2->Draw("ep");
397 cZEM2_Mean_Values->Print(Form("%s/cZEM2_Mean_Values.png",plotDir.Data()));
398
399 //---------------------------------------------------------------------------------------------------
400 //centroids
401 //---------------------------------------------------------------------------------------------------
402 TCanvas* cZNA_X_centroid = new TCanvas("cZNA_X_centroid","cZNA_X_centroid", 50,50,750,550);
403 hzna_Xcentroid->Draw();
404 cZNA_X_centroid->Print(Form("%s/cZNA_X_centroid.png",plotDir.Data()));
405
406 TCanvas* cZNA_Y_centroid = new TCanvas("cZNA_Y_centroid","cZNA_Y_centroid", 50,50,750,550);
407 hzna_Ycentroid->Draw();
408 cZNA_Y_centroid->Print(Form("%s/cZNA_Y_centroid.png",plotDir.Data()));
409
410 TCanvas* cZNC_X_centroid = new TCanvas("cZNC_X_centroid","cZNC_X_centroid", 50,50,750,550);
411 hznc_Xcentroid->Draw();
412 cZNC_X_centroid->Print(Form("%s/cZNC_X_centroid.png",plotDir.Data()));
413
414 TCanvas* cZNC_Y_centroid = new TCanvas("cZNC_Y_centroid","cZNC_Y_centroid", 50,50,750,550);
415 hznc_Ycentroid->Draw();
416 cZNC_Y_centroid->Print(Form("%s/cZNC_Y_centroid.png",plotDir.Data()));
417
418 //---------------------------------------------------------------------------------
419 //timing
420 //---------------------------------------------------------------------------------
421 TCanvas* cTimingSum = new TCanvas("cTimingSum","cTimingSum",50,50,750,550);
422 hzn_TDC_Sum->Draw();
423 cTimingSum->Print(Form("%s/cTimingSum.png",plotDir.Data()));
424
425 TCanvas* cTimingDiff = new TCanvas("cTimingDiff","cTimingDiff",50,50,750,550);
426 hzn_TDC_Diff->Draw();
427 cTimingDiff->Print(Form("%s/cTimingDiff.png",plotDir.Data()));
428
429 //----------------------------------------------------------------------
430 //out
431 //----------------------------------------------------------------------
432 tree->Branch("run",&runNumber,"runNumber/I");
433 tree->Branch("ZNC_mean_value",&ZNC_mean,"ZNC_mean/D");
434 tree->Branch("ZNA_mean_value",&ZNA_mean,"ZNA_mean/D");
435 tree->Branch("ZPC_mean_value",&ZPC_mean,"ZPC_mean/D");
436 tree->Branch("ZPA_mean_value",&ZPA_mean,"ZPA_mean/D"); 
437 tree->Branch("ZEM1_mean_value",&ZEM1_mean,"ZEM1_mean/D");
438 tree->Branch("ZEM2_mean_value",&ZEM2_mean,"ZEM2_mean/D");  
439 tree->Branch("ZNC_X_Centroid",&ZNC_XCent,"ZNC_XCent/D");
440 tree->Branch("ZNC_Y_Centroid",&ZNC_YCent,"ZNC_YCent/D");   
441 tree->Branch("ZNA_X_Centroid",&ZNA_XCent,"ZNA_XCent/D");
442 tree->Branch("ZNA_Y_Centroid",&ZNA_YCent,"ZNA_YCent/D");  
443 tree->Branch("ZNC_X_Centroid_Err",&ZNC_XCent_err,"ZNC_XCent_err/D");
444 tree->Branch("ZNC_Y_Centroid_Err",&ZNC_YCent_err,"ZNC_YCent_err/D");   
445 tree->Branch("ZNA_X_Centroid_Err",&ZNA_XCent_err,"ZNA_XCent_err/D");
446 tree->Branch("ZNA_Y_Centroid_Err",&ZNA_YCent_err,"ZNA_YCent_err/D");    
447 tree->Branch("ZN_TDC_Sum",&ZN_TDC_Sum,"ZN_TDC_Sum/D");
448 tree->Branch("ZN_TDC_Diff",&ZN_TDC_Diff,"ZN_TDC_Diff/D");    
449 tree->Branch("ZN_TDC_Sum_Err",&ZN_TDC_Sum_err,"ZN_TDC_Sum_err/D");
450 tree->Branch("ZN_TDC_Diff_Err",&ZN_TDC_Diff_err,"ZN_TDC_Diff_err/D");
451 tree->Fill();
452
453 list.Add(cZNC_Spectra);
454 list.Add(cZNA_Spectra);
455 list.Add(cZPC_Spectra);
456 list.Add(cZPA_Spectra);
457 list.Add(cZEM1_Spectra);
458 list.Add(cZEM2_Spectra);
459 list.Add(hznc);
460 list.Add(hzna);
461 list.Add(hzpc);  
462 list.Add(hzpa);
463 list.Add(hzem1);  
464 list.Add(hzem2);
465 list.Add(hzna_Xcentroid);   
466 list.Add(hzna_Ycentroid);
467 list.Add(hznc_Xcentroid);   
468 list.Add(hznc_Ycentroid);
469 list.Add(hzn_TDC_Sum);   
470 list.Add(hzn_TDC_Diff);
471
472 TFile * fout=new TFile(outfilename,"recreate");
473 fout->cd();
474 list.Write();
475 tree.Write();
476 fout->Close();
477
478 return 0;  
479     
480 }