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(AliQA::GetDetName(AliQA::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 eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
201 Add2RecPointsList(h4, 4, expert) ;
205 //____________________________________________________________________________
206 void AliTOFQADataMaker::InitESDs()
209 //create ESDs histograms in ESDs subdir
212 Bool_t expert = kFALSE;
214 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
216 Add2ESDsList(h0, 0, expert) ;
218 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
220 Add2ESDsList(h1, 1, expert) ;
222 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
224 Add2ESDsList(h2, 2, expert) ;
226 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
228 Add2ESDsList(h3, 3, expert) ;
230 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID glag", 100, 0., 1.) ;
232 Add2ESDsList(h4, 4, expert) ;
236 //____________________________________________________________________________
237 void AliTOFQADataMaker::MakeHits(TClonesArray * hits)
240 //make QA data from Hits
246 Int_t nentries=hits->GetEntriesFast();
248 GetHitsData(0)->Fill(-1.) ;
250 GetHitsData(0)->Fill(TMath::Log10(nentries)) ;
254 while ( (hit = dynamic_cast<AliTOFhitT0 *>(next())) ) {
256 GetHitsData(1)->Fill( hit->GetTof()*1.E9) ;//in ns
257 GetHitsData(2)->Fill( hit->GetLen()) ;//in cm
259 in[0] = hit->GetSector();
260 in[1] = hit->GetPlate();
261 in[2]= hit->GetStrip();
262 in[3]= hit->GetPadx();
263 in[4]= hit->GetPadz();
264 GetMapIndeces(in,out);
265 GetHitsData(3)->Fill( out[0],out[1]) ;//hit map
271 //____________________________________________________________________________
272 void AliTOFQADataMaker::MakeHits(TTree * hitTree)
275 // make QA data from Hit Tree
278 AliError("can't get the tree with TOF hits !");
282 TBranch * branch = hitTree->GetBranch("TOF") ;
285 AliError("TOF branch in Hit Tree not found") ;
289 TClonesArray * hits = new TClonesArray("AliTOFhitT0", 1000);
290 TClonesArray * dummy = new TClonesArray("AliTOFhitT0", 1000);
291 branch->SetAddress(&dummy);
293 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
294 branch->GetEntry(ientry) ;
295 for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
296 AliTOFhitT0 * hit = dynamic_cast<AliTOFhitT0 *> (dummy->At(ihit)) ;
297 new((*hits)[index]) AliTOFhitT0(*hit) ;
308 //____________________________________________________________________________
309 void AliTOFQADataMaker::MakeDigits(TClonesArray * digits)
312 // makes data from Digits
314 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
315 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
319 Int_t nentries=digits->GetEntriesFast();
321 GetDigitsData(0)->Fill(-1.) ;
323 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
327 AliTOFdigit * digit ;
328 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
330 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
331 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
333 in[0] = digit->GetSector();
334 in[1] = digit->GetPlate();
335 in[2] = digit->GetStrip();
336 in[3] = digit->GetPadx();
337 in[4]= digit->GetPadz();
338 GetMapIndeces(in,out);
339 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
345 //____________________________________________________________________________
346 void AliTOFQADataMaker::MakeDigits(TTree * digitTree)
349 // makes data from Digit Tree
351 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
353 TBranch * branch = digitTree->GetBranch("TOF") ;
355 AliError("TOF branch in Digit Tree not found") ;
358 branch->SetAddress(&digits) ;
359 branch->GetEntry(0) ;
363 //____________________________________________________________________________
364 void AliTOFQADataMaker::MakeSDigits(TClonesArray * sdigits)
367 // makes data from SDigits
370 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
374 Int_t nentries=sdigits->GetEntriesFast();
376 GetSDigitsData(0)->Fill(-1.) ;
378 GetSDigitsData(0)->Fill(TMath::Log10(nentries)) ;
381 TIter next(sdigits) ;
382 AliTOFSDigit * sdigit ;
383 while ( (sdigit = dynamic_cast<AliTOFSDigit *>(next())) ) {
385 for(Int_t i=0;i<sdigit->GetNDigits();i++){
386 GetSDigitsData(1)->Fill( sdigit->GetTdc(i)*tdc2ns) ;//in ns
389 in[0] = sdigit->GetSector();
390 in[1] = sdigit->GetPlate();
391 in[2] = sdigit->GetStrip();
392 in[3] = sdigit->GetPadx();
393 in[4]= sdigit->GetPadz();
394 GetMapIndeces(in,out);
395 GetSDigitsData(2)->Fill( out[0],out[1]) ;//sdigit map
399 //____________________________________________________________________________
400 void AliTOFQADataMaker::MakeSDigits(TTree * sdigitTree)
403 // makes data from SDigit Tree
405 TClonesArray * sdigits = new TClonesArray("AliTOFSDigit", 1000) ;
407 TBranch * branch = sdigitTree->GetBranch("TOF") ;
409 AliError("TOF branch in SDigit Tree not found") ;
412 branch->SetAddress(&sdigits) ;
413 branch->GetEntry(0) ;
414 MakeSDigits(sdigits) ;
417 //____________________________________________________________________________
418 void AliTOFQADataMaker::MakeRaws(AliRawReader* rawReader)
421 // makes data from Raws
424 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
425 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
432 TClonesArray * clonesRawData;
433 AliTOFRawStream tofInput(rawReader);
434 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
436 tofInput.LoadRawData(iDDL);
437 clonesRawData = (TClonesArray*)tofInput.GetRawData();
438 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
439 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
440 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
442 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
443 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
445 tofInput.EquipmentId2VolumeId(iDDL,
446 tofRawDatum->GetTRM(),
447 tofRawDatum->GetTRMchain(),
448 tofRawDatum->GetTDC(),
449 tofRawDatum->GetTDCchannel(),
452 GetMapIndeces(in,out);
453 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
457 clonesRawData->Clear();
463 GetRawsData(0)->Fill(-1.) ;
465 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
469 //____________________________________________________________________________
470 void AliTOFQADataMaker::MakeRecPoints(TTree * clustersTree)
473 // Make data from Clusters
476 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
477 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
482 TBranch *branch=clustersTree->GetBranch("TOF");
484 AliError("can't get the branch with the TOF clusters !");
488 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
489 branch->SetAddress(&clusters);
492 clustersTree->GetEvent(0);
494 Int_t nentries=clusters->GetEntriesFast();
496 GetRecPointsData(0)->Fill(-1.) ;
498 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
501 TIter next(clusters) ;
503 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
504 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
505 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
506 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
508 in[0] = c->GetDetInd(0);
509 in[1] = c->GetDetInd(1);
510 in[2] = c->GetDetInd(2);
511 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
512 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
514 GetMapIndeces(in,out);
515 GetRecPointsData(4)->Fill(out[0],out[1]);
520 //____________________________________________________________________________
521 void AliTOFQADataMaker::MakeESDs(AliESDEvent * esd)
524 // make QA data from ESDs
526 Int_t ntrk = esd->GetNumberOfTracks() ;
530 AliESDtrack *track=esd->GetTrack(ntrk);
531 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
532 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
533 Double_t tofToT=track->GetTOFsignalToT(); //in ns
534 if(!(tofTime>0))continue;
536 GetESDsData(1)->Fill(tofTime);
537 GetESDsData(2)->Fill(tofTimeRaw);
538 GetESDsData(3)->Fill(tofToT);
539 //check how many tracks where ESD PID is ok
540 UInt_t status=track->GetStatus();
541 if (((status&AliESDtrack::kESDpid)==0) ||
542 ((status&AliESDtrack::kTOFpid)==0)) continue;
548 GetESDsData(0)->Fill(-1.) ;
550 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
553 if(ntof>0)GetESDsData(4)->Fill(ntofpid/ntof) ;
557 //____________________________________________________________________________
558 void AliTOFQADataMaker::StartOfDetectorCycle()
561 //Detector specific actions at start of cycle
565 //____________________________________________________________________________
566 void AliTOFQADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TObjArray * list)
568 //Detector specific actions at end of cycle
569 // do the QA checking
571 AliQAChecker::Instance()->Run(AliQA::kTOF, task, list) ;
573 //____________________________________________________________________________
574 void AliTOFQADataMaker::GetMapIndeces(Int_t* in , Int_t* out)
577 //return appropriate indeces for the theta-phi map
580 Int_t npadX = AliTOFGeometry::NpadX();
581 Int_t npadZ = AliTOFGeometry::NpadZ();
582 Int_t nStripA = AliTOFGeometry::NStripA();
583 Int_t nStripB = AliTOFGeometry::NStripB();
584 Int_t nStripC = AliTOFGeometry::NStripC();
586 Int_t isector = in[0];
587 Int_t iplate = in[1];
588 Int_t istrip = in[2];
592 Int_t stripOffset = 0;
598 stripOffset = nStripC;
601 stripOffset = nStripC+nStripB;
604 stripOffset = nStripC+nStripB+nStripA;
607 stripOffset = nStripC+nStripB+nStripA+nStripB;
610 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
613 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
614 Int_t phiindex=npadX*isector+ipadX+1;