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