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")
53 //____________________________________________________________________________
54 AliTOFQADataMaker::AliTOFQADataMaker(const AliTOFQADataMaker& qadm) :
60 SetName((const char*)qadm.GetName()) ;
61 SetTitle((const char*)qadm.GetTitle());
64 //__________________________________________________________________
65 AliTOFQADataMaker& AliTOFQADataMaker::operator = (const AliTOFQADataMaker& qadm )
68 // assignment operator.
70 this->~AliTOFQADataMaker();
71 new(this) AliTOFQADataMaker(qadm);
75 //____________________________________________________________________________
76 void AliTOFQADataMaker::InitHits()
79 // create Hits histograms in Hits subdir
82 Bool_t expert = kFALSE;
84 TH1F * h0 = new TH1F("hTOFHits", "Number of TOF Hits ",301, -1.02, 5.) ;
86 Add2HitsList(h0, 0, expert) ;
88 TH1F * h1 = new TH1F("hTOFHitsTime", "Hits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
90 Add2HitsList(h1, 1, expert) ;
92 TH1F * h2 = new TH1F("hTOFHitsLength", "Length Spectrum in TOF (cm)", 500, 0., 500) ;
94 Add2HitsList(h2, 2, expert) ;
96 TH2F * h3 = new TH2F("hTOFHitsClusMap","Hits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
98 Add2HitsList(h3, 3, expert) ;
101 //____________________________________________________________________________
102 void AliTOFQADataMaker::InitDigits()
105 // create Digits histograms in Digits subdir
108 Bool_t expert = kFALSE;
110 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits ",301, -1.02, 5.) ; h0->Sumw2() ;
111 Add2DigitsList(h0, 0, expert) ;
113 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
115 Add2DigitsList(h1, 1, expert) ;
117 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ;
119 Add2DigitsList(h2, 2, expert) ;
121 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
123 Add2DigitsList(h3, 3, expert) ;
127 //____________________________________________________________________________
128 void AliTOFQADataMaker::InitSDigits()
131 // create SDigits histograms in SDigits subdir
134 Bool_t expert = kFALSE;
136 TH1F * h0 = new TH1F("hTOFSDigits", "Number of TOF SDigits ",301, -1.02, 5.) ; h0->Sumw2() ;
137 Add2SDigitsList(h0, 0, expert) ;
139 TH1F * h1 = new TH1F("hTOFSDigitsTime", "SDigits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
141 Add2SDigitsList(h1, 1, expert) ;
143 TH2F * h2 = new TH2F("hTOFSDigitsClusMap","SDigits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
145 Add2SDigitsList(h2, 2, expert) ;
149 //____________________________________________________________________________
150 void AliTOFQADataMaker::InitRaws()
153 // create Raws histograms in Raws subdir
156 Bool_t expert = kFALSE;
158 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ; h0->Sumw2() ;
159 Add2RawsList(h0, 0, expert) ;
161 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
163 Add2RawsList(h1, 1, expert) ;
165 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
167 Add2RawsList(h2, 2, expert) ;
169 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
171 Add2RawsList(h3, 3, expert) ;
175 //____________________________________________________________________________
176 void AliTOFQADataMaker::InitRecPoints()
179 // create RecPoints histograms in RecPoints subdir
182 Bool_t expert = kFALSE;
184 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ; h0->Sumw2() ;
185 Add2RecPointsList(h0, 0, expert) ;
187 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
189 Add2RecPointsList(h1, 1, expert) ;
191 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
193 Add2RecPointsList(h2, 2, expert) ;
195 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
197 Add2RecPointsList(h3, 3, expert) ;
199 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta",183, -0.5, 182.5,865,-0.5,864.5) ;
201 h4->GetXaxis()->SetTitle("2*strip+padz (eta)");
202 h4->GetYaxis()->SetTitle("48*sector+padx (phi)");
203 Add2RecPointsList(h4, 4, expert) ;
207 //____________________________________________________________________________
208 void AliTOFQADataMaker::InitESDs()
211 //create ESDs histograms in ESDs subdir
214 Bool_t expert = kFALSE;
216 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
218 Add2ESDsList(h0, 0, expert) ;
220 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
222 Add2ESDsList(h1, 1, expert) ;
224 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
226 Add2ESDsList(h2, 2, expert) ;
228 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
230 Add2ESDsList(h3, 3, expert) ;
232 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID flag", 101, 0., 101.) ;
234 Add2ESDsList(h4, 4, expert) ;
238 //____________________________________________________________________________
239 void AliTOFQADataMaker::MakeHits(TClonesArray * hits)
242 //make QA data from Hits
248 Int_t nentries=hits->GetEntriesFast();
250 GetHitsData(0)->Fill(-1.) ;
252 GetHitsData(0)->Fill(TMath::Log10(nentries)) ;
256 while ( (hit = dynamic_cast<AliTOFhitT0 *>(next())) ) {
258 GetHitsData(1)->Fill( hit->GetTof()*1.E9) ;//in ns
259 GetHitsData(2)->Fill( hit->GetLen()) ;//in cm
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
273 //____________________________________________________________________________
274 void AliTOFQADataMaker::MakeHits(TTree * hitTree)
277 // make QA data from Hit Tree
280 AliError("can't get the tree with TOF hits !");
284 TBranch * branch = hitTree->GetBranch("TOF") ;
287 AliError("TOF branch in Hit Tree not found") ;
291 TClonesArray * hits = new TClonesArray("AliTOFhitT0", 1000);
292 TClonesArray * dummy = new TClonesArray("AliTOFhitT0", 1000);
293 branch->SetAddress(&dummy);
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) ;
310 //____________________________________________________________________________
311 void AliTOFQADataMaker::MakeDigits(TClonesArray * digits)
314 // makes data from Digits
316 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
317 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
321 Int_t nentries=digits->GetEntriesFast();
323 GetDigitsData(0)->Fill(-1.) ;
325 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
329 AliTOFdigit * digit ;
330 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
332 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
333 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
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
347 //____________________________________________________________________________
348 void AliTOFQADataMaker::MakeDigits(TTree * digitTree)
351 // makes data from Digit Tree
353 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
355 TBranch * branch = digitTree->GetBranch("TOF") ;
357 AliError("TOF branch in Digit Tree not found") ;
360 branch->SetAddress(&digits) ;
361 branch->GetEntry(0) ;
365 //____________________________________________________________________________
366 void AliTOFQADataMaker::MakeSDigits(TClonesArray * sdigits)
369 // makes data from SDigits
372 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
376 Int_t nentries=sdigits->GetEntriesFast();
378 GetSDigitsData(0)->Fill(-1.) ;
380 GetSDigitsData(0)->Fill(TMath::Log10(nentries)) ;
383 TIter next(sdigits) ;
384 AliTOFSDigit * sdigit ;
385 while ( (sdigit = dynamic_cast<AliTOFSDigit *>(next())) ) {
387 for(Int_t i=0;i<sdigit->GetNDigits();i++){
388 GetSDigitsData(1)->Fill( sdigit->GetTdc(i)*tdc2ns) ;//in ns
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
401 //____________________________________________________________________________
402 void AliTOFQADataMaker::MakeSDigits(TTree * sdigitTree)
405 // makes data from SDigit Tree
407 TClonesArray * sdigits = new TClonesArray("AliTOFSDigit", 1000) ;
409 TBranch * branch = sdigitTree->GetBranch("TOF") ;
411 AliError("TOF branch in SDigit Tree not found") ;
414 branch->SetAddress(&sdigits) ;
415 branch->GetEntry(0) ;
416 MakeSDigits(sdigits) ;
419 //____________________________________________________________________________
420 void AliTOFQADataMaker::MakeRaws(AliRawReader* rawReader)
423 // makes data from Raws
426 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
427 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
434 TClonesArray * clonesRawData;
435 AliTOFRawStream tofInput(rawReader);
436 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
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;
444 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
445 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
447 tofInput.EquipmentId2VolumeId(iDDL,
448 tofRawDatum->GetTRM(),
449 tofRawDatum->GetTRMchain(),
450 tofRawDatum->GetTDC(),
451 tofRawDatum->GetTDCchannel(),
454 GetMapIndeces(in,out);
455 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
459 clonesRawData->Clear();
465 GetRawsData(0)->Fill(-1.) ;
467 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
471 //____________________________________________________________________________
472 void AliTOFQADataMaker::MakeRecPoints(TTree * clustersTree)
475 // Make data from Clusters
478 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
479 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
484 TBranch *branch=clustersTree->GetBranch("TOF");
486 AliError("can't get the branch with the TOF clusters !");
490 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
491 branch->SetAddress(&clusters);
494 clustersTree->GetEvent(0);
496 Int_t nentries=clusters->GetEntriesFast();
498 GetRecPointsData(0)->Fill(-1.) ;
500 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
503 TIter next(clusters) ;
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);
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
516 GetMapIndeces(in,out);
517 GetRecPointsData(4)->Fill(out[0],out[1]);
522 //____________________________________________________________________________
523 void AliTOFQADataMaker::MakeESDs(AliESDEvent * esd)
526 // make QA data from ESDs
528 Int_t ntrk = esd->GetNumberOfTracks() ;
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;
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;
550 GetESDsData(0)->Fill(-1.) ;
552 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
555 Float_t ratio = (Float_t)ntofpid/(Float_t)ntof*100.;
556 if(ntof>0)GetESDsData(4)->Fill(ratio) ;
560 //____________________________________________________________________________
561 void AliTOFQADataMaker::StartOfDetectorCycle()
564 //Detector specific actions at start of cycle
568 //____________________________________________________________________________
569 void AliTOFQADataMaker::EndOfDetectorCycle(AliQAv1::TASKINDEX task, TObjArray * list)
571 //Detector specific actions at end of cycle
572 // do the QA checking
574 AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;
576 //____________________________________________________________________________
577 void AliTOFQADataMaker::GetMapIndeces(Int_t* in , Int_t* out)
580 //return appropriate indeces for the theta-phi map
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();
589 Int_t isector = in[0];
590 Int_t iplate = in[1];
591 Int_t istrip = in[2];
595 Int_t stripOffset = 0;
601 stripOffset = nStripC;
604 stripOffset = nStripC+nStripB;
607 stripOffset = nStripC+nStripB+nStripA;
610 stripOffset = nStripC+nStripB+nStripA+nStripB;
613 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
616 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
617 Int_t phiindex=npadX*isector+ipadX+1;