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"
42 ClassImp(AliTOFQADataMakerRec)
44 //____________________________________________________________________________
45 AliTOFQADataMakerRec::AliTOFQADataMakerRec() :
46 AliQADataMakerRec(AliQA::GetDetName(AliQA::kTOF), "TOF Quality Assurance Data Maker")
53 //____________________________________________________________________________
54 AliTOFQADataMakerRec::AliTOFQADataMakerRec(const AliTOFQADataMakerRec& qadm) :
60 SetName((const char*)qadm.GetName()) ;
61 SetTitle((const char*)qadm.GetTitle());
64 //__________________________________________________________________
65 AliTOFQADataMakerRec& AliTOFQADataMakerRec::operator = (const AliTOFQADataMakerRec& qadm )
68 // assignment operator.
70 this->~AliTOFQADataMakerRec();
71 new(this) AliTOFQADataMakerRec(qadm);
75 //____________________________________________________________________________
76 void AliTOFQADataMakerRec::InitRaws()
79 // create Raws histograms in Raws subdir
81 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ; h0->Sumw2() ;
84 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
88 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
92 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
98 //____________________________________________________________________________
99 void AliTOFQADataMakerRec::InitRecPoints()
102 // create RecPoints histograms in RecPoints subdir
104 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ; h0->Sumw2() ;
105 Add2RecPointsList(h0, 0) ;
107 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
109 Add2RecPointsList(h1, 1) ;
111 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
113 Add2RecPointsList(h2, 2) ;
115 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
117 Add2RecPointsList(h3, 3) ;
119 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
121 Add2RecPointsList(h4, 4) ;
125 //____________________________________________________________________________
126 void AliTOFQADataMakerRec::InitESDs()
129 //create ESDs histograms in ESDs subdir
131 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
133 Add2ESDsList(h0, 0) ;
135 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
137 Add2ESDsList(h1, 1) ;
139 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
141 Add2ESDsList(h2, 2) ;
143 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
145 Add2ESDsList(h3, 3) ;
147 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID glag", 100, 0., 1.) ;
149 Add2ESDsList(h4, 4) ;
152 //____________________________________________________________________________
153 void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
156 // makes data from Raws
159 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
160 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
167 TClonesArray * clonesRawData;
168 AliTOFRawStream tofInput(rawReader);
169 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
171 tofInput.LoadRawData(iDDL);
172 clonesRawData = (TClonesArray*)tofInput.GetRawData();
173 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
174 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
175 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
177 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
178 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
180 tofInput.EquipmentId2VolumeId(iDDL,
181 tofRawDatum->GetTRM(),
182 tofRawDatum->GetTRMchain(),
183 tofRawDatum->GetTDC(),
184 tofRawDatum->GetTDCchannel(),
187 GetMapIndeces(in,out);
188 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
192 clonesRawData->Clear();
198 GetRawsData(0)->Fill(-1.) ;
200 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
204 //____________________________________________________________________________
205 void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
208 // Make data from Clusters
211 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
212 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
217 TBranch *branch=clustersTree->GetBranch("TOF");
219 AliError("can't get the branch with the TOF clusters !");
223 static TClonesArray dummy("AliTOFcluster",10000);
225 TClonesArray *clusters=&dummy;
226 branch->SetAddress(&clusters);
229 clustersTree->GetEvent(0);
231 Int_t nentries=clusters->GetEntriesFast();
233 GetRecPointsData(0)->Fill(-1.) ;
235 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
238 TIter next(clusters) ;
240 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
241 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
242 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
243 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
245 in[0] = c->GetDetInd(0);
246 in[1] = c->GetDetInd(1);
247 in[2] = c->GetDetInd(2);
248 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
249 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
251 GetMapIndeces(in,out);
252 GetRecPointsData(4)->Fill(out[0],out[1]);
257 //____________________________________________________________________________
258 void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
261 // make QA data from ESDs
263 Int_t ntrk = esd->GetNumberOfTracks() ;
267 AliESDtrack *track=esd->GetTrack(ntrk);
268 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
269 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
270 Double_t tofToT=track->GetTOFsignalToT(); //in ns
271 if(!(tofTime>0))continue;
273 GetESDsData(1)->Fill(tofTime);
274 GetESDsData(2)->Fill(tofTimeRaw);
275 GetESDsData(3)->Fill(tofToT);
276 //check how many tracks where ESD PID is ok
277 UInt_t status=track->GetStatus();
278 if (((status&AliESDtrack::kESDpid)==0) ||
279 ((status&AliESDtrack::kTOFpid)==0)) continue;
285 GetESDsData(0)->Fill(-1.) ;
287 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
290 if(ntof>0)GetESDsData(4)->Fill(ntofpid/ntof) ;
294 //____________________________________________________________________________
295 void AliTOFQADataMakerRec::StartOfDetectorCycle()
298 //Detector specific actions at start of cycle
302 //____________________________________________________________________________
303 void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray * list)
305 //Detector specific actions at end of cycle
306 // do the QA checking
308 AliQAChecker::Instance()->Run(AliQA::kTOF, task, list) ;
310 //____________________________________________________________________________
311 void AliTOFQADataMakerRec::GetMapIndeces(Int_t* in , Int_t* out)
314 //return appropriate indeces for the theta-phi map
317 Int_t npadX = AliTOFGeometry::NpadX();
318 Int_t npadZ = AliTOFGeometry::NpadZ();
319 Int_t nStripA = AliTOFGeometry::NStripA();
320 Int_t nStripB = AliTOFGeometry::NStripB();
321 Int_t nStripC = AliTOFGeometry::NStripC();
323 Int_t isector = in[0];
324 Int_t iplate = in[1];
325 Int_t istrip = in[2];
329 Int_t stripOffset = 0;
335 stripOffset = nStripC;
338 stripOffset = nStripC+nStripB;
341 stripOffset = nStripC+nStripB+nStripA;
344 stripOffset = nStripC+nStripB+nStripA+nStripB;
347 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
350 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
351 Int_t phiindex=npadX*isector+ipadX+1;