]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDQADataMaker.cxx
TList replaced by TObjArray as QA data container. Introducing OCDB for the reference...
[u/mrichter/AliRoot.git] / TRD / AliTRDQADataMaker.cxx
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
16 /* $Id$ */
17
18 ////////////////////////////////////////////////////////////////////////////
19 //                                                                        //
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)               //
25 //                                                                        //
26 ////////////////////////////////////////////////////////////////////////////
27
28 // --- ROOT system ---
29 #include <TClonesArray.h>
30 #include <TFile.h> 
31 #include <TH1D.h> 
32 #include <TH2D.h>
33 #include <TH3D.h>
34 #include <TProfile.h>
35 #include <TF1.h>
36 #include <TCanvas.h>
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"
45 #include "AliTRDdigitsManager.h"
46 #include "AliTRDgeometry.h"
47 #include "AliTRDdataArrayI.h"
48 #include "AliTRDRawStreamTB.h"
49
50 #include "AliQAChecker.h"
51
52 ClassImp(AliTRDQADataMaker)
53
54 //____________________________________________________________________________ 
55   AliTRDQADataMaker::AliTRDQADataMaker() : 
56   AliQADataMaker(AliQA::GetDetName(AliQA::kTRD), "TRD Quality Assurance Data Maker")
57 {
58   //
59   // Default constructor
60 }
61
62 //____________________________________________________________________________ 
63 AliTRDQADataMaker::AliTRDQADataMaker(const AliTRDQADataMaker& qadm) :
64   AliQADataMaker()
65 {
66   //
67   // Copy constructor 
68   //
69
70   SetName((const char*)qadm.GetName()) ; 
71   SetTitle((const char*)qadm.GetTitle()); 
72
73 }
74
75 //__________________________________________________________________
76 AliTRDQADataMaker& AliTRDQADataMaker::operator=(const AliTRDQADataMaker& qadm)
77 {
78   //
79   // Equal operator.
80   //
81
82   this->~AliTRDQADataMaker();
83   new(this) AliTRDQADataMaker(qadm);
84   return *this;
85
86 }
87
88 //____________________________________________________________________________ 
89 void AliTRDQADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TObjArray * list)
90 {
91   //
92   // Detector specific actions at end of cycle
93   //
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   }
138   
139   // call the checker
140   AliQAChecker::Instance()->Run(AliQA::kTRD, task, list) ;    
141
142
143 }
144
145 //____________________________________________________________________________ 
146 void AliTRDQADataMaker::InitESDs()
147 {
148   //
149   // Create ESDs histograms in ESDs subdir
150   //
151
152   const Int_t kNhist = 19;
153   TH1 *hist[kNhist];
154   Int_t histoCounter = -1 ;
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);
159
160   const Int_t knbits = 6;
161   const char *suf[knbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
162
163   for(Int_t i=0; i<knbits; i++) {
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); 
166   }
167
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);;
171   //hist[++histoCounter] = new TH1D("qaTRD_esd_clsRatio", ";cluster ratio", 100, 0., 1.3);;
172
173   hist[++histoCounter] = new TH2D("qaTRD_esd_sigMom", ";momentum (GeV/c);signal", 100, 0, 5, 200, 0, 1e3);
174
175   for(Int_t i=0; i<=histoCounter; i++) {
176     //hist[i]->Sumw2();
177     Add2ESDsList(hist[i], i);
178   }
179
180 }
181
182 //____________________________________________________________________________ 
183 void AliTRDQADataMaker::InitHits()
184 {
185   //
186   // Create Hits histograms in Hits subdir
187   //
188
189   const Int_t kNhist = 4;
190   TH1D *hist[kNhist];
191
192   hist[0] = new TH1D("qaTRD_hits_det", ";Detector Id of the hit", 540, -0.5, 539.5) ; 
193
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
198   for(Int_t i=0; i<kNhist; i++) {
199     //hist[i]->Sumw2();
200     Add2HitsList(hist[i], i);
201   }
202
203 }
204
205 //____________________________________________________________________________ 
206 void AliTRDQADataMaker::InitDigits()
207 {
208   //
209   // Create Digits histograms in Digits subdir
210   //
211
212   const Int_t kNhist = 3;
213   TH1D *hist[kNhist];
214
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
219   for(Int_t i=0; i<kNhist; i++) {
220     hist[i]->Sumw2();
221     Add2DigitsList(hist[i], i);
222   }
223
224 }
225
226 //____________________________________________________________________________ 
227 void AliTRDQADataMaker::InitRecPoints()
228 {
229   //
230   // Create Reconstructed Points histograms in RecPoints subdir
231   //
232
233   const Int_t kNhist = 14 + 18;
234   TH1 *hist[kNhist];
235
236   hist[0] = new TH1D("qaTRD_recPoints_det", ";Detector ID of the cluster", 540, -0.5, 539.5);
237   hist[1] = new TH2D("qaTRD_recPoints_amp", ";Amplitude", 540, -0.5, 539, 200, -0.5, 199.5);
238   hist[2] = new TH1D("qaTRD_recPoints_npad", ";Number of Pads", 12, -0.5, 11.5);
239
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
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
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, "");
253
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); 
256
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   }
263
264   for(Int_t i=0; i<kNhist; i++) {
265     //hist[i]->Sumw2();
266     Add2RecPointsList(hist[i], i);
267   }
268
269 }
270
271 //____________________________________________________________________________ 
272 void AliTRDQADataMaker::InitRaws()
273 {
274   //
275   // create Raws histograms in Raws subdir
276   //
277
278   const Int_t kSM = 18;
279   //const Int_t kNCh = 540;
280   const Int_t kNhist = 4+kSM;
281   TH1D *hist[kNhist];
282
283   // four histograms to be published
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);
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;
292   for(Int_t i=0; i<kSM; i++)
293     hist[4+i] = new TH1D(Form("qaTRD_raws_sm%d",i),"",kNMCM, -0.5, kNMCM-0.5); 
294   
295   // register
296   for(Int_t i=0; i<kNhist; i++) {
297     //hist[i]->Sumw2();
298     Add2RawsList(hist[i], i);
299   }
300
301 }
302
303 //____________________________________________________________________________ 
304 void AliTRDQADataMaker::InitSDigits()
305 {
306   //
307   // Create SDigits histograms in SDigits subdir
308   //
309
310   const Int_t kNhist = 3;
311   TH1D *hist[kNhist];
312
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);
316
317   for(Int_t i=0; i<kNhist; i++) {
318     hist[i]->Sumw2();
319     Add2SDigitsList(hist[i], i);
320   }
321
322 }
323
324 //____________________________________________________________________________
325 void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
326 {
327   //
328   // Make QA data from ESDs
329   //
330
331   Int_t nTracks = esd->GetNumberOfTracks();
332   GetESDsData(0)->Fill(nTracks);
333
334   // track loop
335   for (Int_t i=0; i<nTracks; i++) {
336
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]) {
375         GetESDsData(b*knbits+3)->Fill(pt); 
376         GetESDsData(b*knbits+4)->Fill(extZ);
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) {
396
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       }
418
419       fTrdPID[5]->Fill(trdr0); // check unitarity
420       fTrdSigMomPID[trdBestPid]->Fill(track->GetP(), track->GetTRDsignal());
421
422       //fTpcPID[5]->Fill(tpcr0); // check unitarity
423       //fTpcSigMomPID[tpcBestPid]->Fill(track->GetP(), track->GetTPCsignal());
424     }
425     */
426
427   }
428
429 }
430
431 //______________________________________________________________________________
432 Int_t AliTRDQADataMaker::GetSector(const Double_t alpha) const 
433 {
434   //
435   // Gets the sector number 
436   //
437
438   Double_t size = TMath::DegToRad() * 20.; // shall use TRDgeo
439   Int_t sector = (Int_t)((alpha + TMath::Pi())/size);
440   return sector;
441
442 }
443
444 //______________________________________________________________________________
445 Double_t AliTRDQADataMaker::GetExtZ(const AliExternalTrackParam *in) const 
446 {
447   //
448   // Returns the Z position at the entry to TRD
449   // using parameters from the TPC in
450   //
451
452   const Double_t kX0 = 300;
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();
458
459   Double_t zz = z + (kX0-x) * TMath::Tan(theta);
460   return zz;
461
462 }
463
464 //____________________________________________________________________________
465 void AliTRDQADataMaker::MakeHits(TClonesArray * hits)
466 {
467   //
468   // Make QA data from Hits
469   //
470
471   TIter next(hits); 
472   AliTRDhit * hit; 
473
474   while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
475     GetHitsData(0)->Fill(hit->GetDetector());
476     Double_t q = TMath::Abs(hit->GetCharge());
477
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 }
484
485 //____________________________________________________________________________
486 void AliTRDQADataMaker::MakeHits(TTree * hitTree)
487 {
488   //
489   // Make QA data from Hits
490   //
491
492   if (!CheckPointer(hitTree, "TRD hits tree")) return;
493
494   TBranch *branch = hitTree->GetBranch("TRD");
495   if (!CheckPointer(branch, "TRD hits branch")) return;
496
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);
501
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);
516
517 }
518
519 //____________________________________________________________________________
520 void AliTRDQADataMaker::MakeDigits(TClonesArray * digits)
521 {
522   //
523   // Makes data from Digits
524   //
525
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());
532   }
533
534 }
535
536 //____________________________________________________________________________
537 void AliTRDQADataMaker::MakeDigits(TTree * digits)
538 {
539   //
540   // Makes data from digits tree
541   //
542
543   AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
544   digitsManager->CreateArrays();
545   digitsManager->ReadDigits(digits);
546
547   for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
548
549     AliTRDdataArrayI *digitsIn = digitsManager->GetDigits(i);      
550
551     // This is to take care of switched off super modules
552     if (digitsIn->GetNtime() == 0) continue;
553
554     digitsIn->Expand();
555
556     //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
557     //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
558
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         }
572
573     //delete digitsIn;
574   }
575
576   delete digitsManager;
577
578 }
579
580 //____________________________________________________________________________
581 void AliTRDQADataMaker::MakeSDigits(TClonesArray * sdigits)
582 {
583   //
584   // Makes data from Digits
585   //
586
587   TIter next(sdigits) ; 
588   AliTRDdigit * digit ; 
589   while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
590     GetDigitsData(0)->Fill(digit->GetDetector());
591     GetDigitsData(1)->Fill(digit->GetTime());
592     GetDigitsData(2)->Fill(digit->GetAmp());
593   }
594
595 }
596
597 //____________________________________________________________________________
598 void AliTRDQADataMaker::MakeSDigits(TTree * digits)
599 {
600   //
601   // Makes data from SDigits
602   //
603
604   AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
605   digitsManager->CreateArrays();
606   digitsManager->ReadDigits(digits);
607
608   for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
609
610     AliTRDdataArrayI *digitsIn = digitsManager->GetDigits(i);      
611
612     // This is to take care of switched off super modules
613     if (digitsIn->GetNtime() == 0) continue;
614
615     digitsIn->Expand();
616
617     //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
618     //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
619
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         }
634
635     // delete digitsIn;
636   }
637
638   delete digitsManager;
639
640 }
641
642 //____________________________________________________________________________
643 void AliTRDQADataMaker::MakeRaws(AliRawReader* rawReader)
644 {
645   //
646   // Makes QA data from raw data
647   //
648
649   // 157
650   // T9 -- T10
651
652   //const Int_t kSM = 18;
653   //const Int_t kROC = 30;
654   const Int_t kROB = 8;
655   //const Int_t kLayer = 6;
656   //const Int_t kStack = 5;
657   const Int_t kMCM = 16;
658   //  const Int_t kADC = 22;
659
660   AliTRDRawStreamTB *raw = new AliTRDRawStreamTB(rawReader);
661
662   raw->SetRawVersion(3);
663   raw->Init();
664
665   while (raw->Next()) {
666
667     GetRawsData(0)->Fill(raw->GetDet());
668
669     // possibly needs changes with the new reader !!
670     Int_t *sig = raw->GetSignals();
671     for(Int_t i=0; i<3; i++) GetRawsData(1)->Fill(sig[i]);
672     // ---
673
674     GetRawsData(2)->Fill(raw->GetTimeBin());
675
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();
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);
687   }
688 }
689
690 //____________________________________________________________________________
691 void AliTRDQADataMaker::MakeRecPoints(TTree * clustersTree)
692 {
693   //  
694   // Makes data from RecPoints
695   // 
696
697   Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster))); 
698   TObjArray *clusterArray = new TObjArray(nsize+1000); 
699
700   TBranch *branch = clustersTree->GetBranch("TRDcluster");
701   if (!branch) {
702     AliError("Can't get the branch !");
703     return;
704   }
705   branch->SetAddress(&clusterArray); 
706
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;
711   Int_t nDet[540];
712   for (Int_t i=0; i<540; i++) nDet[i] = 0;
713
714   for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {    
715
716     // Import the tree
717     nbytes += clustersTree->GetEvent(iEntry);  
718
719     // Get the number of points in the detector
720     Int_t nCluster = clusterArray->GetEntriesFast();  
721
722     // Loop through all TRD digits
723     for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) { 
724       c = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster);
725
726       Int_t iDet = c->GetDetector();
727       nDet[iDet]++;
728       GetRecPointsData(0)->Fill(iDet);
729       GetRecPointsData(1)->Fill(iDet, c->GetQ());
730       GetRecPointsData(2)->Fill(c->GetNPads());
731       if (c->GetNPads() < 6)
732         GetRecPointsData(1+c->GetNPads())->Fill(c->GetCenter());
733
734       //if (c->GetPadTime() < 5)
735       ((TH2D*)GetRecPointsData(7))->Fill(c->GetPadRow(), c->GetPadCol());
736       GetRecPointsData(8)->Fill(c->GetPadTime());
737
738       ((TH3D*)GetRecPointsData(10))->Fill(iDet, c->GetPadTime(), c->GetQ());
739
740       // PRF for 2pad
741       //if (c->GetNPads() == 2) {
742       Short_t *sig = c->GetSignals();
743       Double_t frac = -10;
744
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]);
747
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]);
750
751       if (frac > -10)  ((TProfile*)GetRecPointsData(11))->Fill(c->GetCenter(), frac);
752         
753       //}
754     }
755   }
756
757   for(Int_t i=0; i<540; i++) 
758     if (nDet[i] > 0) GetRecPointsData(9)->Fill(nDet[i]);
759
760   delete clusterArray;
761
762 }
763
764 //____________________________________________________________________________ 
765 void AliTRDQADataMaker::StartOfDetectorCycle()
766 {
767   //
768   // Detector specific actions at start of cycle
769   //
770
771 }
772
773 //__________________________________________________________________________
774 Int_t AliTRDQADataMaker::CheckPointer(TObject *obj, const char *name) 
775 {
776   //
777   // Checks initialization of pointers
778   //
779
780   if (!obj) AliWarning(Form("null pointer: %s", name));
781   return !!obj;
782
783 }