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