]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDqaBlackEvents.cxx
Update of DAQ DAs for trunk version
[u/mrichter/AliRoot.git] / TRD / AliTRDqaBlackEvents.cxx
CommitLineData
0f772b9f 1/**************************************************************************\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3 * *\r
4 * Author: The ALICE Off-line Project. *\r
5 * Contributors are mentioned in the code where appropriate. *\r
6 * *\r
7 * Permission to use, copy, modify and distribute this software and its *\r
8 * documentation strictly for non-commercial purposes is hereby granted *\r
f5fd37e8 9 * withount fee, provided that the abov copyright notice appears in all *\r
0f772b9f 10 * copies and that both the copyright notice and this permission notice *\r
11 * appear in the supporting documentation. The authors make no claims *\r
12 * about the suitability of this software for any purpose. It is *\r
13 * provided "as is" without express or implied warranty. *\r
14 **************************************************************************/\r
15\r
16/* $Id: AliTRDqaBlackEvents.cxx 23387 2008-01-17 17:25:16Z cblume $ */\r
17\r
18////////////////////////////////////////////////////////////////////////////\r
19// //\r
20// QA of black events //\r
21// //\r
22// Author: //\r
23// Sylwester Radomski (radomski@physi.uni-heidelberg.de) //\r
24// //\r
25////////////////////////////////////////////////////////////////////////////\r
26\r
27#include "TH1D.h"\r
28#include "TH2D.h"\r
29#include "TH3D.h"\r
30#include "TF1.h"\r
31#include "TFile.h"\r
32#include "TCanvas.h"\r
33#include "TPad.h"\r
34#include "TLatex.h"\r
35#include "TStyle.h"\r
36\r
37#include "AliTRDgeometry.h"\r
38#include "AliTRDrawStreamTB.h"\r
39#include "AliTRDqaBlackEvents.h"\r
40\r
41ClassImp(AliTRDqaBlackEvents)\r
42\r
43\r
44///////////////////////////////////////////////////////////////////////////////////////////////////\r
45\r
46AliTRDqaBlackEvents::AliTRDqaBlackEvents() \r
47 :TObject() \r
c29b11ff 48 ,fnEvents(0)\r
49 ,fOccupancy(0)\r
50 ,fFitType(0)\r
0f772b9f 51 ,fMinNoise(0.5)\r
52 ,fMaxNoise(2) \r
53{\r
54 //\r
55 // Constructor \r
56 // to create the histograms call Init()\r
57 //\r
58}\r
59\r
60///////////////////////////////////////////////////////////////////////////////////////////////////\r
61\r
62AliTRDqaBlackEvents::AliTRDqaBlackEvents(const AliTRDqaBlackEvents &qa) \r
63 :TObject(qa) \r
c29b11ff 64 ,fnEvents(0)\r
65 ,fOccupancy(0)\r
66 ,fFitType(0)\r
0f772b9f 67 ,fMinNoise(0.5)\r
68 ,fMaxNoise(2) \r
69{\r
70 //\r
71 // Copy constructor \r
72 // to create the histograms call Init()\r
73 //\r
74}\r
75\r
76///////////////////////////////////////////////////////////////////////////////////////////////////\r
77\r
78void AliTRDqaBlackEvents::Init() \r
79{\r
80 //\r
81 // creates histograms \r
82 // \r
83\r
84 //TFile *file = new \r
85 //Info("Init", "Statring");\r
86\r
9b99c029 87 fnEvents = 0;\r
88\r
0f772b9f 89 for(Int_t i=0; i<540; i++) {\r
9b99c029 90 fNPoint[i] = new TH2D(Form("entries_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);\r
0f772b9f 91 fData[i] = new TH3D(Form("data_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5, 50, -0.5, 49.5);\r
9b99c029 92 fChPed[i] = new TH2D(Form("ped_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);\r
0f772b9f 93 fChNoise[i] = new TH2D(Form("noise_%d", i), "", 16, -0.5, 15.5, 144, -0.5, 143.5);\r
9b99c029 94 fPed[i] = new TH1D(Form("pedDist_%d", i), ";pedestals (ADC counts)", 100, 5, 15);\r
f5fd37e8 95\r
96 fNoise[i] = new TH1D(Form("noiseDist_%d", i), ";noise (ADC counts)", 100, 0, 5); \r
c29b11ff 97 fSignal[i] = new TH1D(Form("signal_%d", i), ";signal (ADC counts)", 100, -0.5, 99.5);\r
f5fd37e8 98\r
c29b11ff 99 fnEntriesRM[i] = new TH2D(Form("entriesRM_%d", i), ";ROB,MCM", 8, -0.5, 7.5, 16, -0.5, 15.5);\r
0f772b9f 100 }\r
101\r
9b99c029 102 fOccupancy = new TH1D("occupancy", "", 20, -0.5, 19.5);\r
103\r
0f772b9f 104 //Info("Init", "Done");\r
105}\r
106\r
107\r
108///////////////////////////////////////////////////////////////////////////////////////////////////\r
109\r
110void AliTRDqaBlackEvents::Reset() \r
111{\r
112 //\r
113 // Resets the histograms\r
114 //\r
115\r
116 for(Int_t i=0; i<540; i++) {\r
117 fData[i]->Reset();\r
118 fChPed[i]->Reset();\r
119 fChNoise[i]->Reset();\r
120 }\r
121}\r
122\r
123///////////////////////////////////////////////////////////////////////////////////////////////////\r
124\r
125Int_t AliTRDqaBlackEvents::AddEvent(AliTRDrawStreamTB *data) \r
126{\r
127 //\r
128 // Add an event\r
129 //\r
130\r
9b99c029 131 \r
132 Char_t isUsed[540][16][144]; \r
133 for(Int_t i=0; i<540; i++)\r
134 for(Int_t j=0; j<16; j++)\r
135 for(Int_t k=0; k<144; k++)\r
136 isUsed[i][j][k] = 0;\r
137 \r
0f772b9f 138 Int_t nb = 0;\r
c29b11ff 139 Int_t rob_last = -1;\r
140 Int_t mcm_last = -1;\r
141\r
0f772b9f 142 while (data->Next()) {\r
143\r
144 Int_t det = data->GetDet();\r
f5fd37e8 145\r
9b99c029 146 Int_t row = data->GetRow();\r
147 Int_t col = data->GetCol();\r
f5fd37e8 148\r
c29b11ff 149 Int_t rob = data->GetROB();\r
150 Int_t mcm = data->GetMCM();\r
f5fd37e8 151\r
0f772b9f 152 Int_t *sig = data->GetSignals();\r
153 nb++;\r
154\r
9b99c029 155 //printf("det = %d\n", det);\r
156 \r
0f772b9f 157 if (det<0 || det>=540) continue;\r
c29b11ff 158\r
9b99c029 159 isUsed[det][row][col]++;\r
160\r
c29b11ff 161 if ((rob_last != rob) || (mcm_last != mcm)) {\r
162 rob_last = rob;\r
163 mcm_last = mcm;\r
164 fnEntriesRM[det]->Fill(rob,mcm);\r
165 }\r
166\r
9b99c029 167 // if (!isUsed[det][data->GetRow()][data->GetCol()]) {\r
168 // isUsed[det][data->GetRow()][data->GetCol()] = 1;\r
169 // continue;\r
170 // }\r
171\r
172 fNPoint[det]->Fill(row, col);\r
0f772b9f 173 \r
9b99c029 174 for(Int_t k=0; k<30; k++) { /// to be corrected\r
0f772b9f 175 fSignal[det]->Fill(sig[k]);\r
9b99c029 176 fData[det]->Fill(row, col, sig[k]);\r
0f772b9f 177 }\r
178 }\r
9b99c029 179 \r
180 for(Int_t i=0; i<540; i++) {\r
181 if (i != 0 && i != 8) continue;\r
182 for(Int_t j=0; j<16; j++)\r
183 for(Int_t k=0; k<144; k++)\r
184 fOccupancy->Fill(isUsed[i][j][k]);\r
185 }\r
0f772b9f 186\r
9b99c029 187 \r
188 fnEvents++;\r
0f772b9f 189 return nb;\r
190}\r
191\r
192///////////////////////////////////////////////////////////////////////////////////////////////////\r
193\r
194void AliTRDqaBlackEvents::Process(const char *filename) \r
195{\r
196 //\r
197 // Process something\r
198 //\r
199\r
200 Int_t map[540];\r
201 \r
202 TH1D *hist = new TH1D("fitSignal", "", 50, -0.5, 49.5);\r
203 TF1 *fit = new TF1("fit", "gaus(0)", 0, 20);\r
204 fit->SetParameters(1e3, 10, 1);\r
205 \r
206 for(Int_t i=0; i<540; i++) {\r
9b99c029 207 \r
0f772b9f 208 map[i] = 0;\r
9b99c029 209 if (fData[i]->GetSum() < 10) continue;\r
0f772b9f 210 map[i] = 1;\r
211\r
212 Info("process", "processing chamber %d", i);\r
213\r
214 for(Int_t j=0; j<fData[i]->GetXaxis()->GetNbins(); j++) {\r
215 for(Int_t k=0; k<fData[i]->GetYaxis()->GetNbins(); k++) {\r
216 \r
217 // project the histogramm\r
218 hist->Reset();\r
219 for(Int_t bb=0; bb<50; bb++) {\r
220 Int_t dataBin = fData[i]->FindBin(j, k, bb);\r
221 Double_t v = fData[i]->GetBinContent(dataBin);\r
222 hist->SetBinContent(bb+1, v);\r
223 }\r
224\r
225 //TH1D *hist = fData[i]->ProjectionZ(Form("pad_%_%d_%d", i, j, k), j+1, j+1, k+1, k+1);\r
226 \r
227 Int_t bin = fChPed[i]->FindBin(j, k);\r
228\r
9b99c029 229 if (hist->GetSum() > 1) {\r
230 \r
231 Double_t ped = 0, noise = 0;\r
232\r
233 if (fFitType == 0) {\r
234 fit->SetParameters(1e3, 10, 1);\r
235 hist->Fit(fit, "q0", "goff", 0, 20);\r
236 TF1 *f = hist->GetFunction("fit");\r
237 ped = TMath::Abs(f->GetParameter(1));\r
238 noise = TMath::Abs(f->GetParameter(2));\r
239 } else {\r
240 ped = hist->GetMean();\r
241 noise = hist->GetRMS();\r
242 }\r
0f772b9f 243\r
244 fChPed[i]->SetBinContent(bin, ped);\r
245 fChNoise[i]->SetBinContent(bin, noise);\r
246 \r
247 fPed[i]->Fill(ped);\r
248 fNoise[i]->Fill(noise);\r
249\r
250 } else {\r
9b99c029 251 fChPed[i]->SetBinContent(bin, 0);\r
252 fChNoise[i]->SetBinContent(bin, 0);\r
0f772b9f 253 }\r
254 \r
255 //delete hist;\r
256 }\r
257 }\r
258 }\r
259\r
c29b11ff 260 Info("Process", "Number of events = %d", fnEvents);\r
9b99c029 261\r
c29b11ff 262 // normalize number of entries histos\r
9b99c029 263 Int_t max = 0;\r
264 for(Int_t i=0; i<540; i++) { \r
265 if (!map[i]) continue;\r
266 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {\r
267 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {\r
268 Int_t dataBin = fNPoint[i]->FindBin(j, k);\r
269 Double_t v = fNPoint[i]->GetBinContent(dataBin);\r
270 if (v > max) max = (Int_t)v;\r
271 }\r
272 }\r
273 }\r
274 \r
275 for(Int_t i=0; i<540; i++) {\r
276 \r
277 if (!map[i]) continue;\r
278 \r
279 fNPointDist[i] = new TH1D(Form("entriesDist_%d", i), ";number of events", max+2, -0.5, max+1.5);\r
280 \r
281 for(Int_t j=0; j<fNPoint[i]->GetXaxis()->GetNbins(); j++) {\r
282 for(Int_t k=0; k<fNPoint[i]->GetYaxis()->GetNbins(); k++) {\r
283 Int_t dataBin = fNPoint[i]->FindBin(j, k);\r
284 Double_t v = fNPoint[i]->GetBinContent(dataBin);\r
285 //if (v > fnEvents) printf("N = %d V = %lf\n", fnEvents, v);\r
286 fNPointDist[i]->Fill(v); \r
287 }\r
288 }\r
289 \r
290 fNPoint[i]->Scale(1./fnEvents);\r
291 }\r
292 \r
f5fd37e8 293\r
c29b11ff 294 for(Int_t i=0; i<540; i++) {\r
295 fnEntriesRM[i]->SetMaximum(fnEvents * 1.5);\r
296 }\r
297\r
0f772b9f 298 TFile *file = new TFile(filename, "UPDATE");\r
299 for(Int_t i=0; i<540; i++) {\r
300 if (!map[i]) continue; \r
301 fChPed[i]->Write();\r
302 fChNoise[i]->Write();\r
9b99c029 303 fNPoint[i]->Write();\r
304 fNPointDist[i]->Write();\r
0f772b9f 305 fPed[i]->Write();\r
306 fNoise[i]->Write();\r
307 fSignal[i]->Write();\r
c29b11ff 308 fnEntriesRM[i]->Write();\r
0f772b9f 309 }\r
9b99c029 310 fOccupancy->Write();\r
0f772b9f 311 file->Close();\r
312 delete file;\r
313}\r
314\r
315///////////////////////////////////////////////////////////////////////////////////////////////////\r
316\r
317void AliTRDqaBlackEvents::DrawChamber(const char *filename, Int_t det, Int_t w, Int_t h) \r
318{\r
319 //\r
320 // Draw raport for one chamber: \r
321 // pedestal map, noise map, distribution of pedestal and noise\r
322 // \r
323 // input:\r
324 // name of the file with histograms (created with Process())\r
325 // detector Id (0 - 539)\r
326 // \r
327\r
328 // setup global style\r
329 gStyle->SetPalette(1);\r
330 gStyle->SetOptStat(0);\r
331 gStyle->SetPadTopMargin(0.02);\r
332 gStyle->SetPadBottomMargin(0.05);\r
333\r
334 TFile *file = new TFile(filename, "READ");\r
335\r
336 TCanvas *c = new TCanvas("blackEvents",Form("blackEvents %d",det), w, h);\r
337 c->SetVertical(kFALSE);\r
338 c->Divide(3,1, 0.01, 0.01);\r
339 c->cd(3);\r
340 \r
341 TPad *mPad = (TPad*) gPad;\r
342 mPad->Divide(1,2,0.01,0.01);\r
343 \r
344 c->cd(1);\r
345 TH2D *h2 = (TH2D*)file->Get(Form("ped_%d",det));\r
346 h2->SetMinimum(5);\r
347 h2->SetMaximum(15);\r
348 h2->SetTitle(";Z direction;#phi direction");\r
349 h2->Draw("colz");\r
350 \r
351 c->cd(2);\r
352 h2 = (TH2D*)file->Get(Form("noise_%d",det));\r
353 h2->SetMinimum(fMinNoise);\r
354 h2->SetMaximum(fMaxNoise);\r
355 h2->SetTitle(";Z direction;#phi direction");\r
356 h2->Draw("colz");\r
357 \r
358 mPad->cd(1);\r
359 //gPad->SetLogy();\r
360 TH1D *h1 = (TH1D*)file->Get(Form("pedDist_%d", det));\r
361 h1->Draw();\r
362 \r
363 mPad->cd(2);\r
364 gPad->SetLogy();\r
365 h1 = (TH1D*)file->Get(Form("noiseDist_%d", det));\r
366 h1->Draw(); \r
367 \r
368 h1->Fit("gaus");\r
369 TF1 *f = h1->GetFunction("gaus");\r
370 const char *tt = Form("#mu = %.2f #sigma = %0.2f ", f->GetParameter(1),f->GetParameter(2));\r
371 TLatex *ll = new TLatex(2, 100, tt);\r
372 ll->SetTextSize(0.06);\r
373 ll->Draw();\r
374}\r
375\r
376///////////////////////////////////////////////////////////////////////////////////////////////////\r
377\r
378void AliTRDqaBlackEvents::DrawSm(const char *filename, Int_t sm, Int_t w, Int_t h) \r
379{\r
380 //\r
381 // ????????????\r
382 //\r
383 \r
384 gStyle->SetPalette(1);\r
385 gStyle->SetOptStat(0);\r
386 \r
387 gStyle->SetPadTopMargin(0.02);\r
388 //gStyle->SetPadBottomMargin(0.05); \r
389 //gStyle->SetPadLeftMargin(0.02); \r
390 //gStyle->SetPadRightMargin(0.02);\r
391\r
392 TFile *file = new TFile(filename, "READ");\r
393\r
394 TCanvas *c = new TCanvas("blackEventsSM",Form("blackEvents SM %d",sm), w, h);\r
395 c->SetVertical(kFALSE);\r
396 c->Divide(5, 6, 0.001, 0.01);\r
397 \r
398 for(Int_t i=0; i<30; i++) {\r
399 \r
400 TH2D *h2 = (TH2D*)file->Get(Form("noise_%d",i+30*sm));\r
401 if (!h2) continue;\r
402 h2->SetMinimum(fMinNoise);\r
403 h2->SetMaximum(fMaxNoise);\r
404\r
405 // to be replaced by the official calculation\r
406 Int_t stack = i/6;\r
407 Int_t layer = i%6;\r
408 Int_t index = (5-layer)*5 + stack + 1;\r
409 //printf("%d %d %d %d\n", i, stack, layer, index);\r
410 c->cd(index);\r
411 gPad->SetBottomMargin(0.02);\r
412 gPad->SetTopMargin(0.02);\r
413\r
414 h2->Draw("col");\r
415 }\r
416}\r
417\r
418///////////////////////////////////////////////////////////////////////////////////////////////////\r