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