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(AliQAv1::GetDetName(AliQAv1::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 phi-eta",183, -0.5, 182.5,865,-0.5,864.5) ;
127 h4->GetXaxis()->SetTitle("2*strip+padz (eta)");
128 h4->GetYaxis()->SetTitle("48*sector+padx (phi)");
130 Add2RecPointsList(h4, 4, expert) ;
134 //____________________________________________________________________________
135 void AliTOFQADataMakerRec::InitESDs()
138 //create ESDs histograms in ESDs subdir
141 Bool_t expert = kFALSE;
143 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
145 Add2ESDsList(h0, 0, expert) ;
147 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
149 Add2ESDsList(h1, 1, expert) ;
151 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
153 Add2ESDsList(h2, 2, expert) ;
155 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
157 Add2ESDsList(h3, 3, expert) ;
159 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID flag (%)", 101, 0., 101.) ;
161 Add2ESDsList(h4, 4, expert) ;
164 //____________________________________________________________________________
165 void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
168 // makes data from Raws
171 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
172 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
179 TClonesArray * clonesRawData;
180 AliTOFRawStream tofInput(rawReader);
181 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
183 tofInput.LoadRawData(iDDL);
184 clonesRawData = (TClonesArray*)tofInput.GetRawData();
185 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
186 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
187 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
189 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
190 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
192 tofInput.EquipmentId2VolumeId(iDDL,
193 tofRawDatum->GetTRM(),
194 tofRawDatum->GetTRMchain(),
195 tofRawDatum->GetTDC(),
196 tofRawDatum->GetTDCchannel(),
199 GetMapIndeces(in,out);
200 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
204 clonesRawData->Clear();
210 GetRawsData(0)->Fill(-1.) ;
212 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
216 //____________________________________________________________________________
217 void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
220 // Make data from Clusters
223 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
224 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
229 TBranch *branch=clustersTree->GetBranch("TOF");
231 AliError("can't get the branch with the TOF clusters !");
235 static TClonesArray dummy("AliTOFcluster",10000);
237 TClonesArray *clusters=&dummy;
238 branch->SetAddress(&clusters);
241 clustersTree->GetEvent(0);
243 Int_t nentries=clusters->GetEntriesFast();
245 GetRecPointsData(0)->Fill(-1.) ;
247 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
250 TIter next(clusters) ;
252 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
253 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
254 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
255 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
257 in[0] = c->GetDetInd(0);
258 in[1] = c->GetDetInd(1);
259 in[2] = c->GetDetInd(2);
260 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
261 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
263 GetMapIndeces(in,out);
264 GetRecPointsData(4)->Fill(out[0],out[1]);
269 //____________________________________________________________________________
270 void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
273 // make QA data from ESDs
275 Int_t ntrk = esd->GetNumberOfTracks() ;
279 AliESDtrack *track=esd->GetTrack(ntrk);
280 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
281 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
282 Double_t tofToT=track->GetTOFsignalToT(); //in ns
283 if(!(tofTime>0))continue;
285 GetESDsData(1)->Fill(tofTime);
286 GetESDsData(2)->Fill(tofTimeRaw);
287 GetESDsData(3)->Fill(tofToT);
288 //check how many tracks where ESD PID is ok
289 UInt_t status=track->GetStatus();
290 if (((status&AliESDtrack::kESDpid)==0) ||
291 ((status&AliESDtrack::kTOFpid)==0)) continue;
297 GetESDsData(0)->Fill(-1.) ;
299 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
302 Float_t ratio = (Float_t)ntofpid/(Float_t)ntof*100.;
303 if(ntof>0)GetESDsData(4)->Fill(ratio) ;
307 //____________________________________________________________________________
308 void AliTOFQADataMakerRec::StartOfDetectorCycle()
311 //Detector specific actions at start of cycle
315 //____________________________________________________________________________
316 void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
318 //Detector specific actions at end of cycle
319 // do the QA checking
321 AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;
323 //____________________________________________________________________________
324 void AliTOFQADataMakerRec::GetMapIndeces(Int_t* in , Int_t* out)
327 //return appropriate indeces for the theta-phi map
330 Int_t npadX = AliTOFGeometry::NpadX();
331 Int_t npadZ = AliTOFGeometry::NpadZ();
332 Int_t nStripA = AliTOFGeometry::NStripA();
333 Int_t nStripB = AliTOFGeometry::NStripB();
334 Int_t nStripC = AliTOFGeometry::NStripC();
336 Int_t isector = in[0];
337 Int_t iplate = in[1];
338 Int_t istrip = in[2];
342 Int_t stripOffset = 0;
348 stripOffset = nStripC;
351 stripOffset = nStripC+nStripB;
354 stripOffset = nStripC+nStripB+nStripA;
357 stripOffset = nStripC+nStripB+nStripA+nStripB;
360 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
363 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
364 Int_t phiindex=npadX*isector+ipadX+1;