1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////
18 // Produces the data needed to calculate the TOF quality assurance. //
19 // QA objects are 1 & 2 Dimensional histograms. //
20 // author: S.Arcelli //
22 ///////////////////////////////////////////////////////////////////////
24 #include <TClonesArray.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"
42 ClassImp(AliTOFQADataMaker)
44 //____________________________________________________________________________
45 AliTOFQADataMaker::AliTOFQADataMaker() :
46 AliQADataMaker(AliQAv1::GetDetName(AliQAv1::kTOF), "TOF Quality Assurance Data Maker"),
47 fTOFRawStream(AliTOFRawStream())
54 //____________________________________________________________________________
55 AliTOFQADataMaker::AliTOFQADataMaker(const AliTOFQADataMaker& qadm) :
57 fTOFRawStream(AliTOFRawStream(qadm.fTOFRawStream))
62 SetName((const char*)qadm.GetName()) ;
63 SetTitle((const char*)qadm.GetTitle());
66 //__________________________________________________________________
67 AliTOFQADataMaker& AliTOFQADataMaker::operator = (const AliTOFQADataMaker& qadm )
70 // assignment operator.
72 this->~AliTOFQADataMaker();
73 new(this) AliTOFQADataMaker(qadm);
77 //____________________________________________________________________________
78 void AliTOFQADataMaker::InitHits()
81 // create Hits histograms in Hits subdir
84 Bool_t expert = kFALSE;
86 TH1F * h0 = new TH1F("hTOFHits", "Number of TOF Hits ",301, -1.02, 5.) ;
88 h0->GetXaxis()->SetTitle("TOF hit number [10 power]");
89 Add2HitsList(h0, 0, expert) ;
91 TH1F * h1 = new TH1F("hTOFHitsTime", "Hits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
93 h1->GetXaxis()->SetTitle("Simulated TOF time [ns]");
94 Add2HitsList(h1, 1, expert) ;
96 TH1F * h2 = new TH1F("hTOFHitsLength", "Length Spectrum in TOF (cm)", 500, 0., 500) ;
98 h2->GetXaxis()->SetTitle("Track length from primary vertex till hit TOF pad [cm]");
99 Add2HitsList(h2, 2, expert) ;
101 TH2F * h3 = new TH2F("hTOFHitsClusMap","Hits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
103 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
104 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
105 h3->GetYaxis()->SetTitleOffset(1.15);
106 Add2HitsList(h3, 3, expert) ;
108 ClonePerTrigClass(AliQAv1::kHITS); // this should be the last line
111 //____________________________________________________________________________
112 void AliTOFQADataMaker::InitDigits()
115 // create Digits histograms in Digits subdir
118 Bool_t expert = kFALSE;
120 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits ",301, -1.02, 5.) ;
122 h0->GetXaxis()->SetTitle("TOF digit number [10 power]");
123 Add2DigitsList(h0, 0, expert) ;
125 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
127 h1->GetXaxis()->SetTitle("Digitized TOF time [ns]");
128 Add2DigitsList(h1, 1, expert) ;
130 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ;
132 h2->GetXaxis()->SetTitle("Digitized TOT [ns]");
133 h2->GetYaxis()->SetTitle("Digitized TOF time [ns]");
134 Add2DigitsList(h2, 2, expert) ;
136 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
138 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
139 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
140 h3->GetYaxis()->SetTitleOffset(1.15);
141 Add2DigitsList(h3, 3, expert) ;
143 ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
146 //____________________________________________________________________________
147 void AliTOFQADataMaker::InitSDigits()
150 // create SDigits histograms in SDigits subdir
153 Bool_t expert = kFALSE;
155 TH1F * h0 = new TH1F("hTOFSDigits", "Number of TOF SDigits ",301, -1.02, 5.) ;
157 h0->GetXaxis()->SetTitle("TOF sdigit number [10 power]");
158 Add2SDigitsList(h0, 0, expert) ;
160 TH1F * h1 = new TH1F("hTOFSDigitsTime", "SDigits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
162 h1->GetXaxis()->SetTitle("SDigitized TOF time [ns]");
163 Add2SDigitsList(h1, 1, expert) ;
165 TH2F * h2 = new TH2F("hTOFSDigitsClusMap","SDigits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
167 h2->GetXaxis()->SetTitle("2*strip+padz (eta)");
168 h2->GetYaxis()->SetTitle("48*sector+padx (phi)");
169 h2->GetYaxis()->SetTitleOffset(1.15);
170 Add2SDigitsList(h2, 2, expert) ;
172 ClonePerTrigClass(AliQAv1::kSDIGITS); // this should be the last line
175 //____________________________________________________________________________
176 void AliTOFQADataMaker::InitRaws()
179 // create Raws histograms in Raws subdir
182 Bool_t expert = kFALSE;
184 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ;
186 h0->GetXaxis()->SetTitle("TOF raw number [10 power]");
187 Add2RawsList(h0, 0, expert) ;
189 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 20000, 0., 2000) ;
191 h1->GetXaxis()->SetTitle("Measured TOF time [ns]");
192 Add2RawsList(h1, 1, expert) ;
194 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
196 h2->GetXaxis()->SetTitle("Measured TOT [ns]");
197 h2->GetYaxis()->SetTitle("Measured TOF time [ns]");
198 Add2RawsList(h2, 2, expert) ;
200 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
202 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
203 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
204 h3->GetYaxis()->SetTitleOffset(1.15);
205 Add2RawsList(h3, 3, expert) ;
207 ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
210 //____________________________________________________________________________
211 void AliTOFQADataMaker::InitRecPoints()
214 // create RecPoints histograms in RecPoints subdir
217 Bool_t expert = kFALSE;
219 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ;
221 h0->GetXaxis()->SetTitle("TOF recPoint number [10 power]");
222 Add2RecPointsList(h0, 0, expert) ;
224 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 20000, 0., 2000) ;
226 h1->GetXaxis()->SetTitle("Calibrated TOF time [ns]");
227 Add2RecPointsList(h1, 1, expert) ;
229 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 20000, 0., 2000) ;
231 h2->GetXaxis()->SetTitle("Measured TOT [ns]");
232 h2->GetYaxis()->SetTitle("Measured TOF time [ns]");
233 Add2RecPointsList(h2, 2, expert) ;
235 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
237 h3->GetXaxis()->SetTitle("Measured TOT [ns]");
238 Add2RecPointsList(h3, 3, expert) ;
240 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta",183, -0.5, 182.5,865,-0.5,864.5) ;
242 h4->GetXaxis()->SetTitle("2*strip+padz (eta)");
243 h4->GetYaxis()->SetTitle("48*sector+padx (phi)");
244 h4->GetYaxis()->SetTitleOffset(1.15);
245 Add2RecPointsList(h4, 4, expert) ;
247 ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
250 //____________________________________________________________________________
251 void AliTOFQADataMaker::InitESDs()
254 //create ESDs histograms in ESDs subdir
257 Bool_t expert = kFALSE;
259 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
261 h0->GetXaxis()->SetTitle("Number of TOF matched ESD tracks [10 power]");
262 Add2ESDsList(h0, 0, expert) ;
264 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 20000, 0., 2000) ;
266 h1->GetXaxis()->SetTitle("Calibrated TOF time [ns]");
267 Add2ESDsList(h1, 1, expert) ;
269 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 20000, 0., 2000) ;
271 h2->GetXaxis()->SetTitle("Measured TOF time [ns]");
272 Add2ESDsList(h2, 2, expert) ;
274 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
276 h3->GetXaxis()->SetTitle("Measured TOT [ns]");
277 Add2ESDsList(h3, 3, expert) ;
279 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID flag", 101, 0., 101.) ;
281 h4->GetXaxis()->SetTitle("Fraction of TOF matched ESD tracks with good flag [%]");
282 Add2ESDsList(h4, 4, expert) ;
284 ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
288 //____________________________________________________________________________
289 void AliTOFQADataMaker::MakeHits(TClonesArray * hits)
292 //make QA data from Hits
298 Int_t nentries=hits->GetEntriesFast();
300 FillHitsData(0,-1.) ;
302 FillHitsData(0,TMath::Log10(nentries)) ;
306 while ( (hit = dynamic_cast<AliTOFhitT0 *>(next())) ) {
308 FillHitsData(1, hit->GetTof()*1.E9) ;//in ns
309 FillHitsData(2, hit->GetLen()) ;//in cm
311 in[0] = hit->GetSector();
312 in[1] = hit->GetPlate();
313 in[2]= hit->GetStrip();
314 in[3]= hit->GetPadx();
315 in[4]= hit->GetPadz();
316 GetMapIndeces(in,out);
317 FillHitsData(3, out[0],out[1]) ;//hit map
323 //____________________________________________________________________________
324 void AliTOFQADataMaker::MakeHits(TTree * hitTree)
327 // make QA data from Hit Tree
330 AliError("can't get the tree with TOF hits !");
334 TBranch * branch = hitTree->GetBranch("TOF") ;
337 AliError("TOF branch in Hit Tree not found") ;
341 TClonesArray * hits = new TClonesArray("AliTOFhitT0", 1000);
342 TClonesArray * dummy = new TClonesArray("AliTOFhitT0", 1000);
343 branch->SetAddress(&dummy);
345 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
346 branch->GetEntry(ientry) ;
347 for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
348 AliTOFhitT0 * hit = dynamic_cast<AliTOFhitT0 *> (dummy->At(ihit)) ;
349 new((*hits)[index]) AliTOFhitT0(*hit) ;
358 IncEvCountCycleHits();
359 IncEvCountTotalHits();
363 //____________________________________________________________________________
364 void AliTOFQADataMaker::MakeDigits(TClonesArray * digits)
367 // makes data from Digits
369 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
370 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
374 Int_t nentries=digits->GetEntriesFast();
376 FillDigitsData(0,-1.) ;
378 FillDigitsData(0, TMath::Log10(nentries)) ;
382 AliTOFdigit * digit ;
383 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
385 FillDigitsData(1, digit->GetTdc()*tdc2ns) ;//in ns
386 FillDigitsData(2, digit->GetToT()*tot2ns) ;//in ns
388 in[0] = digit->GetSector();
389 in[1] = digit->GetPlate();
390 in[2] = digit->GetStrip();
391 in[3] = digit->GetPadx();
392 in[4]= digit->GetPadz();
393 GetMapIndeces(in,out);
394 FillDigitsData(3, out[0],out[1]) ;//digit map
400 //____________________________________________________________________________
401 void AliTOFQADataMaker::MakeDigits(TTree * digitTree)
404 // makes data from Digit Tree
406 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
408 TBranch * branch = digitTree->GetBranch("TOF") ;
410 AliError("TOF branch in Digit Tree not found") ;
413 branch->SetAddress(&digits) ;
414 branch->GetEntry(0) ;
417 IncEvCountCycleDigits();
418 IncEvCountTotalDigits();
422 //____________________________________________________________________________
423 void AliTOFQADataMaker::MakeSDigits(TClonesArray * sdigits)
426 // makes data from SDigits
429 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
433 Int_t nentries=sdigits->GetEntriesFast();
435 FillSDigitsData(0,-1.) ;
437 FillSDigitsData(0,TMath::Log10(nentries)) ;
440 TIter next(sdigits) ;
441 AliTOFSDigit * sdigit ;
442 while ( (sdigit = dynamic_cast<AliTOFSDigit *>(next())) ) {
444 for(Int_t i=0;i<sdigit->GetNDigits();i++){
445 FillSDigitsData(1, sdigit->GetTdc(i)*tdc2ns) ;//in ns
448 in[0] = sdigit->GetSector();
449 in[1] = sdigit->GetPlate();
450 in[2] = sdigit->GetStrip();
451 in[3] = sdigit->GetPadx();
452 in[4]= sdigit->GetPadz();
453 GetMapIndeces(in,out);
454 FillSDigitsData(2, out[0],out[1]) ;//sdigit map
458 //____________________________________________________________________________
459 void AliTOFQADataMaker::MakeSDigits(TTree * sdigitTree)
462 // makes data from SDigit Tree
464 TClonesArray * sdigits = new TClonesArray("AliTOFSDigit", 1000) ;
466 TBranch * branch = sdigitTree->GetBranch("TOF") ;
468 AliError("TOF branch in SDigit Tree not found") ;
471 branch->SetAddress(&sdigits) ;
472 branch->GetEntry(0) ;
473 MakeSDigits(sdigits) ;
475 IncEvCountCycleSDigits();
476 IncEvCountTotalSDigits();
480 //____________________________________________________________________________
481 void AliTOFQADataMaker::MakeRaws(AliRawReader* rawReader)
484 // makes data from Raws
487 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
488 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
495 TClonesArray * clonesRawData;
496 //AliTOFRawStream tofInput(rawReader);
497 fTOFRawStream.SetRawReader(rawReader);
498 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
500 fTOFRawStream.LoadRawData(iDDL);
501 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
502 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
503 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
504 //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
505 if (!tofRawDatum->GetTOF()) continue;
507 FillRawsData(1, tofRawDatum->GetTOF()*tdc2ns) ;//in ns
508 FillRawsData(2, tofRawDatum->GetTOT()*tot2ns) ;//in ns
510 fTOFRawStream.EquipmentId2VolumeId(iDDL,
511 tofRawDatum->GetTRM(),
512 tofRawDatum->GetTRMchain(),
513 tofRawDatum->GetTDC(),
514 tofRawDatum->GetTDCchannel(),
517 GetMapIndeces(in,out);
518 FillRawsData(3, out[0],out[1]) ;//raw map
522 clonesRawData->Clear();
526 fTOFRawStream.Clear();
530 FillRawsData(0,-1.) ;
532 FillRawsData(0,TMath::Log10(nentries)) ;
535 IncEvCountCycleRaws();
536 IncEvCountTotalRaws();
540 //____________________________________________________________________________
541 void AliTOFQADataMaker::MakeRecPoints(TTree * clustersTree)
544 // Make data from Clusters
547 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
548 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
553 TBranch *branch=clustersTree->GetBranch("TOF");
555 AliError("can't get the branch with the TOF clusters !");
559 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
560 branch->SetAddress(&clusters);
563 clustersTree->GetEvent(0);
565 Int_t nentries=clusters->GetEntriesFast();
567 FillRecPointsData(0,-1.) ;
569 FillRecPointsData(0,TMath::Log10(nentries)) ;
572 TIter next(clusters) ;
574 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
575 FillRecPointsData(1,c->GetTDC()*tdc2ns);
576 FillRecPointsData(2,c->GetTDCRAW()*tdc2ns);
577 FillRecPointsData(3,c->GetToT()*tot2ns);
579 in[0] = c->GetDetInd(0);
580 in[1] = c->GetDetInd(1);
581 in[2] = c->GetDetInd(2);
582 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
583 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
585 GetMapIndeces(in,out);
586 FillRecPointsData(4,out[0],out[1]);
589 IncEvCountCycleRecPoints();
590 IncEvCountTotalRecPoints();
594 //____________________________________________________________________________
595 void AliTOFQADataMaker::MakeESDs(AliESDEvent * esd)
598 // make QA data from ESDs
600 Int_t ntrk = esd->GetNumberOfTracks() ;
604 AliESDtrack *track=esd->GetTrack(ntrk);
605 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
606 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
607 Double_t tofToT=track->GetTOFsignalToT(); //in ns
608 if(!(tofTime>0))continue;
610 FillESDsData(1,tofTime);
611 FillESDsData(2,tofTimeRaw);
612 FillESDsData(3,tofToT);
613 //check how many tracks where ESD PID is ok
614 UInt_t status=track->GetStatus();
615 if (((status&AliESDtrack::kESDpid)==0) ||
616 ((status&AliESDtrack::kTOFpid)==0)) continue;
622 FillESDsData(0,-1.) ;
624 FillESDsData(0,TMath::Log10(nentries)) ;
628 if(ntof>0) ratio=(Float_t)ntofpid/(Float_t)ntof*100.;
629 FillESDsData(4,ratio) ;
631 IncEvCountCycleESDs();
632 IncEvCountTotalESDs();
636 //____________________________________________________________________________
637 void AliTOFQADataMaker::StartOfDetectorCycle()
640 //Detector specific actions at start of cycle
644 //____________________________________________________________________________
645 void AliTOFQADataMaker::EndOfDetectorCycle(AliQAv1::TASKINDEX task, TObjArray * list)
647 //Detector specific actions at end of cycle
648 // do the QA checking
650 AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;
652 //____________________________________________________________________________
653 void AliTOFQADataMaker::GetMapIndeces(Int_t* in , Int_t* out)
656 //return appropriate indeces for the theta-phi map
659 Int_t npadX = AliTOFGeometry::NpadX();
660 Int_t npadZ = AliTOFGeometry::NpadZ();
661 Int_t nStripA = AliTOFGeometry::NStripA();
662 Int_t nStripB = AliTOFGeometry::NStripB();
663 Int_t nStripC = AliTOFGeometry::NStripC();
665 Int_t isector = in[0];
666 Int_t iplate = in[1];
667 Int_t istrip = in[2];
671 Int_t stripOffset = 0;
677 stripOffset = nStripC;
680 stripOffset = nStripC+nStripB;
683 stripOffset = nStripC+nStripB+nStripA;
686 stripOffset = nStripC+nStripB+nStripA+nStripB;
689 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
692 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
693 Int_t phiindex=npadX*isector+ipadX+1;