]>
Commit | Line | Data |
---|---|---|
e508dc19 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id: AliTRDqaRecPoints.cxx 23387 2008-01-17 17:25:16Z cblume $ */ | |
17 | ||
18 | //////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Produces the data needed to calculate the quality assurance. // | |
21 | // All data must be mergeable objects. // | |
22 | // // | |
23 | // Author: // | |
24 | // Sylwester Radomski (radomski@physi.uni-heidelberg.de) // | |
25 | // // | |
26 | //////////////////////////////////////////////////////////////////////////// | |
27 | ||
28 | // --- ROOT system --- | |
29 | #include <TClonesArray.h> | |
30 | #include <TFile.h> | |
31 | #include <TH1D.h> | |
32 | #include <TH2D.h> | |
33 | #include <TH3D.h> | |
34 | #include <TProfile.h> | |
35 | #include <TF1.h> | |
36 | #include <TCanvas.h> | |
37 | ||
38 | // --- AliRoot header files --- | |
39 | #include "AliESDEvent.h" | |
40 | #include "AliLog.h" | |
41 | #include "AliTRDcluster.h" | |
42 | #include "AliTRDqaRecPoints.h" | |
43 | #include "AliTRDgeometry.h" | |
e508dc19 | 44 | |
45 | #include "AliQAChecker.h" | |
46 | ||
47 | ClassImp(AliTRDqaRecPoints) | |
48 | ||
49 | //____________________________________________________________________________ | |
50 | ||
51 | AliTRDqaRecPoints::AliTRDqaRecPoints() : | |
52 | TObject(), | |
53 | fnEvents(0), | |
54 | fHist(0), | |
55 | fnPad(0), | |
56 | fRef(0) | |
57 | { | |
58 | // | |
59 | // Default constructor | |
60 | // | |
61 | ||
62 | } | |
63 | ||
64 | //____________________________________________________________________________ | |
65 | ||
66 | AliTRDqaRecPoints::AliTRDqaRecPoints(const AliTRDqaRecPoints &/*qa*/) : | |
67 | TObject(), | |
68 | fnEvents(0), | |
69 | fHist(0), | |
70 | fnPad(0), | |
71 | fRef(0) | |
72 | { | |
73 | // | |
74 | // Copy constructor | |
75 | // | |
76 | ||
77 | } | |
78 | ||
79 | //____________________________________________________________________________ | |
80 | void AliTRDqaRecPoints::Process(const char* filename) | |
81 | { | |
82 | // | |
83 | // Detector specific actions at end of cycle | |
84 | // | |
85 | //TStopwatch watch; | |
86 | //watch.Start(); | |
87 | ||
88 | AliInfo("End of TRD cycle"); | |
89 | ||
90 | //if (task == AliQA::kRECPOINTS) { | |
91 | ||
92 | TH1D *hist = new TH1D("fitHist", "", 200, -0.5, 199.5); | |
93 | //fHist->Print(); | |
94 | ||
95 | // fill detector map; | |
96 | for(int i=0; i<540; i++) { | |
97 | Double_t v = ((TH1D*)fHist->At(0))->GetBinContent(i+1); | |
98 | Int_t sm = i/30; | |
99 | Int_t det = i%30; | |
100 | ||
101 | TH2D *detMap = (TH2D*)fHist->At(87); | |
102 | Int_t bin = detMap->FindBin(sm, det); | |
103 | detMap->SetBinContent(bin, v); | |
104 | } | |
105 | ||
106 | ||
107 | // Rec points full chambers | |
108 | for (Int_t i=0; i<540; i++) { | |
109 | ||
110 | //AliInfo(Form("I = %d", i)); | |
111 | ||
112 | //TH1D *h = ((TH2D*)fHist->At(1))->ProjectionY(Form("qaTRD_recPoints_amp_%d",i), i+1, i+1); | |
113 | hist->Reset(); | |
114 | for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) { | |
115 | Double_t xvalue = hist->GetBinCenter(b); | |
116 | Int_t bin = ((TH2D*)fHist->At(1))->FindBin(i,xvalue); | |
117 | Double_t value = ((TH2D*)fHist->At(1))->GetBinContent(bin); | |
118 | hist->SetBinContent(b, value); | |
119 | } | |
120 | ||
121 | //printf("Sum = %d %f\n", i, hist->GetSum()); | |
122 | if (hist->GetSum() < 100) continue; // chamber not present | |
123 | ||
124 | hist->Fit("landau", "q0", "goff", 10, 180); | |
125 | TF1 *fit = hist->GetFunction("landau"); | |
126 | ((TH1D*)fHist->At(12))->Fill(fit->GetParameter(1)); | |
127 | ((TH1D*)fHist->At(13))->Fill(fit->GetParameter(2)); | |
128 | } | |
129 | ||
130 | // time-bin by time-bin sm by sm | |
131 | for(Int_t i=0; i<18; i++) { // loop over super-modules | |
132 | ||
133 | for(Int_t j=0; j<35; j++) { // loop over time bins | |
134 | ||
135 | //TH1D *h = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, j+1, j+1); | |
136 | hist->Reset(); | |
137 | for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) { | |
138 | Double_t xvalue = hist->GetBinCenter(b); | |
139 | Double_t svalue = 0; | |
140 | ||
141 | for(Int_t det=i*30; det<(i+1)*30; det++) { // loop over detectors | |
142 | Int_t bin = ((TH3D*)fHist->At(10))->FindBin(det,j,xvalue); | |
143 | Double_t value = ((TH3D*)fHist->At(10))->GetBinContent(bin); | |
144 | svalue += value; | |
145 | } | |
146 | //printf("v = %f\n", value); | |
147 | hist->SetBinContent(b, svalue); | |
148 | } | |
149 | ||
150 | if (hist->GetSum() < 100) continue; | |
151 | //printf("fitting %d %d %f\n", i, j, hist->GetSum()); | |
152 | ||
153 | hist->Fit("landau", "q0", "goff", 10, 180); | |
154 | TF1 *fit = hist->GetFunction("landau"); | |
155 | ||
156 | TH1D *h1 = (TH1D*)fHist->At(14+18+i); | |
157 | Int_t bin = h1->FindBin(j); | |
158 | // printf("%d %d %d\n", det, j, bin); | |
159 | h1->SetBinContent(bin, TMath::Abs(fit->GetParameter(1))); | |
160 | } | |
161 | } | |
162 | ||
163 | ||
164 | // time-bin by time-bin chamber by chamber | |
165 | ||
166 | for (Int_t i=0; i<540; i++) { | |
167 | ||
168 | //TH1D *test = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, 0, 35); | |
169 | //if (test->GetSum() < 100) continue; | |
170 | ||
171 | //AliInfo(Form("fitting det = %d", i)); | |
172 | ||
173 | for(Int_t j=0; j<35; j++) { | |
174 | ||
175 | //TH1D *h = ((TH3D*)fHist->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, j+1, j+1); | |
176 | hist->Reset(); | |
177 | for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) { | |
178 | Double_t xvalue = hist->GetBinCenter(b); | |
179 | Int_t bin = ((TH3D*)fHist->At(10))->FindBin(i,j,xvalue); | |
180 | Double_t value = ((TH3D*)fHist->At(10))->GetBinContent(bin); | |
181 | //printf("v = %f\n", value); | |
182 | hist->SetBinContent(b, value); | |
183 | } | |
184 | ||
185 | if (hist->GetSum() < 100) continue; | |
186 | //printf("fitting %d %d %f\n", i, j, hist->GetSum()); | |
187 | ||
188 | hist->Fit("landau", "q0", "goff", 10, 180); | |
189 | TF1 *fit = hist->GetFunction("landau"); | |
190 | ||
191 | Int_t sm = i/30; | |
192 | Int_t det = i%30; | |
193 | TH2D *h2 = (TH2D*)fHist->At(14+sm); | |
194 | Int_t bin = h2->FindBin(det,j); | |
195 | // printf("%d %d %d\n", det, j, bin); | |
196 | h2->SetBinContent(bin, TMath::Abs(fit->GetParameter(1))); | |
197 | h2->SetBinError(bin,fit->GetParError(1)); | |
198 | } | |
199 | } | |
200 | ||
201 | if (hist) delete hist; | |
202 | ||
203 | ||
204 | TFile *outFile = new TFile(filename, "RECREATE"); | |
205 | outFile->mkdir("TRD"); | |
206 | gDirectory->cd("TRD"); | |
207 | gDirectory->mkdir("RecPoints"); | |
208 | gDirectory->cd("RecPoints"); | |
209 | fHist->Write(); | |
210 | ||
211 | if (fRef) { | |
212 | for(Int_t i=0; i<540; i++) { | |
213 | //fRefHist[i]->Scale(1./fnEvents); | |
214 | fRefHist[i]->Write(); | |
215 | } | |
216 | } | |
217 | ||
218 | outFile->Close(); | |
219 | ||
220 | } | |
221 | ||
222 | //____________________________________________________________________________ | |
223 | ||
224 | void AliTRDqaRecPoints::Init() | |
225 | { | |
226 | // | |
227 | // Create Reconstructed Points histograms in RecPoints subdir | |
228 | // | |
229 | ||
230 | //const Int_t kNhist = 14 + 4 * 18 + 2; | |
231 | const Int_t kNhist = 88+2*18+1; | |
232 | TH1 *hist[kNhist]; | |
233 | ||
234 | hist[0] = new TH1D("qaTRD_recPoints_det", ";Detector ID of the cluster", 540, -0.5, 539.5); | |
235 | hist[1] = new TH2D("qaTRD_recPoints_amp", ";Amplitude", 540, -0.5, 539, 200, -0.5, 199.5); | |
236 | hist[2] = new TH1D("qaTRD_recPoints_npad", ";Number of Pads", 12, -0.5, 11.5); | |
237 | ||
238 | hist[3] = new TH1D("qaTRD_recPoints_dist2", ";residuals [2pad]", 100, -1, 1); | |
239 | hist[4] = new TH1D("qaTRD_recPoints_dist3", ";residuals [3pad]", 100, -1, 1); | |
240 | hist[5] = new TH1D("qaTRD_recPoints_dist4", ";residuals [4pad]", 100, -1, 1); | |
241 | hist[6] = new TH1D("qaTRD_recPoints_dist5", ";residuals [5pad]", 100, -1, 1); | |
242 | ||
243 | hist[7] = new TH2D("qaTRD_recPoints_rowCol", ";row;col", 16, -0.5, 15.5, 145, -0.5, 144.5); | |
244 | hist[8] = new TH1D("qaTRD_recPoints_time", ";time bin", 35, -0.5, 34.5); | |
245 | hist[9] = new TH1D("qaTRD_recPoints_nCls", ";number of clusters", 500, -0.5, 499.5); | |
246 | ||
247 | hist[10] = new TH3D("qaTRD_recPoints_sigTime", ";chamber;time bin;signal", | |
248 | 540, -0.5, 539.5, 35, -0.5, 34.5, 200, -0.5, 199.5); | |
249 | hist[11] = new TProfile("qaTRD_recPoints_prf", ";distance;center of gravity" | |
250 | , 120, -0.6, 0.6, -1.2, 1.2, ""); | |
251 | ||
252 | hist[12] = new TH1D("qaTRD_recPoints_ampMPV", ";amplitude MPV", 150, 0, 150); | |
253 | hist[13] = new TH1D("qaTRD_recPoints_ampSigma", ";amplitude Sigma", 200, 0, 200); | |
254 | ||
255 | // chamber by chamber | |
256 | for(Int_t i=0; i<18; i++) { | |
257 | hist[14+i] = new TH2D(Form("qaTRD_recPoints_sigTime_sm%d",i), Form("sm%d;det;time bin"), | |
258 | 30, -0.5, 29.5, 35, -0.5, 34.5); | |
259 | hist[14+i]->SetMinimum(20); | |
260 | hist[14+i]->SetMaximum(40); | |
261 | } | |
262 | ||
263 | // time bin by time bin sm-by-sm | |
264 | for(Int_t i=0; i<18; i++) { | |
265 | hist[14+18+i] = new TH1D(Form("qaTRD_recPoints_sigTimeShape_sm%d", i), | |
266 | Form("sm%d;time bin;signal"), | |
267 | 35, -0.5, 34.5); | |
268 | ||
269 | hist[14+18+i]->SetMaximum(120); | |
270 | } | |
271 | ||
272 | // str = 50 | |
273 | for(Int_t i=0; i<18; i++) { | |
274 | hist[50+i] = new TH1D(Form("qaTRD_recPoints_nCls_sm%d",i), | |
275 | Form("sm%d;time bin;number of clusters",i), | |
276 | 35, -0.5, 34.5); | |
277 | } | |
278 | ||
279 | // str = 68 | |
280 | for(Int_t i=0; i<18; i++) { | |
281 | hist[68+i] = new TH1D(Form("qaTRD_recPoints_totalCharge_sm%d", i), | |
282 | Form("sm%d;time bin;total charge", i), | |
283 | 35, -0.5, 34.5); | |
284 | } | |
285 | ||
286 | hist[86] = new TH1D("qaTRD_recPoints_signal", ";amplitude", 200, -0.5, 199.5); | |
287 | hist[87] = new TH2D("qaTRD_recPoints_detMap", ";sm;chamber", 18, -0.5, 17.5, 30, -0.5, 29.5); | |
288 | ||
289 | for(Int_t i=0; i<18; i++) | |
290 | hist[88+i] = new TH2D(Form("qaTRD_recPoints_XY_sm%d", i), | |
291 | Form("SM%d;Y;X",i), 240, -60, 60, 200, 290, 370); | |
292 | ||
293 | for(Int_t i=0; i<18; i++) | |
294 | hist[106+i] = new TH2D(Form("qaTRD_recPoints_XPad_sm%d", i), | |
295 | Form("SM%d;Y;X",i), 144, -0.5, 143.5, 200, 290, 370); | |
296 | ||
297 | ||
298 | hist[124] = new TH1D("qRef", "ref", 100, 0, 1e4); | |
299 | ||
300 | fHist = new TObjArray(200); | |
301 | for(Int_t i=0; i<kNhist; i++) { | |
302 | //hist[i]->Sumw2(); | |
303 | fHist->AddAt(hist[i], i); | |
304 | } | |
305 | ||
306 | // reference histograms | |
307 | if (fRef) { | |
308 | for(Int_t i=0; i<540; i++) { | |
309 | fRefHist[i] = new TH2D(Form("refRecPoints_sm%d", i), "", | |
310 | 16, -0.5, 15.5, 144, -0.5, 143.5); //, 30, -0.5, 29.5); | |
311 | } | |
312 | } else { | |
313 | ||
314 | TFile *refFile = new TFile("outRef.root"); | |
315 | refFile->cd("TRD/RecPoints"); | |
316 | ||
317 | for(Int_t i=0; i<540; i++) { | |
318 | fRefHist[i] = (TH2D*)gDirectory->Get(Form("refRecPoints_sm%d", i)); | |
319 | } | |
320 | } | |
321 | } | |
322 | ||
323 | //____________________________________________________________________________ | |
324 | ||
325 | void AliTRDqaRecPoints::AddEvent(TTree * clustersTree) | |
326 | { | |
327 | // | |
328 | // Makes data from RecPoints | |
329 | // | |
330 | ||
331 | // Info("MakeRecPoints", "making"); | |
332 | ||
333 | Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster))); | |
334 | TObjArray *clusterArray = new TObjArray(nsize+1000); | |
335 | ||
336 | TBranch *branch = clustersTree->GetBranch("TRDcluster"); | |
337 | if (!branch) { | |
338 | AliError("Can't get the branch !"); | |
339 | return; | |
340 | } | |
341 | branch->SetAddress(&clusterArray); | |
342 | ||
343 | // Loop through all entries in the tree | |
344 | Int_t nEntries = (Int_t) clustersTree->GetEntries(); | |
345 | Int_t nbytes = 0; | |
346 | AliTRDcluster *c = 0; | |
347 | Int_t nDet[540]; | |
348 | for (Int_t i=0; i<540; i++) nDet[i] = 0; | |
349 | ||
350 | for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) { | |
351 | ||
352 | //printf("Entry = %d\n", iEntry); | |
353 | ||
354 | // Import the tree | |
355 | nbytes += clustersTree->GetEvent(iEntry); | |
356 | ||
357 | // Get the number of points in the detector | |
358 | Int_t nCluster = clusterArray->GetEntriesFast(); | |
359 | ||
360 | // Loop through all TRD digits | |
361 | for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) { | |
362 | c = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster); | |
363 | ||
364 | Int_t iDet = c->GetDetector(); | |
365 | if (iDet < 0 || iDet > 539) continue; | |
366 | ||
367 | ||
368 | Int_t iSM = iDet / 30; | |
369 | //Int_t iStack = iDet % 30; | |
370 | Int_t nPad = c->GetNPads(); | |
371 | ||
372 | if (fnPad && nPad != fnPad) continue; | |
373 | ||
374 | //if (iSM == 0 && iStack == 29) continue; | |
375 | //if (iSM == 8 && iStack == 11) continue; | |
376 | //if (iSM == 8 && iStack == 7) continue; | |
377 | ||
378 | Int_t padRow = c->GetPadRow(); | |
379 | Int_t padCol = c->GetPadCol(); | |
380 | //Int_t timeBin = c->GetPadTime(); | |
381 | ||
382 | Double_t refQ = 0; | |
383 | ||
384 | if (fRef) { | |
385 | fRefHist[iDet]->Fill(padRow, padCol, c->GetQ()); | |
386 | } else { | |
387 | Int_t bin = fRefHist[iDet]->FindBin(padRow, padCol); | |
388 | refQ = fRefHist[iDet]->GetBinContent(bin); | |
389 | //printf("bin = %d\n", bin); | |
390 | } | |
391 | ||
392 | ((TH1D*)fHist->At(124))->Fill(refQ); | |
393 | //printf("ref Q = %lf\n", refQ); | |
394 | ||
395 | Double_t charge = c->GetQ() - (refQ / (490. * 30)); | |
396 | if (charge < 0) continue; | |
397 | ||
398 | if (charge > 20) { | |
399 | ((TH2D*)fHist->At(88+iSM))->Fill(c->GetY(), c->GetX()); | |
400 | ((TH2D*)fHist->At(106+iSM))->Fill(c->GetPadCol(), c->GetX()); | |
401 | } | |
402 | ||
403 | nDet[iDet]++; | |
404 | ((TH1D*)fHist->At(0))->Fill(iDet); | |
405 | ((TH1D*)fHist->At(86))->Fill(charge); | |
406 | ((TH1D*)fHist->At(1))->Fill(iDet, charge); | |
407 | ((TH1D*)fHist->At(2))->Fill(c->GetNPads()); | |
408 | if (c->GetNPads() < 6) | |
409 | ((TH1D*)fHist->At(1+c->GetNPads()))->Fill(c->GetCenter()); | |
410 | ||
411 | //if (c->GetPadTime() < 5) | |
412 | ((TH2D*)fHist->At(7))->Fill(padRow, c->GetPadCol()); | |
413 | ((TH1D*)fHist->At(8))->Fill(c->GetPadTime()); | |
414 | ||
415 | ((TH3D*)fHist->At(10))->Fill(iDet, c->GetPadTime(), charge); | |
416 | ||
417 | ((TH1D*)fHist->At(50+iSM))->Fill(c->GetPadTime()); | |
418 | ((TH1D*)fHist->At(68+iSM))->Fill(c->GetPadTime(), charge); | |
419 | ||
420 | // PRF for 2pad | |
421 | //if (c->GetNPads() == 2) { | |
422 | Short_t *sig = c->GetSignals(); | |
423 | Double_t frac = -10; | |
424 | ||
425 | if (sig[0] == 0 && sig[1] == 0 && sig[2] == 0 && sig[5] == 0 && sig[6] == 0) | |
426 | frac = 1. * sig[4] / (sig[3] + sig[4]); | |
427 | ||
428 | if (sig[0] == 0 && sig[1] == 0 && sig[4] == 0 && sig[5] == 0 && sig[6] == 0) | |
429 | frac = -1. * sig[2] / (sig[2] + sig[3]); | |
430 | ||
431 | if (frac > -10) ((TProfile*)fHist->At(11))->Fill(c->GetCenter(), frac); | |
432 | ||
433 | //} | |
434 | } | |
435 | } | |
436 | ||
437 | for(Int_t i=0; i<540; i++) | |
438 | if (nDet[i] > 0) ((TH1D*)fHist->At(9))->Fill(nDet[i]); | |
439 | ||
440 | delete clusterArray; | |
441 | ||
442 | /* | |
443 | TFile *outFile = new TFile("outQA.root", "RECREATE"); | |
444 | outFile->mkdir("TRD"); | |
445 | gDirectory->cd("TRD"); | |
446 | gDirectory->mkdir("RecPoints"); | |
447 | gDirectory->cd("RecPoints"); | |
448 | fHist->Write(); | |
449 | outFile->Close(); | |
450 | */ | |
451 | } | |
452 | ||
453 | //____________________________________________________________________________ |