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
81 TH1F * h0 = new TH1F("hTOFHits", "Number of TOF Hits ",301, -1.02, 5.) ;
85 TH1F * h1 = new TH1F("hTOFHitsTime", "Hits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
89 TH1F * h2 = new TH1F("hTOFHitsLength", "Length Spectrum in TOF (cm)", 500, 0., 500) ;
93 TH2F * h3 = new TH2F("hTOFHitsClusMap","Hits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
98 //____________________________________________________________________________
99 void AliTOFQADataMaker::InitDigits()
102 // create Digits histograms in Digits subdir
104 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits ",301, -1.02, 5.) ; h0->Sumw2() ;
105 Add2DigitsList(h0, 0) ;
107 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
109 Add2DigitsList(h1, 1) ;
111 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ;
113 Add2DigitsList(h2, 2) ;
115 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
117 Add2DigitsList(h3, 3) ;
121 //____________________________________________________________________________
122 void AliTOFQADataMaker::InitSDigits()
125 // create SDigits histograms in SDigits subdir
127 TH1F * h0 = new TH1F("hTOFSDigits", "Number of TOF SDigits ",301, -1.02, 5.) ; h0->Sumw2() ;
128 Add2SDigitsList(h0, 0) ;
130 TH1F * h1 = new TH1F("hTOFSDigitsTime", "SDigits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
132 Add2SDigitsList(h1, 1) ;
134 TH2F * h2 = new TH2F("hTOFSDigitsClusMap","SDigits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
136 Add2SDigitsList(h2, 2) ;
140 //____________________________________________________________________________
141 void AliTOFQADataMaker::InitRaws()
144 // create Raws histograms in Raws subdir
146 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ; h0->Sumw2() ;
147 Add2RawsList(h0, 0) ;
149 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
151 Add2RawsList(h1, 1) ;
153 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
155 Add2RawsList(h2, 2) ;
157 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
159 Add2RawsList(h3, 3) ;
163 //____________________________________________________________________________
164 void AliTOFQADataMaker::InitRecPoints()
167 // create RecPoints histograms in RecPoints subdir
169 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ; h0->Sumw2() ;
170 Add2RecPointsList(h0, 0) ;
172 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
174 Add2RecPointsList(h1, 1) ;
176 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
178 Add2RecPointsList(h2, 2) ;
180 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
182 Add2RecPointsList(h3, 3) ;
184 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
186 Add2RecPointsList(h4, 4) ;
190 //____________________________________________________________________________
191 void AliTOFQADataMaker::InitESDs()
194 //create ESDs histograms in ESDs subdir
196 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
198 Add2ESDsList(h0, 0) ;
200 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
202 Add2ESDsList(h1, 1) ;
204 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
206 Add2ESDsList(h2, 2) ;
208 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
210 Add2ESDsList(h3, 3) ;
212 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID glag", 100, 0., 1.) ;
214 Add2ESDsList(h4, 4) ;
218 //____________________________________________________________________________
219 void AliTOFQADataMaker::MakeHits(TClonesArray * hits)
222 //make QA data from Hits
228 Int_t nentries=hits->GetEntriesFast();
230 GetHitsData(0)->Fill(-1.) ;
232 GetHitsData(0)->Fill(TMath::Log10(nentries)) ;
236 while ( (hit = dynamic_cast<AliTOFhitT0 *>(next())) ) {
238 GetHitsData(1)->Fill( hit->GetTof()*1.E9) ;//in ns
239 GetHitsData(2)->Fill( hit->GetLen()) ;//in cm
241 in[0] = hit->GetSector();
242 in[1] = hit->GetPlate();
243 in[2]= hit->GetStrip();
244 in[3]= hit->GetPadx();
245 in[4]= hit->GetPadz();
246 GetMapIndeces(in,out);
247 GetHitsData(3)->Fill( out[0],out[1]) ;//hit map
253 //____________________________________________________________________________
254 void AliTOFQADataMaker::MakeHits(TTree * hitTree)
257 // make QA data from Hit Tree
260 AliError("can't get the tree with TOF hits !");
264 TBranch * branch = hitTree->GetBranch("TOF") ;
267 AliError("TOF branch in Hit Tree not found") ;
271 TClonesArray * hits = new TClonesArray("AliTOFhitT0", 1000);
272 TClonesArray * dummy = new TClonesArray("AliTOFhitT0", 1000);
273 branch->SetAddress(&dummy);
275 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
276 branch->GetEntry(ientry) ;
277 for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
278 AliTOFhitT0 * hit = dynamic_cast<AliTOFhitT0 *> (dummy->At(ihit)) ;
279 new((*hits)[index]) AliTOFhitT0(*hit) ;
290 //____________________________________________________________________________
291 void AliTOFQADataMaker::MakeDigits(TClonesArray * digits)
294 // makes data from Digits
296 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
297 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
301 Int_t nentries=digits->GetEntriesFast();
303 GetDigitsData(0)->Fill(-1.) ;
305 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
309 AliTOFdigit * digit ;
310 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
312 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
313 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
315 in[0] = digit->GetSector();
316 in[1] = digit->GetPlate();
317 in[2] = digit->GetStrip();
318 in[3] = digit->GetPadx();
319 in[4]= digit->GetPadz();
320 GetMapIndeces(in,out);
321 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
327 //____________________________________________________________________________
328 void AliTOFQADataMaker::MakeDigits(TTree * digitTree)
331 // makes data from Digit Tree
333 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
335 TBranch * branch = digitTree->GetBranch("TOF") ;
337 AliError("TOF branch in Digit Tree not found") ;
340 branch->SetAddress(&digits) ;
341 branch->GetEntry(0) ;
345 //____________________________________________________________________________
346 void AliTOFQADataMaker::MakeSDigits(TClonesArray * sdigits)
349 // makes data from SDigits
352 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
356 Int_t nentries=sdigits->GetEntriesFast();
358 GetSDigitsData(0)->Fill(-1.) ;
360 GetSDigitsData(0)->Fill(TMath::Log10(nentries)) ;
363 TIter next(sdigits) ;
364 AliTOFSDigit * sdigit ;
365 while ( (sdigit = dynamic_cast<AliTOFSDigit *>(next())) ) {
367 for(Int_t i=0;i<sdigit->GetNDigits();i++){
368 GetSDigitsData(1)->Fill( sdigit->GetTdc(i)*tdc2ns) ;//in ns
371 in[0] = sdigit->GetSector();
372 in[1] = sdigit->GetPlate();
373 in[2] = sdigit->GetStrip();
374 in[3] = sdigit->GetPadx();
375 in[4]= sdigit->GetPadz();
376 GetMapIndeces(in,out);
377 GetSDigitsData(2)->Fill( out[0],out[1]) ;//sdigit map
381 //____________________________________________________________________________
382 void AliTOFQADataMaker::MakeSDigits(TTree * sdigitTree)
385 // makes data from SDigit Tree
387 TClonesArray * sdigits = new TClonesArray("AliTOFSDigit", 1000) ;
389 TBranch * branch = sdigitTree->GetBranch("TOF") ;
391 AliError("TOF branch in SDigit Tree not found") ;
394 branch->SetAddress(&sdigits) ;
395 branch->GetEntry(0) ;
396 MakeSDigits(sdigits) ;
399 //____________________________________________________________________________
400 void AliTOFQADataMaker::MakeRaws(AliRawReader* rawReader)
403 // makes data from Raws
406 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
407 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
414 TClonesArray * clonesRawData;
415 AliTOFRawStream tofInput(rawReader);
416 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
418 tofInput.LoadRawData(iDDL);
419 clonesRawData = (TClonesArray*)tofInput.GetRawData();
420 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
421 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
422 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
424 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
425 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
427 tofInput.EquipmentId2VolumeId(iDDL,
428 tofRawDatum->GetTRM(),
429 tofRawDatum->GetTRMchain(),
430 tofRawDatum->GetTDC(),
431 tofRawDatum->GetTDCchannel(),
434 GetMapIndeces(in,out);
435 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
439 clonesRawData->Clear();
445 GetRawsData(0)->Fill(-1.) ;
447 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
451 //____________________________________________________________________________
452 void AliTOFQADataMaker::MakeRecPoints(TTree * clustersTree)
455 // Make data from Clusters
458 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
459 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
464 TBranch *branch=clustersTree->GetBranch("TOF");
466 AliError("can't get the branch with the TOF clusters !");
470 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
471 branch->SetAddress(&clusters);
474 clustersTree->GetEvent(0);
476 Int_t nentries=clusters->GetEntriesFast();
478 GetRecPointsData(0)->Fill(-1.) ;
480 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
483 TIter next(clusters) ;
485 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
486 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
487 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
488 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
490 in[0] = c->GetDetInd(0);
491 in[1] = c->GetDetInd(1);
492 in[2] = c->GetDetInd(2);
493 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
494 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
496 GetMapIndeces(in,out);
497 GetRecPointsData(4)->Fill(out[0],out[1]);
502 //____________________________________________________________________________
503 void AliTOFQADataMaker::MakeESDs(AliESDEvent * esd)
506 // make QA data from ESDs
508 Int_t ntrk = esd->GetNumberOfTracks() ;
512 AliESDtrack *track=esd->GetTrack(ntrk);
513 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
514 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
515 Double_t tofToT=track->GetTOFsignalToT(); //in ns
516 if(!(tofTime>0))continue;
518 GetESDsData(1)->Fill(tofTime);
519 GetESDsData(2)->Fill(tofTimeRaw);
520 GetESDsData(3)->Fill(tofToT);
521 //check how many tracks where ESD PID is ok
522 UInt_t status=track->GetStatus();
523 if (((status&AliESDtrack::kESDpid)==0) ||
524 ((status&AliESDtrack::kTOFpid)==0)) continue;
530 GetESDsData(0)->Fill(-1.) ;
532 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
535 if(ntof>0)GetESDsData(4)->Fill(ntofpid/ntof) ;
539 //____________________________________________________________________________
540 void AliTOFQADataMaker::StartOfDetectorCycle()
543 //Detector specific actions at start of cycle
547 //____________________________________________________________________________
548 void AliTOFQADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TObjArray * list)
550 //Detector specific actions at end of cycle
551 // do the QA checking
553 AliQAChecker::Instance()->Run(AliQA::kTOF, task, list) ;
555 //____________________________________________________________________________
556 void AliTOFQADataMaker::GetMapIndeces(Int_t* in , Int_t* out)
559 //return appropriate indeces for the theta-phi map
562 Int_t npadX = AliTOFGeometry::NpadX();
563 Int_t npadZ = AliTOFGeometry::NpadZ();
564 Int_t nStripA = AliTOFGeometry::NStripA();
565 Int_t nStripB = AliTOFGeometry::NStripB();
566 Int_t nStripC = AliTOFGeometry::NStripC();
568 Int_t isector = in[0];
569 Int_t iplate = in[1];
570 Int_t istrip = in[2];
574 Int_t stripOffset = 0;
580 stripOffset = nStripC;
583 stripOffset = nStripC+nStripB;
586 stripOffset = nStripC+nStripB+nStripA;
589 stripOffset = nStripC+nStripB+nStripA+nStripB;
592 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
595 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
596 Int_t phiindex=npadX*isector+ipadX+1;