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;TOF raw number [10 power];Counts ",301, -1.02, 5.) ;
89 Add2RawsList(h0, 0, !expert, image, !saveCorr) ;
91 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns);Measured TOF time [ns];Counts", 2000, 0., 200) ;
93 Add2RawsList(h1, 1, !expert, image, !saveCorr) ;
95 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns);Measured TOT time [ns];Counts", 500, 0., 50) ;
97 Add2RawsList(h2, 2, !expert, image, !saveCorr) ;
99 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi;2*strip+padz (eta);48*sector+padx (phi)",183, -0.5, 182.5,865,-0.5,864.5) ;
101 h3->GetYaxis()->SetTitleOffset(1.15);
102 Add2RawsList(h3, 3, !expert, image, !saveCorr) ;
106 //____________________________________________________________________________
107 void AliTOFQADataMakerRec::InitDigits()
110 // create Digits histograms in Digits subdir
113 const Bool_t expert = kTRUE ;
114 const Bool_t image = kTRUE ;
116 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits;TOF digit number [10 power];Counts ",301, -1.02, 5.) ;
118 Add2DigitsList(h0, 0, !expert, image) ;
120 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns);Digitized TOF time [ns];Counts", 2000, 0., 200) ;
122 Add2DigitsList(h1, 1, !expert, image) ;
124 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns);Digitized TOF time [ns];Counts", 500, 0., 50) ;
126 Add2DigitsList(h2, 2, !expert, image) ;
128 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi;2*strip+padz (eta);48*sector+padx (phi)",183, -0.5, 182.5,865,-0.5,864.5) ;
130 h3->GetYaxis()->SetTitleOffset(1.15);
131 Add2DigitsList(h3, 3, !expert, image) ;
134 //____________________________________________________________________________
135 void AliTOFQADataMakerRec::InitRecPoints()
138 // create RecPoints histograms in RecPoints subdir
141 const Bool_t expert = kTRUE ;
142 const Bool_t image = kTRUE ;
144 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints;TOF recPoint number [10 power];Counts",301, -1.02, 5.) ;
146 Add2RecPointsList(h0, 0, !expert, image) ;
148 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns);Calibrated TOF time [ns];Counts", 2000, 0., 200) ;
150 Add2RecPointsList(h1, 1, !expert, image) ;
152 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns);Measured TOF time [ns];Counts", 2000, 0., 200) ;
154 Add2RecPointsList(h2, 2, !expert, image) ;
156 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns);Measured TOT [ns];Counts", 500, 0., 50) ;
158 Add2RecPointsList(h3, 3, !expert, image) ;
160 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta;2*strip+padz (eta);48*sector+padx (phi)",183, -0.5, 182.5,865,-0.5,864.5) ;
162 h4->GetYaxis()->SetTitleOffset(1.15);
163 Add2RecPointsList(h4, 4, !expert, image) ;
166 //____________________________________________________________________________
167 void AliTOFQADataMakerRec::InitESDs()
170 //create ESDs histograms in ESDs subdir
173 const Bool_t expert = kTRUE ;
174 const Bool_t image = kTRUE ;
175 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs;Number of TOF matched ESD tracks [10 power];Counts", 250, -1., 4.) ;
177 Add2ESDsList(h0, 0, !expert, image) ;
179 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns);Calibrated TOF time [ns];Counts", 2000, 0., 200) ;
181 Add2ESDsList(h1, 1, !expert, image) ;
183 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns);Measured TOF time [ns];Counts", 2000, 0., 200) ;
185 Add2ESDsList(h2, 2, !expert, image) ;
187 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns);Measured TOF time [ns];Counts", 500, 0., 50) ;
189 Add2ESDsList(h3, 3, !expert, image) ;
191 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID flag (%);Fraction of TOF matched ESD tracks with good flag [%];Counts", 101, 0., 101.) ;
193 Add2ESDsList(h4, 4, !expert, image) ;
196 //____________________________________________________________________________
197 void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
200 // makes data from Raws
203 // Check id histograms already created for this Event Specie
204 if ( ! GetRawsData(0) )
207 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
208 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
215 TClonesArray * clonesRawData;
216 AliTOFRawStream tofInput(rawReader);
217 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
219 tofInput.LoadRawData(iDDL);
220 clonesRawData = (TClonesArray*)tofInput.GetRawData();
221 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
222 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
223 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
225 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
226 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
228 tofInput.EquipmentId2VolumeId(iDDL,
229 tofRawDatum->GetTRM(),
230 tofRawDatum->GetTRMchain(),
231 tofRawDatum->GetTDC(),
232 tofRawDatum->GetTDCchannel(),
235 GetMapIndeces(in,out);
236 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
240 clonesRawData->Clear();
246 GetRawsData(0)->Fill(-1.) ;
248 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
252 //____________________________________________________________________________
253 void AliTOFQADataMakerRec::MakeDigits(TClonesArray * digits)
256 // makes data from Digits
259 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
260 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
264 Int_t nentries=digits->GetEntriesFast();
266 GetDigitsData(0)->Fill(-1.) ;
268 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
272 AliTOFdigit * digit ;
273 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
275 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
276 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
278 in[0] = digit->GetSector();
279 in[1] = digit->GetPlate();
280 in[2] = digit->GetStrip();
281 in[3] = digit->GetPadx();
282 in[4]= digit->GetPadz();
283 GetMapIndeces(in,out);
284 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
288 //____________________________________________________________________________
289 void AliTOFQADataMakerRec::MakeDigits(TTree * digitTree)
292 // makes data from Digit Tree
294 // Check id histograms already created for this Event Specie
295 if ( ! GetDigitsData(0) )
298 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
300 TBranch * branch = digitTree->GetBranch("TOF") ;
302 AliError("TOF branch in Digit Tree not found") ;
305 branch->SetAddress(&digits) ;
306 branch->GetEntry(0) ;
310 //____________________________________________________________________________
311 void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
314 // Make data from Clusters
317 // Check id histograms already created for this Event Specie
318 if ( ! GetRecPointsData(0) )
321 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
322 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
327 TBranch *branch=clustersTree->GetBranch("TOF");
329 AliError("can't get the branch with the TOF clusters !");
333 static TClonesArray dummy("AliTOFcluster",10000);
335 TClonesArray *clusters=&dummy;
336 branch->SetAddress(&clusters);
339 clustersTree->GetEvent(0);
341 Int_t nentries=clusters->GetEntriesFast();
343 GetRecPointsData(0)->Fill(-1.) ;
345 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
348 TIter next(clusters) ;
350 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
351 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
352 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
353 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
355 in[0] = c->GetDetInd(0);
356 in[1] = c->GetDetInd(1);
357 in[2] = c->GetDetInd(2);
358 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
359 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
361 GetMapIndeces(in,out);
362 GetRecPointsData(4)->Fill(out[0],out[1]);
367 //____________________________________________________________________________
368 void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
371 // make QA data from ESDs
373 // Check id histograms already created for this Event Specie
374 if ( ! GetESDsData(0) )
377 Int_t ntrk = esd->GetNumberOfTracks() ;
381 AliESDtrack *track=esd->GetTrack(ntrk);
382 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
383 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
384 Double_t tofToT=track->GetTOFsignalToT(); //in ns
385 if(!(tofTime>0))continue;
387 GetESDsData(1)->Fill(tofTime);
388 GetESDsData(2)->Fill(tofTimeRaw);
389 GetESDsData(3)->Fill(tofToT);
390 //check how many tracks where ESD PID is ok
391 UInt_t status=track->GetStatus();
392 if (((status&AliESDtrack::kESDpid)==0) ||
393 ((status&AliESDtrack::kTOFpid)==0)) continue;
399 GetESDsData(0)->Fill(-1.) ;
401 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
405 Float_t ratio = (Float_t)ntofpid/(Float_t)ntof*100.;
406 GetESDsData(4)->Fill(ratio) ;
410 //____________________________________________________________________________
411 void AliTOFQADataMakerRec::StartOfDetectorCycle()
414 //Detector specific actions at start of cycle
418 //____________________________________________________________________________
419 void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
421 //Detector specific actions at end of cycle
422 // do the QA checking
423 AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;
425 //____________________________________________________________________________
426 void AliTOFQADataMakerRec::GetMapIndeces(Int_t* in , Int_t* out)
429 //return appropriate indeces for the theta-phi map
432 Int_t npadX = AliTOFGeometry::NpadX();
433 Int_t npadZ = AliTOFGeometry::NpadZ();
434 Int_t nStripA = AliTOFGeometry::NStripA();
435 Int_t nStripB = AliTOFGeometry::NStripB();
436 Int_t nStripC = AliTOFGeometry::NStripC();
438 Int_t isector = in[0];
439 Int_t iplate = in[1];
440 Int_t istrip = in[2];
444 Int_t stripOffset = 0;
450 stripOffset = nStripC;
453 stripOffset = nStripC+nStripB;
456 stripOffset = nStripC+nStripB+nStripA;
459 stripOffset = nStripC+nStripB+nStripA+nStripB;
462 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
465 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
466 Int_t phiindex=npadX*isector+ipadX+1;