]>
Commit | Line | Data |
---|---|---|
2a250bc5 | 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 | #endif | |
18 | 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 kUseOriginalFile=kFALSE , Char_t especiename[50]="LowMultiplicity") | |
19 | { | |
20 | Int_t m; | |
21 | vector<Int_t> n; | |
22 | //Char_t FileName[200];//="/home/msicilia/Desktop/createlists"; | |
23 | char FileName[150]; | |
24 | Char_t FileName1[150]; | |
25 | sprintf(FileName1,"%s",filelist); | |
26 | FILE * pFile; | |
27 | pFile = fopen (FileName1,"r"); | |
28 | while (fscanf (pFile,"%d\n",&m)==1){ | |
29 | ||
30 | if(kUseOriginalFile)sprintf(FileName,"run%d/%s/File.QA.%d.%s.%s.Run.%d.root",m,pass,year,period,pass,m); | |
31 | else sprintf(FileName, "run%d/%s/%s.root", m,pass,filename); | |
32 | if(gSystem->Exec(Form("ls %s >/dev/null 2>&1", FileName))==0){ | |
33 | TFile mergedfile(FileName); | |
34 | if(kUseOriginalFile){ | |
35 | if(mergedfile.GetKey("ITS")==0x0){ | |
36 | printf("Run %d, In this run ITS QA has not been executed.-- Exit file\n",m); | |
37 | continue; | |
38 | } | |
39 | else {n.push_back(m);} //this is to grow the vector | |
40 | }else {n.push_back(m);} | |
41 | } | |
42 | else{printf("Run %d,: no file %s present -- Continue\n",m, FileName);continue;} | |
43 | } | |
44 | fclose (pFile); | |
45 | ||
46 | Char_t filepath[200]; | |
47 | TH1F *histocharge; | |
48 | TH1F *histochargetrend[2]; | |
49 | ||
50 | char name[100]; | |
51 | char title[100]; | |
52 | ||
53 | for(Int_t layer=3;layer<5;layer++) | |
54 | { | |
55 | sprintf(name,"histochargetrend_%d", layer); | |
56 | sprintf(title,"Trend of the Charge of the Layer %d", layer); | |
57 | histochargetrend[layer-3]=new TH1F(name,title,n.size(),0.,(float)n.size()); | |
58 | } | |
59 | ||
60 | gStyle->SetOptStat(0); | |
61 | TCanvas *canvas[6]; | |
62 | ||
63 | for(Int_t i=0;i<3;i++) | |
64 | { | |
65 | sprintf(name,"canvas%i",i); | |
66 | canvas[i]=new TCanvas(name,name); | |
67 | canvas[i]->Divide(2,1); | |
68 | } | |
69 | ||
70 | TLegend *legend =new TLegend(0.83,0.8,0.97,0.2); | |
71 | TLegend *legend2=new TLegend(0.83,0.8,0.97,0.2); | |
72 | ||
73 | Char_t runnmbr[20]; | |
74 | Float_t fmax=0; | |
75 | Float_t fmaxold=0; | |
76 | Float_t fmaxmargin=0; | |
77 | ||
78 | Float_t fmaxtime=0; | |
79 | Float_t fmaxoldtime=0; | |
80 | Float_t fmaxmargintime=0; | |
81 | ||
82 | Int_t j=0; | |
83 | Int_t hh=0; | |
84 | //Int_t kk=0; | |
85 | char buffer [10]; | |
86 | ||
87 | printf("%d \n",n.size()); | |
88 | ||
89 | for(Int_t layer=3;layer<5;layer++){ | |
90 | for (Int_t irun=0; irun<(Int_t)(n.size());irun++) | |
91 | { | |
92 | if(kUseOriginalFile)sprintf(FileName,"run%d/%s/File.QA.%d.%s.%s.Run.%d.root",n[irun],pass,year,period,pass,n[irun]); | |
93 | else sprintf(FileName, "run%d/%s/%s.root", n[irun],pass,filename); | |
94 | ||
95 | TFile mergedfile(FileName); | |
96 | if(kUseOriginalFile){ | |
97 | if(mergedfile.GetKey("ITS")==0x0){ | |
98 | printf("Run %d, In this run ITS QA has not been executed.-- Exit file\n",n[irun]); | |
99 | continue; | |
100 | } | |
101 | } | |
102 | if(kUseOriginalFile)sprintf(filepath,"ITS/RecPoints/%s/%s_SDDLay%dTotCh",especiename,especiename,layer); | |
103 | else sprintf(filepath,"%s_SDDLay%dTotCh",especiename,layer); | |
104 | histocharge=(TH1F*)(mergedfile.Get(filepath)); | |
105 | ||
106 | if(histocharge) | |
107 | { | |
108 | sprintf(buffer, "%d", n[irun]); | |
109 | histochargetrend[layer-3]->Fill(buffer,histocharge->GetMean()); | |
110 | histochargetrend[layer-3]->SetMinimum(0.); | |
111 | histochargetrend[layer-3]->SetMaximum(250.); | |
112 | histochargetrend[layer-3]->GetXaxis()->SetTitle("# Run"); | |
113 | histochargetrend[layer-3]->GetYaxis()->SetTitle("keV"); | |
114 | fmax=histocharge->GetMaximum(); | |
115 | if (j==0) { fmaxold=fmax;} | |
116 | if (j!=0) { if(fmaxold<fmax) { fmaxold=fmax;} } | |
117 | j++; | |
118 | }//end if histocharge | |
119 | ||
120 | histocharge=NULL; | |
121 | ||
122 | //drift time | |
123 | ||
124 | if(kUseOriginalFile)sprintf(filepath,"ITS/RecPoints/%s/%s_SDDdrifttime_Layer%d",especiename,especiename,layer); | |
125 | else sprintf(filepath,"%s_SDDdrifttime_Layer%d",especiename,layer); | |
126 | histocharge=(TH1F*)(mergedfile.Get(filepath)); | |
127 | ||
128 | if(histocharge) | |
129 | { | |
130 | sprintf(buffer, "%d", n[irun]); | |
131 | fmaxtime=histocharge->GetMaximum(); | |
132 | if (j==0) { fmaxoldtime=fmaxtime;} | |
133 | if (j!=0) { if(fmaxoldtime<fmaxtime) { fmaxoldtime=fmaxtime;} } | |
134 | j++; | |
135 | }//end if histocharge | |
136 | ||
137 | histocharge=NULL; | |
138 | ||
139 | }//end for run | |
140 | fmaxmargin=fmaxold; | |
141 | fmaxmargintime=1.023*fmaxoldtime; | |
142 | printf("Max Y Range is %4.1f time %4.1f\n",fmaxmargin,fmaxmargintime); | |
143 | ||
144 | canvas[0]->SetFillColor(46); | |
145 | canvas[0]->cd(layer-2)->SetFillColor(46); | |
146 | histochargetrend[layer-3]->SetMarkerStyle(20); | |
147 | histochargetrend[layer-3]->SetMarkerSize(1); | |
148 | histochargetrend[layer-3]->SetMarkerColor(kGreen+4); | |
149 | histochargetrend[layer-3]->SetFillColor(42); | |
150 | canvas[0]->cd(layer-2)->SetFrameFillColor(kAzure-9); | |
151 | histochargetrend[layer-3]->SetBarWidth(0.9); | |
152 | histochargetrend[layer-3]->SetBarOffset(0.05); | |
153 | histochargetrend[layer-3]->DrawCopy("P"); | |
154 | ||
155 | j=0; | |
156 | hh=0; | |
157 | Int_t color=0; | |
158 | for (Int_t irun=0; irun< (Int_t)(n.size());irun++) | |
159 | { | |
160 | ||
161 | if(kUseOriginalFile) sprintf(FileName, "run%d/%s/File.QA.%d.%s.%s.Run.%d.root", n[irun],pass,year,period,pass,n[irun]); | |
162 | else sprintf(FileName, "run%d/%s/%s.root", n[irun],pass,filename); | |
163 | ||
164 | TFile mergedfile(FileName); | |
165 | if(kUseOriginalFile){ | |
166 | if(mergedfile.GetKey("ITS")==0x0){ | |
167 | printf("run %d In this run ITS QA has not been executed.--- Exit file\n",n[irun]); | |
168 | continue; | |
169 | } | |
170 | } | |
171 | if(kUseOriginalFile)sprintf(filepath,"ITS/RecPoints/%s/%s_SDDLay%dTotCh",especiename,especiename,layer); | |
172 | else sprintf(filepath,"%s_SDDLay%dTotCh",especiename,layer); | |
173 | sprintf(runnmbr,"run%d",n[irun]); | |
174 | printf("%s %s",filepath,runnmbr); | |
175 | histocharge=(TH1F*)(mergedfile.Get(filepath)); | |
176 | if(histocharge) | |
177 | { | |
178 | color=2+j; | |
179 | if (color>=12 && color<=27) { color=j+28; } | |
180 | histocharge->SetLineColor(color); | |
181 | if (j==0) | |
182 | { | |
183 | canvas[1]->cd(layer-2); | |
184 | ||
185 | canvas[1]->cd(layer-2)->SetFrameFillColor(kGray+3); | |
186 | histocharge->SetMaximum(fmaxmargin); | |
187 | histocharge->GetYaxis()->SetTitle(""); | |
188 | histocharge->DrawNormalized(); | |
189 | histocharge->SetMaximum(fmaxmargin); | |
190 | canvas[1]->cd(layer-2)->Update(); | |
191 | } | |
192 | if (j!=0) | |
193 | { | |
194 | ||
195 | canvas[1]->cd(layer-2); | |
196 | histocharge->DrawNormalized("same"); | |
197 | canvas[1]->cd(layer-2)->Update(); | |
198 | } | |
199 | if(layer==3)legend->AddEntry(histocharge,runnmbr,"l"); | |
200 | canvas[1]->cd(layer-2); | |
201 | legend->Draw(); | |
202 | canvas[1]->Update(); | |
203 | j++; | |
204 | printf("...Found\n"); | |
205 | ||
206 | }//end if histocharge | |
207 | else{printf("...Not Found....\n");} | |
208 | histocharge=NULL; | |
209 | ||
210 | //======================================================== Drift Time | |
211 | if(kUseOriginalFile)sprintf(filepath,"ITS/RecPoints/%s/%s_SDDdrifttime_Layer%d",especiename,especiename,layer); | |
212 | else sprintf(filepath,"%s_SDDdrifttime_Layer%d",especiename,layer); | |
213 | sprintf(runnmbr,"run %d",n[irun]); | |
214 | printf("%s %s",filepath,runnmbr); | |
215 | histocharge=(TH1F*)(mergedfile.Get(filepath)); | |
216 | if(histocharge) | |
217 | { | |
218 | printf("...Found\n"); | |
219 | histocharge->SetLineColor(color); | |
220 | if (hh==0) | |
221 | { | |
222 | canvas[2]->cd(layer-2); | |
223 | canvas[2]->cd(layer-2)->SetFrameFillColor(kGray+3); | |
224 | histocharge->SetMaximum(fmaxmargintime); | |
225 | histocharge->GetYaxis()->SetTitle(""); | |
226 | histocharge->DrawNormalized(); | |
227 | histocharge->SetMaximum(fmaxmargintime); | |
228 | } | |
229 | if (hh!=0) | |
230 | { | |
231 | canvas[2]->cd(layer-2); | |
232 | histocharge->DrawNormalized("same"); | |
233 | } | |
234 | if(layer==3)legend2->AddEntry(histocharge,runnmbr,"l"); | |
235 | canvas[2]->cd(layer-2); | |
236 | legend2->Draw(); | |
237 | canvas[2]->Update(); | |
238 | hh++; | |
239 | }//end if histocharge | |
240 | else{printf("...Not Found....\n");} | |
241 | histocharge=NULL; | |
242 | }//enf for | |
243 | }//end for layer | |
244 | ||
245 | TFile trendfile(Form("SDDQAtrend%s%s.root",period,pass),"recreate"); | |
246 | trendfile.cd(); | |
247 | for(Int_t ican=0;ican<3;ican++)canvas[ican]->Write(); | |
248 | trendfile.Close(); | |
249 | Char_t psfile[50]; | |
250 | sprintf(psfile,"SDDtrend%s%s.ps",period,pass); | |
251 | canvas[0]->Print(Form("%s[",psfile)); | |
252 | for(Int_t ifile=0;ifile<3;ifile++){canvas[ifile]->Print(psfile);} | |
253 | ||
254 | canvas[2]->Print(Form("%s]",psfile)); | |
255 | ||
256 | ||
257 | delete histocharge; | |
258 | ||
259 | ||
260 | ||
261 | ||
262 | }//end macro |