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
82 Bool_t expert = kFALSE;
84 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ; h0->Sumw2() ;
85 Add2RawsList(h0, 0, expert) ;
87 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
89 Add2RawsList(h1, 1, expert) ;
91 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
93 Add2RawsList(h2, 2, expert) ;
95 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
97 Add2RawsList(h3, 3, expert) ;
101 //____________________________________________________________________________
102 void AliTOFQADataMakerRec::InitRecPoints()
105 // create RecPoints histograms in RecPoints subdir
108 Bool_t expert = kFALSE;
110 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ; h0->Sumw2() ;
111 Add2RecPointsList(h0, 0, expert) ;
113 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
115 Add2RecPointsList(h1, 1, expert) ;
117 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
119 Add2RecPointsList(h2, 2, expert) ;
121 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
123 Add2RecPointsList(h3, 3, expert) ;
125 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
127 Add2RecPointsList(h4, 4, expert) ;
131 //____________________________________________________________________________
132 void AliTOFQADataMakerRec::InitESDs()
135 //create ESDs histograms in ESDs subdir
138 Bool_t expert = kFALSE;
140 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
142 Add2ESDsList(h0, 0, expert) ;
144 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
146 Add2ESDsList(h1, 1, expert) ;
148 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
150 Add2ESDsList(h2, 2, expert) ;
152 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
154 Add2ESDsList(h3, 3, expert) ;
156 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID glag", 100, 0., 1.) ;
158 Add2ESDsList(h4, 4, expert) ;
161 //____________________________________________________________________________
162 void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
165 // makes data from Raws
168 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
169 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
176 TClonesArray * clonesRawData;
177 AliTOFRawStream tofInput(rawReader);
178 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
180 tofInput.LoadRawData(iDDL);
181 clonesRawData = (TClonesArray*)tofInput.GetRawData();
182 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
183 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
184 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
186 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
187 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
189 tofInput.EquipmentId2VolumeId(iDDL,
190 tofRawDatum->GetTRM(),
191 tofRawDatum->GetTRMchain(),
192 tofRawDatum->GetTDC(),
193 tofRawDatum->GetTDCchannel(),
196 GetMapIndeces(in,out);
197 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
201 clonesRawData->Clear();
207 GetRawsData(0)->Fill(-1.) ;
209 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
213 //____________________________________________________________________________
214 void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
217 // Make data from Clusters
220 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
221 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
226 TBranch *branch=clustersTree->GetBranch("TOF");
228 AliError("can't get the branch with the TOF clusters !");
232 static TClonesArray dummy("AliTOFcluster",10000);
234 TClonesArray *clusters=&dummy;
235 branch->SetAddress(&clusters);
238 clustersTree->GetEvent(0);
240 Int_t nentries=clusters->GetEntriesFast();
242 GetRecPointsData(0)->Fill(-1.) ;
244 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
247 TIter next(clusters) ;
249 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
250 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
251 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
252 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
254 in[0] = c->GetDetInd(0);
255 in[1] = c->GetDetInd(1);
256 in[2] = c->GetDetInd(2);
257 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
258 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
260 GetMapIndeces(in,out);
261 GetRecPointsData(4)->Fill(out[0],out[1]);
266 //____________________________________________________________________________
267 void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
270 // make QA data from ESDs
272 Int_t ntrk = esd->GetNumberOfTracks() ;
276 AliESDtrack *track=esd->GetTrack(ntrk);
277 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
278 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
279 Double_t tofToT=track->GetTOFsignalToT(); //in ns
280 if(!(tofTime>0))continue;
282 GetESDsData(1)->Fill(tofTime);
283 GetESDsData(2)->Fill(tofTimeRaw);
284 GetESDsData(3)->Fill(tofToT);
285 //check how many tracks where ESD PID is ok
286 UInt_t status=track->GetStatus();
287 if (((status&AliESDtrack::kESDpid)==0) ||
288 ((status&AliESDtrack::kTOFpid)==0)) continue;
294 GetESDsData(0)->Fill(-1.) ;
296 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
299 if(ntof>0)GetESDsData(4)->Fill(ntofpid/ntof) ;
303 //____________________________________________________________________________
304 void AliTOFQADataMakerRec::StartOfDetectorCycle()
307 //Detector specific actions at start of cycle
311 //____________________________________________________________________________
312 void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray ** list)
314 //Detector specific actions at end of cycle
315 // do the QA checking
317 AliQAChecker::Instance()->Run(AliQA::kTOF, task, list) ;
319 //____________________________________________________________________________
320 void AliTOFQADataMakerRec::GetMapIndeces(Int_t* in , Int_t* out)
323 //return appropriate indeces for the theta-phi map
326 Int_t npadX = AliTOFGeometry::NpadX();
327 Int_t npadZ = AliTOFGeometry::NpadZ();
328 Int_t nStripA = AliTOFGeometry::NStripA();
329 Int_t nStripB = AliTOFGeometry::NStripB();
330 Int_t nStripC = AliTOFGeometry::NStripC();
332 Int_t isector = in[0];
333 Int_t iplate = in[1];
334 Int_t istrip = in[2];
338 Int_t stripOffset = 0;
344 stripOffset = nStripC;
347 stripOffset = nStripC+nStripB;
350 stripOffset = nStripC+nStripB+nStripA;
353 stripOffset = nStripC+nStripB+nStripA+nStripB;
356 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
359 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
360 Int_t phiindex=npadX*isector+ipadX+1;