Updated directory names on LDC in SDD calibration plotting macro (Mario Sitta)
[u/mrichter/AliRoot.git] / ITS / macrosSDD / TrendQASDD.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TFile.h>
3 #include <TFileMerger.h>
4 #include <TAlienFile.h>
5 //#include <TExec.h>
6 #include <TSystem.h>
7 #include <TGrid.h>
8 #include <TGridResult.h>
9 #include <Riostream.h>
10 #include <TObjArray.h>
11 #include <TClass.h>
12 #include <TH1F.h>
13 #include <TStyle.h>
14 #include <TCanvas.h>
15 #include <TLegend.h>
16 #include <TMath.h>
17 #include <TROOT.h>
18 #endif
19 void TrendQASDD( Char_t filelist[150]="LHC10b.txt", Char_t filename[20]="FileQAtrend",Char_t pass[7]="pass1",Int_t year=2010, Char_t period[7]="LHC10b", Bool_t kDOSuperimpose=kFALSE,Bool_t kUseOriginalFile=kFALSE , Char_t especiename[50]="LowMultiplicity")
20 {
21   gROOT->SetStyle("Plain");
22   Int_t  m;
23   vector<Int_t> n;
24   //Char_t FileName[200];//="/home/msicilia/Desktop/createlists";
25   char FileName[150];
26   Char_t FileName1[150];
27   sprintf(FileName1,"%s",filelist);
28   FILE * pFile;
29   pFile = fopen (FileName1,"r");
30   while (fscanf (pFile,"%d\n",&m)==1){
31     
32     if(kUseOriginalFile)sprintf(FileName,"run%d/%s/File.QA.%d.%s.%s.Run.%d.root",m,pass,year,period,pass,m);
33     else sprintf(FileName, "run%d/%s/%s.root", m,pass,filename);
34     if(gSystem->Exec(Form("ls %s >/dev/null 2>&1", FileName))==0){
35       TFile mergedfile(FileName);
36       if(kUseOriginalFile){
37       if(mergedfile.GetKey("ITS")==0x0){
38         printf("Run %d, In this run ITS QA has not been executed.-- Exit file\n",m);
39         continue;
40       }
41       else {n.push_back(m);} //this is to grow the vector
42       }else {n.push_back(m);}
43     }
44     else{printf("Run %d,: no file %s present -- Continue\n",m, FileName);continue;}
45   }
46   fclose (pFile);
47   
48   Char_t filepath[200];
49
50   char name[100];
51   char title[100];
52
53   TH1F *histocharge;
54   TH1F *histochargerp;
55
56   sprintf(name,"histoRAWeventtrend");
57   sprintf(title,"Events used for the QA analysis - RAW");
58   TH1F *histoRAWeventtrend=new TH1F(name,title,n.size(),0.,(float)n.size());
59   histoRAWeventtrend->GetXaxis()->SetTitle("# Run");
60   histoRAWeventtrend->GetXaxis()->SetTicks("-");
61   histoRAWeventtrend->GetXaxis()->SetLabelSize(0.02);
62   histoRAWeventtrend->GetXaxis()->SetTitleSize(0.02);
63   histoRAWeventtrend->GetXaxis()->SetTitleOffset(-2.);
64   histoRAWeventtrend->GetXaxis()->SetTickLength(0.01);
65   histoRAWeventtrend->GetYaxis()->SetTitle("Events");
66   histoRAWeventtrend->GetYaxis()->SetLabelSize(0.02);
67   histoRAWeventtrend->GetYaxis()->SetTitleSize(0.02);
68   histoRAWeventtrend->GetYaxis()->SetTitleOffset(1.5);
69   histoRAWeventtrend->SetMarkerStyle(20);
70   histoRAWeventtrend->SetMarkerColor(1);
71
72   sprintf(name,"histoRPeventtrend");
73   sprintf(title,"Events used for the QA analysis - RP");
74   TH1F *histoRPeventtrend=new TH1F(name,title,n.size(),0.,(float)n.size());
75   histoRPeventtrend->GetXaxis()->SetTitle("# Run");
76   histoRPeventtrend->GetXaxis()->SetTicks("-");
77   histoRPeventtrend->GetXaxis()->SetLabelSize(0.02);
78   histoRPeventtrend->GetXaxis()->SetTitleSize(0.02);
79   histoRPeventtrend->GetXaxis()->SetTitleOffset(-2.);
80   histoRPeventtrend->GetXaxis()->SetTickLength(0.01);
81   histoRPeventtrend->GetYaxis()->SetTitle("Events");
82   histoRPeventtrend->GetYaxis()->SetLabelSize(0.02);
83   histoRPeventtrend->GetYaxis()->SetTitleSize(0.02);
84   histoRPeventtrend->GetYaxis()->SetTitleOffset(1.5);
85   histoRPeventtrend->SetMarkerStyle(24);
86   histoRPeventtrend->SetMarkerColor(4);
87
88
89   TH1F *histoRAWnormevents[3];
90   TH1F *histoRPnormevents[3];
91   
92   TH1F *histoRAWfilledmodules[3];
93   TH1F *histoRPfilledmodules[3];
94
95   TH1F *histoRAWfilleddr[3];
96   TH1F *histoRPfilleddr[3];
97
98   TH1F *histoRAWactivemodules[3];
99   TH1F *histoRPactivemodules[3];
100
101   TH1F *histoRAWactivedr[3];
102   TH1F *histoRPactivedr[3];
103
104   TH1F *histoRAWoverthmodules[3];
105   TH1F *histoRPoverthmodules[3];
106
107   TH1F *histoRAWoverthdr[3];
108   TH1F *histoRPoverthdr[3];
109
110   TH1F *histochargetrend[2];
111   TH1F *historadiustrend[2];
112   
113
114   //index on the histograms
115
116   Int_t event=1;
117   Int_t normevtRAW[3]={2,3,4};
118   Int_t normevtRP[3]={2,3,4};
119
120   Int_t filledmodRAW[3]={6,20,34};
121   Int_t filledmodRP[3] ={6,20,36};
122
123   Int_t filleddrRAW[3]={8,22,36};
124   Int_t filleddrRP[3] ={8,22,38};
125
126   Int_t activemodRAW[3]={5,19,33};
127   Int_t activemodRP[3] ={5,19,35};
128
129   Int_t activedrRAW[3]={7,21,35};
130   Int_t activedrRP[3] ={7,21,37};
131
132   Int_t overthmodRAW[3]={17,31,45};
133   Int_t overthmodRP[3] ={17,33,49};
134
135   Int_t overthdrRAW[3]={18,32,46};
136   Int_t overthdrRP[3] ={18,34,50};
137
138   Int_t chargeindex[2]={31,47};
139   Int_t radiusindex[2]={32,48};
140
141   const TString histoname[3]={"Total","Layer 3","Layer 4"};
142   const TString histolegend[3]={"All","Layer 3","Layer 4"};
143   const TString histolegend2[2]={"Filled","Active"};
144   const TString histolegend3[2]={"Raw","RecPoints"};
145
146   const TString drawoptionevents[3]={"P","PSAME","PSAME"};
147   const TString drawoptionfill[3]={"P","P","PSAME"};
148   const TString drawoptionactive[3]={"PSAME","PSAME","PSAME"};
149
150   TLegend *legend =new TLegend(0.83,0.8,0.97,0.2);
151   TLegend *legend2=new TLegend(0.83,0.8,0.97,0.2);
152   TLegend *legendevents=new TLegend(0.83,01.,0.97,0.9);
153   TLegend *legendchecks =new TLegend(0.83,1.,0.97,0.9);
154   TLegend *legendchecks2 =new TLegend(0.83,1.,0.97,0.9);
155   TLegend *legendchecks3 =new TLegend(0.83,1.,0.97,0.9);
156   TLegend *legendchecks4 =new TLegend(0.83,1.,0.97,0.9);
157
158   Char_t runnmbr[20];
159   Float_t fmax[2];
160   for(Int_t i=0;i<2;i++)fmax[i]=0;
161   Float_t fmaxold=0;
162   Float_t fmaxmargin[2];
163   for(Int_t i=0;i<2;i++)fmaxmargin[i]=0;
164
165   Float_t fmaxtime=0;
166   Float_t fmaxoldtime=0;
167   Float_t fmaxmargintime[2];
168   for(Int_t i=0;i<2;i++)fmaxmargintime[i]=0;
169
170   Int_t j=0;
171   Int_t hh=0;
172
173   for(Int_t ii=0;ii<3;ii++)
174
175     {
176       sprintf(name,"histoRAWnormevent%d", ii);
177       sprintf(title,"Trend of the Norm Events  %s RAW",histoname[ii].Data());
178       histoRAWnormevents[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
179       histoRAWnormevents[ii]->SetStats(0);
180       histoRAWnormevents[ii]->SetMinimum(0.);
181       histoRAWnormevents[ii]->GetXaxis()->SetTitle("# Run");
182       histoRAWnormevents[ii]->GetXaxis()->SetTicks("-");
183       histoRAWnormevents[ii]->GetXaxis()->SetLabelSize(0.02);
184       histoRAWnormevents[ii]->GetXaxis()->SetTitleSize(0.02);
185       histoRAWnormevents[ii]->GetXaxis()->SetTitleOffset(-2.);
186       histoRAWnormevents[ii]->GetXaxis()->SetTickLength(0.01);
187       histoRAWnormevents[ii]->GetYaxis()->SetTitle("entries/(goodch*totevents)");
188       histoRAWnormevents[ii]->GetYaxis()->SetLabelSize(0.02);
189       histoRAWnormevents[ii]->GetYaxis()->SetTitleSize(0.02);
190       histoRAWnormevents[ii]->GetYaxis()->SetTitleOffset(1.5);
191       histoRAWnormevents[ii]->SetMarkerStyle(20+ii);
192       histoRAWnormevents[ii]->SetMarkerColor(1+ii);
193
194       sprintf(name,"histoRPnormevent%d", ii);
195       sprintf(title,"Trend of the Norm Events  %s RP", histoname[ii].Data());
196       histoRPnormevents[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
197       histoRPnormevents[ii]->SetStats(0);
198       histoRPnormevents[ii]->SetMinimum(0.);
199       histoRPnormevents[ii]->GetXaxis()->SetTitle("# Run");
200       histoRPnormevents[ii]->GetXaxis()->SetTicks("-");
201       histoRPnormevents[ii]->GetXaxis()->SetLabelSize(0.02);
202       histoRPnormevents[ii]->GetXaxis()->SetTickLength(0.01);
203       histoRPnormevents[ii]->GetXaxis()->SetTitleSize(0.02);
204       histoRPnormevents[ii]->GetXaxis()->SetTitleOffset(-2.);
205       histoRPnormevents[ii]->GetYaxis()->SetTitle("entries/(goodch*totevents)");
206       histoRPnormevents[ii]->GetYaxis()->SetLabelSize(0.02);
207       histoRPnormevents[ii]->GetYaxis()->SetTitleSize(0.02);
208       histoRPnormevents[ii]->GetYaxis()->SetTitleOffset(1.5);
209       histoRPnormevents[ii]->SetMarkerStyle(20+ii);
210       histoRPnormevents[ii]->SetMarkerColor(1+ii);
211
212
213       sprintf(name,"histoRAWfilledmodules%d", ii);
214       sprintf(title,"Trend of the filled modules %s RAW", histoname[ii].Data());
215       histoRAWfilledmodules[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
216       histoRAWfilledmodules[ii]->SetStats(0);
217       histoRAWfilledmodules[ii]->SetMaximum(272.);
218       histoRAWfilledmodules[ii]->SetMinimum(-1.);
219       histoRAWfilledmodules[ii]->GetXaxis()->SetTitle("# Run");
220       histoRAWfilledmodules[ii]->GetXaxis()->SetTicks("-");
221       histoRAWfilledmodules[ii]->GetXaxis()->SetLabelSize(0.02);
222       histoRAWfilledmodules[ii]->GetXaxis()->SetTickLength(0.01);
223       histoRAWfilledmodules[ii]->GetXaxis()->SetTitleSize(0.02);
224       histoRAWfilledmodules[ii]->GetXaxis()->SetTitleOffset(-2.);
225       histoRAWfilledmodules[ii]->GetYaxis()->SetTitle("modules");
226       histoRAWfilledmodules[ii]->GetYaxis()->SetLabelSize(0.02);
227       histoRAWfilledmodules[ii]->GetYaxis()->SetTitleSize(0.02);
228       histoRAWfilledmodules[ii]->GetYaxis()->SetTitleOffset(1.5);
229       histoRAWfilledmodules[ii]->SetMarkerStyle(20+ii);
230       histoRAWfilledmodules[ii]->SetMarkerColor(1+ii);
231
232       sprintf(name,"histoRPfilledmodules%d", ii);
233       sprintf(title,"Trend of the filled modules %s RP",  histoname[ii].Data());
234       histoRPfilledmodules[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
235       histoRPfilledmodules[ii]->GetXaxis()->SetTitle("# Run");
236       histoRPfilledmodules[ii]->SetStats(0);
237       histoRPfilledmodules[ii]->SetMaximum(272.);
238       histoRPfilledmodules[ii]->SetMinimum(-1.);
239       histoRPfilledmodules[ii]->GetXaxis()->SetTicks("-");
240       histoRPfilledmodules[ii]->GetYaxis()->SetTitle("modules");
241       histoRPfilledmodules[ii]->GetXaxis()->SetLabelSize(0.02);
242       histoRPfilledmodules[ii]->GetXaxis()->SetTickLength(0.01);
243       histoRPfilledmodules[ii]->GetXaxis()->SetTitleSize(0.02);
244       histoRPfilledmodules[ii]->GetXaxis()->SetTitleOffset(-2.);
245       histoRPfilledmodules[ii]->GetYaxis()->SetLabelSize(0.02);
246       histoRPfilledmodules[ii]->GetYaxis()->SetTitleSize(0.02);
247       histoRPfilledmodules[ii]->GetYaxis()->SetTitleOffset(1.5);
248       histoRPfilledmodules[ii]->SetMarkerStyle(20+ii);
249       histoRPfilledmodules[ii]->SetMarkerColor(1+ii);
250
251       sprintf(name,"histoRAWfilleddr%d", ii);
252       sprintf(title,"Trend of the filled drift regions %s RAW",  histoname[ii].Data());
253       histoRAWfilleddr[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
254       histoRAWfilleddr[ii]->GetXaxis()->SetTitle("# Run");
255       histoRAWfilleddr[ii]->SetStats(0);
256       histoRAWfilleddr[ii]->SetMaximum(272.);
257       histoRAWfilleddr[ii]->SetMinimum(-1.);
258       histoRAWfilleddr[ii]->GetXaxis()->SetTicks("-");
259       histoRAWfilleddr[ii]->GetXaxis()->SetLabelSize(0.02);
260       histoRAWfilleddr[ii]->GetXaxis()->SetTickLength(0.01);
261       histoRAWfilleddr[ii]->GetXaxis()->SetTitleSize(0.02);
262       histoRAWfilleddr[ii]->GetXaxis()->SetTitleOffset(-2.);
263       histoRAWfilleddr[ii]->GetYaxis()->SetTitle("Drift Regions");
264       histoRAWfilleddr[ii]->GetYaxis()->SetLabelSize(0.02);
265       histoRAWfilleddr[ii]->GetYaxis()->SetTitleSize(0.02);
266       histoRAWfilleddr[ii]->GetYaxis()->SetTitleOffset(1.5);
267       histoRAWfilleddr[ii]->SetMarkerStyle(20+ii);
268       histoRAWfilleddr[ii]->SetMarkerColor(1+ii);
269
270       sprintf(name,"histoRPfilleddr%d", ii);
271       sprintf(title,"Trend of the filled drift regions %s RP", histoname[ii].Data());
272       histoRPfilleddr[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
273       histoRPfilleddr[ii]->SetStats(0);
274       histoRPfilleddr[ii]->SetMaximum(272.);
275       histoRPfilleddr[ii]->SetMinimum(-1.);
276       histoRPfilleddr[ii]->GetXaxis()->SetTitle("# Run");
277       histoRPfilleddr[ii]->GetXaxis()->SetTicks("-");
278       histoRPfilleddr[ii]->GetXaxis()->SetLabelSize(0.02);
279       histoRPfilleddr[ii]->GetXaxis()->SetTickLength(0.01);
280       histoRPfilleddr[ii]->GetXaxis()->SetTitleSize(0.02);
281       histoRPfilleddr[ii]->GetXaxis()->SetTitleOffset(-2.);
282       histoRPfilleddr[ii]->GetYaxis()->SetTitle("Drift Regions");
283       histoRPfilleddr[ii]->GetYaxis()->SetLabelSize(0.02);
284       histoRPfilleddr[ii]->GetYaxis()->SetTitleSize(0.02);
285       histoRPfilleddr[ii]->GetYaxis()->SetTitleOffset(1.5);
286       histoRPfilleddr[ii]->SetMarkerStyle(20+ii);
287       histoRPfilleddr[ii]->SetMarkerColor(1+ii);
288
289
290       sprintf(name,"histoRAWactivemodules%d", ii);
291       sprintf(title,"Trend of the active module %s RAW",  histoname[ii].Data());
292       histoRAWactivemodules[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
293       histoRAWactivemodules[ii]->SetStats(0);
294       histoRAWactivemodules[ii]->GetXaxis()->SetTitle("# Run");
295       histoRAWactivemodules[ii]->GetXaxis()->SetTicks("-");
296       histoRAWactivemodules[ii]->GetXaxis()->SetLabelSize(0.02);
297       histoRAWactivemodules[ii]->GetXaxis()->SetTickLength(0.01);
298       histoRAWactivemodules[ii]->GetXaxis()->SetTitleSize(0.02);
299       histoRAWactivemodules[ii]->GetXaxis()->SetTitleOffset(-2.);
300       histoRAWactivemodules[ii]->GetYaxis()->SetTitle("modules");
301       histoRAWactivemodules[ii]->GetYaxis()->SetLabelSize(0.02);
302       histoRAWactivemodules[ii]->GetYaxis()->SetTitleSize(0.02);
303       histoRAWactivemodules[ii]->GetYaxis()->SetTitleOffset(1.5);
304       histoRAWactivemodules[ii]->SetMarkerStyle(24+ii);
305       histoRAWactivemodules[ii]->SetMarkerColor(4);
306
307
308
309       sprintf(name,"histoRPactivemodules%d", ii);
310       sprintf(title,"Trend of the active modules %s RP",  histoname[ii].Data());
311       histoRPactivemodules[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
312       histoRPactivemodules[ii]->SetStats(0);
313       histoRPactivemodules[ii]->GetXaxis()->SetTitle("# Run");
314       histoRPactivemodules[ii]->GetXaxis()->SetTicks("-");
315       histoRPactivemodules[ii]->GetXaxis()->SetLabelSize(0.02);
316       histoRPactivemodules[ii]->GetXaxis()->SetTickLength(0.01);
317       histoRPactivemodules[ii]->GetXaxis()->SetTitleSize(0.02);
318       histoRPactivemodules[ii]->GetXaxis()->SetTitleOffset(-2.);
319       histoRPactivemodules[ii]->GetYaxis()->SetTitle("modules");
320       histoRPactivemodules[ii]->GetYaxis()->SetLabelSize(0.02);
321       histoRPactivemodules[ii]->GetYaxis()->SetTitleSize(0.02);
322       histoRPactivemodules[ii]->GetYaxis()->SetTitleOffset(1.5);
323       histoRPactivemodules[ii]->SetMarkerStyle(24+ii);
324       histoRPactivemodules[ii]->SetMarkerColor(4);
325
326
327       sprintf(name,"histoRAWactivedr%d", ii);
328       sprintf(title,"Trend of the active drift region %s RAW", histoname[ii].Data());
329       histoRAWactivedr[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
330       histoRAWactivedr[ii]->SetStats(0);
331       histoRAWactivedr[ii]->GetXaxis()->SetTitle("# Run");
332       histoRAWactivedr[ii]->GetXaxis()->SetTicks("-");
333       histoRAWactivedr[ii]->GetXaxis()->SetLabelSize(0.02);
334       histoRAWactivedr[ii]->GetXaxis()->SetTickLength(0.01);
335       histoRAWactivedr[ii]->GetXaxis()->SetTitleSize(0.02);
336       histoRAWactivedr[ii]->GetXaxis()->SetTitleOffset(-2.);
337       histoRAWactivedr[ii]->GetYaxis()->SetTitle("Drift Regions");
338       histoRAWactivedr[ii]->GetYaxis()->SetLabelSize(0.02);
339       histoRAWactivedr[ii]->GetYaxis()->SetTitleSize(0.02);
340       histoRAWactivedr[ii]->GetYaxis()->SetTitleOffset(1.5);
341       histoRAWactivedr[ii]->SetMarkerStyle(24+ii);
342       histoRAWactivedr[ii]->SetMarkerColor(4);
343
344       sprintf(name,"histoRPactivedr%d", ii);
345       sprintf(title,"Trend of the active drift region %s RP",  histoname[ii].Data());
346       histoRPactivedr[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
347       histoRPactivedr[ii]->SetStats(0);
348       histoRPactivedr[ii]->GetXaxis()->SetTitle("# Run");
349       histoRPactivedr[ii]->GetXaxis()->SetTicks("-");
350       histoRPactivedr[ii]->GetXaxis()->SetLabelSize(0.02);
351       histoRPactivedr[ii]->GetXaxis()->SetTickLength(0.01);
352       histoRPactivedr[ii]->GetXaxis()->SetTitleSize(0.02);
353       histoRPactivedr[ii]->GetXaxis()->SetTitleOffset(-2.);
354       histoRPactivedr[ii]->GetYaxis()->SetTitle("Drift Regions");
355       histoRPactivedr[ii]->GetYaxis()->SetLabelSize(0.02);
356       histoRPactivedr[ii]->GetYaxis()->SetTitleSize(0.02);
357       histoRPactivedr[ii]->GetYaxis()->SetTitleOffset(1.5);
358       histoRPactivedr[ii]->SetMarkerStyle(24+ii);
359       histoRPactivedr[ii]->SetMarkerColor(4);
360
361       sprintf(name,"histoRAWoverthmodules%d", ii);
362       sprintf(title,"Trend of the over th modules %s RAW", histoname[ii].Data());
363       histoRAWoverthmodules[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
364       histoRAWoverthmodules[ii]->SetStats(0);
365       histoRAWoverthmodules[ii]->GetXaxis()->SetTitle("# Run");
366       histoRAWoverthmodules[ii]->GetXaxis()->SetTicks("-");
367       histoRAWoverthmodules[ii]->GetXaxis()->SetLabelSize(0.02);
368       histoRAWoverthmodules[ii]->GetXaxis()->SetTickLength(0.01);
369       histoRAWoverthmodules[ii]->GetXaxis()->SetTitleSize(0.02);
370       histoRAWoverthmodules[ii]->GetXaxis()->SetTitleOffset(-2.);
371       histoRAWoverthmodules[ii]->GetYaxis()->SetTitle("modules");
372       histoRAWoverthmodules[ii]->GetYaxis()->SetLabelSize(0.02);
373       histoRAWoverthmodules[ii]->GetYaxis()->SetTitleSize(0.02);
374       histoRAWoverthmodules[ii]->GetYaxis()->SetTitleOffset(1.5);
375       histoRAWoverthmodules[ii]->SetMarkerStyle(20+ii);
376       histoRAWoverthmodules[ii]->SetMarkerColor(1+ii);
377
378       sprintf(name,"histoRPoverthmodules%d", ii);
379       sprintf(title,"Trend of the over th modules %s RP",  histoname[ii].Data());
380       histoRPoverthmodules[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
381       histoRPoverthmodules[ii]->SetStats(0);
382       histoRPoverthmodules[ii]->GetXaxis()->SetTitle("# Run");
383       histoRPoverthmodules[ii]->GetXaxis()->SetTicks("-");
384       histoRPoverthmodules[ii]->GetXaxis()->SetLabelSize(0.02);
385       histoRPoverthmodules[ii]->GetXaxis()->SetTickLength(0.01);
386       histoRPoverthmodules[ii]->GetXaxis()->SetTitleOffset(-2.);
387       histoRPoverthmodules[ii]->GetYaxis()->SetTitle("modules");
388       histoRPoverthmodules[ii]->GetYaxis()->SetLabelSize(0.02);
389       histoRPoverthmodules[ii]->GetYaxis()->SetTitleSize(0.02);
390       histoRPoverthmodules[ii]->GetYaxis()->SetTitleOffset(1.5);
391       histoRPoverthmodules[ii]->SetMarkerStyle(20+ii);
392       histoRPoverthmodules[ii]->SetMarkerColor(1+ii);
393
394
395       sprintf(name,"histoRAWoverthdr%d", ii);
396       sprintf(title,"Trend of the over th drift regions %s RAW",  histoname[ii].Data());
397       histoRAWoverthdr[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
398       histoRAWoverthdr[ii]->SetStats(0);
399       histoRAWoverthdr[ii]->GetXaxis()->SetTitle("# Run");
400       histoRAWoverthdr[ii]->GetXaxis()->SetTicks("-");
401       histoRAWoverthdr[ii]->GetXaxis()->SetLabelSize(0.02);
402       histoRAWoverthdr[ii]->GetXaxis()->SetTickLength(0.01);
403       histoRAWoverthdr[ii]->GetXaxis()->SetTitleSize(0.02);
404       histoRAWoverthdr[ii]->GetXaxis()->SetTitleOffset(-2.);
405       histoRAWoverthdr[ii]->GetYaxis()->SetTitle("Drift Regions");
406       histoRAWoverthdr[ii]->GetYaxis()->SetLabelSize(0.02);
407       histoRAWoverthdr[ii]->GetYaxis()->SetTitleSize(0.02);
408       histoRAWoverthdr[ii]->GetYaxis()->SetTitleOffset(1.5);
409       histoRAWoverthdr[ii]->SetMarkerStyle(20+ii);
410       histoRAWoverthdr[ii]->SetMarkerColor(1+ii);
411
412
413       sprintf(name,"histoRPoverthdr%d", ii);
414       sprintf(title,"Trend of the over th drift regions %s RP",  histoname[ii].Data());
415       histoRPoverthdr[ii]=new TH1F(name,title,n.size(),0.,(float)n.size());
416       histoRPoverthdr[ii]->SetStats(0);
417       histoRPoverthdr[ii]->GetXaxis()->SetTitle("# Run");
418       histoRPoverthdr[ii]->GetXaxis()->SetTicks("-");
419       histoRPoverthdr[ii]->GetXaxis()->SetLabelSize(0.02);
420       histoRPoverthdr[ii]->GetXaxis()->SetTickLength(0.01);
421       histoRPoverthdr[ii]->GetXaxis()->SetTitleSize(0.02);
422       histoRPoverthdr[ii]->GetXaxis()->SetTitleOffset(-2.);
423       histoRPoverthdr[ii]->GetYaxis()->SetTitle("Drift Regions");
424       histoRPoverthdr[ii]->GetYaxis()->SetLabelSize(0.02);
425       histoRPoverthdr[ii]->GetYaxis()->SetTitleSize(0.02);
426       histoRPoverthdr[ii]->GetYaxis()->SetTitleOffset(1.5);
427       histoRPoverthdr[ii]->SetMarkerStyle(20+ii);
428       histoRPoverthdr[ii]->SetMarkerColor(1+ii);
429
430     }
431
432   for(Int_t layer=3;layer<5;layer++)
433     {
434       sprintf(name,"histochargetrend_%d", layer);
435       sprintf(title,"Trend of the Charge of the Layer %d", layer);
436       histochargetrend[layer-3]=new TH1F(name,title,n.size(),0.,(float)n.size());
437       histochargetrend[layer-3]->SetStats(0);
438       histochargetrend[layer-3]->GetXaxis()->SetTicks("-");
439       histochargetrend[layer-3]->GetXaxis()->SetLabelSize(0.02);
440       histochargetrend[layer-3]->GetXaxis()->SetTickLength(0.01);
441       histochargetrend[layer-3]->GetYaxis()->SetTitleSize(0.02);
442       histochargetrend[layer-3]->GetXaxis()->SetTitleOffset(-2.);
443       histochargetrend[layer-3]->GetXaxis()->SetLabelSize(0.02);
444       histochargetrend[layer-3]->GetYaxis()->SetTitleSize(0.02);
445       histochargetrend[layer-3]->GetYaxis()->SetTitleOffset(1.5);
446       histochargetrend[layer-3]->GetXaxis()->SetTitle("# Run");
447       histochargetrend[layer-3]->GetYaxis()->SetTitle("keV");
448       histochargetrend[layer-3]->SetMinimum(0.);
449       histochargetrend[layer-3]->SetMaximum(250.);
450       histochargetrend[layer-3]->SetMarkerStyle(20);
451       histochargetrend[layer-3]->SetMarkerSize(1);
452       histochargetrend[layer-3]->SetMarkerColor(kGreen+4);
453       histochargetrend[layer-3]->SetFillColor(42);
454
455
456       sprintf(name,"historadiustrend_%d", layer);
457       sprintf(title,"Trend of the radius of the Layer %d", layer);
458       historadiustrend[layer-3]=new TH1F(name,title,n.size(),0.,(float)n.size());
459       historadiustrend[layer-3]->SetStats(0);
460       historadiustrend[layer-3]->GetXaxis()->SetTicks("-");
461       historadiustrend[layer-3]->GetXaxis()->SetLabelSize(0.02);
462       historadiustrend[layer-3]->GetXaxis()->SetTickLength(0.01);
463       historadiustrend[layer-3]->GetXaxis()->SetTitleSize(0.02);
464       historadiustrend[layer-3]->GetXaxis()->SetTitleOffset(-2.);
465       historadiustrend[layer-3]->GetYaxis()->SetLabelSize(0.02);
466       historadiustrend[layer-3]->GetYaxis()->SetTitleSize(0.02);
467       historadiustrend[layer-3]->GetYaxis()->SetTitleOffset(1.5);
468       historadiustrend[layer-3]->GetXaxis()->SetTitle("# Run");
469       historadiustrend[layer-3]->GetYaxis()->SetTitle("r [cm]");
470       historadiustrend[layer-3]->SetMinimum(0.);
471       historadiustrend[layer-3]->SetMaximum(26.);
472       historadiustrend[layer-3]->SetMarkerStyle(20);
473       historadiustrend[layer-3]->SetMarkerSize(1);
474       historadiustrend[layer-3]->SetMarkerColor(kGreen+4);
475       historadiustrend[layer-3]->SetFillColor(42);
476     }
477   
478
479   gStyle->SetOptStat(0);
480         
481   TCanvas *canvas[12];
482   
483   for(Int_t i=0;i<12;i++)
484     {
485       sprintf(name,"canvas%i",i);
486       //printf("--> %s \n",name);
487       
488       canvas[i]=new TCanvas(name,name);
489
490     }
491   
492   char buffer [10];
493   for (Int_t irun=0; irun<(Int_t)(n.size());irun++)
494     {
495         if(kUseOriginalFile) sprintf(FileName, "run%d/%s/File.QA.%d.%s.%s.Run.%d.root", n[irun],pass,year,period,pass,n[irun]);
496         else sprintf(FileName, "run%d/%s/%s.root", n[irun],pass,filename);         
497         
498         TFile mergedfile(FileName);
499         if(kUseOriginalFile){
500           if(mergedfile.GetKey("ITS")==0x0){
501             printf("run %d In this run ITS QA has not been executed.--- Exit file\n",n[irun]);
502             continue;
503           }
504         }
505         sprintf(buffer, "%d", n[irun]);
506         if(kUseOriginalFile)sprintf(filepath,"ITS/Raws/%s/Expert/%s_SDDRawDataCheck",especiename,especiename);
507         else sprintf(filepath,"%s_SDDRawDataCheck",especiename);        
508         sprintf(runnmbr,"run%d",n[irun]);
509         //printf("%s  %s\n",filepath,runnmbr);  
510         histocharge=(TH1F*)(mergedfile.Get(filepath));
511         if(histocharge)
512           {
513             histoRAWeventtrend->Fill(buffer,(histocharge->GetBinContent(event)));
514           }
515         
516         if(kUseOriginalFile)sprintf(filepath,"ITS/RecPoints/%s/Expert/%s_SDDRecPointDataCheck",especiename,especiename);
517         else sprintf(filepath,"%s_SDDRecPointCheck",especiename);       
518         sprintf(runnmbr,"run%d",n[irun]);
519         //printf("%s  %s\n",filepath,runnmbr);  
520         histochargerp=(TH1F*)(mergedfile.Get(filepath));        
521         if(histochargerp)
522           {
523             histoRPeventtrend->Fill(buffer,histochargerp->GetBinContent(event));
524           }
525         for(Int_t iindex=0;iindex<3;iindex++)
526           {
527             if(histocharge)
528               {
529                 histoRAWnormevents[iindex]->Fill(buffer,histocharge->GetBinContent(normevtRAW[iindex]));  
530                 histoRAWfilledmodules[iindex]->Fill(buffer,histocharge->GetBinContent(filledmodRAW[iindex]));       
531                 histoRAWfilleddr[iindex]->Fill(buffer,histocharge->GetBinContent(filleddrRAW[iindex]));
532                 histoRAWactivemodules[iindex]->Fill(buffer,histocharge->GetBinContent(activemodRAW[iindex]));       
533                 histoRAWactivedr[iindex]->Fill(buffer,histocharge->GetBinContent(activedrRAW[iindex]));     
534                 histoRAWoverthmodules[iindex]->Fill(buffer,histocharge->GetBinContent(overthmodRAW[iindex]));     
535                 histoRAWoverthdr[iindex]->Fill(buffer,histocharge->GetBinContent(overthdrRAW[iindex]));
536               }
537             
538             if(histochargerp)
539               {
540                 histoRPnormevents[iindex]->Fill(buffer,histochargerp->GetBinContent(normevtRP[iindex]));
541                 histoRPfilledmodules[iindex]->Fill(buffer,histochargerp->GetBinContent(filledmodRP[iindex]));
542                 histoRPfilleddr[iindex]->Fill(buffer,histochargerp->GetBinContent(filleddrRP[iindex]));
543                 histoRPactivemodules[iindex]->Fill(buffer,histochargerp->GetBinContent(activemodRP[iindex]));
544                 histoRPactivedr[iindex]->Fill(buffer,histochargerp->GetBinContent(activedrRP[iindex]));
545                 histoRPoverthmodules[iindex]->Fill(buffer,histochargerp->GetBinContent(overthmodRP[iindex]));
546                 histoRPoverthdr[iindex]->Fill(buffer,histochargerp->GetBinContent(overthdrRP[iindex]));
547                 if(iindex<2){
548                   histochargetrend[iindex]->Fill(buffer,histochargerp->GetBinContent(chargeindex[iindex]));
549                   histochargetrend[iindex]->SetBinError(irun+1,histochargerp->GetBinError(chargeindex[iindex]));
550                   historadiustrend[iindex]->Fill(buffer,histochargerp->GetBinContent(radiusindex[iindex]));
551                   historadiustrend[iindex]->SetBinError(irun+1,histochargerp->GetBinError(radiusindex[iindex]));
552                 }
553
554               }
555           }
556         histocharge=NULL;
557         histochargerp=NULL;
558     }//end loop on run
559   
560   canvas[3]->cd();
561   //  histoRAWeventtrend->GetXaxis()->LabelsOption("v");
562   histoRAWeventtrend->Draw("E0");
563   //  histoRPeventtrend->GetXaxis()->LabelsOption("v");
564   histoRPeventtrend->Draw("E0SAME");
565   legendevents->AddEntry(histoRAWeventtrend,histolegend3[0].Data(),"P");
566   legendevents->AddEntry(histoRPeventtrend,histolegend3[1].Data(),"P");
567   legendevents->Draw();
568   canvas[3]->Update();
569   
570   canvas[4]->Divide(2,1);  
571   canvas[4]->cd(1);
572   Char_t legendtext[50];
573   for(Int_t i=0;i<3;i++)
574     {
575       //      histoRAWnormevents[i]->GetXaxis()->LabelsOption("v");
576       histoRAWnormevents[i]->Draw(drawoptionevents[i].Data());
577       //      sprintf(legendtext,"%s %s",histolegend);
578       legendchecks->AddEntry(histoRAWnormevents[i],histolegend[i].Data(),"P");
579     }
580   legendchecks->Draw();
581   canvas[4]->cd(2);
582
583   for(Int_t i=0;i<3;i++)
584     {
585       histoRPnormevents[i]->Draw(drawoptionevents[i].Data());
586       //legendchecks->AddEntry(histoRPnormevent,histolegend[i].Data(),"P");
587
588     }
589   legendchecks->Draw("same");
590   canvas[4]->Update();
591   
592   canvas[5]->Divide(2,1);  
593   canvas[5]->cd(1);
594   for(Int_t i=1;i<3;i++)
595     {
596       //histoRAWfilledmodules[i]->GetXaxis()->LabelsOption("v");
597       histoRAWfilledmodules[i]->Draw(drawoptionfill[i].Data());
598       sprintf(legendtext,"%s %s",histolegend[i].Data(),histolegend2[0].Data());
599       legendchecks2->AddEntry(histoRAWfilledmodules[i],legendtext,"P");
600       //histoRAWactivemodules[i]->GetXaxis()->LabelsOption("v");
601       histoRAWactivemodules[i]->Draw(drawoptionactive[i].Data());
602       sprintf(legendtext,"%s %s",histolegend[i].Data(),histolegend2[1].Data());
603       legendchecks2->AddEntry(histoRAWactivemodules[i],legendtext,"P");
604     }
605   legendchecks2->Draw("same");
606   canvas[5]->cd(2);
607   for(Int_t i=1;i<3;i++)
608     {
609       //histoRPfilledmodules[i]->GetXaxis()->LabelsOption("v");
610       histoRPfilledmodules[i]->Draw(drawoptionfill[i].Data());
611       //histoRPactivemodules[i]->GetXaxis()->LabelsOption("v");
612       histoRPactivemodules[i]->Draw(drawoptionactive[i].Data());
613     }
614   legendchecks2->Draw("same");
615   canvas[5]->Update();
616
617   canvas[6]->Divide(2,1);  
618   canvas[6]->cd(1);
619   for(Int_t i=1;i<3;i++)
620     {
621       //histoRAWfilleddr[i]->GetXaxis()->LabelsOption("v");
622       histoRAWfilleddr[i]->Draw(drawoptionfill[i].Data());
623       //histoRAWactivedr[i]->GetXaxis()->LabelsOption("v");
624       histoRAWactivedr[i]->Draw(drawoptionactive[i].Data());
625     }
626   legendchecks2->Draw("same");
627   canvas[6]->cd(2);
628   for(Int_t i=1;i<3;i++)
629     {
630       //histoRPfilleddr[i]->GetXaxis()->LabelsOption("v");
631       histoRPfilleddr[i]->Draw(drawoptionfill[i].Data());
632       //histoRPactivedr[i]->GetXaxis()->LabelsOption("v");
633       histoRPactivedr[i]->Draw(drawoptionactive[i].Data());
634     }
635   legendchecks2->Draw("same");
636   canvas[6]->Update();
637
638
639
640   ///////////////////////////////////////////////
641
642
643   
644   canvas[10]->Divide(2,1);  
645   canvas[10]->cd(1);
646   
647   //histoRAWfilledmodules[i]->GetXaxis()->LabelsOption("v");
648   histoRAWfilledmodules[0]->Draw(drawoptionfill[0].Data());
649   sprintf(legendtext,"%s %s",histolegend[0].Data(),histolegend2[0].Data());
650   legendchecks3->AddEntry(histoRAWfilledmodules[0],legendtext,"P");
651   //histoRAWactivemodules[i]->GetXaxis()->LabelsOption("v");
652   histoRAWactivemodules[0]->Draw(drawoptionactive[0].Data());
653   sprintf(legendtext,"%s %s",histolegend[0].Data(),histolegend2[1].Data());
654   legendchecks3->AddEntry(histoRAWactivemodules[0],legendtext,"P");
655   legendchecks3->Draw("same");
656   canvas[10]->cd(2);
657   
658   //histoRPfilledmodules[i]->GetXaxis()->LabelsOption("v");
659   histoRPfilledmodules[0]->Draw(drawoptionfill[0].Data());
660   //histoRPactivemodules[i]->GetXaxis()->LabelsOption("v");
661   histoRPactivemodules[0]->Draw(drawoptionactive[0].Data());
662   legendchecks3->Draw("same");
663   canvas[10]->Update();
664   
665   canvas[11]->Divide(2,1);  
666   canvas[11]->cd(1);
667   
668   //histoRAWfilleddr[i]->GetXaxis()->LabelsOption("v");
669   histoRAWfilleddr[0]->Draw(drawoptionfill[0].Data());
670   //histoRAWactivedr[i]->GetXaxis()->LabelsOption("v");
671   histoRAWactivedr[0]->Draw(drawoptionactive[0].Data());
672   legendchecks3->Draw("same");
673   canvas[11]->cd(2);
674   
675   //histoRPfilleddr[i]->GetXaxis()->LabelsOption("v");
676   histoRPfilleddr[0]->Draw(drawoptionfill[0].Data());
677   //histoRPactivedr[i]->GetXaxis()->LabelsOption("v");
678   histoRPactivedr[0]->Draw(drawoptionactive[0].Data());
679   legendchecks3->Draw("same");
680   canvas[11]->Update();
681
682
683   ///////////////////////////////////////////////
684
685   canvas[8]->Divide(2,1);  
686   canvas[8]->cd(1);
687   for(Int_t i=0;i<3;i++)
688     {
689       //histoRAWoverthmodules[i]->GetXaxis()->LabelsOption("v");
690       histoRAWoverthmodules[i]->Draw(drawoptionfill[i].Data());
691       //histoRAWoverthmodules[i]->Draw(drawoptionactive[i].Data());
692     }
693   canvas[8]->cd(2);
694   for(Int_t i=0;i<3;i++)
695     {
696       //histoRPoverthmodules[i]->GetXaxis()->LabelsOption("v");
697       histoRPoverthmodules[i]->Draw(drawoptionfill[i].Data());
698       //histoRPoverthmodules[i]->Draw(drawoptionactive[i].Data());
699     }
700   canvas[8]->Update();
701
702   canvas[9]->Divide(2,1);  
703   canvas[9]->cd(1);
704   for(Int_t i=0;i<3;i++)
705     {
706       histoRAWoverthdr[i]->GetXaxis()->LabelsOption("v");
707       histoRAWoverthdr[i]->Draw(drawoptionfill[i].Data());
708       //histoRAWoverthdr[i]->Draw(drawoptionactive[i].Data());
709     }
710   canvas[9]->cd(2);
711   for(Int_t i=0;i<3;i++)
712     {
713       //histoRPoverthdr[i]->GetXaxis()->LabelsOption("v");
714       histoRPoverthdr[i]->Draw(drawoptionfill[i].Data());
715       //histoRPoverthdr[i]->Draw(drawoptionactive[i].Data());
716     }
717   canvas[9]->Update();
718   
719   //Int_t kk=0;
720
721
722   printf("Total runs: %d \n",(int)(n.size()));
723   canvas[0]->Divide(2,1);
724
725   for(Int_t layer=3;layer<5;layer++){
726     canvas[0]->SetFillColor(46);
727     canvas[0]->cd(layer-2)->SetFillColor(46);
728     //histochargetrend[layer-3]->GetXaxis()->LabelsOption("v");
729     histochargetrend[layer-3]->SetMarkerStyle(20);
730     histochargetrend[layer-3]->SetMarkerSize(1);
731     histochargetrend[layer-3]->SetMarkerColor(kGreen+4);
732     histochargetrend[layer-3]->SetFillColor(42);
733     canvas[0]->cd(layer-2)->SetFrameFillColor(kAzure-9);
734     //    histochargetrend[layer-3]->GetXaxis()->LabelsOption("v");
735     histochargetrend[layer-3]->SetBarWidth(0.9);
736     histochargetrend[layer-3]->SetBarOffset(0.05);
737     histochargetrend[layer-3]->DrawCopy("P");
738     canvas[0]->Update();
739  
740     canvas[7]->cd();
741     canvas[7]->SetFillColor(46);
742     //canvas[7]->SetFillColor(46);
743     //historadiustrend[layer-3]->GetXaxis()->LabelsOption("v");
744     historadiustrend[layer-3]->SetMarkerStyle(20);
745     historadiustrend[layer-3]->SetMarkerSize(1);
746     historadiustrend[layer-3]->SetMarkerColor(8+layer-3);
747     legendchecks4->AddEntry(historadiustrend[layer-3],histolegend[layer-2].Data(),"P");
748     //historadiustrend[layer-3]->SetFillColor(42);
749     canvas[7]->SetFrameFillColor(kAzure-9);
750     historadiustrend[layer-3]->SetBarWidth(0.9);
751     historadiustrend[layer-3]->SetBarOffset(0.05);
752     historadiustrend[layer-3]->DrawCopy(drawoptionevents[layer-3].Data());
753     canvas[7]->Update();
754   }
755   legendchecks4->Draw("same");
756   canvas[7]->Update();
757   canvas[1]->Divide(2,1);
758   canvas[2]->Divide(2,1);
759   //canvas[7]->Divide(2,1);
760   
761   if(kDOSuperimpose==kTRUE)
762     {
763       Int_t jj=0;
764       for (Int_t irun=0; irun<(Int_t)(n.size());irun++)
765         {
766           for(Int_t ilayer=3;ilayer<5;ilayer++)
767             {
768             if(kUseOriginalFile)sprintf(FileName,"run%d/%s/File.QA.%d.%s.%s.Run.%d.root",n[irun],pass,year,period,pass,n[irun]);
769             else sprintf(FileName, "run%d/%s/%s.root", n[irun],pass,filename);
770             
771             TFile mergedfile(FileName);
772             
773             if(kUseOriginalFile){
774               if(mergedfile.GetKey("ITS")==0x0){
775                 printf("Run %d, In this run ITS QA has not been executed.-- Exit file\n",n[irun]);
776                 continue;
777               }
778             }
779             if(kUseOriginalFile)sprintf(filepath,"ITS/RecPoints/%s/%s_SDDLay%dTotCh",especiename,especiename,ilayer);
780             else sprintf(filepath,"%s_SDDLay%dTotCh",especiename,ilayer);
781             histocharge=(TH1F*)(mergedfile.Get(filepath));       
782             
783             if(histocharge)
784               {
785                 sprintf(buffer, "%d", n[irun]);
786                 
787                 fmax[ilayer-3]=histocharge->GetMaximum();
788                 if (jj==0)      { fmaxold=fmax[ilayer-3];}
789                 if (jj!=0) { if(fmaxold<fmax[ilayer-3]) { fmaxold=fmax[ilayer-3];} }
790                 //j++;
791               }//end if histocharge
792             
793             histocharge=NULL;
794             
795             //drift time
796             
797             if(kUseOriginalFile)sprintf(filepath,"ITS/RecPoints/%s/%s_SDDdrifttime_Layer%d",especiename,especiename,ilayer);
798             else sprintf(filepath,"%s_SDDdrifttime_Layer%d",especiename,ilayer);
799             histocharge=(TH1F*)(mergedfile.Get(filepath));       
800             
801             if(histocharge)
802               {
803                 sprintf(buffer, "%d", n[irun]); 
804                 fmaxtime=histocharge->GetMaximum();
805                 if (jj==0)      { fmaxoldtime=fmaxtime;}
806                 if (jj!=0) { if(fmaxoldtime<fmaxtime) { fmaxoldtime=fmaxtime;} }
807                 //j++;
808               }//end if histocharge
809             jj++;
810             histocharge=NULL;
811             
812           }//end for run
813         }//end layer
814
815     fmaxmargin[0]=fmaxold;
816     fmaxmargintime[0]=1.023*fmaxoldtime;
817   
818
819     fmaxmargin[1]=fmaxmargin[0];
820     fmaxmargintime[1]=fmaxmargintime[0];
821
822
823   for(Int_t layer=3;layer<5;layer++){
824   
825     printf("Max Y Range is %4.1f time %4.1f\n",fmaxmargin[layer-3],fmaxmargintime[layer-3]);  
826     j=0;
827     hh=0;
828     Int_t color=0;
829     for (Int_t irun=0; irun< (Int_t)(n.size());irun++)
830       {
831         
832         if(kUseOriginalFile) sprintf(FileName, "run%d/%s/File.QA.%d.%s.%s.Run.%d.root", n[irun],pass,year,period,pass,n[irun]);
833         else sprintf(FileName, "run%d/%s/%s.root", n[irun],pass,filename);         
834         
835         TFile mergedfile(FileName);
836         if(kUseOriginalFile){
837           if(mergedfile.GetKey("ITS")==0x0){
838             printf("run %d In this run ITS QA has not been executed.--- Exit file\n",n[irun]);
839             continue;
840           }
841         }       
842         if(kUseOriginalFile)sprintf(filepath,"ITS/RecPoints/%s/%s_SDDLay%dTotCh",especiename,especiename,layer);
843         else sprintf(filepath,"%s_SDDLay%dTotCh",especiename,layer);    
844         sprintf(runnmbr,"run%d",n[irun]);
845         printf("%s  %s",filepath,runnmbr);      
846         histocharge=(TH1F*)(mergedfile.Get(filepath));  
847         if(histocharge)
848           {         
849             color=2+j;
850             if (color>=12 && color<=27) { color=j+28; }
851             histocharge->SetLineColor(color);
852             if (j==0)
853               { 
854                 canvas[1]->cd(layer-2);
855
856                 canvas[1]->cd(layer-2)->SetFrameFillColor(kGray+3);
857                 histocharge->SetMaximum(fmaxmargin[layer-3]);
858                 histocharge->GetYaxis()->SetTitle("");
859                 histocharge->DrawNormalized();
860                 canvas[1]->cd(layer-2)->Update();
861                 histocharge->GetYaxis()->SetRangeUser(0.,fmaxmargin[layer-3]);
862                 canvas[1]->cd(layer-2)->Update();
863               }    
864             if (j!=0)
865               {
866                 //printf("new j %d\n",j);
867                 canvas[1]->cd(layer-2);
868                 histocharge->DrawNormalized("same");
869                 canvas[1]->cd(layer-2)->Update();
870               }     
871             if(layer==3)legend->AddEntry(histocharge,runnmbr,"l");
872             canvas[1]->cd(layer-2);
873             legend->Draw("same");           
874             canvas[1]->Update();
875             j++;
876             printf("...Found\n");
877             
878           }//end if histocharge
879         else{printf("...Not Found....\n");}
880         histocharge=NULL;
881         
882             //======================================================== Drift Time       
883         if(kUseOriginalFile)sprintf(filepath,"ITS/RecPoints/%s/%s_SDDdrifttime_Layer%d",especiename,especiename,layer);
884         else sprintf(filepath,"%s_SDDdrifttime_Layer%d",especiename,layer);     
885         sprintf(runnmbr,"run %d",n[irun]);
886         printf("%s  %s",filepath,runnmbr);      
887         histocharge=(TH1F*)(mergedfile.Get(filepath));  
888         if(histocharge)
889           {         
890             printf("...Found\n");
891             histocharge->SetLineColor(color);
892             if (hh==0)
893               { 
894                 canvas[2]->cd(layer-2);
895                 canvas[2]->cd(layer-2)->SetFrameFillColor(kGray+3);
896                 histocharge->SetMaximum(fmaxmargintime[layer-3]);
897                 histocharge->GetYaxis()->SetTitle("");
898                 histocharge->DrawNormalized();
899               }    
900             if (hh!=0)
901               {
902                 canvas[2]->cd(layer-2);
903                 histocharge->DrawNormalized("same");
904               }     
905             if(layer==3)legend2->AddEntry(histocharge,runnmbr,"l");
906             canvas[2]->cd(layer-2);
907             legend2->Draw("same");          
908             canvas[2]->Update();
909             hh++;
910           }//end if histocharge
911         else{printf("...Not Found....\n");}
912         histocharge=NULL;
913       }//enf for 
914       }//end for layer
915     }
916   
917   TFile trendfile(Form("SDDQAtrend%s%s.root",period,pass),"recreate");  
918   trendfile.cd();
919   for(Int_t ican=0;ican<10;ican++)canvas[ican]->Write();
920   trendfile.Close();
921   Char_t psfile[50];
922   sprintf(psfile,"SDDtrend%s%s.ps",period,pass);
923   canvas[0]->Print(Form("%s[",psfile));
924   for(Int_t ifile=0;ifile<12;ifile++){canvas[ifile]->Print(psfile);}
925
926   canvas[11]->Print(Form("%s]",psfile));
927   
928   
929   delete histocharge;
930   delete histochargerp;
931
932
933
934 }//end macro