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