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