]>
Commit | Line | Data |
---|---|---|
91282711 | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | #include <TH2F.h> | |
3 | #include <TCanvas.h> | |
4 | #include <TStopwatch.h> | |
5 | #include <TStyle.h> | |
6 | #include <TGrid.h> | |
7 | #include <TSystem.h> | |
8 | #include <TLatex.h> | |
9 | #include <TFile.h> | |
10 | #include "AliRawReader.h" | |
11 | #include "AliRawReaderDate.h" | |
12 | #include "AliRawReaderRoot.h" | |
13 | #include "AliITSOnlineSDDBase.h" | |
14 | #include "AliITSOnlineSDDCMN.h" | |
15 | #include "AliITSRawStreamSDD.h" | |
16 | #include "TPaveStats.h" | |
17 | #endif | |
18 | ||
19 | // Macro for the analysis of PEDESTAL runs (equivalent to ITSSDDBASda.cxx) | |
20 | // Two functions named AnalyzeSDDNoiseAllModules: | |
21 | // The first is for analyzing a local raw data file and takes as agrument the file name. | |
22 | // The second is for running on ALIEN | |
23 | // All DDLs are analyzed, the argument nDDL selects the DDL to be plotted | |
24 | // Origin: F. Prino (prino@to.infn.it) | |
25 | ||
26 | void AnalyzeSDDNoiseAllMod(Char_t *datafil, Int_t nDDL, Int_t firstEv=10, Int_t lastEv=12){ | |
5a4e63d5 | 27 | |
91282711 | 28 | const Int_t kTotDDL=24; |
29 | const Int_t kModPerDDL=12; | |
30 | const Int_t kSides=2; | |
31 | ||
32 | AliITSOnlineSDDBase **base=new AliITSOnlineSDDBase*[kTotDDL*kModPerDDL*kSides]; | |
33 | TH2F **histo=new TH2F*[kTotDDL*kModPerDDL*kSides]; | |
34 | ||
35 | Char_t hisnam[20]; | |
36 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
37 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
38 | for(Int_t isid=0;isid<kSides;isid++){ | |
39 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
40 | base[index]=new AliITSOnlineSDDBase(iddl,imod,isid); | |
91282711 | 41 | sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid); |
42 | histo[index]=new TH2F(hisnam,"",128,-0.5,127.5,256,-0.5,255.5); | |
43 | } | |
44 | } | |
45 | } | |
46 | ||
47 | ||
48 | TCanvas* c0 = new TCanvas("c0","Ev Display",900,900); | |
49 | gStyle->SetPalette(1); | |
50 | Char_t text[50]; | |
51 | ||
52 | Int_t iev=firstEv; | |
53 | AliRawReader *rd; | |
54 | if(strstr(datafil,".root")!=0){ | |
55 | rd=new AliRawReaderRoot(datafil,iev); | |
56 | }else{ | |
57 | rd=new AliRawReaderDate(datafil,iev); | |
58 | } | |
59 | TLatex *t0=new TLatex(); | |
60 | t0->SetNDC(); | |
61 | t0->SetTextSize(0.06); | |
62 | t0->SetTextColor(4); | |
63 | ||
64 | do{ | |
65 | c0->Clear(); | |
66 | c0->Divide(4,6,0.001,0.001); | |
67 | printf("Event # %d ",iev); | |
91282711 | 68 | rd->Reset(); |
69 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
70 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
71 | for(Int_t isid=0;isid<kSides;isid++){ | |
72 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
73 | histo[index]->Reset(); | |
74 | } | |
75 | } | |
76 | } | |
77 | AliITSRawStreamSDD s(rd); | |
91282711 | 78 | while(s.Next()){ |
79 | Int_t iDDL=rd->GetDDLID(); | |
80 | Int_t iCarlos=s.GetCarlosId(); | |
81 | if(iDDL>=0 && iDDL<kTotDDL && s.IsCompletedModule()==kFALSE){ | |
82 | Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s.GetChannel(); | |
83 | histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal()); | |
84 | } | |
85 | } | |
86 | iev++; | |
87 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
88 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
89 | for(Int_t isid=0;isid<kSides;isid++){ | |
90 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
91 | base[index]->AddEvent(histo[index]); | |
92 | if(iddl==nDDL){ | |
93 | Int_t index2=kSides*imod+isid; | |
94 | c0->cd(index2+1); | |
95 | histo[index]->DrawCopy("colz"); | |
96 | sprintf(text,"DDL %d channel %d Side %d",nDDL,imod,isid); | |
97 | t0->DrawLatex(0.15,0.92,text); | |
98 | c0->Update(); | |
99 | } | |
100 | } | |
101 | } | |
102 | } | |
103 | printf(" --- OK\n"); | |
104 | }while(rd->NextEvent()&&iev<=lastEv); | |
105 | ||
106 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
107 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
108 | for(Int_t isid=0;isid<kSides;isid++){ | |
109 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
110 | base[index]->ValidateAnodes(); | |
111 | base[index]->WriteToASCII(); // fondamentale!!!!!!!!! | |
112 | delete base[index]; | |
113 | } | |
114 | } | |
115 | } | |
116 | delete rd; | |
117 | delete [] base; | |
118 | ||
119 | printf("Start second analysis for Common Mode correction\n"); | |
120 | AliITSOnlineSDDCMN **corr=new AliITSOnlineSDDCMN*[kTotDDL*kModPerDDL*kSides]; | |
121 | Bool_t isFilled[kTotDDL*kModPerDDL*kSides]; | |
122 | ||
123 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
124 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
125 | for(Int_t isid=0;isid<kSides;isid++){ | |
126 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
127 | corr[index]=new AliITSOnlineSDDCMN(iddl,imod,isid); | |
128 | isFilled[index]=0; | |
129 | } | |
130 | } | |
131 | } | |
132 | ||
133 | iev=firstEv; | |
134 | AliRawReader *rd2; | |
135 | if(strstr(datafil,".root")!=0){ | |
136 | rd2=new AliRawReaderRoot(datafil,iev); | |
137 | }else{ | |
138 | rd2=new AliRawReaderDate(datafil,iev); | |
139 | } | |
140 | do{ | |
141 | c0->Clear(); | |
142 | c0->Divide(4,6,0.001,0.001); | |
143 | printf("Event # %d ",iev); | |
91282711 | 144 | rd2->Reset(); |
145 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
146 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
147 | for(Int_t isid=0;isid<kSides;isid++){ | |
148 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
149 | histo[index]->Reset(); | |
150 | } | |
151 | } | |
152 | } | |
153 | ||
154 | AliITSRawStreamSDD s(rd2); | |
91282711 | 155 | while(s.Next()){ |
156 | Int_t iDDL=rd2->GetDDLID(); | |
157 | Int_t iCarlos=s.GetCarlosId(); | |
158 | if(iDDL>=0 && iDDL<kTotDDL && s.IsCompletedModule()==kFALSE){ | |
159 | Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s.GetChannel(); | |
160 | histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal()); | |
161 | isFilled[index]=1; | |
162 | } | |
163 | } | |
164 | iev++; | |
165 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
166 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
167 | for(Int_t isid=0;isid<kSides;isid++){ | |
168 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
169 | if(isFilled[index]) corr[index]->AddEvent(histo[index]); | |
170 | if(iddl==nDDL){ | |
171 | Int_t index2=kSides*imod+isid; | |
172 | c0->cd(index2+1); | |
173 | histo[index]->DrawCopy("colz"); | |
174 | sprintf(text,"DDL %d channel %d Side %d",nDDL,imod,isid); | |
175 | t0->DrawLatex(0.15,0.92,text); | |
176 | c0->Update(); | |
177 | } | |
178 | } | |
179 | } | |
180 | } | |
181 | printf(" --- OK\n"); | |
182 | }while(rd2->NextEvent()&&iev<=lastEv); | |
183 | ||
184 | TH1F *htotbas=new TH1F("htotbas","",100,0.,150.); | |
185 | TH1F *htotbaseq=new TH1F("htotbaseq","",100,0.,150.); | |
186 | TH1F *htotnoise=new TH1F("htotnoise","",100,0.,10.); | |
187 | TH1F *htotnoisecorr=new TH1F("htotnoisecorr","",100,0.,10.); | |
188 | TH1F *hstatus=new TH1F("hstatus","",2,-0.5,1.5); | |
189 | ||
190 | TFile *outfil=new TFile("SDDbase-results.root","recreate"); | |
191 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
192 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
193 | for(Int_t isid=0;isid<kSides;isid++){ | |
194 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
195 | if(isFilled[index]){ | |
196 | corr[index]->ValidateAnodes(); | |
197 | corr[index]->WriteToASCII(); | |
198 | corr[index]->WriteToROOT(outfil); | |
199 | for(Int_t ian=0; ian<256;ian++){ | |
200 | Float_t basl=corr[index]->GetAnodeBaseline(ian); | |
201 | Float_t basleq=corr[index]->GetAnodeEqualizedBaseline(ian); | |
202 | Float_t noi=corr[index]->GetAnodeRawNoise(ian); | |
203 | Float_t cornoi=corr[index]->GetAnodeCorrNoise(ian); | |
204 | Int_t anstatus=corr[index]->IsAnodeGood(ian); | |
205 | hstatus->Fill(anstatus); | |
206 | htotbas->Fill(basl); | |
207 | htotbaseq->Fill(basleq); | |
208 | htotnoise->Fill(noi); | |
209 | htotnoisecorr->Fill(cornoi); | |
210 | } | |
211 | } | |
212 | } | |
213 | } | |
214 | } | |
215 | outfil->Close(); | |
216 | // Draw Statistics of baselines and noise | |
217 | TCanvas *call=new TCanvas("call","General stats",700,700); | |
218 | call->Divide(2,2); | |
219 | call->cd(1); | |
220 | htotbas->Draw(); | |
221 | htotbas->GetXaxis()->SetTitle("Baselines"); | |
222 | htotbas->GetXaxis()->SetTitleSize(0.07); | |
223 | htotbas->GetXaxis()->SetTitleOffset(0.6); | |
224 | call->cd(2); | |
225 | htotbaseq->Draw(); | |
226 | htotbaseq->GetXaxis()->SetTitle("Baselines after equalization"); | |
227 | htotbaseq->GetXaxis()->SetTitleSize(0.07); | |
228 | htotbaseq->GetXaxis()->SetTitleOffset(0.6); | |
229 | call->cd(3); | |
230 | htotnoisecorr->SetLineColor(2); | |
231 | htotnoisecorr->Draw(); | |
232 | call->Update(); | |
233 | TPaveStats *st1=(TPaveStats*)htotnoisecorr->GetListOfFunctions()->FindObject("stats"); | |
234 | st1->SetY1NDC(0.51); | |
235 | st1->SetY2NDC(0.7); | |
236 | htotnoisecorr->GetXaxis()->SetTitle("Noise"); | |
237 | htotnoisecorr->GetXaxis()->SetTitleSize(0.07); | |
238 | htotnoisecorr->GetXaxis()->SetTitleOffset(0.6); | |
239 | htotnoise->Draw("SAMES"); | |
240 | call->Update(); | |
241 | TPaveStats *st2=(TPaveStats*)htotnoise->GetListOfFunctions()->FindObject("stats"); | |
242 | st2->SetY1NDC(0.71); | |
243 | st2->SetY2NDC(0.9); | |
244 | ||
245 | call->cd(4); | |
246 | hstatus->Draw(); | |
247 | hstatus->GetXaxis()->SetTitle("Anode Status (0=bad 1=good)"); | |
248 | hstatus->GetXaxis()->SetTitleSize(0.07); | |
249 | hstatus->GetXaxis()->SetTitleOffset(0.6); | |
250 | call->Update(); | |
251 | call->SaveAs("GenStatsPedestal.gif"); | |
252 | ||
253 | // Draw baselines and noise for all modules of the selected DDL | |
254 | ||
255 | TH1F** hbas = new TH1F*[kSides*kModPerDDL]; | |
256 | TH1F** hrawn = new TH1F*[kSides*kModPerDDL]; | |
257 | TH1F** hcorrn = new TH1F*[kSides*kModPerDDL]; | |
258 | TH1F** hdbas = new TH1F*[kSides*kModPerDDL]; | |
259 | TH1F** hdrawn = new TH1F*[kSides*kModPerDDL]; | |
260 | TH1F** hdcorrn = new TH1F*[kSides*kModPerDDL]; | |
261 | TCanvas *c1=new TCanvas("c1","DDL: Baselines vs anode",900,900); | |
262 | c1->SetBottomMargin(0.14); | |
263 | c1->Divide(4,6,0.001,0.001); | |
264 | TCanvas *c2=new TCanvas("c2","DDL: Noise vs anode",900,900); | |
265 | c2->SetBottomMargin(0.14); | |
266 | c2->Divide(4,6,0.001,0.001); | |
267 | TCanvas *c3=new TCanvas("c3","DDL: Baselines distr",900,900); | |
268 | c3->SetBottomMargin(0.14); | |
269 | c3->Divide(4,6,0.001,0.001); | |
270 | TCanvas *c4=new TCanvas("c4","DDL: Noise Distr",900,900); | |
271 | c4->SetBottomMargin(0.14); | |
272 | c4->Divide(4,6,0.001,0.001); | |
273 | TLatex *t1=new TLatex(0.15,0.2,"Raw Noise"); | |
274 | t1->SetNDC(); | |
275 | t1->SetTextSize(0.05); | |
276 | TLatex *t2=new TLatex(0.4,0.2,"Corrected Noise"); | |
277 | t2->SetNDC(); | |
278 | t2->SetTextSize(0.05); | |
279 | t2->SetTextColor(2); | |
280 | TLatex *t3=new TLatex(); | |
281 | t3->SetNDC(); | |
282 | t3->SetTextSize(0.06); | |
283 | t3->SetTextColor(4); | |
284 | ||
285 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
286 | for(Int_t isid=0;isid<kSides;isid++){ | |
287 | Int_t index1=kSides*(kModPerDDL*nDDL+imod)+isid; | |
288 | Int_t index2=kSides*imod+isid; | |
289 | sprintf(text,"DDL %d channel %d Side %d",nDDL,imod,isid); | |
290 | hbas[index2]=corr[index1]->GetBaselineAnodeHisto(); | |
291 | hrawn[index2]=corr[index1]->GetRawNoiseAnodeHisto(); | |
292 | hcorrn[index2]=corr[index1]->GetCorrNoiseAnodeHisto(); | |
293 | hdbas[index2]=corr[index1]->GetBaselineHisto(); | |
294 | hdrawn[index2]=corr[index1]->GetRawNoiseHisto(); | |
295 | hdcorrn[index2]=corr[index1]->GetCorrNoiseHisto(); | |
296 | c1->cd(index2+1); | |
297 | hbas[index2]->Draw(); | |
298 | hbas[index2]->SetMinimum(0); | |
299 | hbas[index2]->SetMaximum(75); | |
300 | hbas[index2]->GetXaxis()->SetTitle("Anode"); | |
301 | hbas[index2]->GetYaxis()->SetTitle("Baseline"); | |
302 | hbas[index2]->GetXaxis()->SetTitleSize(0.07); | |
303 | hbas[index2]->GetYaxis()->SetTitleSize(0.07); | |
304 | hbas[index2]->GetXaxis()->SetTitleOffset(0.6); | |
305 | hbas[index2]->GetYaxis()->SetTitleOffset(0.7); | |
306 | t3->DrawLatex(0.15,0.92,text); | |
307 | c1->Update(); | |
308 | ||
309 | ||
310 | c2->cd(index2+1); | |
311 | hrawn[index2]->SetMinimum(1.); | |
312 | hrawn[index2]->SetMaximum(6.); | |
313 | hrawn[index2]->Draw(); | |
314 | hrawn[index2]->GetXaxis()->SetTitle("Anode"); | |
315 | hrawn[index2]->GetYaxis()->SetTitle("Noise"); | |
316 | hrawn[index2]->GetXaxis()->SetTitleSize(0.07); | |
317 | hrawn[index2]->GetYaxis()->SetTitleSize(0.07); | |
318 | hrawn[index2]->GetXaxis()->SetTitleOffset(0.6); | |
319 | hrawn[index2]->GetYaxis()->SetTitleOffset(0.7); | |
320 | gStyle->SetOptStat(0); | |
321 | hrawn[index2]->SetStats(0); | |
322 | hcorrn[index2]->SetLineColor(2); | |
323 | hcorrn[index2]->Draw("SAME"); | |
324 | t1->Draw(); | |
325 | t2->Draw(); | |
326 | t3->DrawLatex(0.15,0.92,text); | |
327 | c2->Update(); | |
328 | ||
329 | c3->cd(index2+1); | |
330 | hdbas[index2]->Draw(); | |
331 | hdbas[index2]->GetXaxis()->SetTitle("Baseline"); | |
332 | hdbas[index2]->GetXaxis()->SetTitleSize(0.07); | |
333 | hdbas[index2]->GetXaxis()->SetTitleOffset(0.6); | |
334 | t3->DrawLatex(0.15,0.92,text); | |
335 | c3->Update(); | |
336 | ||
337 | c4->cd(index2+1); | |
338 | hdrawn[index2]->Draw(); | |
339 | hdrawn[index2]->GetXaxis()->SetTitle("Noise"); | |
340 | hdrawn[index2]->GetXaxis()->SetTitleSize(0.07); | |
341 | hdrawn[index2]->GetXaxis()->SetTitleOffset(0.6); | |
342 | hdcorrn[index2]->SetLineColor(2); | |
343 | hdcorrn[index2]->Draw("SAME"); | |
344 | t1->Draw(); | |
345 | t2->Draw(); | |
346 | t3->DrawLatex(0.15,0.92,text); | |
347 | c4->Update(); | |
348 | } | |
349 | } | |
350 | ||
351 | c1->SaveAs("Baselines.gif"); | |
352 | c2->SaveAs("Noise.gif"); | |
353 | c3->SaveAs("BaselinesDist.gif"); | |
354 | c4->SaveAs("NoiseDist.gif"); | |
355 | ||
356 | Char_t delfil[100]; | |
357 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
358 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
359 | for(Int_t isid=0;isid<kSides;isid++){ | |
360 | sprintf(delfil,"rm SDDbase_step1_ddl%02dc%02d_sid%d.data",iddl,imod,isid); | |
361 | gSystem->Exec(delfil); | |
362 | } | |
363 | } | |
364 | } | |
365 | ||
366 | } | |
367 | ||
a7996467 | 368 | void AnalyzeSDDNoiseAllMod(Int_t nrun, Int_t n2, Char_t* dir="LHC08d_SDD",Int_t nDDL=0, Int_t firstEv=15, Int_t lastEv=18){ |
91282711 | 369 | TGrid::Connect("alien:",0,0,"t"); |
370 | Char_t filnam[200]; | |
a7996467 | 371 | sprintf(filnam,"alien:///alice/data/2008/%s/%09d/raw/08%09d%03d.10.root",dir,nrun,nrun,n2); |
91282711 | 372 | printf("Open file %s\n",filnam); |
373 | AnalyzeSDDNoiseAllMod(filnam,nDDL,firstEv,lastEv); | |
374 | } |