]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/Macros/AliTRDtestDigitsRW.C
Bug fixes
[u/mrichter/AliRoot.git] / TRD / Macros / AliTRDtestDigitsRW.C
CommitLineData
c3cb2041 1//
2// Test digits
3// Author: Mateusz Ploskon
4//
5void showLegend(TH1F *h, TH1F *h2)
6{
7 TLegend * leg = new TLegend(0, 0, 0.2, 0.2);
8 leg->AddEntry(h, h->GetTitle(), "LBF");
9 leg->AddEntry(h2, h2->GetTitle(), "LBF");
10 leg->Draw();
11}
12
13void AliTRDtestDigitsRW(Int_t thresh = 0, Int_t maxDet = 540)
14{
15 AliCDBManager *cdb = AliCDBManager::Instance();
162637e4 16 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
c3cb2041 17 cdb->SetRun(0);
18 cout << endl;
19
20 TFile *finD = TFile::Open("TRD.Digits.root");
21 TTree *treeD = (TTree*)finD->Get("Event0/TreeD");
22
23 AliTRDdigitsManager manD;
24 manD.ReadDigits(treeD);
25
26 AliTRDdigitsManager manR;
27 manR.CreateArrays();
28
29 AliRawReaderRoot reader("raw.root", 0);
30 reader.Select("TRD");
31 AliTRDRawStreamV2 stream(&reader);
32 stream.SetRawVersion(3);
33
34 Int_t ichambers = 0;
35 while (stream.NextChamber(&manR) >= 0)
36 ichambers++;
37
38 cout << "Chambers loaded - stream V2 " << ichambers << endl;
39
40 TH1F *hsignalD = new TH1F("hsignalD", "hsignalD - stream D", 1000, 0, 1000);
41 hsignalD->SetFillColor(32);
42 hsignalD->SetFillStyle(1001);
43 TH1F *hsignalR = new TH1F("hsignalR", "hsignalR - stream V2", 1000, 0, 1000);
44 hsignalR->SetLineWidth(2);
45 hsignalR->SetLineColor(kRed);
46
47 TH1F *htbinD = new TH1F("htbinD", "htbinD - stream D", 30, 0, 30);
48 htbinD->SetFillColor(32);
49 htbinD->SetFillStyle(1001);
50 TH1F *htbinR = new TH1F("htbinR", "htbinR - stream V2", 30, 0, 30);
51 htbinR->SetLineWidth(2);
52 htbinR->SetLineColor(kRed);
53
54 TH1F *hdetD = new TH1F("hdetD", "hdetD - stream D", 540, 0, 540);
55 hdetD->SetFillColor(32);
56 hdetD->SetFillStyle(1001);
57 TH1F *hdetR = new TH1F("hdetR", "hdetR - stream V2", 540, 0, 540);
58 hdetR->SetLineWidth(2);
59 hdetR->SetLineColor(kRed);
60
61 TH2F *h2D = new TH2F("h2D", "h2D - stream D", 16, 0, 16, 144, 0, 144 );
62 TH2F *h2R = new TH2F("h2R", "h2R - stream V2", 16, 0, 16, 144, 0, 144 );
63
64 TH2F *h2Drct[16]; // 1 for each row
65 TH2F *h2Rrct[16]; // 1 for each row
66 for (Int_t ir = 0; ir < 16; ir++)
67 {
68 char cname[255];
69 char ctitle[255];
70 sprintf(cname, "h2Drct_%d", ir);
71 sprintf(ctitle, "D Row %d;col;tbin;value", ir);
72 h2Drct[ir] = new TH2F(cname, ctitle, 144, 0, 144, 30, 0, 30);
73
74 sprintf(cname, "h2Rrct_%d", ir);
75 sprintf(ctitle, "R Row %d;col;tbin;value", ir);
76 h2Rrct[ir] = new TH2F(cname, ctitle, 144, 0, 144, 30, 0, 30);
77 }
78
79 for (Int_t idet = 0; idet < maxDet; idet++)
80 {
81 digitsD = manD.GetDigits(idet);
82 digitsD->Expand();
83 digitsR = manR.GetDigits(idet);
84
85 Int_t rowMax = digitsD->GetNrow();
86 Int_t colMax = digitsD->GetNcol();
87 Int_t timeMax = digitsD->GetNtime();
88
89 //cout << "\r Detector " << idet << endl;
90 cout << "\r Detector " << idet; cout.flush();
91
92 for (Int_t irow = 0; irow < rowMax; irow++)
93 {
94 for (Int_t icol = 0; icol < colMax; icol++)
95 {
96 for (Int_t itime = 0; itime < timeMax; itime++)
97 {
98 Int_t ivalD = digitsD->GetDataUnchecked(irow, icol, itime);
99 Int_t ivalR = digitsR->GetDataUnchecked(irow, icol, itime);
100
101 //if (ivalD > thresh && ivalR > thresh)
102 if (ivalD > thresh)
103 {
104 hsignalD->Fill(ivalD);
105 htbinD->Fill(itime, ivalD);
106 hdetD->Fill(idet, ivalD);
107 h2D->Fill(irow, icol, ivalD);
108 h2Drct[irow]->Fill(icol, itime, ivalD);
109 }
110
111 hsignalR->Fill(ivalR);
112 htbinR->Fill(itime, ivalR);
113 hdetR->Fill(idet, ivalR);
114 h2R->Fill(irow, icol, ivalR);
115 h2Rrct[irow]->Fill(icol, itime, ivalR);
116 } //time
117 } //col
118 } //row
119
120 digitsD->Compress(1,0);
121 }
122
123 cout << endl;
124
125 gStyle->SetPalette(1);
126
127 TCanvas *tc = new TCanvas("tc_d", "tc_d");
128 tc->Divide(2,3);
129 tc->cd(1);
130 hsignalR->Draw();
131 hsignalD->Draw("same");
132 hsignalR->Draw("same");
133 gPad->SetLogy();
134 showLegend(hsignalR, hsignalD);
135
136 tc->cd(2);
137 htbinR->Draw();
138 htbinD->Draw("same");
139 htbinR->Draw("same");
140 gPad->SetLogy();
141
142 tc->cd(3);
143 hdetR->Draw();
144 hdetD->Draw("same");
145 hdetR->Draw("same");
146 gPad->SetLogy();
147
148 tc->cd(5);
149 h2D->Draw("colz");
150 tc->cd(6);
151 h2R->Draw("colz");
152
153 TCanvas *tc1 = new TCanvas("tc_d_rct_1", "tc_d_rct_1");
154 tc1->Divide(4, 4);
155
156 TCanvas *tc2 = new TCanvas("tc_d_rct_2", "tc_d_rct_2");
157 tc2->Divide(4, 4);
158 for (Int_t ir = 0; ir < 16; ir++)
159 {
160 if (ir < 8)
161 {
162 tc1->cd(ir*2 + 1);
163 h2Drct[ir]->Draw("colz");
164 tc1->cd(ir*2 + 2);
165 h2Rrct[ir]->Draw("colz");
166 }
167 else
168 {
169 tc2->cd((ir-8)*2 + 1);
170 h2Drct[ir]->Draw("colz");
171 tc2->cd((ir-8)*2 + 2);
172 h2Rrct[ir]->Draw("colz");
173 }
174 }
175
176 //TCanvas *tc = new TCanvas("tc_d_rct", "tc_d_rct");
177 //tc->Divide(4, 8);
178
179// for (Int_t ir = 0; ir < 16; ir++)
180// {
181// tc1->cd(ir + 1);
182// h2Drct[ir]->Draw("colz");
183
184// tc2->cd(ir + 1);
185// h2Rrct[ir]->Draw("colz");
186// }
187
188}
189
190///---------------------------------------------------------------
191void testDigits2streams()
192{
193 AliCDBManager *cdb = AliCDBManager::Instance();
162637e4 194 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
c3cb2041 195 cdb->SetRun(0);
162637e4 196 //AliCDBStorage* localStorage = cdb->GetStorage("local://$ALICE_ROOT/OCDB");
c3cb2041 197 // cout << "[I] Is storage set : " << cdb->IsDefaultStorageSet() << endl;
198 cout << endl;
199
200// TFile *finD = TFile::Open("TRD.Digits.root");
201// TTree *treeD = (TTree*)finD->Get("Event0/TreeD");
202
203// AliTRDdigitsManager manD;
204// manD.ReadDigits(treeD);
205
206 //OLD stream
207 AliTRDdigitsManager manD;
208 manD.CreateArrays();
209
210 AliRawReaderRoot reader1("raw.root", 0);
211 reader1.Select("TRD");
212 AliTRDRawStream stream1(&reader1);
213 stream1.SetRawVersion(2);
214
215 Int_t ichambers = 0;
216 while (stream1.NextChamber(&manD) >= 0)
217 ichambers++;
218
219 cout << "Chambers loaded - stream V1" << ichambers << endl;
220
221 // NEW STREAM
222 AliTRDdigitsManager manR;
223 manR.CreateArrays();
224
225 AliRawReaderRoot reader("raw.root", 0);
226 reader.Select("TRD");
227 AliTRDRawStreamV2 stream(&reader);
228 stream.SetRawVersion(2);
229
230 Int_t ichambers = 0;
231 while (stream.NextChamber(&manR) >= 0)
232 ichambers++;
233
234 cout << "Chambers loaded - stream V2" << ichambers << endl;
235
236 AliTRDdataArrayI *digitsD = 0;
237 AliTRDdataArrayI *digitsR = 0;
238
239 TH1F *hsignalD = new TH1F("hsignalD", "hsignalD - stream V1", 1000, 0, 1000);
240 hsignalD->SetFillColor(32);
241 hsignalD->SetFillStyle(1001);
242 TH1F *hsignalR = new TH1F("hsignalR", "hsignalR - stream V2", 1000, 0, 1000);
243 hsignalR->SetLineWidth(2);
244 hsignalR->SetLineColor(kRed);
245
246 TH1F *htbinD = new TH1F("htbinD", "htbinD - stream V1", 30, 0, 30);
247 htbinD->SetFillColor(32);
248 htbinD->SetFillStyle(1001);
249 TH1F *htbinR = new TH1F("htbinR", "htbinR - stream V2", 30, 0, 30);
250 htbinR->SetLineWidth(2);
251 htbinR->SetLineColor(kRed);
252
253 TH2F *h2D = new TH2F("h2D", "h2D - stream V1", 16, 0, 16, 144, 0, 144 );
254 TH2F *h2R = new TH2F("h2R", "h2R - stream V2", 16, 0, 16, 144, 0, 144 );
255
256 //for (Int_t idet = 0; idet < 540; idet++)
257 for (Int_t idet = 0; idet < 10; idet++)
258 //for (Int_t idet = 0; idet < 10; idet++)
259 {
260 digitsD = manD.GetDigits(idet);
261 digitsD->Expand();
262 digitsR = manR.GetDigits(idet);
263
264 Int_t rowMax = digitsD->GetNrow();
265 Int_t colMax = digitsD->GetNcol();
266 Int_t timeMax = digitsD->GetNtime();
267
268 //cout << "\r Detector " << idet << endl;
269 cout << "\r Detector " << idet; cout.flush();
270
271 for (Int_t irow = 0; irow < rowMax; irow++)
272 {
273 for (Int_t icol = 0; icol < colMax; icol++)
274 {
275 for (Int_t itime = 0; itime < timeMax; itime++)
276 {
277 Int_t ivalD = digitsD->GetDataUnchecked(irow, icol, itime);
278 Int_t ivalR = digitsR->GetDataUnchecked(irow, icol, itime);
279
280 hsignalD->Fill(ivalD);
281 hsignalR->Fill(ivalR);
282
283 htbinD->Fill(itime, ivalD);
284 htbinR->Fill(itime, ivalR);
285
286 h2D->Fill(irow, icol, ivalD);
287 h2R->Fill(irow, icol, ivalR);
288
289 } //time
290 } //col
291 } //row
292
293 digitsD->Compress(1,0);
294 }
295
296 cout << endl;
297
298 gStyle->SetPalette(1);
299
300 TCanvas *tc = new TCanvas("tc", "tc");
301 tc->Divide(2,2);
302 tc->cd(1);
303 hsignalR->Draw();
304 hsignalD->Draw("same");
305 hsignalR->Draw("same");
306 gPad->SetLogy();
307 showLegend(hsignalR, hsignalD);
308
309 tc->cd(2);
310 htbinR->Draw();
311 htbinD->Draw("same");
312 htbinR->Draw("same");
313 gPad->SetLogy();
314
315 tc->cd(3);
316 h2D->Draw("colz");
317 tc->cd(4);
318 h2R->Draw("colz");
319}
320
321///---------------------------------------------------------------
322void printDigits()
323{
324 AliCDBManager *cdb = AliCDBManager::Instance();
162637e4 325 cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
c3cb2041 326 cdb->SetRun(0);
162637e4 327 //AliCDBStorage* localStorage = cdb->GetStorage("local://$ALICE_ROOT/OCDB");
c3cb2041 328 // cout << "[I] Is storage set : " << cdb->IsDefaultStorageSet() << endl;
329 cout << endl;
330
331 TFile *finD = TFile::Open("TRD.Digits.root");
332 TTree *treeD = (TTree*)finD->Get("Event0/TreeD");
333
334 AliTRDdigitsManager manD;
335 manD.SetRaw();
336 manD.ReadDigits(treeD);
337
338 AliTRDdataArrayI *digitsD = 0;
339
340 for (Int_t idet = 0; idet < 540; idet++)
341 {
342 digitsD = manD.GetDigits(idet);
343 digitsD.Expand();
344
345 Int_t rowMax = digitsD->GetNrow();
346 Int_t colMax = digitsD->GetNcol();
347 Int_t timeMax = digitsD->GetNtime();
348
349 cout << "Detector " << idet << " nrows " << rowMax << endl;
350
351 for (Int_t irow = 0; irow < rowMax; irow++)
352 {
353 for (Int_t icol = 0; icol < colMax; icol++)
354 {
355 for (Int_t itime = 0; itime < timeMax; itime++)
356 {
357 Int_t ivalD = digitsD->GetDataUnchecked(irow, icol, itime);
358 cout << Form("det %d rct %d %d %d valD=%d", idet, irow, icol, itime, ivalD) << endl;
359 }
360 }
361 }
362
363 digitsD->Compress(1,0);
364 }
365}