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 "AliRawReader.h"
37 #include "AliTOFRawStream.h"
38 #include "AliTOFrawData.h"
41 ClassImp(AliTOFQADataMaker)
43 //____________________________________________________________________________
44 AliTOFQADataMaker::AliTOFQADataMaker() :
45 AliQADataMaker(AliQA::GetDetName(AliQA::kTOF), "TOF Quality Assurance Data Maker")
52 //____________________________________________________________________________
53 AliTOFQADataMaker::AliTOFQADataMaker(const AliTOFQADataMaker& qadm) :
59 SetName((const char*)qadm.GetName()) ;
60 SetTitle((const char*)qadm.GetTitle());
63 //__________________________________________________________________
64 AliTOFQADataMaker& AliTOFQADataMaker::operator = (const AliTOFQADataMaker& qadm )
67 // assignment operator.
69 this->~AliTOFQADataMaker();
70 new(this) AliTOFQADataMaker(qadm);
74 //____________________________________________________________________________
75 void AliTOFQADataMaker::InitHits()
78 // create Hits histograms in Hits subdir
80 TH1F * h0 = new TH1F("hTOFHits", "Number of TOF Hits ",301, -1.02, 5.) ;
84 TH1F * h1 = new TH1F("hTOFHitsTime", "Hits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
88 TH1F * h2 = new TH1F("hTOFHitsLength", "Length Spectrum in TOF (cm)", 500, 0., 500) ;
92 TH2F * h3 = new TH2F("hTOFHitsClusMap","Hits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
97 //____________________________________________________________________________
98 void AliTOFQADataMaker::InitDigits()
101 // create Digits histograms in Digits subdir
103 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits ",301, -1.02, 5.) ; h0->Sumw2() ;
104 Add2DigitsList(h0, 0) ;
106 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
108 Add2DigitsList(h1, 1) ;
110 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ;
112 Add2DigitsList(h2, 2) ;
114 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
116 Add2DigitsList(h3, 3) ;
120 //____________________________________________________________________________
121 void AliTOFQADataMaker::InitSDigits()
124 // create SDigits histograms in SDigits subdir
126 TH1F * h0 = new TH1F("hTOFSDigits", "Number of TOF SDigits ",301, -1.02, 5.) ; h0->Sumw2() ;
127 Add2SDigitsList(h0, 0) ;
129 TH1F * h1 = new TH1F("hTOFSDigitsTime", "SDigits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
131 Add2SDigitsList(h1, 1) ;
133 TH2F * h2 = new TH2F("hTOFSDigitsClusMap","SDigits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
135 Add2SDigitsList(h2, 2) ;
139 //____________________________________________________________________________
140 void AliTOFQADataMaker::InitRaws()
143 // create Raws histograms in Raws subdir
145 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ; h0->Sumw2() ;
146 Add2RawsList(h0, 0) ;
148 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
150 Add2RawsList(h1, 1) ;
152 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
154 Add2RawsList(h2, 2) ;
156 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
158 Add2RawsList(h3, 3) ;
162 //____________________________________________________________________________
163 void AliTOFQADataMaker::InitRecPoints()
166 // create RecPoints histograms in RecPoints subdir
168 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ; h0->Sumw2() ;
169 Add2RecPointsList(h0, 0) ;
171 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
173 Add2RecPointsList(h1, 1) ;
175 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
177 Add2RecPointsList(h2, 2) ;
179 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
181 Add2RecPointsList(h3, 3) ;
183 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
185 Add2RecPointsList(h4, 4) ;
189 //____________________________________________________________________________
190 void AliTOFQADataMaker::InitESDs()
193 //create ESDs histograms in ESDs subdir
195 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
197 Add2ESDsList(h0, 0) ;
199 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
201 Add2ESDsList(h1, 1) ;
203 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
205 Add2ESDsList(h2, 2) ;
207 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
209 Add2ESDsList(h3, 3) ;
211 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID glag", 100, 0., 1.) ;
213 Add2ESDsList(h4, 4) ;
217 //____________________________________________________________________________
218 void AliTOFQADataMaker::MakeHits(TClonesArray * hits)
221 //make QA data from Hits
227 Int_t nentries=hits->GetEntriesFast();
229 GetHitsData(0)->Fill(-1.) ;
231 GetHitsData(0)->Fill(TMath::Log10(nentries)) ;
235 while ( (hit = dynamic_cast<AliTOFhitT0 *>(next())) ) {
237 GetHitsData(1)->Fill( hit->GetTof()*1.E9) ;//in ns
238 GetHitsData(2)->Fill( hit->GetLen()) ;//in cm
240 in[0] = hit->GetSector();
241 in[1] = hit->GetPlate();
242 in[2]= hit->GetStrip();
243 in[3]= hit->GetPadx();
244 in[4]= hit->GetPadz();
245 GetMapIndeces(in,out);
246 GetHitsData(3)->Fill( out[0],out[1]) ;//hit map
252 //____________________________________________________________________________
253 void AliTOFQADataMaker::MakeHits(TTree * hitTree)
256 // make QA data from Hit Tree
259 AliError("can't get the tree with TOF hits !");
263 TBranch * branch = hitTree->GetBranch("TOF") ;
266 AliError("TOF branch in Hit Tree not found") ;
270 TClonesArray * hits = new TClonesArray("AliTOFhitT0", 1000);
271 TClonesArray * dummy = new TClonesArray("AliTOFhitT0", 1000);
272 branch->SetAddress(&dummy);
274 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
275 branch->GetEntry(ientry) ;
276 for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
277 AliTOFhitT0 * hit = dynamic_cast<AliTOFhitT0 *> (dummy->At(ihit)) ;
278 new((*hits)[index]) AliTOFhitT0(*hit) ;
289 //____________________________________________________________________________
290 void AliTOFQADataMaker::MakeDigits(TClonesArray * digits)
293 // makes data from Digits
295 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
296 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
300 Int_t nentries=digits->GetEntriesFast();
302 GetDigitsData(0)->Fill(-1.) ;
304 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
308 AliTOFdigit * digit ;
309 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
311 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
312 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
314 in[0] = digit->GetSector();
315 in[1] = digit->GetPlate();
316 in[2] = digit->GetStrip();
317 in[3] = digit->GetPadx();
318 in[4]= digit->GetPadz();
319 GetMapIndeces(in,out);
320 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
326 //____________________________________________________________________________
327 void AliTOFQADataMaker::MakeDigits(TTree * digitTree)
330 // makes data from Digit Tree
332 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
334 TBranch * branch = digitTree->GetBranch("TOF") ;
336 AliError("TOF branch in Digit Tree not found") ;
339 branch->SetAddress(&digits) ;
340 branch->GetEntry(0) ;
344 //____________________________________________________________________________
345 void AliTOFQADataMaker::MakeSDigits(TClonesArray * sdigits)
348 // makes data from SDigits
351 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
355 Int_t nentries=sdigits->GetEntriesFast();
357 GetSDigitsData(0)->Fill(-1.) ;
359 GetSDigitsData(0)->Fill(TMath::Log10(nentries)) ;
362 TIter next(sdigits) ;
363 AliTOFSDigit * sdigit ;
364 while ( (sdigit = dynamic_cast<AliTOFSDigit *>(next())) ) {
366 for(Int_t i=0;i<sdigit->GetNDigits();i++){
367 GetSDigitsData(1)->Fill( sdigit->GetTdc(i)*tdc2ns) ;//in ns
370 in[0] = sdigit->GetSector();
371 in[1] = sdigit->GetPlate();
372 in[2] = sdigit->GetStrip();
373 in[3] = sdigit->GetPadx();
374 in[4]= sdigit->GetPadz();
375 GetMapIndeces(in,out);
376 GetSDigitsData(2)->Fill( out[0],out[1]) ;//sdigit map
380 //____________________________________________________________________________
381 void AliTOFQADataMaker::MakeSDigits(TTree * sdigitTree)
384 // makes data from SDigit Tree
386 TClonesArray * sdigits = new TClonesArray("AliTOFSDigit", 1000) ;
388 TBranch * branch = sdigitTree->GetBranch("TOF") ;
390 AliError("TOF branch in SDigit Tree not found") ;
393 branch->SetAddress(&sdigits) ;
394 branch->GetEntry(0) ;
395 MakeSDigits(sdigits) ;
398 //____________________________________________________________________________
399 void AliTOFQADataMaker::MakeRaws(AliRawReader* rawReader)
402 // makes data from Raws
405 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
406 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
413 TClonesArray * clonesRawData;
414 AliTOFRawStream tofInput(rawReader);
415 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
417 tofInput.LoadRawData(iDDL);
418 clonesRawData = (TClonesArray*)tofInput.GetRawData();
419 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
420 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
421 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
423 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
424 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
426 tofInput.EquipmentId2VolumeId(iDDL,
427 tofRawDatum->GetTRM(),
428 tofRawDatum->GetTRMchain(),
429 tofRawDatum->GetTDC(),
430 tofRawDatum->GetTDCchannel(),
433 GetMapIndeces(in,out);
434 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
438 clonesRawData->Clear();
444 GetRawsData(0)->Fill(-1.) ;
446 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
450 //____________________________________________________________________________
451 void AliTOFQADataMaker::MakeRecPoints(TTree * clustersTree)
454 // Make data from Clusters
457 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
458 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
463 TBranch *branch=clustersTree->GetBranch("TOF");
465 AliError("can't get the branch with the TOF clusters !");
469 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
470 branch->SetAddress(&clusters);
473 clustersTree->GetEvent(0);
475 Int_t nentries=clusters->GetEntriesFast();
477 GetRecPointsData(0)->Fill(-1.) ;
479 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
482 TIter next(clusters) ;
484 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
485 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
486 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
487 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
489 in[0] = c->GetDetInd(0);
490 in[1] = c->GetDetInd(1);
491 in[2] = c->GetDetInd(2);
492 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
493 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
495 GetMapIndeces(in,out);
496 GetRecPointsData(4)->Fill(out[0],out[1]);
501 //____________________________________________________________________________
502 void AliTOFQADataMaker::MakeESDs(AliESDEvent * esd)
505 // make QA data from ESDs
507 Int_t ntrk = esd->GetNumberOfTracks() ;
511 AliESDtrack *track=esd->GetTrack(ntrk);
512 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
513 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
514 Double_t tofToT=track->GetTOFsignalToT(); //in ns
515 if(!(tofTime>0))continue;
517 GetESDsData(1)->Fill(tofTime);
518 GetESDsData(2)->Fill(tofTimeRaw);
519 GetESDsData(3)->Fill(tofToT);
520 //check how many tracks where ESD PID is ok
521 UInt_t status=track->GetStatus();
522 if (((status&AliESDtrack::kESDpid)==0) ||
523 ((status&AliESDtrack::kTOFpid)==0)) continue;
529 GetESDsData(0)->Fill(-1.) ;
531 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
534 if(ntof>0)GetESDsData(4)->Fill(ntofpid/ntof) ;
538 //____________________________________________________________________________
539 void AliTOFQADataMaker::StartOfDetectorCycle()
542 //Detector specific actions at start of cycle
546 //____________________________________________________________________________
547 void AliTOFQADataMaker::GetMapIndeces(Int_t* in , Int_t* out)
550 //return appropriate indeces for the theta-phi map
553 Int_t npadX = AliTOFGeometry::NpadX();
554 Int_t npadZ = AliTOFGeometry::NpadZ();
555 Int_t nStripA = AliTOFGeometry::NStripA();
556 Int_t nStripB = AliTOFGeometry::NStripB();
557 Int_t nStripC = AliTOFGeometry::NStripC();
559 Int_t isector = in[0];
560 Int_t iplate = in[1];
561 Int_t istrip = in[2];
565 Int_t stripOffset = 0;
571 stripOffset = nStripC;
574 stripOffset = nStripC+nStripB;
577 stripOffset = nStripC+nStripB+nStripA;
580 stripOffset = nStripC+nStripB+nStripA+nStripB;
583 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
586 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
587 Int_t phiindex=npadX*isector+ipadX+1;