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 Produces the data needed to calculate the TOF quality assurance.
17 QA objects are 1 & 2 Dimensional histograms.
21 #include <TClonesArray.h>
26 #include "AliESDEvent.h"
27 #include "AliESDtrack.h"
28 #include "AliTOFcluster.h"
29 #include "AliTOFdigit.h"
30 #include "AliTOFSDigit.h"
31 #include "AliTOFhitT0.h"
32 #include "AliTOFQADataMaker.h"
33 #include "AliRawReader.h"
34 #include "AliTOFRawStream.h"
35 #include "AliTOFrawData.h"
38 ClassImp(AliTOFQADataMaker)
40 //____________________________________________________________________________
41 AliTOFQADataMaker::AliTOFQADataMaker() :
42 AliQADataMaker(AliQA::GetDetName(AliQA::kTOF), "TOF Quality Assurance Data Maker")
49 //____________________________________________________________________________
50 AliTOFQADataMaker::AliTOFQADataMaker(const AliTOFQADataMaker& qadm) :
56 SetName((const char*)qadm.GetName()) ;
57 SetTitle((const char*)qadm.GetTitle());
60 //__________________________________________________________________
61 AliTOFQADataMaker& AliTOFQADataMaker::operator = (const AliTOFQADataMaker& qadm )
64 // assignment operator.
66 this->~AliTOFQADataMaker();
67 new(this) AliTOFQADataMaker(qadm);
71 //____________________________________________________________________________
72 void AliTOFQADataMaker::InitHits()
75 // create Hits histograms in Hits subdir
77 TH1F * h0 = new TH1F("hTOFHits", "Number of TOF Hits ",301, -1.02, 5.) ;
81 TH1F * h1 = new TH1F("hTOFHitsTime", "Hits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
85 TH1F * h2 = new TH1F("hTOFHitsLength", "Length Spectrum in TOF (cm)", 500, 0., 500) ;
89 TH2F * h3 = new TH2F("hTOFHitsClusMap","Hits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
94 //____________________________________________________________________________
95 void AliTOFQADataMaker::InitDigits()
98 // create Digits histograms in Digits subdir
100 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits ",301, -1.02, 5.) ; h0->Sumw2() ;
101 Add2DigitsList(h0, 0) ;
103 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
105 Add2DigitsList(h1, 1) ;
107 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ;
109 Add2DigitsList(h2, 2) ;
111 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
113 Add2DigitsList(h3, 3) ;
117 //____________________________________________________________________________
118 void AliTOFQADataMaker::InitSDigits()
121 // create SDigits histograms in SDigits subdir
123 TH1F * h0 = new TH1F("hTOFSDigits", "Number of TOF SDigits ",301, -1.02, 5.) ; h0->Sumw2() ;
124 Add2SDigitsList(h0, 0) ;
126 TH1F * h1 = new TH1F("hTOFSDigitsTime", "SDigits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
128 Add2SDigitsList(h1, 1) ;
130 TH2F * h2 = new TH2F("hTOFSDigitsClusMap","SDigits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
132 Add2SDigitsList(h2, 2) ;
136 //____________________________________________________________________________
137 void AliTOFQADataMaker::InitRaws()
140 // create Raws histograms in Raws subdir
142 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ; h0->Sumw2() ;
143 Add2RawsList(h0, 0) ;
145 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
147 Add2RawsList(h1, 1) ;
149 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
151 Add2RawsList(h2, 2) ;
153 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
155 Add2RawsList(h3, 3) ;
159 //____________________________________________________________________________
160 void AliTOFQADataMaker::InitRecPoints()
163 // create RecPoints histograms in RecPoints subdir
165 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ; h0->Sumw2() ;
166 Add2RecPointsList(h0, 0) ;
168 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
170 Add2RecPointsList(h1, 1) ;
172 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
174 Add2RecPointsList(h2, 2) ;
176 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
178 Add2RecPointsList(h3, 3) ;
180 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
182 Add2RecPointsList(h4, 4) ;
186 //____________________________________________________________________________
187 void AliTOFQADataMaker::InitESDs()
190 //create ESDs histograms in ESDs subdir
192 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
194 Add2ESDsList(h0, 0) ;
196 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
198 Add2ESDsList(h1, 1) ;
200 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
202 Add2ESDsList(h2, 2) ;
204 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
206 Add2ESDsList(h3, 3) ;
208 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID glag", 100, 0., 1.) ;
210 Add2ESDsList(h4, 4) ;
214 //____________________________________________________________________________
215 void AliTOFQADataMaker::MakeHits(TClonesArray * hits)
218 //make QA data from Hits
224 Int_t nentries=hits->GetEntriesFast();
226 GetHitsData(0)->Fill(-1.) ;
228 GetHitsData(0)->Fill(TMath::Log10(nentries)) ;
232 while ( (hit = dynamic_cast<AliTOFhitT0 *>(next())) ) {
234 GetHitsData(1)->Fill( hit->GetTof()*1.E9) ;//in ns
235 GetHitsData(2)->Fill( hit->GetLen()) ;//in cm
237 in[0] = hit->GetSector();
238 in[1] = hit->GetPlate();
239 in[2]= hit->GetStrip();
240 in[3]= hit->GetPadx();
241 in[4]= hit->GetPadz();
242 GetMapIndeces(in,out);
243 GetHitsData(3)->Fill( out[0],out[1]) ;//hit map
249 //____________________________________________________________________________
250 void AliTOFQADataMaker::MakeHits(TTree * hitTree)
253 // make QA data from Hit Tree
256 AliError("can't get the tree with TOF hits !");
260 TBranch * branch = hitTree->GetBranch("TOF") ;
263 AliError("TOF branch in Hit Tree not found") ;
267 TClonesArray * hits = new TClonesArray("AliTOFhitT0", 1000);
268 TClonesArray * dummy = new TClonesArray("AliTOFhitT0", 1000);
269 branch->SetAddress(&dummy);
271 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
272 branch->GetEntry(ientry) ;
273 for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
274 AliTOFhitT0 * hit = dynamic_cast<AliTOFhitT0 *> (dummy->At(ihit)) ;
275 new((*hits)[index]) AliTOFhitT0(*hit) ;
286 //____________________________________________________________________________
287 void AliTOFQADataMaker::MakeDigits(TClonesArray * digits)
290 // makes data from Digits
292 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
293 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
297 Int_t nentries=digits->GetEntriesFast();
299 GetDigitsData(0)->Fill(-1.) ;
301 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
305 AliTOFdigit * digit ;
306 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
308 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
309 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
311 in[0] = digit->GetSector();
312 in[1] = digit->GetPlate();
313 in[2] = digit->GetStrip();
314 in[3] = digit->GetPadx();
315 in[4]= digit->GetPadz();
316 GetMapIndeces(in,out);
317 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
323 //____________________________________________________________________________
324 void AliTOFQADataMaker::MakeDigits(TTree * digitTree)
327 // makes data from Digit Tree
329 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
331 TBranch * branch = digitTree->GetBranch("TOF") ;
333 AliError("TOF branch in Digit Tree not found") ;
336 branch->SetAddress(&digits) ;
337 branch->GetEntry(0) ;
341 //____________________________________________________________________________
342 void AliTOFQADataMaker::MakeSDigits(TClonesArray * sdigits)
345 // makes data from SDigits
348 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
352 Int_t nentries=sdigits->GetEntriesFast();
354 GetSDigitsData(0)->Fill(-1.) ;
356 GetSDigitsData(0)->Fill(TMath::Log10(nentries)) ;
359 TIter next(sdigits) ;
360 AliTOFSDigit * sdigit ;
361 while ( (sdigit = dynamic_cast<AliTOFSDigit *>(next())) ) {
363 for(Int_t i=0;i<sdigit->GetNDigits();i++){
364 GetSDigitsData(1)->Fill( sdigit->GetTdc(i)*tdc2ns) ;//in ns
367 in[0] = sdigit->GetSector();
368 in[1] = sdigit->GetPlate();
369 in[2] = sdigit->GetStrip();
370 in[3] = sdigit->GetPadx();
371 in[4]= sdigit->GetPadz();
372 GetMapIndeces(in,out);
373 GetSDigitsData(2)->Fill( out[0],out[1]) ;//sdigit map
377 //____________________________________________________________________________
378 void AliTOFQADataMaker::MakeSDigits(TTree * sdigitTree)
381 // makes data from SDigit Tree
383 TClonesArray * sdigits = new TClonesArray("AliTOFSDigit", 1000) ;
385 TBranch * branch = sdigitTree->GetBranch("TOF") ;
387 AliError("TOF branch in SDigit Tree not found") ;
390 branch->SetAddress(&sdigits) ;
391 branch->GetEntry(0) ;
392 MakeSDigits(sdigits) ;
395 //____________________________________________________________________________
396 void AliTOFQADataMaker::MakeRaws(AliRawReader* rawReader)
399 // makes data from Raws
402 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
403 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
410 TClonesArray * clonesRawData;
411 AliTOFRawStream tofInput(rawReader);
412 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
414 tofInput.LoadRawData(iDDL);
415 clonesRawData = (TClonesArray*)tofInput.GetRawData();
416 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
417 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
418 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
420 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
421 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
423 tofInput.EquipmentId2VolumeId(iDDL,
424 tofRawDatum->GetTRM(),
425 tofRawDatum->GetTRMchain(),
426 tofRawDatum->GetTDC(),
427 tofRawDatum->GetTDCchannel(),
430 GetMapIndeces(in,out);
431 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
435 clonesRawData->Clear();
441 GetRawsData(0)->Fill(-1.) ;
443 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
447 //____________________________________________________________________________
448 void AliTOFQADataMaker::MakeRecPoints(TTree * clustersTree)
451 // Make data from Clusters
454 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
455 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
460 TBranch *branch=clustersTree->GetBranch("TOF");
462 AliError("can't get the branch with the TOF clusters !");
466 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
467 branch->SetAddress(&clusters);
470 clustersTree->GetEvent(0);
472 Int_t nentries=clusters->GetEntriesFast();
474 GetRecPointsData(0)->Fill(-1.) ;
476 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
479 TIter next(clusters) ;
481 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
482 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
483 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
484 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
486 in[0] = c->GetDetInd(0);
487 in[1] = c->GetDetInd(1);
488 in[2] = c->GetDetInd(2);
489 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
490 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
492 GetMapIndeces(in,out);
493 GetRecPointsData(4)->Fill(out[0],out[1]);
498 //____________________________________________________________________________
499 void AliTOFQADataMaker::MakeESDs(AliESDEvent * esd)
502 // make QA data from ESDs
504 Int_t ntrk = esd->GetNumberOfTracks() ;
508 AliESDtrack *track=esd->GetTrack(ntrk);
509 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
510 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
511 Double_t tofToT=track->GetTOFsignalToT(); //in ns
512 if(!(tofTime>0))continue;
514 GetESDsData(1)->Fill(tofTime);
515 GetESDsData(2)->Fill(tofTimeRaw);
516 GetESDsData(3)->Fill(tofToT);
517 //check how many tracks where ESD PID is ok
518 UInt_t status=track->GetStatus();
519 if (((status&AliESDtrack::kESDpid)==0) ||
520 ((status&AliESDtrack::kTOFpid)==0)) continue;
526 GetESDsData(0)->Fill(-1.) ;
528 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
531 if(ntof>0)GetESDsData(4)->Fill(ntofpid/ntof) ;
535 //____________________________________________________________________________
536 void AliTOFQADataMaker::StartOfDetectorCycle()
539 //Detector specific actions at start of cycle
543 //____________________________________________________________________________
544 void AliTOFQADataMaker::GetMapIndeces(Int_t* in , Int_t* out)
547 //return appropriate indeces for the theta-phi map
550 Int_t npadX = AliTOFGeometry::NpadX();
551 Int_t npadZ = AliTOFGeometry::NpadZ();
552 Int_t nStripA = AliTOFGeometry::NStripA();
553 Int_t nStripB = AliTOFGeometry::NStripB();
554 Int_t nStripC = AliTOFGeometry::NStripC();
556 Int_t isector = in[0];
557 Int_t iplate = in[1];
558 Int_t istrip = in[2];
562 Int_t stripOffset = 0;
568 stripOffset = nStripC;
571 stripOffset = nStripC+nStripB;
574 stripOffset = nStripC+nStripB+nStripA;
577 stripOffset = nStripC+nStripB+nStripA+nStripB;
580 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
583 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
584 Int_t phiindex=npadX*isector+ipadX+1;