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) ;
109 //____________________________________________________________________________
110 void AliTOFQADataMaker::InitDigits()
113 // create Digits histograms in Digits subdir
116 Bool_t expert = kFALSE;
118 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits ",301, -1.02, 5.) ;
120 h0->GetXaxis()->SetTitle("TOF digit number [10 power]");
121 Add2DigitsList(h0, 0, expert) ;
123 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
125 h1->GetXaxis()->SetTitle("Digitized TOF time [ns]");
126 Add2DigitsList(h1, 1, expert) ;
128 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ;
130 h2->GetXaxis()->SetTitle("Digitized TOT [ns]");
131 h2->GetYaxis()->SetTitle("Digitized TOF time [ns]");
132 Add2DigitsList(h2, 2, expert) ;
134 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
136 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
137 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
138 h3->GetYaxis()->SetTitleOffset(1.15);
139 Add2DigitsList(h3, 3, expert) ;
143 //____________________________________________________________________________
144 void AliTOFQADataMaker::InitSDigits()
147 // create SDigits histograms in SDigits subdir
150 Bool_t expert = kFALSE;
152 TH1F * h0 = new TH1F("hTOFSDigits", "Number of TOF SDigits ",301, -1.02, 5.) ;
154 h0->GetXaxis()->SetTitle("TOF sdigit number [10 power]");
155 Add2SDigitsList(h0, 0, expert) ;
157 TH1F * h1 = new TH1F("hTOFSDigitsTime", "SDigits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
159 h1->GetXaxis()->SetTitle("SDigitized TOF time [ns]");
160 Add2SDigitsList(h1, 1, expert) ;
162 TH2F * h2 = new TH2F("hTOFSDigitsClusMap","SDigits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
164 h2->GetXaxis()->SetTitle("2*strip+padz (eta)");
165 h2->GetYaxis()->SetTitle("48*sector+padx (phi)");
166 h2->GetYaxis()->SetTitleOffset(1.15);
167 Add2SDigitsList(h2, 2, expert) ;
171 //____________________________________________________________________________
172 void AliTOFQADataMaker::InitRaws()
175 // create Raws histograms in Raws subdir
178 Bool_t expert = kFALSE;
180 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ;
182 h0->GetXaxis()->SetTitle("TOF raw number [10 power]");
183 Add2RawsList(h0, 0, expert) ;
185 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 20000, 0., 2000) ;
187 h1->GetXaxis()->SetTitle("Measured TOF time [ns]");
188 Add2RawsList(h1, 1, expert) ;
190 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
192 h2->GetXaxis()->SetTitle("Measured TOT [ns]");
193 h2->GetYaxis()->SetTitle("Measured TOF time [ns]");
194 Add2RawsList(h2, 2, expert) ;
196 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
198 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
199 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
200 h3->GetYaxis()->SetTitleOffset(1.15);
201 Add2RawsList(h3, 3, expert) ;
205 //____________________________________________________________________________
206 void AliTOFQADataMaker::InitRecPoints()
209 // create RecPoints histograms in RecPoints subdir
212 Bool_t expert = kFALSE;
214 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ;
216 h0->GetXaxis()->SetTitle("TOF recPoint number [10 power]");
217 Add2RecPointsList(h0, 0, expert) ;
219 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 20000, 0., 2000) ;
221 h1->GetXaxis()->SetTitle("Calibrated TOF time [ns]");
222 Add2RecPointsList(h1, 1, expert) ;
224 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 20000, 0., 2000) ;
226 h2->GetXaxis()->SetTitle("Measured TOT [ns]");
227 h2->GetYaxis()->SetTitle("Measured TOF time [ns]");
228 Add2RecPointsList(h2, 2, expert) ;
230 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
232 h3->GetXaxis()->SetTitle("Measured TOT [ns]");
233 Add2RecPointsList(h3, 3, expert) ;
235 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta",183, -0.5, 182.5,865,-0.5,864.5) ;
237 h4->GetXaxis()->SetTitle("2*strip+padz (eta)");
238 h4->GetYaxis()->SetTitle("48*sector+padx (phi)");
239 h4->GetYaxis()->SetTitleOffset(1.15);
240 Add2RecPointsList(h4, 4, expert) ;
244 //____________________________________________________________________________
245 void AliTOFQADataMaker::InitESDs()
248 //create ESDs histograms in ESDs subdir
251 Bool_t expert = kFALSE;
253 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
255 h0->GetXaxis()->SetTitle("Number of TOF matched ESD tracks [10 power]");
256 Add2ESDsList(h0, 0, expert) ;
258 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 20000, 0., 2000) ;
260 h1->GetXaxis()->SetTitle("Calibrated TOF time [ns]");
261 Add2ESDsList(h1, 1, expert) ;
263 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 20000, 0., 2000) ;
265 h2->GetXaxis()->SetTitle("Measured TOF time [ns]");
266 Add2ESDsList(h2, 2, expert) ;
268 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
270 h3->GetXaxis()->SetTitle("Measured TOT [ns]");
271 Add2ESDsList(h3, 3, expert) ;
273 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID flag", 101, 0., 101.) ;
275 h4->GetXaxis()->SetTitle("Fraction of TOF matched ESD tracks with good flag [%]");
276 Add2ESDsList(h4, 4, expert) ;
280 //____________________________________________________________________________
281 void AliTOFQADataMaker::MakeHits(TClonesArray * hits)
284 //make QA data from Hits
290 Int_t nentries=hits->GetEntriesFast();
292 GetHitsData(0)->Fill(-1.) ;
294 GetHitsData(0)->Fill(TMath::Log10(nentries)) ;
298 while ( (hit = dynamic_cast<AliTOFhitT0 *>(next())) ) {
300 GetHitsData(1)->Fill( hit->GetTof()*1.E9) ;//in ns
301 GetHitsData(2)->Fill( hit->GetLen()) ;//in cm
303 in[0] = hit->GetSector();
304 in[1] = hit->GetPlate();
305 in[2]= hit->GetStrip();
306 in[3]= hit->GetPadx();
307 in[4]= hit->GetPadz();
308 GetMapIndeces(in,out);
309 GetHitsData(3)->Fill( out[0],out[1]) ;//hit map
315 //____________________________________________________________________________
316 void AliTOFQADataMaker::MakeHits(TTree * hitTree)
319 // make QA data from Hit Tree
322 AliError("can't get the tree with TOF hits !");
326 TBranch * branch = hitTree->GetBranch("TOF") ;
329 AliError("TOF branch in Hit Tree not found") ;
333 TClonesArray * hits = new TClonesArray("AliTOFhitT0", 1000);
334 TClonesArray * dummy = new TClonesArray("AliTOFhitT0", 1000);
335 branch->SetAddress(&dummy);
337 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
338 branch->GetEntry(ientry) ;
339 for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
340 AliTOFhitT0 * hit = dynamic_cast<AliTOFhitT0 *> (dummy->At(ihit)) ;
341 new((*hits)[index]) AliTOFhitT0(*hit) ;
352 //____________________________________________________________________________
353 void AliTOFQADataMaker::MakeDigits(TClonesArray * digits)
356 // makes data from Digits
358 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
359 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
363 Int_t nentries=digits->GetEntriesFast();
365 GetDigitsData(0)->Fill(-1.) ;
367 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
371 AliTOFdigit * digit ;
372 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
374 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
375 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
377 in[0] = digit->GetSector();
378 in[1] = digit->GetPlate();
379 in[2] = digit->GetStrip();
380 in[3] = digit->GetPadx();
381 in[4]= digit->GetPadz();
382 GetMapIndeces(in,out);
383 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
389 //____________________________________________________________________________
390 void AliTOFQADataMaker::MakeDigits(TTree * digitTree)
393 // makes data from Digit Tree
395 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
397 TBranch * branch = digitTree->GetBranch("TOF") ;
399 AliError("TOF branch in Digit Tree not found") ;
402 branch->SetAddress(&digits) ;
403 branch->GetEntry(0) ;
407 //____________________________________________________________________________
408 void AliTOFQADataMaker::MakeSDigits(TClonesArray * sdigits)
411 // makes data from SDigits
414 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
418 Int_t nentries=sdigits->GetEntriesFast();
420 GetSDigitsData(0)->Fill(-1.) ;
422 GetSDigitsData(0)->Fill(TMath::Log10(nentries)) ;
425 TIter next(sdigits) ;
426 AliTOFSDigit * sdigit ;
427 while ( (sdigit = dynamic_cast<AliTOFSDigit *>(next())) ) {
429 for(Int_t i=0;i<sdigit->GetNDigits();i++){
430 GetSDigitsData(1)->Fill( sdigit->GetTdc(i)*tdc2ns) ;//in ns
433 in[0] = sdigit->GetSector();
434 in[1] = sdigit->GetPlate();
435 in[2] = sdigit->GetStrip();
436 in[3] = sdigit->GetPadx();
437 in[4]= sdigit->GetPadz();
438 GetMapIndeces(in,out);
439 GetSDigitsData(2)->Fill( out[0],out[1]) ;//sdigit map
443 //____________________________________________________________________________
444 void AliTOFQADataMaker::MakeSDigits(TTree * sdigitTree)
447 // makes data from SDigit Tree
449 TClonesArray * sdigits = new TClonesArray("AliTOFSDigit", 1000) ;
451 TBranch * branch = sdigitTree->GetBranch("TOF") ;
453 AliError("TOF branch in SDigit Tree not found") ;
456 branch->SetAddress(&sdigits) ;
457 branch->GetEntry(0) ;
458 MakeSDigits(sdigits) ;
461 //____________________________________________________________________________
462 void AliTOFQADataMaker::MakeRaws(AliRawReader* rawReader)
465 // makes data from Raws
468 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
469 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
476 TClonesArray * clonesRawData;
477 //AliTOFRawStream tofInput(rawReader);
478 fTOFRawStream.SetRawReader(rawReader);
479 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
481 fTOFRawStream.LoadRawData(iDDL);
482 clonesRawData = (TClonesArray*)fTOFRawStream.GetRawData();
483 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
484 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
485 //if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
486 if (!tofRawDatum->GetTOF()) continue;
488 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
489 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
491 fTOFRawStream.EquipmentId2VolumeId(iDDL,
492 tofRawDatum->GetTRM(),
493 tofRawDatum->GetTRMchain(),
494 tofRawDatum->GetTDC(),
495 tofRawDatum->GetTDCchannel(),
498 GetMapIndeces(in,out);
499 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
503 clonesRawData->Clear();
507 fTOFRawStream.Clear();
511 GetRawsData(0)->Fill(-1.) ;
513 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
517 //____________________________________________________________________________
518 void AliTOFQADataMaker::MakeRecPoints(TTree * clustersTree)
521 // Make data from Clusters
524 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
525 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
530 TBranch *branch=clustersTree->GetBranch("TOF");
532 AliError("can't get the branch with the TOF clusters !");
536 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
537 branch->SetAddress(&clusters);
540 clustersTree->GetEvent(0);
542 Int_t nentries=clusters->GetEntriesFast();
544 GetRecPointsData(0)->Fill(-1.) ;
546 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
549 TIter next(clusters) ;
551 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
552 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
553 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
554 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
556 in[0] = c->GetDetInd(0);
557 in[1] = c->GetDetInd(1);
558 in[2] = c->GetDetInd(2);
559 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
560 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
562 GetMapIndeces(in,out);
563 GetRecPointsData(4)->Fill(out[0],out[1]);
568 //____________________________________________________________________________
569 void AliTOFQADataMaker::MakeESDs(AliESDEvent * esd)
572 // make QA data from ESDs
574 Int_t ntrk = esd->GetNumberOfTracks() ;
578 AliESDtrack *track=esd->GetTrack(ntrk);
579 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
580 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
581 Double_t tofToT=track->GetTOFsignalToT(); //in ns
582 if(!(tofTime>0))continue;
584 GetESDsData(1)->Fill(tofTime);
585 GetESDsData(2)->Fill(tofTimeRaw);
586 GetESDsData(3)->Fill(tofToT);
587 //check how many tracks where ESD PID is ok
588 UInt_t status=track->GetStatus();
589 if (((status&AliESDtrack::kESDpid)==0) ||
590 ((status&AliESDtrack::kTOFpid)==0)) continue;
596 GetESDsData(0)->Fill(-1.) ;
598 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
602 if(ntof>0) ratio=(Float_t)ntofpid/(Float_t)ntof*100.;
603 GetESDsData(4)->Fill(ratio) ;
607 //____________________________________________________________________________
608 void AliTOFQADataMaker::StartOfDetectorCycle()
611 //Detector specific actions at start of cycle
615 //____________________________________________________________________________
616 void AliTOFQADataMaker::EndOfDetectorCycle(AliQAv1::TASKINDEX task, TObjArray * list)
618 //Detector specific actions at end of cycle
619 // do the QA checking
621 AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;
623 //____________________________________________________________________________
624 void AliTOFQADataMaker::GetMapIndeces(Int_t* in , Int_t* out)
627 //return appropriate indeces for the theta-phi map
630 Int_t npadX = AliTOFGeometry::NpadX();
631 Int_t npadZ = AliTOFGeometry::NpadZ();
632 Int_t nStripA = AliTOFGeometry::NStripA();
633 Int_t nStripB = AliTOFGeometry::NStripB();
634 Int_t nStripC = AliTOFGeometry::NStripC();
636 Int_t isector = in[0];
637 Int_t iplate = in[1];
638 Int_t istrip = in[2];
642 Int_t stripOffset = 0;
648 stripOffset = nStripC;
651 stripOffset = nStripC+nStripB;
654 stripOffset = nStripC+nStripB+nStripA;
657 stripOffset = nStripC+nStripB+nStripA+nStripB;
660 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
663 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
664 Int_t phiindex=npadX*isector+ipadX+1;