]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDQADataMaker.cxx
Fix for memory leaks in digits TClonesArrays (Matevz)
[u/mrichter/AliRoot.git] / TRD / AliTRDQADataMaker.cxx
CommitLineData
ffb5de4c 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
01abcaa3 16/* $Id$ */
17
18////////////////////////////////////////////////////////////////////////////
19// //
c8ab4518 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) //
01abcaa3 25// //
26////////////////////////////////////////////////////////////////////////////
ffb5de4c 27
28// --- ROOT system ---
29#include <TClonesArray.h>
ffb5de4c 30#include <TH1D.h>
01abcaa3 31#include <TH2D.h>
4e13cdf5 32#include <TH3D.h>
01abcaa3 33#include <TProfile.h>
4e13cdf5 34#include <TF1.h>
ffb5de4c 35
36// --- AliRoot header files ---
37#include "AliESDEvent.h"
4f5f1ae2 38#include "AliQAChecker.h"
39
ffb5de4c 40#include "AliTRDdigit.h"
41#include "AliTRDhit.h"
42#include "AliTRDcluster.h"
43#include "AliTRDQADataMaker.h"
01abcaa3 44#include "AliTRDdigitsManager.h"
45#include "AliTRDgeometry.h"
b65e5048 46#include "AliTRDarrayADC.h"
ffb5de4c 47
48ClassImp(AliTRDQADataMaker)
4e13cdf5 49
ffb5de4c 50//____________________________________________________________________________
4e13cdf5 51 AliTRDQADataMaker::AliTRDQADataMaker() :
4e25ac79 52 AliQADataMaker(AliQAv1::GetDetName(AliQAv1::kTRD), "TRD Quality Assurance Data Maker")
ffb5de4c 53{
c8ab4518 54 //
55 // Default constructor
ffb5de4c 56}
57
58//____________________________________________________________________________
4e13cdf5 59AliTRDQADataMaker::AliTRDQADataMaker(const AliTRDQADataMaker& qadm) :
60 AliQADataMaker()
ffb5de4c 61{
c8ab4518 62 //
4e13cdf5 63 // Copy constructor
c8ab4518 64 //
4e13cdf5 65
ffb5de4c 66 SetName((const char*)qadm.GetName()) ;
67 SetTitle((const char*)qadm.GetTitle());
c8ab4518 68
ffb5de4c 69}
70
71//__________________________________________________________________
4e13cdf5 72AliTRDQADataMaker& AliTRDQADataMaker::operator=(const AliTRDQADataMaker& qadm)
ffb5de4c 73{
c8ab4518 74 //
ffb5de4c 75 // Equal operator.
c8ab4518 76 //
77
ffb5de4c 78 this->~AliTRDQADataMaker();
79 new(this) AliTRDQADataMaker(qadm);
80 return *this;
c8ab4518 81
ffb5de4c 82}
4e13cdf5 83
ffb5de4c 84//____________________________________________________________________________
4e25ac79 85void AliTRDQADataMaker::EndOfDetectorCycle(AliQAv1::TASKINDEX task, TObjArray * list)
ffb5de4c 86{
c8ab4518 87 //
88 // Detector specific actions at end of cycle
89 //
8f3f00a4 90 //TStopwatch watch;
91 //watch.Start();
4e13cdf5 92
5379c4a3 93 //AliDebug(AliQAv1::GetQADebugLevel(), Form("EndOfCycle", "Fitting RecPoints %d", task))
8f3f00a4 94 TH1D *hist = new TH1D("fitHist", "", 200, -0.5, 199.5);
b6186d2c 95
4e25ac79 96 if (task == AliQAv1::kRECPOINTS) {
4e13cdf5 97
98 //list->Print();
4e13cdf5 99
b6186d2c 100 // Rec points full chambers
8f3f00a4 101 for (Int_t i=0; i<540; i++) {
4e13cdf5 102
8f3f00a4 103 //TH1D *h = ((TH2D*)list->At(1))->ProjectionY(Form("qaTRD_recPoints_amp_%d",i), i+1, i+1);
104 hist->Reset();
105 for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) {
106 Double_t xvalue = hist->GetBinCenter(b);
107 Int_t bin = ((TH2D*)list->At(1))->FindBin(i,xvalue);
108 Double_t value = ((TH2D*)list->At(1))->GetBinContent(bin);
109 hist->SetBinContent(b, value);
b6186d2c 110 }
8f3f00a4 111
112 //printf("Sum = %d %f\n", i, hist->GetSum());
113 if (hist->GetSum() < 100) continue; // chamber not present
114
115 hist->Fit("landau", "q0", "goff", 10, 180);
116 TF1 *fit = hist->GetFunction("landau");
117 ((TH1D*)list->At(12))->Fill(fit->GetParameter(1));
118 ((TH1D*)list->At(13))->Fill(fit->GetParameter(2));
b6186d2c 119 }
8f3f00a4 120
121 // time-bin by time-bin
122 for (Int_t i=0; i<540; i++) {
b6186d2c 123
8f3f00a4 124 //TH1D *test = ((TH3D*)list->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, 0, 35);
125 //if (test->GetSum() < 100) continue;
126
5379c4a3 127 //AliDebug(AliQAv1::GetQADebugLevel(), Form("fitting det = %d", i));
8f3f00a4 128
129 for(Int_t j=0; j<35; j++) {
4e13cdf5 130
8f3f00a4 131 //TH1D *h = ((TH3D*)list->At(10))->ProjectionZ(Form("ampTime_%d",i), i+1, i+1, j+1, j+1);
132 hist->Reset();
133 for(Int_t b=1; b<hist->GetXaxis()->GetNbins()-1; b++) {
134 Double_t xvalue = hist->GetBinCenter(b);
135 Int_t bin = ((TH3D*)list->At(10))->FindBin(i,j,xvalue);
136 Double_t value = ((TH3D*)list->At(10))->GetBinContent(bin);
137 //printf("v = %f\n", value);
138 hist->SetBinContent(b, value);
b6186d2c 139 }
8f3f00a4 140
141 if (hist->GetSum() < 100) continue;
142 //printf("fitting %d %d %f\n", i, j, hist->GetSum());
143
144 hist->Fit("landau", "q0", "goff", 10, 180);
145 TF1 *fit = hist->GetFunction("landau");
146
147 Int_t sm = i/18;
148 Int_t det = i%18;
149 TH2D *h2 = (TH2D*)list->At(14+sm);
150 Int_t bin = h2->FindBin(det,j);
151 // printf("%d %d %d\n", det, j, bin);
152 h2->SetBinContent(bin, fit->GetParameter(1));
4e13cdf5 153 }
154 }
155 }
01abcaa3 156
8f3f00a4 157 delete hist;
158
4e13cdf5 159 // call the checker
4e25ac79 160 AliQAChecker::Instance()->Run(AliQAv1::kTRD, task, list) ;
4e13cdf5 161
8f3f00a4 162 //watch.Stop();
163 //watch.Print();
ffb5de4c 164}
165
166//____________________________________________________________________________
167void AliTRDQADataMaker::InitESDs()
168{
b78bfa3c 169 //
c8ab4518 170 // Create ESDs histograms in ESDs subdir
b78bfa3c 171 //
172
4e13cdf5 173 const Int_t kNhist = 19;
c8ab4518 174 TH1 *hist[kNhist];
4e13cdf5 175 Int_t histoCounter = -1 ;
b78bfa3c 176
177 hist[++histoCounter] = new TH1D("qaTRD_esd_ntracks", ":Number of tracks", 300, -0.5, 299.5);
178 hist[++histoCounter] = new TH1D("qaTRD_esd_sector", ":Sector", 18, -0.5, 17.7);
179 hist[++histoCounter] = new TH1D("qaTRD_esd_bits", ";Bits", 64, -0.5, 63.5);
01abcaa3 180
181 const Int_t knbits = 6;
182 const char *suf[knbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
b78bfa3c 183
01abcaa3 184 for(Int_t i=0; i<knbits; i++) {
b78bfa3c 185 hist[++histoCounter] = new TH1D(Form("qaTRD_esd_pt%s",suf[i]), ";p_{T} (GeV/c);", 50, 0, 10);
186 hist[++histoCounter] = new TH1D(Form("qaTRD_esd_trdz%s", suf[i]), ";z (cm)", 200, -400, 400);
01abcaa3 187 }
01abcaa3 188
b78bfa3c 189 hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDo", "TRDo;number of clusters", 130, -0.5, 129.5);;
190 hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDr", "TRDr;number of clusters", 130, -0.5, 129.5);;
191 hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDz", "TRDz;number of clusters", 130, -0.5, 129.5);;
4e13cdf5 192 //hist[++histoCounter] = new TH1D("qaTRD_esd_clsRatio", ";cluster ratio", 100, 0., 1.3);;
b78bfa3c 193
194 hist[++histoCounter] = new TH2D("qaTRD_esd_sigMom", ";momentum (GeV/c);signal", 100, 0, 5, 200, 0, 1e3);
ffb5de4c 195
b78bfa3c 196 for(Int_t i=0; i<=histoCounter; i++) {
ffb5de4c 197 //hist[i]->Sumw2();
198 Add2ESDsList(hist[i], i);
199 }
c8ab4518 200
ffb5de4c 201}
202
203//____________________________________________________________________________
204void AliTRDQADataMaker::InitHits()
205{
c8ab4518 206 //
207 // Create Hits histograms in Hits subdir
208 //
209
210 const Int_t kNhist = 4;
211 TH1D *hist[kNhist];
4e13cdf5 212
ffb5de4c 213 hist[0] = new TH1D("qaTRD_hits_det", ";Detector Id of the hit", 540, -0.5, 539.5) ;
4e13cdf5 214
ffb5de4c 215 hist[1] = new TH1D("qaTRD_hist_Qdrift", ";Charge from tracks", 100, 0, 100);
216 hist[2] = new TH1D("qaTRD_hist_Qamp", ";Charge from TRD photon", 100, 0, 100);
217 hist[3] = new TH1D("qaTRD_hist_Qphoton", ";Charge from TRD photon", 100, 0, 100);
218
c8ab4518 219 for(Int_t i=0; i<kNhist; i++) {
ffb5de4c 220 //hist[i]->Sumw2();
221 Add2HitsList(hist[i], i);
222 }
c8ab4518 223
ffb5de4c 224}
225
226//____________________________________________________________________________
227void AliTRDQADataMaker::InitDigits()
228{
c8ab4518 229 //
230 // Create Digits histograms in Digits subdir
231 //
232
233 const Int_t kNhist = 3;
234 TH1D *hist[kNhist];
4e13cdf5 235
ffb5de4c 236 hist[0] = new TH1D("qaTRD_digits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
237 hist[1] = new TH1D("qaTRD_digits_time", ";Time bin", 40, -0.5, 39.5);
238 hist[2] = new TH1D("qaTRD_digits_amp", ";Amplitude", 100, 0, 100.);
239
c8ab4518 240 for(Int_t i=0; i<kNhist; i++) {
ffb5de4c 241 hist[i]->Sumw2();
242 Add2DigitsList(hist[i], i);
243 }
ffb5de4c 244}
245
246//____________________________________________________________________________
247void AliTRDQADataMaker::InitRecPoints()
248{
c8ab4518 249 //
250 // Create Reconstructed Points histograms in RecPoints subdir
251 //
252
4e13cdf5 253 const Int_t kNhist = 14 + 18;
c8ab4518 254 TH1 *hist[kNhist];
ffb5de4c 255
256 hist[0] = new TH1D("qaTRD_recPoints_det", ";Detector ID of the cluster", 540, -0.5, 539.5);
01abcaa3 257 hist[1] = new TH2D("qaTRD_recPoints_amp", ";Amplitude", 540, -0.5, 539, 200, -0.5, 199.5);
ffb5de4c 258 hist[2] = new TH1D("qaTRD_recPoints_npad", ";Number of Pads", 12, -0.5, 11.5);
4e13cdf5 259
ffb5de4c 260 hist[3] = new TH1D("qaTRD_recPoints_dist2", ";residuals [2pad]", 100, -1, 1);
261 hist[4] = new TH1D("qaTRD_recPoints_dist3", ";residuals [3pad]", 100, -1, 1);
262 hist[5] = new TH1D("qaTRD_recPoints_dist4", ";residuals [4pad]", 100, -1, 1);
263 hist[6] = new TH1D("qaTRD_recPoints_dist5", ";residuals [5pad]", 100, -1, 1);
264
01abcaa3 265 hist[7] = new TH2D("qaTRD_recPoints_rowCol", ";row;col", 16, -0.5, 15.5, 145, -0.5, 144.5);
266 hist[8] = new TH1D("qaTRD_recPoints_time", ";time bin", 35, -0.5, 34.5);
267 hist[9] = new TH1D("qaTRD_recPoints_nCls", ";number of clusters", 500, -0.5, 499.5);
268
4e13cdf5 269 hist[10] = new TH3D("qaTRD_recPoints_sigTime", ";chamber;time bin;signal",
8f3f00a4 270 540, -0.5, 539.5, 35, -0.5, 34.5, 200, 0.5, 199.5);
4e13cdf5 271 hist[11] = new TProfile("qaTRD_recPoints_prf", ";distance;center of gravity"
272 , 120, -0.6, 0.6, -1.2, 1.2, "");
01abcaa3 273
4e13cdf5 274 hist[12] = new TH1D("qaTRD_recPoints_ampMPV", ";amplitude MPV", 100, 0, 100);
275 hist[13] = new TH1D("qaTRD_recPoints_ampSigma", ";amplitude Sigma", 100, 0, 100);
01abcaa3 276
4e13cdf5 277 for(Int_t i=0; i<18; i++) {
278 hist[14+i] = new TH2D(Form("qaTRD_recPoints_sigTime_sm%d",i), Form("sm%d;det;time bin"),
279 30, -0.5, 29.5, 35, -0.5, 34.5);
280 hist[14+i]->SetMinimum(20);
281 hist[14+i]->SetMaximum(40);
282 }
01abcaa3 283
c8ab4518 284 for(Int_t i=0; i<kNhist; i++) {
ffb5de4c 285 //hist[i]->Sumw2();
286 Add2RecPointsList(hist[i], i);
287 }
c8ab4518 288
ffb5de4c 289}
290
291//____________________________________________________________________________
292void AliTRDQADataMaker::InitRaws()
293{
c8ab4518 294 //
4e13cdf5 295 // create Raws histograms in Raws subdir
c8ab4518 296 //
297
ffb5de4c 298 const Int_t kSM = 18;
4e13cdf5 299 //const Int_t kNCh = 540;
300 const Int_t kNhist = 4+kSM;
c8ab4518 301 TH1D *hist[kNhist];
4e13cdf5 302
303 // four histograms to be published
ffb5de4c 304 hist[0] = new TH1D("qaTRD_raws_det", ";detector", 540, -0.5, 539.5);
305 hist[1] = new TH1D("qaTRD_raws_sig", ";signal", 100, -0.5, 99.5);
4e13cdf5 306 hist[2] = new TH1D("qaTRD_raws_timeBin", ";time bin", 40, -0.5, 39.5);
307 hist[3] = new TH1D("qaTRD_raws_smId", ";supermodule", 18, -0.5, 17.5);
308 //
309
310 // one double per MCM (not published)
311 const Int_t kNMCM = 30 * 8 * 16;
ffb5de4c 312 for(Int_t i=0; i<kSM; i++)
4e13cdf5 313 hist[4+i] = new TH1D(Form("qaTRD_raws_sm%d",i),"",kNMCM, -0.5, kNMCM-0.5);
314
315 // register
c8ab4518 316 for(Int_t i=0; i<kNhist; i++) {
ffb5de4c 317 //hist[i]->Sumw2();
318 Add2RawsList(hist[i], i);
319 }
c8ab4518 320
ffb5de4c 321}
322
323//____________________________________________________________________________
324void AliTRDQADataMaker::InitSDigits()
325{
c8ab4518 326 //
327 // Create SDigits histograms in SDigits subdir
328 //
329
330 const Int_t kNhist = 3;
331 TH1D *hist[kNhist];
4e13cdf5 332
01abcaa3 333 hist[0] = new TH1D("qaTRD_sdigits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
334 hist[1] = new TH1D("qaTRD_sdigits_time", ";Time bin", 40, -0.5, 39.5);
335 hist[2] = new TH1D("qaTRD_sdigits_amp", ";Amplitude", 100, 0, 1e7);
ffb5de4c 336
c8ab4518 337 for(Int_t i=0; i<kNhist; i++) {
ffb5de4c 338 hist[i]->Sumw2();
339 Add2SDigitsList(hist[i], i);
340 }
c8ab4518 341
ffb5de4c 342}
343
344//____________________________________________________________________________
4f5f1ae2 345void AliTRDQADataMaker::MakeESDs(AliESDEvent * const esd)
ffb5de4c 346{
c8ab4518 347 //
348 // Make QA data from ESDs
349 //
350
01abcaa3 351 Int_t nTracks = esd->GetNumberOfTracks();
352 GetESDsData(0)->Fill(nTracks);
4e13cdf5 353
01abcaa3 354 // track loop
4e13cdf5 355 for (Int_t i=0; i<nTracks; i++) {
356
01abcaa3 357 AliESDtrack *track = esd->GetTrack(i);
358 const AliExternalTrackParam *paramOut = track->GetOuterParam();
359 const AliExternalTrackParam *paramIn = track->GetInnerParam();
360
361 // long track ..
362 if (!paramIn) continue;
363 if (!paramOut) continue;
364
365 // not a kink
366 if (track->GetKinkIndex(0) > 0) continue;
367
368 Double_t extZ = GetExtZ(paramIn);
369 if (TMath::Abs(extZ) > 320) continue; // acceptance cut
370
371 // .. in the acceptance
372 Int_t sector = GetSector(paramOut->GetAlpha());
01abcaa3 373
374 UInt_t u = 1;
375 UInt_t status = track->GetStatus();
376 for(Int_t bit=0; bit<32; bit++)
377 if (u<<bit & status) GetESDsData(2)->Fill(bit);
378
379 const Int_t knbits = 6;
380 Int_t bit[6] = {0,0,0,0,0,0};
381 bit[0] = status & AliESDtrack::kTPCin;
382 bit[1] = status & AliESDtrack::kTPCout;
383 bit[2] = (status & AliESDtrack::kTPCout) && !(status & AliESDtrack::kTRDout);
384 bit[3] = status & AliESDtrack::kTRDout;
385 bit[4] = status & AliESDtrack::kTRDrefit;
386 bit[5] = (status & AliESDtrack::kTRDout) && !(status & AliESDtrack::kTRDrefit);
387
388 // transverse momentum
389 //const Double_t *val = paramOut->GetParameter(); // parameters at the Outer plane
390 Double_t pt = paramOut->Pt(); //1./TMath::Abs(val[4]);
391
392 for(Int_t b=0; b<knbits; b++) {
393 if (bit[b]) {
6b6b748d 394 GetESDsData(2*b+3)->Fill(pt);
395 GetESDsData(2*b+4)->Fill(extZ);
01abcaa3 396 }
397 }
398
399 // clusters
400 for(Int_t b=0; b<3; b++)
401 if (bit[3+b]) GetESDsData(b+15)->Fill(track->GetTRDncls());
402
403 // refitted only
404 if (!bit[4]) continue;
405
406 //fQuality->Fill(track->GetTRDQuality());
407 //fBudget->Fill(track->GetTRDBudget());
408 //fSignal->Fill(track->GetTRDsignal());
409
410 GetESDsData(18)->Fill(track->GetP(), track->GetTRDsignal());
c29b11ff 411 GetESDsData(1)->Fill(sector);
01abcaa3 412
413 /*
414 // PID only
415 if (status & AliESDtrack::kTRDpid) {
4e13cdf5 416
01abcaa3 417 for(Int_t l=0; l<6; l++) fTime->Fill(track->GetTRDTimBin(l));
418
419 // fill pid histograms
420 Double_t trdr0 = 0; //, tpcr0 = 0;
421 Int_t trdBestPid = 5; //, tpcBestPid = 5; // charged
422 const Double_t kminPidValue = 0.9;
423
424 //Double_t pp[5];
425 //track->GetTPCpid(pp); // ESD inconsequence
426
427 for(Int_t pid=0; pid<5; pid++) {
428
429 trdr0 += track->GetTRDpid(pid);
430 //tpcr0 += pp[pid];
431
432 fTrdPID[pid]->Fill(track->GetTRDpid(pid));
433 //fTpcPID[pid]->Fill(pp[pid]);
434
435 if (track->GetTRDpid(pid) > kminPidValue) trdBestPid = pid;
436 //if (pp[pid] > kminPidValue) tpcBestPid = pid;
437 }
4e13cdf5 438
01abcaa3 439 fTrdPID[5]->Fill(trdr0); // check unitarity
440 fTrdSigMomPID[trdBestPid]->Fill(track->GetP(), track->GetTRDsignal());
4e13cdf5 441
01abcaa3 442 //fTpcPID[5]->Fill(tpcr0); // check unitarity
443 //fTpcSigMomPID[tpcBestPid]->Fill(track->GetP(), track->GetTPCsignal());
444 }
445 */
4e13cdf5 446
01abcaa3 447 }
448
01abcaa3 449}
450
451//______________________________________________________________________________
c8ab4518 452Int_t AliTRDQADataMaker::GetSector(const Double_t alpha) const
453{
454 //
01abcaa3 455 // Gets the sector number
c8ab4518 456 //
01abcaa3 457
458 Double_t size = TMath::DegToRad() * 20.; // shall use TRDgeo
459 Int_t sector = (Int_t)((alpha + TMath::Pi())/size);
460 return sector;
c8ab4518 461
01abcaa3 462}
463
464//______________________________________________________________________________
c8ab4518 465Double_t AliTRDQADataMaker::GetExtZ(const AliExternalTrackParam *in) const
466{
01abcaa3 467 //
c8ab4518 468 // Returns the Z position at the entry to TRD
01abcaa3 469 // using parameters from the TPC in
470 //
471
c8ab4518 472 const Double_t kX0 = 300;
01abcaa3 473
474 Double_t x = in->GetX();
475 const Double_t *par = in->GetParameter();
476 Double_t theta = par[3];
477 Double_t z = in->GetZ();
4e13cdf5 478
c8ab4518 479 Double_t zz = z + (kX0-x) * TMath::Tan(theta);
01abcaa3 480 return zz;
4e13cdf5 481
ffb5de4c 482}
483
484//____________________________________________________________________________
4f5f1ae2 485void AliTRDQADataMaker::MakeHits(TClonesArray * const hits)
ffb5de4c 486{
c8ab4518 487 //
488 // Make QA data from Hits
489 //
ffb5de4c 490
491 TIter next(hits);
492 AliTRDhit * hit;
4e13cdf5 493
ffb5de4c 494 while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
495 GetHitsData(0)->Fill(hit->GetDetector());
496 Double_t q = TMath::Abs(hit->GetCharge());
4e13cdf5 497
ffb5de4c 498 if (hit->FromDrift()) GetHitsData(1)->Fill(q);
499 if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
500 if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
501 }
502
503}
01abcaa3 504
ffb5de4c 505//____________________________________________________________________________
506void AliTRDQADataMaker::MakeHits(TTree * hitTree)
507{
c8ab4518 508 //
509 // Make QA data from Hits
510 //
4e13cdf5 511
ffb5de4c 512 if (!CheckPointer(hitTree, "TRD hits tree")) return;
4e13cdf5 513
ffb5de4c 514 TBranch *branch = hitTree->GetBranch("TRD");
515 if (!CheckPointer(branch, "TRD hits branch")) return;
4e13cdf5 516
ffb5de4c 517 Int_t nhits = (Int_t)(hitTree->GetTotBytes()/sizeof(AliTRDhit));
518 TClonesArray *hits = new TClonesArray("AliTRDhit", nhits+1000);
519 TClonesArray *tmp = new TClonesArray("AliTRDhit", 1000);
520 branch->SetAddress(&tmp);
4e13cdf5 521
ffb5de4c 522 Int_t index = 0;
523 Int_t nEntries = (Int_t)branch->GetEntries();
524 for(Int_t i = 0; i < nEntries; i++) {
525 branch->GetEntry(i);
526 Int_t nHits = (Int_t)tmp->GetEntries();
527 for(Int_t j=0; j<nHits; j++) {
528 AliTRDhit *hit = (AliTRDhit*)tmp->At(j);
529 new((*hits)[index++]) AliTRDhit(*hit);
530 }
531 }
532
533 tmp->Delete();
534 delete tmp;
535 MakeHits(hits);
c8ab4518 536
ffb5de4c 537}
01abcaa3 538
ffb5de4c 539//____________________________________________________________________________
4f5f1ae2 540void AliTRDQADataMaker::MakeDigits(TClonesArray * const digits)
ffb5de4c 541{
c8ab4518 542 //
4e13cdf5 543 // Makes data from Digits
c8ab4518 544 //
545
ffb5de4c 546 TIter next(digits) ;
547 AliTRDdigit * digit ;
548 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
549 GetDigitsData(0)->Fill(digit->GetDetector());
550 GetDigitsData(1)->Fill(digit->GetTime());
551 GetDigitsData(2)->Fill(digit->GetAmp());
c8ab4518 552 }
553
ffb5de4c 554}
555
01abcaa3 556//____________________________________________________________________________
557void AliTRDQADataMaker::MakeDigits(TTree * digits)
558{
c8ab4518 559 //
560 // Makes data from digits tree
561 //
01abcaa3 562
563 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
564 digitsManager->CreateArrays();
565 digitsManager->ReadDigits(digits);
566
567 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
4e13cdf5 568
b65e5048 569 AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);
4e13cdf5 570
01abcaa3 571 // This is to take care of switched off super modules
572 if (digitsIn->GetNtime() == 0) continue;
4e13cdf5 573
b65e5048 574 digitsIn->Expand();
4e13cdf5 575
01abcaa3 576 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
577 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
4e13cdf5 578
01abcaa3 579 Int_t nRows = digitsIn->GetNrow();
580 Int_t nCols = digitsIn->GetNcol();
581 Int_t nTbins = digitsIn->GetNtime();
582
583 for(Int_t row = 0; row < nRows; row++)
584 for(Int_t col = 0; col < nCols; col++)
b65e5048 585 for(Int_t time = 0; time < nTbins; time++)
586 {
587 Float_t signal = digitsIn->GetData(row,col,time);
588 GetDigitsData(0)->Fill(i);
589 GetDigitsData(1)->Fill(time);
590 GetDigitsData(2)->Fill(signal);
591 }
4e13cdf5 592
01abcaa3 593 //delete digitsIn;
594 }
c8ab4518 595
01abcaa3 596 delete digitsManager;
c8ab4518 597
01abcaa3 598}
599
ffb5de4c 600//____________________________________________________________________________
4f5f1ae2 601void AliTRDQADataMaker::MakeSDigits(TClonesArray * const sdigits)
ffb5de4c 602{
c8ab4518 603 //
4e13cdf5 604 // Makes data from Digits
c8ab4518 605 //
606
ffb5de4c 607 TIter next(sdigits) ;
608 AliTRDdigit * digit ;
609 while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
610 GetDigitsData(0)->Fill(digit->GetDetector());
01abcaa3 611 GetDigitsData(1)->Fill(digit->GetTime());
612 GetDigitsData(2)->Fill(digit->GetAmp());
4e13cdf5 613 }
614
ffb5de4c 615}
616
01abcaa3 617//____________________________________________________________________________
618void AliTRDQADataMaker::MakeSDigits(TTree * digits)
619{
c8ab4518 620 //
4e13cdf5 621 // Makes data from SDigits
c8ab4518 622 //
01abcaa3 623
624 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
625 digitsManager->CreateArrays();
626 digitsManager->ReadDigits(digits);
627
b65e5048 628 for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++)
629 {
630 AliTRDarrayADC *digitsIn = (AliTRDarrayADC *) digitsManager->GetDigits(i);
4e13cdf5 631
01abcaa3 632 // This is to take care of switched off super modules
633 if (digitsIn->GetNtime() == 0) continue;
4e13cdf5 634
b65e5048 635 digitsIn->Expand();
4e13cdf5 636
01abcaa3 637 //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
638 //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
4e13cdf5 639
01abcaa3 640 Int_t nRows = digitsIn->GetNrow();
641 Int_t nCols = digitsIn->GetNcol();
642 Int_t nTbins = digitsIn->GetNtime();
643
644 for(Int_t row = 0; row < nRows; row++)
645 for(Int_t col = 0; col < nCols; col++)
b65e5048 646 for(Int_t time = 0; time < nTbins; time++)
647 {
648 Float_t signal = digitsIn->GetData(row,col,time);
649 if (signal <= 0) continue;
650 GetSDigitsData(0)->Fill(i);
651 GetSDigitsData(1)->Fill(time);
652 GetSDigitsData(2)->Fill(signal);
653 }
654
01abcaa3 655 // delete digitsIn;
656 }
657
658 delete digitsManager;
c8ab4518 659
01abcaa3 660}
661
ffb5de4c 662//____________________________________________________________________________
4f5f1ae2 663void AliTRDQADataMaker::MakeRaws(AliRawReader * const rawReader)
ffb5de4c 664{
c8ab4518 665 //
4e13cdf5 666 // Makes QA data from raw data
667 //
668
ffb5de4c 669 // 157
670 // T9 -- T10
671
4e13cdf5 672 //const Int_t kSM = 18;
ffb5de4c 673 //const Int_t kROC = 30;
4e13cdf5 674 const Int_t kROB = 8;
ffb5de4c 675 //const Int_t kLayer = 6;
676 //const Int_t kStack = 5;
677 const Int_t kMCM = 16;
4e13cdf5 678 // const Int_t kADC = 22;
679
66eae3f0 680 AliTRDrawStream raw(rawReader);
681 raw.SetRawVersion(3);
682 raw.Init();
4e13cdf5 683
66eae3f0 684 while (raw.Next()) {
4e13cdf5 685
66eae3f0 686 GetRawsData(0)->Fill(raw.GetDet());
4e13cdf5 687
688 // possibly needs changes with the new reader !!
66eae3f0 689 Int_t *sig = raw.GetSignals();
ffb5de4c 690 for(Int_t i=0; i<3; i++) GetRawsData(1)->Fill(sig[i]);
4e13cdf5 691 // ---
692
66eae3f0 693 GetRawsData(2)->Fill(raw.GetTimeBin());
4e13cdf5 694
ffb5de4c 695 // calculate the index;
66eae3f0 696 Int_t sm = raw.GetSM();
697 Int_t roc = raw.GetROC();
698 Int_t rob = raw.GetROB();
699 Int_t mcm = raw.GetMCM();
700 //Int_t adc = raw.GetADC();
4e13cdf5 701
702 //Int_t index = roc * (kROB*kMCM*kADC) + rob * (kMCM*kADC) + mcm * kADC + adc;
703 Int_t index = roc * (kROB*kMCM) + rob * kMCM + mcm;
704 GetRawsData(3)->Fill(sm);
705 GetRawsData(4+sm)->Fill(index);
ffb5de4c 706 }
ad1b4ece 707
ffb5de4c 708}
709
710//____________________________________________________________________________
711void AliTRDQADataMaker::MakeRecPoints(TTree * clustersTree)
712{
c8ab4518 713 //
714 // Makes data from RecPoints
ffb5de4c 715 //
4e13cdf5 716
ffb5de4c 717 Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster)));
718 TObjArray *clusterArray = new TObjArray(nsize+1000);
4e13cdf5 719
ffb5de4c 720 TBranch *branch = clustersTree->GetBranch("TRDcluster");
721 if (!branch) {
722 AliError("Can't get the branch !");
723 return;
724 }
725 branch->SetAddress(&clusterArray);
4e13cdf5 726
ffb5de4c 727 // Loop through all entries in the tree
728 Int_t nEntries = (Int_t) clustersTree->GetEntries();
729 Int_t nbytes = 0;
730 AliTRDcluster *c = 0;
01abcaa3 731 Int_t nDet[540];
732 for (Int_t i=0; i<540; i++) nDet[i] = 0;
4e13cdf5 733
ffb5de4c 734 for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {
4e13cdf5 735
ffb5de4c 736 // Import the tree
737 nbytes += clustersTree->GetEvent(iEntry);
4e13cdf5 738
ffb5de4c 739 // Get the number of points in the detector
740 Int_t nCluster = clusterArray->GetEntriesFast();
4e13cdf5 741
ffb5de4c 742 // Loop through all TRD digits
743 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
744 c = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster);
4e13cdf5 745
01abcaa3 746 Int_t iDet = c->GetDetector();
747 nDet[iDet]++;
748 GetRecPointsData(0)->Fill(iDet);
749 GetRecPointsData(1)->Fill(iDet, c->GetQ());
ffb5de4c 750 GetRecPointsData(2)->Fill(c->GetNPads());
751 if (c->GetNPads() < 6)
752 GetRecPointsData(1+c->GetNPads())->Fill(c->GetCenter());
01abcaa3 753
754 //if (c->GetPadTime() < 5)
755 ((TH2D*)GetRecPointsData(7))->Fill(c->GetPadRow(), c->GetPadCol());
756 GetRecPointsData(8)->Fill(c->GetPadTime());
4e13cdf5 757
758 ((TH3D*)GetRecPointsData(10))->Fill(iDet, c->GetPadTime(), c->GetQ());
759
01abcaa3 760 // PRF for 2pad
761 //if (c->GetNPads() == 2) {
762 Short_t *sig = c->GetSignals();
763 Double_t frac = -10;
4e13cdf5 764
01abcaa3 765 if (sig[0] == 0 && sig[1] == 0 && sig[2] == 0 && sig[5] == 0 && sig[6] == 0)
766 frac = 1. * sig[4] / (sig[3] + sig[4]);
4e13cdf5 767
01abcaa3 768 if (sig[0] == 0 && sig[1] == 0 && sig[4] == 0 && sig[5] == 0 && sig[6] == 0)
769 frac = -1. * sig[2] / (sig[2] + sig[3]);
4e13cdf5 770
01abcaa3 771 if (frac > -10) ((TProfile*)GetRecPointsData(11))->Fill(c->GetCenter(), frac);
772
773 //}
ffb5de4c 774 }
775 }
4e13cdf5 776
01abcaa3 777 for(Int_t i=0; i<540; i++)
778 if (nDet[i] > 0) GetRecPointsData(9)->Fill(nDet[i]);
779
ffb5de4c 780 delete clusterArray;
c8ab4518 781
ffb5de4c 782}
783
784//____________________________________________________________________________
785void AliTRDQADataMaker::StartOfDetectorCycle()
786{
c8ab4518 787 //
788 // Detector specific actions at start of cycle
789 //
ffb5de4c 790
791}
01abcaa3 792
ffb5de4c 793//__________________________________________________________________________
4f5f1ae2 794Int_t AliTRDQADataMaker::CheckPointer(TObject * const obj, const char *name)
c8ab4518 795{
796 //
797 // Checks initialization of pointers
798 //
ffb5de4c 799
800 if (!obj) AliWarning(Form("null pointer: %s", name));
801 return !!obj;
c8ab4518 802
ffb5de4c 803}