]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - TOF/AliTOFQADataMaker.cxx
Fixes for bug #49914: Compilation breaks in trunk, and bug #48629: Trunk cannot read...
[u/mrichter/AliRoot.git] / TOF / AliTOFQADataMaker.cxx
... / ...
CommitLineData
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///////////////////////////////////////////////////////////////////////
17// //
18// Produces the data needed to calculate the TOF quality assurance. //
19// QA objects are 1 & 2 Dimensional histograms. //
20// author: S.Arcelli //
21// //
22///////////////////////////////////////////////////////////////////////
23
24#include <TClonesArray.h>
25#include <TFile.h>
26#include <TH1I.h>
27#include <TH1F.h>
28#include <TH2F.h>
29#include "AliESDEvent.h"
30#include "AliESDtrack.h"
31#include "AliTOFcluster.h"
32#include "AliTOFdigit.h"
33#include "AliTOFSDigit.h"
34#include "AliTOFhitT0.h"
35#include "AliTOFQADataMaker.h"
36#include "AliQAChecker.h"
37#include "AliRawReader.h"
38#include "AliTOFRawStream.h"
39#include "AliTOFrawData.h"
40#include "AliLog.h"
41
42ClassImp(AliTOFQADataMaker)
43
44//____________________________________________________________________________
45 AliTOFQADataMaker::AliTOFQADataMaker() :
46 AliQADataMaker(AliQAv1::GetDetName(AliQAv1::kTOF), "TOF Quality Assurance Data Maker")
47{
48 //
49 // ctor
50 //
51}
52
53//____________________________________________________________________________
54AliTOFQADataMaker::AliTOFQADataMaker(const AliTOFQADataMaker& qadm) :
55 AliQADataMaker()
56{
57 //
58 //copy ctor
59 //
60 SetName((const char*)qadm.GetName()) ;
61 SetTitle((const char*)qadm.GetTitle());
62}
63
64//__________________________________________________________________
65AliTOFQADataMaker& AliTOFQADataMaker::operator = (const AliTOFQADataMaker& qadm )
66{
67 //
68 // assignment operator.
69 //
70 this->~AliTOFQADataMaker();
71 new(this) AliTOFQADataMaker(qadm);
72 return *this;
73}
74
75//____________________________________________________________________________
76void AliTOFQADataMaker::InitHits()
77{
78 //
79 // create Hits histograms in Hits subdir
80 //
81
82 Bool_t expert = kFALSE;
83
84 TH1F * h0 = new TH1F("hTOFHits", "Number of TOF Hits ",301, -1.02, 5.) ;
85 h0->Sumw2() ;
86 Add2HitsList(h0, 0, expert) ;
87
88 TH1F * h1 = new TH1F("hTOFHitsTime", "Hits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
89 h1->Sumw2() ;
90 Add2HitsList(h1, 1, expert) ;
91
92 TH1F * h2 = new TH1F("hTOFHitsLength", "Length Spectrum in TOF (cm)", 500, 0., 500) ;
93 h2->Sumw2() ;
94 Add2HitsList(h2, 2, expert) ;
95
96 TH2F * h3 = new TH2F("hTOFHitsClusMap","Hits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
97 h3->Sumw2() ;
98 Add2HitsList(h3, 3, expert) ;
99}
100
101//____________________________________________________________________________
102void AliTOFQADataMaker::InitDigits()
103{
104 //
105 // create Digits histograms in Digits subdir
106 //
107
108 Bool_t expert = kFALSE;
109
110 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits ",301, -1.02, 5.) ; h0->Sumw2() ;
111 Add2DigitsList(h0, 0, expert) ;
112
113 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
114 h1->Sumw2() ;
115 Add2DigitsList(h1, 1, expert) ;
116
117 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ;
118 h2->Sumw2() ;
119 Add2DigitsList(h2, 2, expert) ;
120
121 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
122 h3->Sumw2() ;
123 Add2DigitsList(h3, 3, expert) ;
124
125}
126
127//____________________________________________________________________________
128void AliTOFQADataMaker::InitSDigits()
129{
130 //
131 // create SDigits histograms in SDigits subdir
132 //
133
134 Bool_t expert = kFALSE;
135
136 TH1F * h0 = new TH1F("hTOFSDigits", "Number of TOF SDigits ",301, -1.02, 5.) ; h0->Sumw2() ;
137 Add2SDigitsList(h0, 0, expert) ;
138
139 TH1F * h1 = new TH1F("hTOFSDigitsTime", "SDigits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
140 h1->Sumw2() ;
141 Add2SDigitsList(h1, 1, expert) ;
142
143 TH2F * h2 = new TH2F("hTOFSDigitsClusMap","SDigits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
144 h2->Sumw2() ;
145 Add2SDigitsList(h2, 2, expert) ;
146
147}
148
149//____________________________________________________________________________
150void AliTOFQADataMaker::InitRaws()
151{
152 //
153 // create Raws histograms in Raws subdir
154 //
155
156 Bool_t expert = kFALSE;
157
158 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ; h0->Sumw2() ;
159 Add2RawsList(h0, 0, expert) ;
160
161 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
162 h1->Sumw2() ;
163 Add2RawsList(h1, 1, expert) ;
164
165 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
166 h2->Sumw2() ;
167 Add2RawsList(h2, 2, expert) ;
168
169 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
170 h3->Sumw2() ;
171 Add2RawsList(h3, 3, expert) ;
172
173}
174
175//____________________________________________________________________________
176void AliTOFQADataMaker::InitRecPoints()
177{
178 //
179 // create RecPoints histograms in RecPoints subdir
180 //
181
182 Bool_t expert = kFALSE;
183
184 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ; h0->Sumw2() ;
185 Add2RecPointsList(h0, 0, expert) ;
186
187 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
188 h1->Sumw2() ;
189 Add2RecPointsList(h1, 1, expert) ;
190
191 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
192 h2->Sumw2() ;
193 Add2RecPointsList(h2, 2, expert) ;
194
195 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
196 h3->Sumw2() ;
197 Add2RecPointsList(h3, 3, expert) ;
198
199 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta",183, -0.5, 182.5,865,-0.5,864.5) ;
200 h4->Sumw2() ;
201 h4->GetXaxis()->SetTitle("2*strip+padz (eta)");
202 h4->GetYaxis()->SetTitle("48*sector+padx (phi)");
203 Add2RecPointsList(h4, 4, expert) ;
204
205}
206
207//____________________________________________________________________________
208void AliTOFQADataMaker::InitESDs()
209{
210 //
211 //create ESDs histograms in ESDs subdir
212 //
213
214 Bool_t expert = kFALSE;
215
216 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
217 h0->Sumw2() ;
218 Add2ESDsList(h0, 0, expert) ;
219
220 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
221 h1->Sumw2() ;
222 Add2ESDsList(h1, 1, expert) ;
223
224 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
225 h2->Sumw2() ;
226 Add2ESDsList(h2, 2, expert) ;
227
228 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
229 h3->Sumw2() ;
230 Add2ESDsList(h3, 3, expert) ;
231
232 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID flag", 101, 0., 101.) ;
233 h4->Sumw2() ;
234 Add2ESDsList(h4, 4, expert) ;
235}
236
237
238//____________________________________________________________________________
239void AliTOFQADataMaker::MakeHits(TClonesArray * hits)
240{
241 //
242 //make QA data from Hits
243 //
244
245 Int_t in[5];
246 Int_t out[5];
247
248 Int_t nentries=hits->GetEntriesFast();
249 if(nentries<=0) {
250 GetHitsData(0)->Fill(-1.) ;
251 } else{
252 GetHitsData(0)->Fill(TMath::Log10(nentries)) ;
253 }
254 TIter next(hits) ;
255 AliTOFhitT0 * hit ;
256 while ( (hit = dynamic_cast<AliTOFhitT0 *>(next())) ) {
257
258 GetHitsData(1)->Fill( hit->GetTof()*1.E9) ;//in ns
259 GetHitsData(2)->Fill( hit->GetLen()) ;//in cm
260
261 in[0] = hit->GetSector();
262 in[1] = hit->GetPlate();
263 in[2]= hit->GetStrip();
264 in[3]= hit->GetPadx();
265 in[4]= hit->GetPadz();
266 GetMapIndeces(in,out);
267 GetHitsData(3)->Fill( out[0],out[1]) ;//hit map
268 }
269
270}
271
272
273//____________________________________________________________________________
274void AliTOFQADataMaker::MakeHits(TTree * hitTree)
275{
276 //
277 // make QA data from Hit Tree
278 //
279 if(!hitTree){
280 AliError("can't get the tree with TOF hits !");
281 return;
282 }
283
284 TBranch * branch = hitTree->GetBranch("TOF") ;
285
286 if (!branch ) {
287 AliError("TOF branch in Hit Tree not found") ;
288 return;
289 }
290
291 TClonesArray * hits = new TClonesArray("AliTOFhitT0", 1000);
292 TClonesArray * dummy = new TClonesArray("AliTOFhitT0", 1000);
293 branch->SetAddress(&dummy);
294 Int_t index = 0 ;
295 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
296 branch->GetEntry(ientry) ;
297 for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
298 AliTOFhitT0 * hit = dynamic_cast<AliTOFhitT0 *> (dummy->At(ihit)) ;
299 new((*hits)[index]) AliTOFhitT0(*hit) ;
300 index++ ;
301 }
302 }
303
304 dummy->Delete();
305 delete dummy;
306 MakeHits(hits) ;
307
308}
309
310//____________________________________________________________________________
311void AliTOFQADataMaker::MakeDigits(TClonesArray * digits)
312{
313 //
314 // makes data from Digits
315 //
316 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
317 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
318 Int_t in[5];
319 Int_t out[5];
320
321 Int_t nentries=digits->GetEntriesFast();
322 if(nentries<=0){
323 GetDigitsData(0)->Fill(-1.) ;
324 }else{
325 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
326 }
327
328 TIter next(digits) ;
329 AliTOFdigit * digit ;
330 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
331
332 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
333 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
334
335 in[0] = digit->GetSector();
336 in[1] = digit->GetPlate();
337 in[2] = digit->GetStrip();
338 in[3] = digit->GetPadx();
339 in[4]= digit->GetPadz();
340 GetMapIndeces(in,out);
341 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
342 }
343
344}
345
346
347//____________________________________________________________________________
348void AliTOFQADataMaker::MakeDigits(TTree * digitTree)
349{
350 //
351 // makes data from Digit Tree
352 //
353 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
354
355 TBranch * branch = digitTree->GetBranch("TOF") ;
356 if ( ! branch ) {
357 AliError("TOF branch in Digit Tree not found") ;
358 return;
359 }
360 branch->SetAddress(&digits) ;
361 branch->GetEntry(0) ;
362 MakeDigits(digits) ;
363}
364
365//____________________________________________________________________________
366void AliTOFQADataMaker::MakeSDigits(TClonesArray * sdigits)
367{
368 //
369 // makes data from SDigits
370 //
371
372 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
373 Int_t in[5];
374 Int_t out[5];
375
376 Int_t nentries=sdigits->GetEntriesFast();
377 if(nentries<=0){
378 GetSDigitsData(0)->Fill(-1.) ;
379 }else{
380 GetSDigitsData(0)->Fill(TMath::Log10(nentries)) ;
381 }
382
383 TIter next(sdigits) ;
384 AliTOFSDigit * sdigit ;
385 while ( (sdigit = dynamic_cast<AliTOFSDigit *>(next())) ) {
386
387 for(Int_t i=0;i<sdigit->GetNDigits();i++){
388 GetSDigitsData(1)->Fill( sdigit->GetTdc(i)*tdc2ns) ;//in ns
389 }
390
391 in[0] = sdigit->GetSector();
392 in[1] = sdigit->GetPlate();
393 in[2] = sdigit->GetStrip();
394 in[3] = sdigit->GetPadx();
395 in[4]= sdigit->GetPadz();
396 GetMapIndeces(in,out);
397 GetSDigitsData(2)->Fill( out[0],out[1]) ;//sdigit map
398 }
399}
400
401//____________________________________________________________________________
402void AliTOFQADataMaker::MakeSDigits(TTree * sdigitTree)
403{
404 //
405 // makes data from SDigit Tree
406 //
407 TClonesArray * sdigits = new TClonesArray("AliTOFSDigit", 1000) ;
408
409 TBranch * branch = sdigitTree->GetBranch("TOF") ;
410 if ( ! branch ) {
411 AliError("TOF branch in SDigit Tree not found") ;
412 return;
413 }
414 branch->SetAddress(&sdigits) ;
415 branch->GetEntry(0) ;
416 MakeSDigits(sdigits) ;
417}
418
419//____________________________________________________________________________
420void AliTOFQADataMaker::MakeRaws(AliRawReader* rawReader)
421{
422 //
423 // makes data from Raws
424 //
425
426 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
427 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
428
429
430 Int_t ntof = 0 ;
431 Int_t in[5];
432 Int_t out[5];
433
434 TClonesArray * clonesRawData;
435 AliTOFRawStream tofInput(rawReader);
436 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
437 rawReader->Reset();
438 tofInput.LoadRawData(iDDL);
439 clonesRawData = (TClonesArray*)tofInput.GetRawData();
440 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
441 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
442 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
443 ntof++;
444 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
445 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
446
447 tofInput.EquipmentId2VolumeId(iDDL,
448 tofRawDatum->GetTRM(),
449 tofRawDatum->GetTRMchain(),
450 tofRawDatum->GetTDC(),
451 tofRawDatum->GetTDCchannel(),
452 in);
453
454 GetMapIndeces(in,out);
455 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
456
457 } // while loop
458
459 clonesRawData->Clear();
460
461 } // DDL Loop
462
463 Int_t nentries=ntof;
464 if(nentries<=0){
465 GetRawsData(0)->Fill(-1.) ;
466 }else{
467 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
468 }
469}
470
471//____________________________________________________________________________
472void AliTOFQADataMaker::MakeRecPoints(TTree * clustersTree)
473{
474 //
475 // Make data from Clusters
476 //
477
478 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
479 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
480
481 Int_t in[5];
482 Int_t out[5];
483
484 TBranch *branch=clustersTree->GetBranch("TOF");
485 if (!branch) {
486 AliError("can't get the branch with the TOF clusters !");
487 return;
488 }
489
490 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
491 branch->SetAddress(&clusters);
492
493 // Import the tree
494 clustersTree->GetEvent(0);
495
496 Int_t nentries=clusters->GetEntriesFast();
497 if(nentries<=0){
498 GetRecPointsData(0)->Fill(-1.) ;
499 }else{
500 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
501 }
502
503 TIter next(clusters) ;
504 AliTOFcluster * c ;
505 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
506 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
507 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
508 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
509
510 in[0] = c->GetDetInd(0);
511 in[1] = c->GetDetInd(1);
512 in[2] = c->GetDetInd(2);
513 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
514 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
515
516 GetMapIndeces(in,out);
517 GetRecPointsData(4)->Fill(out[0],out[1]);
518
519 }
520}
521
522//____________________________________________________________________________
523void AliTOFQADataMaker::MakeESDs(AliESDEvent * esd)
524{
525 //
526 // make QA data from ESDs
527 //
528 Int_t ntrk = esd->GetNumberOfTracks() ;
529 Int_t ntof=0;
530 Int_t ntofpid=0;
531 while (ntrk--) {
532 AliESDtrack *track=esd->GetTrack(ntrk);
533 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
534 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
535 Double_t tofToT=track->GetTOFsignalToT(); //in ns
536 if(!(tofTime>0))continue;
537 ntof++;
538 GetESDsData(1)->Fill(tofTime);
539 GetESDsData(2)->Fill(tofTimeRaw);
540 GetESDsData(3)->Fill(tofToT);
541 //check how many tracks where ESD PID is ok
542 UInt_t status=track->GetStatus();
543 if (((status&AliESDtrack::kESDpid)==0) ||
544 ((status&AliESDtrack::kTOFpid)==0)) continue;
545 ntofpid++;
546 }
547
548 Int_t nentries=ntof;
549 if(nentries<=0){
550 GetESDsData(0)->Fill(-1.) ;
551 }else{
552 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
553 }
554
555 Float_t ratio = (Float_t)ntofpid/(Float_t)ntof*100.;
556 if(ntof>0)GetESDsData(4)->Fill(ratio) ;
557
558}
559
560//____________________________________________________________________________
561void AliTOFQADataMaker::StartOfDetectorCycle()
562{
563 //
564 //Detector specific actions at start of cycle
565 //to be implemented
566}
567
568//____________________________________________________________________________
569void AliTOFQADataMaker::EndOfDetectorCycle(AliQAv1::TASKINDEX task, TObjArray * list)
570{
571 //Detector specific actions at end of cycle
572 // do the QA checking
573
574 AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;
575}
576//____________________________________________________________________________
577void AliTOFQADataMaker::GetMapIndeces(Int_t* in , Int_t* out)
578{
579 //
580 //return appropriate indeces for the theta-phi map
581 //
582
583 Int_t npadX = AliTOFGeometry::NpadX();
584 Int_t npadZ = AliTOFGeometry::NpadZ();
585 Int_t nStripA = AliTOFGeometry::NStripA();
586 Int_t nStripB = AliTOFGeometry::NStripB();
587 Int_t nStripC = AliTOFGeometry::NStripC();
588
589 Int_t isector = in[0];
590 Int_t iplate = in[1];
591 Int_t istrip = in[2];
592 Int_t ipadX = in[3];
593 Int_t ipadZ = in[4];
594
595 Int_t stripOffset = 0;
596 switch (iplate) {
597 case 0:
598 stripOffset = 0;
599 break;
600 case 1:
601 stripOffset = nStripC;
602 break;
603 case 2:
604 stripOffset = nStripC+nStripB;
605 break;
606 case 3:
607 stripOffset = nStripC+nStripB+nStripA;
608 break;
609 case 4:
610 stripOffset = nStripC+nStripB+nStripA+nStripB;
611 break;
612 default:
613 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
614 break;
615 };
616 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
617 Int_t phiindex=npadX*isector+ipadX+1;
618 out[0]=zindex;
619 out[1]=phiindex;
620
621}