Adding a reminder for coders
[u/mrichter/AliRoot.git] / ZDC / ZDCQAtrending.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <TROOT.h>
6 #include <Riostream.h>
7 #include <TClassTable.h>
8 #include <TStyle.h>
9 #include <TMath.h>
10 #include <TFile.h>
11 #include <TCanvas.h>
12 #include <TH1.h>
13 #include <TH2.h>
14 #include <TProfile.h>
15 #include <TLine.h>
16 #include <TGrid.h>
17 #include <TBits.h>
18 #include <TChain.h>
19 #include <TNtuple.h>
20 #include <TTree.h>
21 #include <TBranch.h>
22 #include <TFileMerger.h>
23 #include <TGridResult.h>
24 #include <TSystem.h>
25 #include <TLegend.h>
26
27 #endif
28
29 void MakePlots(TString ntupleFileName);
30
31 void ZDCQAtrending(TString period,
32                    TString recoPass,
33                    TString qaTrain = "QA",
34                    Bool_t useOnlyMerged = kTRUE,
35                    Int_t firstRun = 0,
36                    Int_t lastRun = 999999999,
37                    TString runListFile = "",
38                    TString fileName = "QAresults.root"){
39
40   gStyle->SetOptStat(0);
41
42   TGrid::Connect("alien:");
43   Int_t year = 0;
44   if(period.Contains("LHC09")) year = 2009;
45   else if(period.Contains("LHC10")) year = 2010;
46   else if(period.Contains("LHC11")) year = 2011;
47   
48   Bool_t useExternalList = kFALSE;
49   Int_t runList[10000];
50   Int_t totRuns  =  0;
51   if(runListFile.Length()>0){
52     if(!gSystem->Exec(Form("ls -l %s > /dev/null 2>&1",runListFile.Data()))){
53       printf("Use Run List from %s  --- runs to be analyzed:\n",runListFile.Data());
54       useExternalList = kTRUE;
55       FILE* rfil = fopen(runListFile.Data(),"r");
56       Int_t nrun;
57       while(!feof(rfil)){
58         fscanf(rfil,"%d, ",&nrun);
59         if(feof(rfil)) break;
60         runList[totRuns++] = nrun;
61       }
62       for(Int_t ir = 0; ir<totRuns; ir++){
63         printf("%d\n",runList[ir]);
64       }
65     }else{
66       printf("File with run list does not exist\n");
67     }
68   }
69
70   TString outFilNam = Form("ZDCtrend_%s_%s_%s.root",period.Data(),recoPass.Data(),qaTrain.Data());
71
72  
73   const Int_t nVariables = 27;
74   TNtuple* ntzdc = new TNtuple("ntzdc","ZDC trending",
75   "nrun:meanZNC:meanZPC:meanZNA:meanZPA:meanZEM1:meanZEM2:emeanZNC:emeanZPC:emeanZNA:emeanZPA:emeanZEM1:emeanZEM2:"
76   "ZNClg:ZNAlg:eZNClg:eZNAlg:pmcZNClg:pmcZNAlg:epmcZNClg:epmcZNAlg:xZNC:yZNC:xZNA:yZNA:tdcSum:tdcDiff");
77   Float_t xnt[nVariables];
78
79   TBits* readRun = new TBits(999999);
80   readRun->ResetAllBits();
81   if(!useExternalList){
82     if(!gSystem->Exec(Form("ls -l %s > /dev/null 2>&1",outFilNam.Data()))){
83       TFile* oldfil = new TFile(outFilNam.Data());
84       TNtuple* ntmp = (TNtuple*)oldfil->Get("ntzdc");
85       Bool_t isOK = kFALSE;
86       if(ntmp){
87         if(ntmp->GetNvar() == ntzdc->GetNvar()){
88           isOK = kTRUE;
89           TObjArray* arr1 = (TObjArray*)ntzdc->GetListOfBranches();
90           TObjArray* arr2 = (TObjArray*)ntmp->GetListOfBranches();
91           for(Int_t iV = 0; iV<ntmp->GetNvar(); iV++){
92             TString vnam1 = arr1->At(iV)->GetName();
93             TString vnam2 = arr2->At(iV)->GetName();
94             if(vnam1 != vnam2) isOK = kFALSE;
95             ntmp->SetBranchAddress(vnam2.Data(),&xnt[iV]);
96           }
97           if(isOK){
98             for(Int_t nE = 0; nE<ntmp->GetEntries(); nE++){
99               ntmp->GetEvent(nE);
100               Int_t theRun = (Int_t)(xnt[0]+0.0001);
101               readRun->SetBitNumber(theRun);
102               ntzdc->Fill(xnt);
103             }
104           }
105         }
106       }
107       if(!isOK){
108         printf("Ntuple in local file not OK -> will be recreated\n");
109       }
110       oldfil->Close();
111       delete oldfil;
112     }
113   }
114
115   if(!gGrid||!gGrid->IsConnected()) {
116     printf("gGrid not found! exit macro\n");
117     return;
118   }
119
120   TString  path = Form("/alice/data/%d/%s/",year,period.Data());
121   TGridResult *gr  =  gGrid->Query(path,fileName);
122   Int_t nFiles  =  gr->GetEntries();
123   printf(" --->%d files found\n", nFiles);
124   if (nFiles < 1) return;
125
126   Int_t nAnalyzedFiles = 0;
127   if(nFiles > 1){
128     for(Int_t iFil  =  0; iFil <nFiles ; iFil++) { 
129       TString fileNameLong = Form("%s",gr->GetKey(iFil,"turl"));
130       if(!fileNameLong.Contains(recoPass.Data())) continue;
131       if(!fileNameLong.Contains(qaTrain.Data())) continue;
132       if(fileNameLong.Contains("TRD") || fileNameLong.Contains("EMCAL")) continue;
133       TString runNumber = fileNameLong;
134       runNumber.ReplaceAll(Form("alien:///alice/data/%d/%s/",year,period.Data()),"");
135       runNumber.Remove(9,runNumber.Sizeof());
136    
137       Int_t iRun = atoi(runNumber.Data());
138       if(useExternalList){
139         Bool_t keepRun = kFALSE;
140         for(Int_t ir = 0; ir<totRuns; ir++){
141           if(iRun == runList[ir]){
142             keepRun = kTRUE;
143             break;
144           }
145         }
146         if(!keepRun) continue;
147       }
148       if(readRun->TestBitNumber(iRun)){ 
149         printf("Run %d already in local ntuple -> skipping it\n",iRun);
150         continue;
151       }
152       if(iRun<firstRun) continue;
153       if(iRun>lastRun) continue;    
154
155       if(useOnlyMerged){
156         TString isMerged = fileNameLong;
157         isMerged.Remove(isMerged.Sizeof()-16); 
158         isMerged.Remove(0,isMerged.Sizeof()-5);
159         if(!isMerged.Contains("QA")) continue;
160       }
161       printf("Open File %s  Run %d\n",fileNameLong.Data(),iRun);
162       
163
164       TFile* f = TFile::Open(fileNameLong.Data());  
165
166       TDirectoryFile* df = (TDirectoryFile*)f->Get("ZDC_Performance");
167       if(!df){
168         printf("Run %d ZDC_Performance MISSING -> Exit\n",iRun);
169         continue;
170       }
171       TList* l = (TList*)df->Get("QAZDCHists");
172       if(!df){
173         printf("Run %d QAZDCHists TList MISSING -> Exit\n",iRun);
174         continue;
175       }  
176
177       nAnalyzedFiles++;
178       if(!useOnlyMerged) readRun->SetBitNumber(iRun);
179
180       TH1F *fhTDCZNSum     = (TH1F*)l->FindObject("fhTDCZNSum");     
181       TH1F *fhTDCZNDiff    = (TH1F*)l->FindObject("fhTDCZNDiff");    
182       TH1F *fhZNCSpectrum  = (TH1F*)l->FindObject("fhZNCSpectrum");  
183       TH1F *fhZNASpectrum  = (TH1F*)l->FindObject("fhZNASpectrum");  
184       TH1F *fhZPCSpectrum  = (TH1F*)l->FindObject("fhZPCSpectrum");  
185       TH1F *fhZPASpectrum  = (TH1F*)l->FindObject("fhZPASpectrum");  
186       TH1F *fhZEM1Spectrum = (TH1F*)l->FindObject("fhZEM1Spectrum"); 
187       TH1F *fhZEM2Spectrum = (TH1F*)l->FindObject("fhZEM2Spectrum"); 
188       /*TH1F *fhZNCpmc   = (TH1F*)l->FindObject("fhZNCpmc");   
189       TH1F *fhZNApmc   = (TH1F*)l->FindObject("fhZNApmc");   
190       TH1F *fhZPCpmc   = (TH1F*)l->FindObject("fhZPCpmc");   
191       TH1F *fhZPApmc   = (TH1F*)l->FindObject("fhZPApmc");*/   
192       TH2F *fhZNCCentroid  = (TH2F*)l->FindObject("fhZNCCentroid");  
193       TH2F *fhZNACentroid  = (TH2F*)l->FindObject("fhZNACentroid");   
194       TH1F *fhZNCemd   = (TH1F*)l->FindObject("fhZNCemd");   
195       TH1F *fhZNAemd   = (TH1F*)l->FindObject("fhZNAemd");   
196       TH1F *fhPMCZNCemd    = (TH1F*)l->FindObject("fhPMCZNCemd");    
197       TH1F *fhPMCZNAemd    = (TH1F*)l->FindObject("fhPMCZNAemd");    
198  
199       TH1D *hxZNC = fhZNCCentroid->ProjectionX("hxZNC");
200       TH1D *hyZNC = fhZNCCentroid->ProjectionY("hyZNC");
201       TH1D *hxZNA = fhZNACentroid->ProjectionX("hxZNA");
202       TH1D *hyZNA = fhZNACentroid->ProjectionY("hyZNA");
203       
204       Int_t index = 0;
205       xnt[index++] = (Float_t)iRun;
206       xnt[index++] = fhZNCSpectrum->GetMean();
207       xnt[index++] = fhZPCSpectrum->GetMean();
208       xnt[index++] = fhZNASpectrum->GetMean();
209       xnt[index++] = fhZPASpectrum->GetMean();
210       xnt[index++] = fhZEM1Spectrum->GetMean();
211       xnt[index++] = fhZEM2Spectrum->GetMean();
212       if(fhZNCSpectrum->GetEntries()>0)  xnt[index++] = fhZNCSpectrum->GetMean()/fhZNCSpectrum->GetEntries();
213       if(fhZPCSpectrum->GetEntries()>0)  xnt[index++] = fhZPCSpectrum->GetMean()/fhZPCSpectrum->GetEntries();
214       if(fhZNASpectrum->GetEntries()>0)  xnt[index++] = fhZNASpectrum->GetMean()/fhZNASpectrum->GetEntries();
215       if(fhZPASpectrum->GetEntries()>0)  xnt[index++] = fhZPASpectrum->GetMean()/fhZPASpectrum->GetEntries();
216       if(fhZEM1Spectrum->GetEntries()>0) xnt[index++] = fhZEM1Spectrum->GetMean()/fhZEM1Spectrum->GetEntries();
217       if(fhZEM2Spectrum->GetEntries()>0) xnt[index++] = fhZEM2Spectrum->GetMean()/fhZEM2Spectrum->GetEntries();
218       xnt[index++] = fhZNCemd->GetMean();
219       xnt[index++] = fhZNAemd->GetMean();
220       if(fhZNCemd->GetEntries()>0) xnt[index++] = fhZNCemd->GetMean()/fhZNCemd->GetEntries();
221       if(fhZNAemd->GetEntries()>0) xnt[index++] = fhZNAemd->GetMean()/fhZNAemd->GetEntries();
222       xnt[index++] = fhPMCZNCemd->GetMean();
223       xnt[index++] = fhPMCZNAemd->GetMean();
224       if(fhPMCZNCemd->GetEntries()>0) xnt[index++] = fhPMCZNCemd->GetMean()/fhPMCZNCemd->GetEntries();
225       if(fhPMCZNAemd->GetEntries()>0) xnt[index++] = fhPMCZNAemd->GetMean()/fhPMCZNAemd->GetEntries();
226       xnt[index++] = hxZNC->GetMean();
227       xnt[index++] = hyZNC->GetMean();
228       xnt[index++] = hxZNA->GetMean();
229       xnt[index++] = hyZNA->GetMean();
230       xnt[index++] = fhTDCZNSum->GetMean();
231       xnt[index++] = fhTDCZNDiff->GetMean();
232       ntzdc->Fill(xnt);
233     }
234   }
235   printf("Number of analyzed files  =  %d\n",nAnalyzedFiles);
236
237   if(nAnalyzedFiles>0){
238     TFile* outfil = new TFile(outFilNam.Data(),"recreate");
239     outfil->cd();
240     ntzdc->Write();
241     outfil->Close();
242     
243     MakePlots(outFilNam);
244   }
245 }
246
247 void MakePlots(TString ntupleFileName){
248   TFile* fil = new TFile(ntupleFileName.Data(),"read");
249   if(!fil){
250     printf("File with ntuple does not exist\n");
251     return;
252   }
253   TNtuple* ntzdc = (TNtuple*)fil->Get("ntzdc");
254
255   Float_t nrun;
256   Float_t meanZNC,meanZPC,meanZNA,meanZPA,meanZEM1,meanZEM2;
257   Float_t emeanZNC,emeanZPC,emeanZNA,emeanZPA,emeanZEM1,emeanZEM2;
258   Float_t ZNClg,ZNAlg,pmcZNClg,pmcZNAlg;
259   Float_t eZNClg,eZNAlg,epmcZNClg,epmcZNAlg;
260   Float_t xZNC,yZNC,xZNA,yZNA,tdcSum,tdcDiff;
261   
262   ntzdc->SetBranchAddress("nrun",&nrun);
263   ntzdc->SetBranchAddress("meanZNC",&meanZNC);
264   ntzdc->SetBranchAddress("meanZPC",&meanZPC);
265   ntzdc->SetBranchAddress("meanZNA",&meanZNA);
266   ntzdc->SetBranchAddress("meanZPA",&meanZPA);
267   ntzdc->SetBranchAddress("meanZEM1",&meanZEM1);
268   ntzdc->SetBranchAddress("meanZEM2",&meanZEM2);
269   ntzdc->SetBranchAddress("emeanZNC",&emeanZNC);
270   ntzdc->SetBranchAddress("emeanZPC",&emeanZPC);
271   ntzdc->SetBranchAddress("emeanZNA",&emeanZNA);
272   ntzdc->SetBranchAddress("emeanZPA",&emeanZPA);
273   ntzdc->SetBranchAddress("emeanZEM1",&emeanZEM1);
274   ntzdc->SetBranchAddress("emeanZEM2",&emeanZEM2);
275   ntzdc->SetBranchAddress("ZNClg",&ZNClg);
276   ntzdc->SetBranchAddress("ZNAlg",&ZNAlg);
277   ntzdc->SetBranchAddress("eZNClg",&eZNClg);
278   ntzdc->SetBranchAddress("eZNAlg",&eZNAlg);
279   ntzdc->SetBranchAddress("pmcZNClg",&pmcZNClg);
280   ntzdc->SetBranchAddress("pmcZNAlg",&pmcZNAlg);
281   ntzdc->SetBranchAddress("epmcZNClg",&epmcZNClg);
282   ntzdc->SetBranchAddress("epmcZNAlg",&epmcZNAlg);
283   ntzdc->SetBranchAddress("xZNC",&xZNC);
284   ntzdc->SetBranchAddress("yZNC",&yZNC);
285   ntzdc->SetBranchAddress("xZNA",&xZNA);
286   ntzdc->SetBranchAddress("yZNA",&yZNA);
287   ntzdc->SetBranchAddress("tdcSum",&tdcSum);
288   ntzdc->SetBranchAddress("tdcDiff",&tdcDiff);
289
290   TH1F *hznc      = new TH1F("hznc","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
291   TH1F *hzna      = new TH1F("hzna","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
292   TH1F *hzpc      = new TH1F("hzpc","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
293   TH1F *hzpa      = new TH1F("hzpa","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
294   TH1F *hzem1     = new TH1F("hzem1","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
295   TH1F *hzem2     = new TH1F("hzem2","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
296   TH1F *hznclg    = new TH1F("hznclg","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
297   TH1F *hznalg    = new TH1F("hznalg","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
298   TH1F *hpmcznclg = new TH1F("hpmcznclg","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
299   TH1F *hpmcznalg = new TH1F("hpmcznalg","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
300   TH1F *hxznc     = new TH1F("hxznc","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
301   TH1F *hyznc     = new TH1F("hyznc","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
302   TH1F *hxzna     = new TH1F("hxzna","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
303   TH1F *hyzna     = new TH1F("hyzna","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
304   TH1F *htdcsum   = new TH1F("htdcsum","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
305   TH1F *htdcdiff  = new TH1F("htdcdiff","",(Int_t)ntzdc->GetEntries(),0.,ntzdc->GetEntries());
306
307   for(Int_t i = 0; i<ntzdc->GetEntries();i++){
308     ntzdc->GetEvent(i);
309     //
310     hznc->SetBinContent(i+1, meanZNC);
311     hznc->SetBinError(i+1, emeanZNC);
312     hznc->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
313     hznc->GetXaxis()->SetTitle("RUN #");
314     hznc->GetYaxis()->SetTitle("ZNC mean signal");
315     hzpc->SetBinContent(i+1, meanZPC);
316     hzpc->SetBinError(i+1, emeanZPC);
317     hzpc->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
318     hzpc->GetXaxis()->SetTitle("RUN #");
319     hzpc->GetYaxis()->SetTitle("ZPC mean signal");
320     hzna->SetBinContent(i+1, meanZNA);
321     hzna->SetBinError(i+1, emeanZNA);
322     hzna->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
323     hzna->GetXaxis()->SetTitle("RUN #");
324     hzna->GetYaxis()->SetTitle("ZNA mean signal");
325     hzpa->SetBinContent(i+1, meanZPA);
326     hzpa->SetBinError(i+1, emeanZPA);
327     hzpa->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
328     hzpa->GetXaxis()->SetTitle("RUN #");
329     hzpa->GetYaxis()->SetTitle("ZPA mean signal");
330     hzem1->SetBinContent(i+1, meanZEM1);
331     hzem1->SetBinError(i+1, emeanZEM1);
332     hzem1->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
333     hzem1->GetXaxis()->SetTitle("RUN #");
334     hzem1->GetYaxis()->SetTitle("ZEM1 mean signal");
335     hzem2->SetBinContent(i+1, meanZEM2);
336     hzem2->SetBinError(i+1, emeanZEM2);
337     hzem2->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
338     hzem2->GetXaxis()->SetTitle("RUN #");
339     hzem2->GetYaxis()->SetTitle("ZEM1 mean signal");
340     hznclg->SetBinContent(i+1, ZNClg);
341     hznclg->SetBinError(i+1, eZNClg);
342     hznclg->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
343     hznclg->GetXaxis()->SetTitle("RUN #");
344     hznclg->GetYaxis()->SetTitle("ZNC LG mean signal");
345     hznalg->SetBinContent(i+1, ZNAlg);
346     hznalg->SetBinError(i+1, eZNAlg);
347     hznalg->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
348     hznalg->GetXaxis()->SetTitle("RUN #");
349     hznalg->GetYaxis()->SetTitle("ZNA LG mean signal");
350     hpmcznclg->SetBinContent(i+1, pmcZNClg);
351     hpmcznclg->SetBinError(i+1, epmcZNClg);
352     hpmcznclg->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
353     hpmcznclg->GetXaxis()->SetTitle("RUN #");
354     hpmcznclg->GetYaxis()->SetTitle("ZNC LG PMC mean signal");
355     hpmcznalg->SetBinContent(i+1, pmcZNAlg);
356     hpmcznalg->SetBinError(i+1, epmcZNAlg);
357     hpmcznalg->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
358     hpmcznalg->GetXaxis()->SetTitle("RUN #");
359     hpmcznalg->GetYaxis()->SetTitle("ZNC LG PMC mean signal");
360     hxznc->SetBinContent(i+1, xZNC);
361     hxznc->SetBinError(i+1, 0.1*xZNC);
362     hxznc->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
363     hxznc->GetXaxis()->SetTitle("RUN #");
364     hxznc->GetYaxis()->SetTitle("X_{ZN} (cm)");
365     hyznc->SetBinContent(i+1, yZNC);
366     hyznc->SetBinError(i+1, 0.1*yZNC);
367     hyznc->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
368     hyznc->GetXaxis()->SetTitle("RUN #");
369     hyznc->GetYaxis()->SetTitle("Y_{ZN} (cm)");
370     hxzna->SetBinContent(i+1, xZNA);
371     hxzna->SetBinError(i+1, 0.1*xZNA);
372     hxzna->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
373     hxzna->GetXaxis()->SetTitle("RUN #");
374     hxzna->GetYaxis()->SetTitle("X_{ZN} (cm)");
375     hyzna->SetBinContent(i+1, yZNA);
376     hyzna->SetBinError(i+1, 0.1*yZNA);
377     hyzna->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
378     hyzna->GetXaxis()->SetTitle("RUN #");
379     hyzna->GetYaxis()->SetTitle("Y_{ZN} (cm)");
380     htdcsum->SetBinContent(i+1, tdcSum);
381     htdcsum->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
382     htdcsum->GetXaxis()->SetTitle("RUN #");
383     htdcsum->GetYaxis()->SetTitle("TDC Sum (ns)");
384     htdcdiff->SetBinContent(i+1, tdcDiff);
385     htdcdiff->GetXaxis()->SetBinLabel(i+1,Form("%d",(Int_t)nrun));
386     htdcdiff->GetXaxis()->SetTitle("RUN #");
387     htdcdiff->GetYaxis()->SetTitle("TDC Diff (ns)");
388   }
389
390   TCanvas *c1 = new TCanvas("c1", "Mean value ZNs", 0, 0, 1200, 1000);
391   c1->Divide(1,2);
392   //
393   c1->cd(1); 
394   hznc->SetMarkerColor(kAzure+6); hznc->SetLineColor(kAzure+6); 
395   hznc->SetMarkerStyle(21);
396   hznc->Draw(""); 
397   hzna->SetMarkerColor(kPink-2);  hzna->SetLineColor(kPink-2);
398   hzna->SetMarkerStyle(20);
399   hzna->Draw("SAME"); 
400   //
401   TLegend *l1 = new TLegend(0.44,0.18,0.54,0.32);
402   l1->SetFillColor(kWhite);
403   l1->AddEntry(hznc," ZNC " ,"P");
404   l1->AddEntry(hzna," ZNA " ,"P");
405   l1->Draw("");
406   //
407   c1->cd(2);
408   hznalg->SetMarkerColor(kBlue+1); hznalg->SetLineColor(kBlue+1); 
409   hznalg->SetMarkerStyle(20);  hznalg->SetMinimum(0);
410   hznalg->Draw("");
411   hznclg->SetMarkerColor(kPink+5); hznclg->SetLineColor(kPink+5); 
412   hznclg->SetMarkerStyle(21);
413   hznclg->Draw("SAME"); 
414   //
415   TLegend *l2 = new TLegend(0.44,0.18,0.54,0.32);
416   l2->SetFillColor(kWhite);
417   l2->AddEntry(hznc," ZNC LG " ,"P");
418   l2->AddEntry(hzna," ZNA LG " ,"P");
419   l2->Draw("");
420   
421
422   TCanvas *c1b = new TCanvas("c1b", "Mean value ZEMs ZPs", 200, 0, 1200, 1000);
423   c1b->Divide(1,2);
424   c1b->cd(1); 
425   hzpc->SetMarkerColor(kAzure+6); hzpc->SetLineColor(kAzure+6); 
426   hzpc->SetMarkerStyle(21);
427   hzpc->Draw(""); 
428   hzpa->SetMarkerColor(kPink-2);  hzpa->SetLineColor(kPink-2);
429   hzpa->SetMarkerStyle(20);
430   hzpa->Draw("SAME"); 
431   //
432   TLegend *l3 = new TLegend(0.44,0.18,0.54,0.32);
433   l3->SetFillColor(kWhite);
434   l3->AddEntry(hzpc," ZPC " ,"P");
435   l3->AddEntry(hzpa," ZPA " ,"P");
436   l3->Draw("");
437   
438   c1b->cd(2);
439   hzem1->SetMarkerColor(kTeal-7); hzem1->SetLineColor(kTeal-7);
440   hzem1->SetMarkerStyle(29);
441   hzem2->SetMarkerColor(kTeal+5); hzem2->SetLineColor(kTeal+5);
442   hzem2->SetMarkerStyle(30);
443   hzem2->Draw(""); 
444   hzem1->Draw("SAME"); 
445   //
446   TLegend *l4 = new TLegend(0.44,0.18,0.54,0.32);
447   l4->SetFillColor(kWhite);
448   l4->AddEntry(hzem1," ZEM1 " ,"P");
449   l4->AddEntry(hzem2," ZEM2 " ,"P");
450   l4->Draw("");
451  
452   
453   /*TCanvas *c2 = new TCanvas("c2", "ZN centroids", 400, 400, 1200, 1000);
454   c2->Divide(1,2);
455   //
456   c2->cd(1);
457   hxznc->SetMarkerColor(kAzure+5); hxznc->SetLineColor(kAzure+5);
458   hxznc->SetMarkerStyle(21); 
459   hxzna->SetMarkerColor(kPink+5); hxzna->SetLineColor(kPink+5);
460   hxzna->SetMarkerStyle(20); 
461   hxznc->Draw(""); 
462   hxzna->Draw("SAME");
463   c2->cd(2);
464   hyznc->SetMarkerColor(kAzure+5); hyznc->SetLineColor(kAzure+5);
465   hyznc->SetMarkerStyle(21); 
466   hyzna->SetMarkerColor(kPink+5); hyzna->SetLineColor(kPink+5);
467   hyzna->SetMarkerStyle(20); 
468   hyznc->Draw(""); 
469   hyzna->Draw("SAME");*/
470
471   
472   TCanvas *c3 = new TCanvas("c3", "LG signals", 600, 0, 1200, 1000);
473   c3->Divide(1,2);
474   //
475   c3->cd(1);
476   hznalg->SetMarkerColor(kBlue+1); hznalg->SetLineColor(kBlue+1); 
477   hznalg->SetMarkerStyle(20);
478   hznalg->Draw(""); 
479   hznclg->SetMarkerColor(kPink+5); hznclg->SetLineColor(kPink+5); 
480   hznclg->SetMarkerStyle(21);
481   hznclg->Draw("SAME"); 
482   TLegend *l7 = new TLegend(0.44,0.18,0.54,0.32);
483   l7->SetFillColor(kWhite);
484   l7->AddEntry(hznclg," ZNC LG " ,"P");
485   l7->AddEntry(hznalg," ZNA LG " ,"P");
486   l7->Draw("");
487   //
488   c3->cd(2);
489   hpmcznalg->SetMarkerColor(kAzure+7); hpmcznalg->SetLineColor(kAzure+7); 
490   hpmcznalg->SetMarkerStyle(20); hpmcznalg->SetMinimum(0);
491   hpmcznalg->Draw(""); 
492   hpmcznclg->SetMarkerColor(kPink+6); hpmcznclg->SetLineColor(kPink+6); 
493   hpmcznclg->SetMarkerStyle(21);
494   hpmcznclg->Draw("SAME"); 
495   TLegend *l8 = new TLegend(0.44,0.15,0.58,0.32);
496   l8->SetFillColor(kWhite);
497   l8->AddEntry(hpmcznclg," ZNC LG PMC" ,"P");
498   l8->AddEntry(hpmcznalg," ZNA LG PMC" ,"P");
499   l8->Draw("");
500 }