]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDQADataMakerRec.cxx
Fix Coverity defects
[u/mrichter/AliRoot.git] / TRD / AliTRDQADataMakerRec.cxx
CommitLineData
04236e67 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$ */
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 ---
490b0b06 29#include <TClonesArray.h>
30#include <TFile.h>
04236e67 31#include <TH1D.h>
32#include <TH2D.h>
33#include <TH3D.h>
34#include <TProfile.h>
35#include <TF1.h>
490b0b06 36#include <TCanvas.h>
04236e67 37
38// --- AliRoot header files ---
39#include "AliESDEvent.h"
490b0b06 40#include "AliLog.h"
78328afd 41#include "AliRawReader.h"
04236e67 42#include "AliTRDcluster.h"
43#include "AliTRDQADataMakerRec.h"
490b0b06 44#include "AliTRDgeometry.h"
45//#include "AliTRDdataArrayI.h"
ef1860eb 46#include "AliTRDrawStreamOld.h"
c1eed4d3 47
490b0b06 48#include "AliTRDdigitsManager.h"
49#include "AliTRDSignalIndex.h"
50#include "AliTRDarrayADC.h"
51
52#include "AliQAChecker.h"
53
04236e67 54ClassImp(AliTRDQADataMakerRec)
55
56//____________________________________________________________________________
57 AliTRDQADataMakerRec::AliTRDQADataMakerRec() :
4e25ac79 58 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTRD), "TRD Quality Assurance Data Maker")
04236e67 59{
60 //
61 // Default constructor
62}
63
64//____________________________________________________________________________
65AliTRDQADataMakerRec::AliTRDQADataMakerRec(const AliTRDQADataMakerRec& qadm) :
66 AliQADataMakerRec()
67{
68 //
69 // Copy constructor
70 //
71
72 SetName((const char*)qadm.GetName()) ;
73 SetTitle((const char*)qadm.GetTitle());
74
75}
76
77//__________________________________________________________________
78AliTRDQADataMakerRec& AliTRDQADataMakerRec::operator=(const AliTRDQADataMakerRec& qadm)
79{
80 //
81 // Equal operator.
82 //
83
84 this->~AliTRDQADataMakerRec();
85 new(this) AliTRDQADataMakerRec(qadm);
86 return *this;
87
88}
89
90//____________________________________________________________________________
4e25ac79 91void AliTRDQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
04236e67 92{
93 //
94 // Detector specific actions at end of cycle
95 //
743496f4 96 //TStopwatch watch;
97 //watch.Start();
c1eed4d3 98 /**/
5379c4a3 99 AliDebug(AliQAv1::GetQADebugLevel(), "End of TRD cycle");
743496f4 100
490b0b06 101
102 if (task == AliQAv1::kRAWS) {
103
104 // loop over event types
105 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
106
107 if (! IsValidEventSpecie(specie, list)) continue;
108
109
110 TH2D *mnCls = (TH2D*)list[specie]->At(1);
111 TH2D *mClsDet = (TH2D*)list[specie]->At(2);
112
113 mClsDet->Divide(mnCls);
114 }
115 }
116
117
4e25ac79 118 if (task == AliQAv1::kRECPOINTS) {
c1eed4d3 119
120 TH1D * hist = new TH1D("fitHist", "", 200, -0.5, 199.5);
121
122 // loop over event types
57acd2d2 123 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
6252ceeb 124 if (! IsValidEventSpecie(specie, list))
eca4fa66 125 continue ;
6252ceeb 126 //list[specie]->Print();
c1eed4d3 127
57acd2d2 128 // fill detector map;
129 for(Int_t i = 0 ; i < 540 ; i++) {
130 Double_t v = ((TH1D*)list[specie]->At(0))->GetBinContent(i+1);
131 Int_t sm = i/30;
132 Int_t det = i%30;
133 TH2D *detMap = (TH2D*)list[specie]->At(87);
134 Int_t bin = detMap->FindBin(sm, det);
135 detMap->SetBinContent(bin, v);
c1eed4d3 136 }
137
57acd2d2 138 // Rec points full chambers
139 for (Int_t i = 0 ; i < 540 ; i++) {
5379c4a3 140 //AliDebug(AliQAv1::GetQADebugLevel(), Form("I = %d", i));
57acd2d2 141 //TH1D *h = ((TH2D*)list[specie]->At(1))->ProjectionY(Form("qaTRD_recPoints_amp_%d",i), i+1, i+1);
142 hist->Reset();
c1eed4d3 143
144 // project TH2D into TH1D
57acd2d2 145 for(Int_t b = 1 ; b < hist->GetXaxis()->GetNbins()-1 ; b++) {
146 Double_t xvalue = hist->GetBinCenter(b);
147 Int_t bin = ((TH2D*)list[specie]->At(1))->FindBin(i,xvalue);
148 Double_t value = ((TH2D*)list[specie]->At(1))->GetBinContent(bin);
149 hist->SetBinContent(b, value);
150 }
5379c4a3 151 //AliDebug(AliQAv1::GetQADebugLevel(), Form("Sum = %d %f\n", i, hist->GetSum()));
57acd2d2 152 if (hist->GetSum() < 100)
c1eed4d3 153 continue; // not enougth data in a chamber
154
57acd2d2 155 hist->Fit("landau", "q0", "goff", 10, 180);
156 TF1 *fit = hist->GetFunction("landau");
157 ((TH1D*)list[specie]->At(12))->Fill(fit->GetParameter(1));
158 ((TH1D*)list[specie]->At(13))->Fill(fit->GetParameter(2));
04236e67 159 }
c1eed4d3 160
161
57acd2d2 162 // time-bin by time-bin sm by sm
c1eed4d3 163 for(Int_t i=0; i<18; i++) { // loop over super-modules
164 for(Int_t j=0; j<kTimeBin; j++) { // loop over time bins
165
57acd2d2 166 hist->Reset();
167 for(Int_t b = 1 ; b < hist->GetXaxis()->GetNbins()-1 ; b++) {
168 Double_t xvalue = hist->GetBinCenter(b);
169 Double_t svalue = 0.0;
170 for(Int_t det = i*30 ; det < (i+1)*30 ; det++) { // loop over detectors
171 Int_t bin = ((TH3D*)list[specie]->At(10))->FindBin(det,j,xvalue);
172 Double_t value = ((TH3D*)list[specie]->At(10))->GetBinContent(bin);
173 svalue += value;
174 }
5379c4a3 175 //AliDebug(AliQAv1::GetQADebugLevel(), Form("v = %f\n", value));
57acd2d2 176 hist->SetBinContent(b, svalue);
177 }
c1eed4d3 178
57acd2d2 179 if (hist->GetSum() < 100)
180 continue;
c1eed4d3 181
182 hist->Fit("landau", "q0", "goff", 10, 180);
183 TF1 *fit = hist->GetFunction("landau");
184
185 TH1D *h1 = (TH1D*)list[specie]->At(14+18+i);
186 h1->SetMarkerStyle(20);
187 Int_t bin = h1->FindBin(j);
188 // printf("%d %d %d\n", det, j, bin);
189
190 Double_t value = TMath::Abs(fit->GetParameter(1));
191 Double_t error = TMath::Abs(fit->GetParError(1));
192
193 if (value/error < 3) continue; // insuficient statistics
194
195 h1->SetBinContent(bin, value);
196 h1->SetBinError(bin, error);
197 }
743496f4 198 }
743496f4 199
c1eed4d3 200 // for numerical convergence
201 TF1 *form = new TF1("formLandau", "landau", 0, 200);
743496f4 202
c1eed4d3 203 // time-bin by time-bin chamber by chamber
204 for (Int_t i=0; i<540; i++) {
205 for(Int_t j=0; j<kTimeBin; j++) {
206
207 hist->Reset();
208 for(Int_t b = 1 ; b < hist->GetXaxis()->GetNbins()-1 ; b++) {
209 Double_t xvalue = hist->GetBinCenter(b);
210 Int_t bin = ((TH3D*)list[specie]->At(10))->FindBin(i,j,xvalue);
211 Double_t value = ((TH3D*)list[specie]->At(10))->GetBinContent(bin);
212 //AliDebug(AliQAv1::GetQADebugLevel(), Form("v = %f\n", value));
213 hist->SetBinContent(b, value);
214 }
215
216 if (hist->GetSum() < 100)
217 continue;
218
219 form->SetParameters(1000, 60, 20);
220 hist->Fit(form, "q0", "goff", 20, 180);
221
222 Int_t sm = i/30;
223 Int_t det = i%30;
224 TH2D *h2 = (TH2D*)list[specie]->At(14+sm);
225 Int_t bin = h2->FindBin(det,j);
226 // printf("%d %d %d\n", det, j, bin);
227
228 Double_t value = TMath::Abs(form->GetParameter(1));
229 Double_t error = TMath::Abs(form->GetParError(1));
230
231 if (value/error < 3) continue;
232
233 h2->SetBinContent(bin, value);
234 h2->SetBinError(bin, error);
235 }
04236e67 236 }
237 }
2d3ab4d8 238 if (hist)
239 delete hist;
04236e67 240 }
743496f4 241 //////////////////////////
242 // const Int_t knbits = 6;
243 // const char *suf[knbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
244 //const char *sufRatio[4] = {"TRDrTRDo", "TRDoTPCo", "TRDrTPCo", "TRDzTPCo"};
04236e67 245
4e25ac79 246 if (task == AliQAv1::kESDS) {
743496f4 247
248 const Int_t knRatio = 4;
249 const Int_t kN[knRatio] = {4,3,4,5};
250 const Int_t kD[knRatio] = {3,1,1,3};
251
252 // create ratios
57acd2d2 253 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
6252ceeb 254 if (! IsValidEventSpecie(specie, list))
eca4fa66 255 continue ;
6252ceeb 256 for(Int_t type = 0 ; type < 2 ; type++) {
57acd2d2 257 for(Int_t i = 0 ; i < knRatio ; i++) {
258 TH1D *ratio = (TH1D*)list[specie]->At(19 + 2*i + type);
259 TH1D *histN = (TH1D*)list[specie]->At(3 + 2*kN[i] + type);
260 TH1D *histD = (TH1D*)list[specie]->At(3 + 2*kD[i] + type);
261 BuildRatio(ratio, histN, histD);
262 //ratio->Reset();
263 //ratio->Add(histN);
264 //ratio->Divide(histD);
265 }
743496f4 266 }
57acd2d2 267 // ratio for the fraction of electrons per stack
268 TH1D *histN = (TH1D*)list[specie]->At(33);
269 TH1D *histD = (TH1D*)list[specie]->At(32);
270 TH1D *ratio = (TH1D*)list[specie]->At(34);
271 BuildRatio(ratio, histN, histD);
743496f4 272 }
273 }
743496f4 274 // call the checker
4e25ac79 275 AliQAChecker::Instance()->Run(AliQAv1::kTRD, task, list) ;
c1eed4d3 276
04236e67 277}
278
279//____________________________________________________________________________
280void AliTRDQADataMakerRec::InitESDs()
281{
282 //
283 // Create ESDs histograms in ESDs subdir
284 //
7d297381 285 const Bool_t expert = kTRUE ;
286 const Bool_t image = kTRUE ;
287
f5fd37e8 288 const Int_t kNhist = 36+5+4;
9b99c029 289
04236e67 290 TH1 *hist[kNhist];
291 Int_t histoCounter = -1 ;
292
db72ff3b 293 hist[++histoCounter] = new TH1D("qaTRD_esd_ntracks", "TRD esd ntracks;Number of tracks;Counts", 300, -0.5, 299.5);
294 hist[++histoCounter] = new TH1D("qaTRD_esd_sector", "TRD esd sector;Sector;Counts", 18, -0.5, 17.7);
295 hist[++histoCounter] = new TH1D("qaTRD_esd_bits", "TRD esd bits;Bits;Counts", 64, -0.5, 63.5);
04236e67 296
297 const Int_t knbits = 6;
298 const char *suf[knbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
299
743496f4 300 // histo = 3
301 for(Int_t i=0; i<knbits; i++) {
db72ff3b 302 hist[++histoCounter] = new TH1D(Form("qaTRD_esd_pt%s",suf[i]), Form("qaTRD_esd_pt%s;p_{T} (GeV/c);Counts",suf[i]), 100, 0, 10);
04236e67 303 hist[++histoCounter] = new TH1D(Form("qaTRD_esd_trdz%s", suf[i]), ";z (cm)", 200, -400, 400);
304 }
305
db72ff3b 306 hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDo", "TRDo;number of clusters;Counts", 180, -0.5, 179.5);;
307 hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDr", "TRDr;number of clusters;Counts", 180, -0.5, 179.5);;
308 hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDz", "TRDz;number of clusters;Counts", 180, -0.5, 179.5);;
04236e67 309 //hist[++histoCounter] = new TH1D("qaTRD_esd_clsRatio", ";cluster ratio", 100, 0., 1.3);;
310
db72ff3b 311 hist[++histoCounter] = new TH2D("qaTRD_esd_sigMom", "TRD esd sig Mom;momentum (GeV/c);signal", 100, 0, 5, 200, 0, 1e3);
04236e67 312
743496f4 313 // end of cycle plots (hist 19)
314 const char *sufRatio[4] = {"TRDrTRDo", "TRDoTPCo", "TRDrTPCo", "TRDzTPCo"};
315
316 for(int i=0; i<4; i++) {
317 hist[++histoCounter] = new TH1D(Form("qaTRD_esd_pt%s",sufRatio[i]),
318 Form("Efficiency in Pt %s;p_{T};eff", sufRatio[i]),
319 100, 0, 10);
320
321 hist[++histoCounter] = new TH1D(Form("qaTRD_esd_trdz%s",sufRatio[i]),
322 Form("Efficiency in Z %s;z (cm);eff", sufRatio[i]),
323 200, -400, 400);
324 }
325
9b99c029 326 // 27 - 31
db72ff3b 327 hist[27] = new TH1D("qaTRD_esd_quality", "TRD esd quality;quality;Counts", 120, 0, 12);
328 hist[28] = new TH1D("qaTRD_esd_budget", "TRD esd budget;NN;Counts", 110, -1000, 100);
329 hist[29] = new TH1D("qaTRD_esd_chi2", "TRD esd chi2;chi2;Counts", 200, 0, 100);
330 hist[30] = new TH1D("qaTRD_esd_timeBin", "TRD esd timeBin;time bin;Counts", 7, -0.5, 6.5);
331 hist[31] = new TH1D("qaTRD_esd_pidQuality", "pid Quality;quality;;Counts", 7, -0.5, 6.5);
9b99c029 332
333 // stack by stack electron identyfication
db72ff3b 334 hist[32] = new TH1D("qaTRD_esd_tracksStack", "number of all tracks;stack;Counts", 90, -0.5, 89.5);
335 hist[33] = new TH1D("qaTRD_esd_electronStack", "number of electron tracks;stack;Counts", 90, -0.5, 89.5);
336 hist[34] = new TH1D("qaTRD_esd_elRatioStack", "fraction of electron tracks;stack;Counts", 90, -0.5, 89.5);
9b99c029 337 hist[35] = new TH1D("qaTRD_esd_thetaOut", ";tan(theta);", 100, -1, 1);
338
339 const char *partType[5] = {"Electron", "Muon", "Pion", "Kaon", "Proton"};
340
341 for(Int_t i=0; i<AliPID::kSPECIES; i++)
342 hist[36+i] = new TH1D(Form("qaTRD_esd_pid%d",i),
db72ff3b 343 Form("%s;probability;Counts",partType[i]), 100, 0, 1);
9b99c029 344
f5fd37e8 345 // dE/dX vs momentum in three regions
346 const char *zoneName[4] = {"total charge", "ampilification range", "plateau", "TR range"};
347
348 // prepare the scale from 0.1 to 10 GeV
8e2f611a 349 const Int_t nscalex= 50;
350 Double_t scalex[nscalex+1];
351 Double_t dd = (TMath::Log(10) - TMath::Log(0.5)) / nscalex;
352 for(Int_t ix=0; ix<nscalex+1; ix++) {
f5fd37e8 353 scalex[ix] = 0.5 * TMath::Exp(dd * ix);
354 }
355
8e2f611a 356 const Int_t nscaley = 50;
357 Double_t scaley[nscaley+1];
358 for(Int_t iy=0; iy<nscaley+1; iy++) {
359 scaley[iy] = iy * (3e3/nscaley);
f5fd37e8 360 }
361
362
363 for(Int_t i=0; i<4; i++) {
364 hist[41+i] = new TH2D(Form("qaTRD_esd_signalPzone_%d",i),
db72ff3b 365 Form("%s;momentum (GeV/c);signal (a.u.)", zoneName[i]),
8e2f611a 366 nscalex, scalex, nscaley, scaley);
f5fd37e8 367 }
9b99c029 368
369 for(Int_t i=0; i<kNhist; i++) {
04236e67 370 //hist[i]->Sumw2();
7d297381 371 Add2ESDsList(hist[i], i, !expert, image);
04236e67 372 }
373
374}
375
376//____________________________________________________________________________
377void AliTRDQADataMakerRec::InitRecPoints()
378{
379 //
380 // Create Reconstructed Points histograms in RecPoints subdir
381 //
7d297381 382 const Bool_t expert = kTRUE ;
383 const Bool_t image = kTRUE ;
384
c1eed4d3 385 //printf("Helo from Init rec points\n");
386
387 const Int_t kNhist = 14 + 4 * 18 + 2 + 9;// + 540;
04236e67 388 TH1 *hist[kNhist];
389
db72ff3b 390 hist[0] = new TH1D("qaTRD_recPoints_det", "RRD recPoints det;Detector ID of the cluster;Counts", 540, -0.5, 539.5);
391 hist[1] = new TH2D("qaTRD_recPoints_amp", "TRD recPoints amp;Amplitude;??", 540, -0.5, 539, 200, -0.5, 199.5);
392 hist[2] = new TH1D("qaTRD_recPoints_npad", "TRD recPoints npad;Number of Pads;Counts", 12, -0.5, 11.5);
04236e67 393
db72ff3b 394 hist[3] = new TH1D("qaTRD_recPoints_dist2", "TRD recPoints dist2;residuals [2pad];Counts", 100, -1, 1);
395 hist[4] = new TH1D("qaTRD_recPoints_dist3", "TRD recPoints dist3;residuals [3pad];Counts", 100, -1, 1);
396 hist[5] = new TH1D("qaTRD_recPoints_dist4", "TRD recPoints dist4;residuals [4pad];Counts", 100, -1, 1);
397 hist[6] = new TH1D("qaTRD_recPoints_dist5", "TRD recPoints dist5;residuals [5pad];Counts", 100, -1, 1);
04236e67 398
db72ff3b 399 hist[7] = new TH2D("qaTRD_recPoints_rowCol", "TRDrecPointsrowCol;row;col", 16, -0.5, 15.5, 145, -0.5, 144.5);
400 hist[8] = new TH1D("qaTRD_recPoints_time", "TRDrecPoints time;time bin;Counts", kTimeBin, -0.5, kTimeBin-0.5);
401 hist[9] = new TH1D("qaTRD_recPoints_nCls", "TRD recPoints nCls;number of clusters;Counts", 500, -0.5, 499.5);
04236e67 402
db72ff3b 403 hist[10] = new TH3D("qaTRD_recPoints_sigTime", "TRD recPoints sigTime;chamber;time bin;signal",
c1eed4d3 404 540, -0.5, 539.5, kTimeBin, -0.5, kTimeBin-0.5, 200, -0.5, 199.5);
db72ff3b 405 hist[11] = new TProfile("qaTRD_recPoints_prf", "TRD recPoints prf;distance;center of gravity;Counts"
04236e67 406 , 120, -0.6, 0.6, -1.2, 1.2, "");
407
db72ff3b 408 hist[12] = new TH1D("qaTRD_recPoints_ampMPV", "TRD recPoints ampMPV;amplitude MPV;Counts", 150, 0, 150);
409 hist[13] = new TH1D("qaTRD_recPoints_ampSigma", "TRD recPoints ampSigma;amplitude Sigma;Counts", 200, 0, 200);
743496f4 410
9b99c029 411 // chamber by chamber
04236e67 412 for(Int_t i=0; i<18; i++) {
20a6e9c2 413 hist[14+i] = new TH2D(Form("qaTRD_recPoints_sigTime_sm%d",i), Form("sm%d;det;time bin",i),
c1eed4d3 414 30, -0.5, 29.5, kTimeBin, -0.5, kTimeBin-0.5);
415 hist[14+i]->SetMinimum(0);
416 hist[14+i]->SetMaximum(150);
04236e67 417 }
743496f4 418
419 // time bin by time bin sm-by-sm
420 for(Int_t i=0; i<18; i++) {
421 hist[14+18+i] = new TH1D(Form("qaTRD_recPoints_sigTimeShape_sm%d", i),
20a6e9c2 422 Form("sm%d;time bin;signal",i),
c1eed4d3 423 kTimeBin, -0.5, kTimeBin-0.5);
9b99c029 424
c1eed4d3 425 hist[14+18+i]->SetMaximum(150);
743496f4 426 }
427
9b99c029 428 // str = 50
429 for(Int_t i=0; i<18; i++) {
430 hist[50+i] = new TH1D(Form("qaTRD_recPoints_nCls_sm%d",i),
431 Form("sm%d;time bin;number of clusters",i),
c1eed4d3 432 kTimeBin, -0.5, kTimeBin-0.5);
9b99c029 433 }
434
435 // str = 68
436 for(Int_t i=0; i<18; i++) {
437 hist[68+i] = new TH1D(Form("qaTRD_recPoints_totalCharge_sm%d", i),
438 Form("sm%d;time bin;total charge", i),
c1eed4d3 439 kTimeBin, -0.5, kTimeBin-0.5);
9b99c029 440 }
441
db72ff3b 442 hist[86] = new TH1D("qaTRD_recPoints_signal", "TRD recPoints signal;amplitude;Counts", 400, -0.5, 399.5);
443 hist[87] = new TH2D("qaTRD_recPoints_detMap", "TRD recPoints detMap;sm;chamber;Counts", 18, -0.5, 17.5, 30, -0.5, 29.5);
743496f4 444
c1eed4d3 445
446 // amplitude as a function of the pad size
447 for(Int_t i=0; i<9; i++) {
db72ff3b 448 hist[88+i] = new TH1D(Form("qaTRD_recPoints_signalNpad_%d", i+2), Form("qaTRD_recPoints_signalNpad_%d;amplitude, ADC", i+2), 400, -0.5, 399.5);
c1eed4d3 449 }
450
451 // one 2D histogram per chamber
452 // for(Int_t i=0; i<540; i++) {
453 // hist[88+i] = new TH2D(Form("qaTRD_recPoints_map%d", i), ";col;row", 16, -0.5, 15.5, 144, -0.5, 143.5);
454 //}
455
04236e67 456
457 for(Int_t i=0; i<kNhist; i++) {
458 //hist[i]->Sumw2();
7d297381 459 Add2RecPointsList(hist[i], i, !expert, image);
04236e67 460 }
04236e67 461}
462
463//____________________________________________________________________________
464void AliTRDQADataMakerRec::InitRaws()
465{
466 //
467 // create Raws histograms in Raws subdir
468 //
7d297381 469 const Bool_t expert = kTRUE ;
470 const Bool_t saveCorr = kTRUE ;
471 const Bool_t image = kTRUE ;
472
c1eed4d3 473 AliInfo("Initialization of QA for Raw Data");
490b0b06 474
475 const Int_t kNhist = 7;
c1eed4d3 476 TH1 *hist[kNhist];
477
490b0b06 478 hist[0] = new TH2D("qaTRD_raws_nADC","number of ADC channels;sector;detector", 18, -0.5, 17.5, 30, -0.5, 29.5);
479 hist[1] = new TH2D("qaTRD_raws_nCls", "number of clusters;sector;detector", 18, -0.5, 17.5, 30, -0.5, 29.5);
480 hist[2] = new TH2D("qaTRD_raws_meanSig", "mean signal;sector;detector", 18, -0.5, 17.5, 30, -0.5, 29.5);
481
482 hist[3] = new TH1D("qaTRD_raws_ADC", "ADC amplitude;ADC counts", 100, -0.5, 99.5);
483 hist[4] = new TH1D("qaTRD_raws_Cls", "Cluster amplitude; ADC counts", 100, -0.5, 199.5);
484 hist[5] = new TH2D("qaTRD_raws_ClsTb", "Clusters vs Time Bin;time bin;amoplitude", 30, -0.5, 29.5, 200, -0.5, 199.5);
485
486 hist[6] = new TH2D("qaTRD_raws_ClsAmpDet", ";detector;amplitude", 540, -0.5, 539.5, 100, 0, 200);
487
04236e67 488
c1eed4d3 489 /*
490b0b06 490 hist[0] = new TH2D("qaTRD_raws_DataVolume", ";Sector;Data Volume, kB", 18, -0.5, 17.5, 100, 0, 30);
491 hist[1] = new TH2D("qaTRD_raws_HC", "Data Headers;Sector;HC", 18, -0.5, 17.5, 60, -0.5, 59.5);
492 hist[2] = new TH2D("qaTRD_raws_LME", "Link Monitor Error;Sector;HC", 18, -0.5, 17.5, 60, -0.5, 59.5);
493
494 hist[3] = new TH1D("qaTRD_rawd_cls", "Clusters amplitude;ADC counts", 100, 0, 200);
495 hist[4] = new TH2D("qaTRD_raws_clsTB", "amplitude - time bins;time bin;amplitude"
496 30, -0.5, 29.5, 100, 0, 200);
497 hist[5] = new TH2D("qaTRD_raws_clsSec", "amplitude in sectors;Sector;amplitude, ADCs"
498 18, -0.5, 17.5);
c1eed4d3 499 */
500
490b0b06 501
04236e67 502 // register
503 for(Int_t i=0; i<kNhist; i++) {
504 //hist[i]->Sumw2();
7d297381 505 Add2RawsList(hist[i], i, !expert, image, !saveCorr);
04236e67 506 }
507
508}
509
510//____________________________________________________________________________
490b0b06 511void AliTRDQADataMakerRec::MakeESDs(AliESDEvent * esd)
04236e67 512{
513 //
514 // Make QA data from ESDs
515 //
eca4fa66 516
04236e67 517 Int_t nTracks = esd->GetNumberOfTracks();
518 GetESDsData(0)->Fill(nTracks);
519
520 // track loop
42a68282 521 for (Int_t iTrack = 0; iTrack<nTracks; iTrack++) {
04236e67 522
42a68282 523 AliESDtrack *track = esd->GetTrack(iTrack);
04236e67 524 const AliExternalTrackParam *paramOut = track->GetOuterParam();
525 const AliExternalTrackParam *paramIn = track->GetInnerParam();
526
527 // long track ..
528 if (!paramIn) continue;
529 if (!paramOut) continue;
530
531 // not a kink
532 if (track->GetKinkIndex(0) > 0) continue;
533
534 Double_t extZ = GetExtZ(paramIn);
535 if (TMath::Abs(extZ) > 320) continue; // acceptance cut
536
537 // .. in the acceptance
538 Int_t sector = GetSector(paramOut->GetAlpha());
9b99c029 539 Int_t stack = GetStack(paramOut);
04236e67 540
541 UInt_t u = 1;
542 UInt_t status = track->GetStatus();
543 for(Int_t bit=0; bit<32; bit++)
544 if (u<<bit & status) GetESDsData(2)->Fill(bit);
545
546 const Int_t knbits = 6;
547 Int_t bit[6] = {0,0,0,0,0,0};
548 bit[0] = status & AliESDtrack::kTPCin;
549 bit[1] = status & AliESDtrack::kTPCout;
550 bit[2] = (status & AliESDtrack::kTPCout) && !(status & AliESDtrack::kTRDout);
551 bit[3] = status & AliESDtrack::kTRDout;
552 bit[4] = status & AliESDtrack::kTRDrefit;
553 bit[5] = (status & AliESDtrack::kTRDout) && !(status & AliESDtrack::kTRDrefit);
554
555 // transverse momentum
556 //const Double_t *val = paramOut->GetParameter(); // parameters at the Outer plane
557 Double_t pt = paramOut->Pt(); //1./TMath::Abs(val[4]);
558
559 for(Int_t b=0; b<knbits; b++) {
560 if (bit[b]) {
561 GetESDsData(2*b+3)->Fill(pt);
562 GetESDsData(2*b+4)->Fill(extZ);
563 }
564 }
565
566 // clusters
567 for(Int_t b=0; b<3; b++)
9b99c029 568 if (bit[3+b]) GetESDsData(b+15)->Fill(track->GetTRDncls0());
04236e67 569
570 // refitted only
571 if (!bit[4]) continue;
572
573 //fQuality->Fill(track->GetTRDQuality());
574 //fBudget->Fill(track->GetTRDBudget());
575 //fSignal->Fill(track->GetTRDsignal());
9b99c029 576
577 GetESDsData(1)->Fill(sector);
04236e67 578 GetESDsData(18)->Fill(track->GetP(), track->GetTRDsignal());
579
9b99c029 580 GetESDsData(27)->Fill(track->GetTRDQuality());
581 GetESDsData(28)->Fill(track->GetTRDBudget());
582 GetESDsData(29)->Fill(track->GetTRDchi2());
583 GetESDsData(30)->Fill(track->GetTRDTimBin(0));
ed15ef4f 584 GetESDsData(31)->Fill(track->GetTRDntrackletsPID());
9b99c029 585
f5fd37e8 586
587 // dedx
7bce990c 588 for(Int_t k=0; k<4; ++k) {
f5fd37e8 589 Double_t dedx = 0;
590 for(Int_t j=0; j<6; j++) {
7bce990c 591 dedx += track->GetTRDslice(j, k-1);
f5fd37e8 592 }
42a68282 593 GetESDsData(41+k)->Fill(paramOut->GetP(), dedx/6.);
f5fd37e8 594 }
595
9b99c029 596 // probabilities
597 if (status & AliESDtrack::kTRDpid) {
7bce990c 598 for(Int_t k=0; k<AliPID::kSPECIES; ++k)
599 GetESDsData(36+k)->Fill(track->GetTRDpid(k));
9b99c029 600 }
601
602 // probabilities uniformity
ed15ef4f 603 if (track->GetTRDntrackletsPID() < 6) continue;
9b99c029 604 GetESDsData(35)->Fill(paramOut->GetZ()/paramOut->GetX());
605
606 Int_t idx = 5 * sector + stack;
607 GetESDsData(32)->Fill(idx); // all tracks
608 if (track->GetTRDpid(AliPID::kElectron) > 0.9)
609 GetESDsData(33)->Fill(idx); // electrons only
610
611
612
613 /*
614 hist[27] = new TH1D("qaTRD_esd_quality", ";quality", 120, 0, 12);
615 hist[28] = new TH1D("qaTRD_esd_budget", ";NN", 110, -1000, 100);
616 hist[29] = new TH1D("qaTRD_esd_chi2", ";chi2", 300, 0, 100);
617 hist[30] = new TH1D("qaTRD_esd_timeBin", 7, -0.5, 6.5);
618 hist[31] = new TH1D("qaTRD_esd_pidQuality", 7, -0.5, 6.5);
619 */
620
04236e67 621 /*
622 // PID only
623 if (status & AliESDtrack::kTRDpid) {
624
625 for(Int_t l=0; l<6; l++) fTime->Fill(track->GetTRDTimBin(l));
626
627 // fill pid histograms
628 Double_t trdr0 = 0; //, tpcr0 = 0;
629 Int_t trdBestPid = 5; //, tpcBestPid = 5; // charged
630 const Double_t kminPidValue = 0.9;
631
632 //Double_t pp[5];
633 //track->GetTPCpid(pp); // ESD inconsequence
634
635 for(Int_t pid=0; pid<5; pid++) {
636
637 trdr0 += track->GetTRDpid(pid);
638 //tpcr0 += pp[pid];
639
640 fTrdPID[pid]->Fill(track->GetTRDpid(pid));
641 //fTpcPID[pid]->Fill(pp[pid]);
642
643 if (track->GetTRDpid(pid) > kminPidValue) trdBestPid = pid;
644 //if (pp[pid] > kminPidValue) tpcBestPid = pid;
645 }
646
647 fTrdPID[5]->Fill(trdr0); // check unitarity
648 fTrdSigMomPID[trdBestPid]->Fill(track->GetP(), track->GetTRDsignal());
649
650 //fTpcPID[5]->Fill(tpcr0); // check unitarity
651 //fTpcSigMomPID[tpcBestPid]->Fill(track->GetP(), track->GetTPCsignal());
652 }
653 */
654
655 }
656
657}
658
659//______________________________________________________________________________
9b99c029 660Int_t AliTRDQADataMakerRec::GetSector(Double_t alpha) const
04236e67 661{
662 //
663 // Gets the sector number
664 //
665
666 Double_t size = TMath::DegToRad() * 20.; // shall use TRDgeo
9b99c029 667 if (alpha < 0) alpha += 2*TMath::Pi();
668 Int_t sector = (Int_t)(alpha/size);
04236e67 669 return sector;
670
671}
9b99c029 672//______________________________________________________________________________
673
674Int_t AliTRDQADataMakerRec::GetStack(const AliExternalTrackParam *paramOut) const
675{
676 //
677 // calculates the stack the track is in
678 //
679
490b0b06 680 const Double_t L = -0.9;
681 const Double_t W = (2*L)/5;
9b99c029 682
683 Double_t tan = paramOut->GetZ() / paramOut->GetX();
490b0b06 684 Double_t pos = (tan - L) / W;
9b99c029 685 return (Int_t) pos;
686}
04236e67 687
688//______________________________________________________________________________
689Double_t AliTRDQADataMakerRec::GetExtZ(const AliExternalTrackParam *in) const
690{
691 //
692 // Returns the Z position at the entry to TRD
693 // using parameters from the TPC in
694 //
695
696 const Double_t kX0 = 300;
697
698 Double_t x = in->GetX();
699 const Double_t *par = in->GetParameter();
700 Double_t theta = par[3];
701 Double_t z = in->GetZ();
702
703 Double_t zz = z + (kX0-x) * TMath::Tan(theta);
704 return zz;
705
706}
707
708//____________________________________________________________________________
709void AliTRDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
710{
711 //
712 // Makes QA data from raw data
713 //
490b0b06 714
715 AliInfo("Making QA for Raws");
716
717 // take histograms
718
719 TH2D *mnADC = (TH2D*)GetRawsData(0);
720 TH2D *mnCls = (TH2D*)GetRawsData(1);
721 TH2D *mClsDet = (TH2D*)GetRawsData(2);
c1eed4d3 722
490b0b06 723 TH1D *mADC = (TH1D*)GetRawsData(3);
724 TH1D *mCls = (TH1D*)GetRawsData(4);
725 TH2D *mClsTb = (TH2D*)GetRawsData(5);
726
727 TH2D *mClsDetAmp = (TH2D*)GetRawsData(6);
c1eed4d3 728
490b0b06 729 const Int_t baseline = 10;
730
490b0b06 731 // configure the reader
c1eed4d3 732 rawReader->Reset();
733 rawReader->SelectEquipment(0, 1024, 1041);
734 rawReader->Select("TRD");
c1eed4d3 735
490b0b06 736 AliTRDrawStreamBase::SetRawStreamVersion("FAST");
737 AliTRDrawStreamBase *data = AliTRDrawStreamBase::GetRawStream(rawReader);
738 data->SetSharedPadReadout(kFALSE);
c1eed4d3 739
490b0b06 740 // build data manager
741 AliTRDdigitsManager *digitsManager;
742 digitsManager = new AliTRDdigitsManager(kTRUE);
743 digitsManager->CreateArrays();
c1eed4d3 744
490b0b06 745 // error container
746 const UShort_t kErrorChmb = 1411;
747 UShort_t **fErrorContainer = new UShort_t *[2];
748 fErrorContainer[0] = new UShort_t[kErrorChmb];
749 fErrorContainer[1] = new UShort_t[kErrorChmb];
750
751 Int_t det = 0;
752 Int_t row, col;
c1eed4d3 753
490b0b06 754 while ((det = data->NextChamber(digitsManager, NULL, fErrorContainer)) >= 0){
c1eed4d3 755
490b0b06 756 //printf("DET = %d\n", det);
c1eed4d3 757
490b0b06 758 AliTRDSignalIndex* indexes = digitsManager->GetIndexes(det);
759 if (indexes->HasEntry()) {
c1eed4d3 760
490b0b06 761 AliTRDarrayADC *digits = (AliTRDarrayADC*) digitsManager->GetDigits(det);
c1eed4d3 762
490b0b06 763 while(indexes->NextRCIndex(row, col)) {
764
765 mnADC->Fill(det/30, det%30);
c1eed4d3 766
490b0b06 767 for(Int_t tb = 0; tb < digits->GetNtime(); tb++) {
768 Int_t value = digits->GetData(row, col, tb);
769 mADC->Fill(value);
770
771 // simple clusterizer
48189aa6 772 if (col < 1 || col > digits->GetNcol()-2) continue;
773 if (tb < 1 || tb > digits->GetNtime()-2) continue;
490b0b06 774
775 value -= baseline;
c1eed4d3 776
490b0b06 777 Int_t valueL = digits->GetData(row, col-1, tb) - baseline;
778 if (valueL >= value) continue;
779
780 Int_t valueR = digits->GetData(row, col+1, tb) - baseline;
781 if (valueR >= value) continue;
782
783 Int_t valueUp = digits->GetData(row, col-1, tb+1) +
784 digits->GetData(row, col, tb+1) + digits->GetData(row, col+1, tb+1) - 3 * baseline;
785 if (valueUp < 10) continue;
786
787 Int_t valueDown = digits->GetData(row, col-1, tb-1) +
788 digits->GetData(row, col, tb-1) + digits->GetData(row, col+1, tb-1) - 3 * baseline;
789 if (valueDown < 10) continue;
c1eed4d3 790
490b0b06 791 Int_t valueTot = value + valueL + valueR;
792 if (valueTot < 0) continue;
793
794 mCls->Fill(valueTot);
795 mClsTb->Fill(tb, valueTot);
796 mClsDetAmp->Fill(det, valueTot);
797
798 if (valueTot < 200) {
799 mnCls->Fill(det/30, det%30);
800 mClsDet->Fill(det/30, det%30, valueTot);
c1eed4d3 801 }
490b0b06 802
803 }
c1eed4d3 804 }
c1eed4d3 805
490b0b06 806 digitsManager->ClearArrays(det); // do we need this if object will be deleted ??
807 }
c1eed4d3 808 }
809
2f9bdd85 810 delete [] fErrorContainer[0];
811 delete [] fErrorContainer[1];
812 delete [] fErrorContainer;
813 fErrorContainer = NULL;
490b0b06 814
815 delete digitsManager;
816 delete data;
44ed7a66 817}
818
04236e67 819//____________________________________________________________________________
820void AliTRDQADataMakerRec::MakeRecPoints(TTree * clustersTree)
821{
822 //
823 // Makes data from RecPoints
824 //
743496f4 825
826 // Info("MakeRecPoints", "making");
6252ceeb 827
04236e67 828 Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster)));
829 TObjArray *clusterArray = new TObjArray(nsize+1000);
830
831 TBranch *branch = clustersTree->GetBranch("TRDcluster");
832 if (!branch) {
833 AliError("Can't get the branch !");
834 return;
835 }
836 branch->SetAddress(&clusterArray);
837
838 // Loop through all entries in the tree
c1eed4d3 839 Int_t nEntries = (Int_t)TMath::Ceil( clustersTree->GetEntries() );
04236e67 840 Int_t nbytes = 0;
841 AliTRDcluster *c = 0;
842 Int_t nDet[540];
843 for (Int_t i=0; i<540; i++) nDet[i] = 0;
844
c1eed4d3 845 Int_t nCls = 0;
846
847 //printf("nEntries = %d\n", nEntries);
848 //nEntries++;
849
850 /*
851 // select the event
852 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
853
854 // Import the tree
855 nbytes += clustersTree->GetEvent(iEntry);
856 Int_t nCluster = clusterArray->GetEntries();
857
858 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
859 c = (AliTRDcluster *) clusterArray->At(iCluster);
860 nCls++;
861 }
862 }
863
864 if (nCls < 100) {
865 delete clusterArray;
866 return;
867 }
868 */
869
870 /////
871
04236e67 872 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
873
874 // Import the tree
875 nbytes += clustersTree->GetEvent(iEntry);
876
877 // Get the number of points in the detector
c1eed4d3 878 Int_t nCluster = clusterArray->GetEntries();
04236e67 879
c1eed4d3 880
04236e67 881 // Loop through all TRD digits
882 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
c1eed4d3 883
884 nCls++;
885 c = (AliTRDcluster *) clusterArray->At(iCluster);
04236e67 886
887 Int_t iDet = c->GetDetector();
c1eed4d3 888 Int_t nPads = c->GetNPads();
889
04236e67 890 nDet[iDet]++;
891 GetRecPointsData(0)->Fill(iDet);
9b99c029 892 GetRecPointsData(86)->Fill(c->GetQ());
04236e67 893 GetRecPointsData(1)->Fill(iDet, c->GetQ());
c1eed4d3 894 GetRecPointsData(2)->Fill(nPads);
895 if (nPads < 6)
04236e67 896 GetRecPointsData(1+c->GetNPads())->Fill(c->GetCenter());
c1eed4d3 897
898 if (nPads < 10)
899 GetRecPointsData(88+nPads-2)->Fill(c->GetQ());
900 else GetRecPointsData(96)->Fill(c->GetQ());
04236e67 901
902 //if (c->GetPadTime() < 5)
903 ((TH2D*)GetRecPointsData(7))->Fill(c->GetPadRow(), c->GetPadCol());
904 GetRecPointsData(8)->Fill(c->GetPadTime());
905
906 ((TH3D*)GetRecPointsData(10))->Fill(iDet, c->GetPadTime(), c->GetQ());
9b99c029 907
908 Int_t iSM = iDet / 30;
909 GetRecPointsData(50+iSM)->Fill(c->GetPadTime());
910 GetRecPointsData(68+iSM)->Fill(c->GetPadTime(), c->GetQ());
c1eed4d3 911
912 // total charge sm / det / timeBin
913 //((TH2D*)GetRecPointsData(14+iSM))->Fill(iDet-iSM*30, c->GetPadTime(), c->GetQ());
914
04236e67 915
916 // PRF for 2pad
917 //if (c->GetNPads() == 2) {
918 Short_t *sig = c->GetSignals();
919 Double_t frac = -10;
920
921 if (sig[0] == 0 && sig[1] == 0 && sig[2] == 0 && sig[5] == 0 && sig[6] == 0)
922 frac = 1. * sig[4] / (sig[3] + sig[4]);
923
924 if (sig[0] == 0 && sig[1] == 0 && sig[4] == 0 && sig[5] == 0 && sig[6] == 0)
925 frac = -1. * sig[2] / (sig[2] + sig[3]);
926
927 if (frac > -10) ((TProfile*)GetRecPointsData(11))->Fill(c->GetCenter(), frac);
928
929 //}
930 }
142373a6 931 clusterArray->Delete();
04236e67 932 }
933
c1eed4d3 934 /*
04236e67 935 for(Int_t i=0; i<540; i++)
936 if (nDet[i] > 0) GetRecPointsData(9)->Fill(nDet[i]);
c1eed4d3 937 */
938 GetRecPointsData(9)->Fill(nCls);
939
04236e67 940 delete clusterArray;
941
942}
943
944//____________________________________________________________________________
945void AliTRDQADataMakerRec::StartOfDetectorCycle()
946{
947 //
948 // Detector specific actions at start of cycle
949 //
950
951}
952
953//__________________________________________________________________________
490b0b06 954Int_t AliTRDQADataMakerRec::CheckPointer(TObject *obj, const char *name)
04236e67 955{
956 //
957 // Checks initialization of pointers
958 //
959
960 if (!obj) AliWarning(Form("null pointer: %s", name));
961 return !!obj;
743496f4 962}
963//__________________________________________________________________________
490b0b06 964void AliTRDQADataMakerRec::BuildRatio(TH1D *ratio, TH1D *histN, TH1D*histD) {
743496f4 965 //
966 // Calculate the ratio of two histograms
967 // error are calculated assuming the histos have the same counts
968 //
04236e67 969
743496f4 970 // calclate
971
972 Int_t nbins = histN->GetXaxis()->GetNbins();
973 for(Int_t i=1; i<nbins+2; i++) {
974
975 Double_t valueN = histN->GetBinContent(i);
976 Double_t valueD = histD->GetBinContent(i);
977
978 if (valueD < 1) {
979 ratio->SetBinContent(i, 0);
980 ratio->SetBinError(i, 0);
981 continue;
982 }
983
984 Double_t eps = (valueN < valueD-valueN)? valueN : valueD-valueN;
985
986 ratio->SetBinContent(i, valueN/valueD);
987 ratio->SetBinError(i, TMath::Sqrt(eps)/valueD);
988 }
989
990 // style
991 ratio->SetMinimum(-0.1);
992 ratio->SetMaximum(1.1);
993 ratio->SetMarkerStyle(20);
04236e67 994}
4f5f1ae2 995//__________________________________________________________________________
490b0b06 996
997Int_t AliTRDQADataMakerRec::FillBits(TH1D *hist, Int_t code, Int_t offset) {
c1eed4d3 998
999 Int_t nb = 0;
1000 UInt_t test = 1;
1001 for(Int_t i=0; i<8; i++) {
1002 if (code & test) {
1003 hist->Fill(i+offset);
1004 nb++;
1005 }
1006 test *= 2;
1007 }
1008
1009 return nb;
1010}
1011
1012//__________________________________________________________________________