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