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