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>
31 #include "AliESDEvent.h"
32 #include "AliESDtrack.h"
33 #include "AliQAChecker.h"
34 #include "AliRawReader.h"
36 #include "AliTOFcluster.h"
37 #include "AliTOFQADataMakerRec.h"
38 #include "AliTOFRawStream.h"
39 #include "AliTOFrawData.h"
40 #include "AliTOFGeometry.h"
41 #include "AliTOFdigit.h"
43 ClassImp(AliTOFQADataMakerRec)
45 //____________________________________________________________________________
46 AliTOFQADataMakerRec::AliTOFQADataMakerRec() :
47 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTOF), "TOF Quality Assurance Data Maker")
54 //____________________________________________________________________________
55 AliTOFQADataMakerRec::AliTOFQADataMakerRec(const AliTOFQADataMakerRec& qadm) :
61 SetName((const char*)qadm.GetName()) ;
62 SetTitle((const char*)qadm.GetTitle());
65 //__________________________________________________________________
66 AliTOFQADataMakerRec& AliTOFQADataMakerRec::operator = (const AliTOFQADataMakerRec& qadm )
69 // assignment operator.
71 this->~AliTOFQADataMakerRec();
72 new(this) AliTOFQADataMakerRec(qadm);
76 //____________________________________________________________________________
77 void AliTOFQADataMakerRec::InitRaws()
80 // create Raws histograms in Raws subdir
83 const Bool_t expert = kTRUE ;
84 const Bool_t saveCorr = kTRUE ;
85 const Bool_t image = kTRUE ;
87 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ;
89 h0->GetXaxis()->SetTitle("TOF raw number [10 power]");
90 Add2RawsList(h0, 0, !expert, image, !saveCorr) ;
92 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
94 h1->GetXaxis()->SetTitle("Measured TOF time [ns]");
95 Add2RawsList(h1, 1, !expert, image, !saveCorr) ;
97 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
99 h2->GetXaxis()->SetTitle("Measured TOT [ns]");
100 h2->GetYaxis()->SetTitle("Measured TOF time [ns]");
101 Add2RawsList(h2, 2, !expert, image, !saveCorr) ;
103 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
105 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
106 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
107 h3->GetYaxis()->SetTitleOffset(1.15);
108 Add2RawsList(h3, 3, !expert, image, !saveCorr) ;
112 //____________________________________________________________________________
113 void AliTOFQADataMakerRec::InitDigits()
116 // create Digits histograms in Digits subdir
119 const Bool_t expert = kTRUE ;
120 const Bool_t image = kTRUE ;
122 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits ",301, -1.02, 5.) ;
124 h0->GetXaxis()->SetTitle("TOF digit number [10 power]");
125 Add2DigitsList(h0, 0, !expert, image) ;
127 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
129 h1->GetXaxis()->SetTitle("Digitized TOF time [ns]");
130 Add2DigitsList(h1, 1, !expert, image) ;
132 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ;
134 h2->GetYaxis()->SetTitle("Digitized TOF time [ns]");
135 Add2DigitsList(h2, 2, !expert, image) ;
137 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
139 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
140 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
141 h3->GetYaxis()->SetTitleOffset(1.15);
142 Add2DigitsList(h3, 3, !expert, image) ;
146 //____________________________________________________________________________
147 void AliTOFQADataMakerRec::InitRecPoints()
150 // create RecPoints histograms in RecPoints subdir
153 const Bool_t expert = kTRUE ;
154 const Bool_t image = kTRUE ;
156 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ;
158 h0->GetXaxis()->SetTitle("TOF recPoint number [10 power]");
159 Add2RecPointsList(h0, 0, !expert, image) ;
161 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
163 h1->GetXaxis()->SetTitle("Calibrated TOF time [ns]");
164 Add2RecPointsList(h1, 1, !expert, image) ;
166 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
168 h2->GetXaxis()->SetTitle("Measured TOT [ns]");
169 h2->GetYaxis()->SetTitle("Measured TOF time [ns]");
170 Add2RecPointsList(h2, 2, !expert, image) ;
172 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
174 h3->GetXaxis()->SetTitle("Measured TOT [ns]");
175 Add2RecPointsList(h3, 3, !expert, image) ;
177 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta",183, -0.5, 182.5,865,-0.5,864.5) ;
179 h4->GetXaxis()->SetTitle("2*strip+padz (eta)");
180 h4->GetYaxis()->SetTitle("48*sector+padx (phi)");
181 h4->GetYaxis()->SetTitleOffset(1.15);
182 Add2RecPointsList(h4, 4, !expert, image) ;
186 //____________________________________________________________________________
187 void AliTOFQADataMakerRec::InitESDs()
190 //create ESDs histograms in ESDs subdir
193 const Bool_t expert = kTRUE ;
194 const Bool_t image = kTRUE ;
195 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
197 h0->GetXaxis()->SetTitle("Number of TOF matched ESD tracks [10 power]");
198 Add2ESDsList(h0, 0, !expert, image) ;
200 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
202 h1->GetXaxis()->SetTitle("Calibrated TOF time [ns]");
203 Add2ESDsList(h1, 1, !expert, image) ;
205 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
207 h2->GetXaxis()->SetTitle("Measured TOF time [ns]");
208 Add2ESDsList(h2, 2, !expert, image) ;
210 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
212 h3->GetXaxis()->SetTitle("Measured TOT [ns]");
213 Add2ESDsList(h3, 3, !expert, image) ;
215 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID flag (%)", 101, 0., 101.) ;
217 h4->GetXaxis()->SetTitle("Fraction of TOF matched ESD tracks with good flag [%]");
218 Add2ESDsList(h4, 4, !expert, image) ;
221 //____________________________________________________________________________
222 void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
225 // makes data from Raws
228 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
229 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
236 TClonesArray * clonesRawData;
237 AliTOFRawStream tofInput(rawReader);
238 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
240 tofInput.LoadRawData(iDDL);
241 clonesRawData = (TClonesArray*)tofInput.GetRawData();
242 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
243 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
244 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
246 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
247 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
249 tofInput.EquipmentId2VolumeId(iDDL,
250 tofRawDatum->GetTRM(),
251 tofRawDatum->GetTRMchain(),
252 tofRawDatum->GetTDC(),
253 tofRawDatum->GetTDCchannel(),
256 GetMapIndeces(in,out);
257 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
261 clonesRawData->Clear();
267 GetRawsData(0)->Fill(-1.) ;
269 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
273 //____________________________________________________________________________
274 void AliTOFQADataMakerRec::MakeDigits(TClonesArray * digits)
277 // makes data from Digits
279 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
280 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
284 Int_t nentries=digits->GetEntriesFast();
286 GetDigitsData(0)->Fill(-1.) ;
288 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
292 AliTOFdigit * digit ;
293 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
295 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
296 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
298 in[0] = digit->GetSector();
299 in[1] = digit->GetPlate();
300 in[2] = digit->GetStrip();
301 in[3] = digit->GetPadx();
302 in[4]= digit->GetPadz();
303 GetMapIndeces(in,out);
304 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
309 //____________________________________________________________________________
310 void AliTOFQADataMakerRec::MakeDigits(TTree * digitTree)
313 // makes data from Digit Tree
315 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
317 TBranch * branch = digitTree->GetBranch("TOF") ;
319 AliError("TOF branch in Digit Tree not found") ;
322 branch->SetAddress(&digits) ;
323 branch->GetEntry(0) ;
327 //____________________________________________________________________________
328 void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
331 // Make data from Clusters
334 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
335 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
340 TBranch *branch=clustersTree->GetBranch("TOF");
342 AliError("can't get the branch with the TOF clusters !");
346 static TClonesArray dummy("AliTOFcluster",10000);
348 TClonesArray *clusters=&dummy;
349 branch->SetAddress(&clusters);
352 clustersTree->GetEvent(0);
354 Int_t nentries=clusters->GetEntriesFast();
356 GetRecPointsData(0)->Fill(-1.) ;
358 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
361 TIter next(clusters) ;
363 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
364 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
365 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
366 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
368 in[0] = c->GetDetInd(0);
369 in[1] = c->GetDetInd(1);
370 in[2] = c->GetDetInd(2);
371 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
372 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
374 GetMapIndeces(in,out);
375 GetRecPointsData(4)->Fill(out[0],out[1]);
380 //____________________________________________________________________________
381 void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
384 // make QA data from ESDs
386 Int_t ntrk = esd->GetNumberOfTracks() ;
390 AliESDtrack *track=esd->GetTrack(ntrk);
391 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
392 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
393 Double_t tofToT=track->GetTOFsignalToT(); //in ns
394 if(!(tofTime>0))continue;
396 GetESDsData(1)->Fill(tofTime);
397 GetESDsData(2)->Fill(tofTimeRaw);
398 GetESDsData(3)->Fill(tofToT);
399 //check how many tracks where ESD PID is ok
400 UInt_t status=track->GetStatus();
401 if (((status&AliESDtrack::kESDpid)==0) ||
402 ((status&AliESDtrack::kTOFpid)==0)) continue;
408 GetESDsData(0)->Fill(-1.) ;
410 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
414 Float_t ratio = (Float_t)ntofpid/(Float_t)ntof*100.;
415 GetESDsData(4)->Fill(ratio) ;
420 //____________________________________________________________________________
421 void AliTOFQADataMakerRec::StartOfDetectorCycle()
424 //Detector specific actions at start of cycle
428 //____________________________________________________________________________
429 void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
431 //Detector specific actions at end of cycle
432 // do the QA checking
434 AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;
436 //____________________________________________________________________________
437 void AliTOFQADataMakerRec::GetMapIndeces(Int_t* in , Int_t* out)
440 //return appropriate indeces for the theta-phi map
443 Int_t npadX = AliTOFGeometry::NpadX();
444 Int_t npadZ = AliTOFGeometry::NpadZ();
445 Int_t nStripA = AliTOFGeometry::NStripA();
446 Int_t nStripB = AliTOFGeometry::NStripB();
447 Int_t nStripC = AliTOFGeometry::NStripC();
449 Int_t isector = in[0];
450 Int_t iplate = in[1];
451 Int_t istrip = in[2];
455 Int_t stripOffset = 0;
461 stripOffset = nStripC;
464 stripOffset = nStripC+nStripB;
467 stripOffset = nStripC+nStripB+nStripA;
470 stripOffset = nStripC+nStripB+nStripA+nStripB;
473 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
476 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
477 Int_t phiindex=npadX*isector+ipadX+1;