add un-use functionality to clusters
[u/mrichter/AliRoot.git] / TOF / AliTOFQADataMakerRec.cxx
CommitLineData
04236e67 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16///////////////////////////////////////////////////////////////////////
17// //
18// Produces the data needed to calculate the TOF quality assurance. //
19// QA objects are 1 & 2 Dimensional histograms. //
20// author: S.Arcelli //
21// //
22///////////////////////////////////////////////////////////////////////
23
24#include <TClonesArray.h>
5c7c93fa 25//#include <TFile.h>
26//#include <TH1I.h>
04236e67 27#include <TH1F.h>
28#include <TH2F.h>
5c7c93fa 29
30#include "AliLog.h"
04236e67 31#include "AliESDEvent.h"
32#include "AliESDtrack.h"
04236e67 33#include "AliQAChecker.h"
34#include "AliRawReader.h"
5c7c93fa 35
36#include "AliTOFcluster.h"
37#include "AliTOFQADataMakerRec.h"
04236e67 38#include "AliTOFRawStream.h"
39#include "AliTOFrawData.h"
5c7c93fa 40#include "AliTOFGeometry.h"
04236e67 41
42ClassImp(AliTOFQADataMakerRec)
43
44//____________________________________________________________________________
45 AliTOFQADataMakerRec::AliTOFQADataMakerRec() :
4e25ac79 46 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTOF), "TOF Quality Assurance Data Maker")
04236e67 47{
48 //
49 // ctor
50 //
51}
52
53//____________________________________________________________________________
54AliTOFQADataMakerRec::AliTOFQADataMakerRec(const AliTOFQADataMakerRec& qadm) :
55 AliQADataMakerRec()
56{
57 //
58 //copy ctor
59 //
60 SetName((const char*)qadm.GetName()) ;
61 SetTitle((const char*)qadm.GetTitle());
62}
63
64//__________________________________________________________________
65AliTOFQADataMakerRec& AliTOFQADataMakerRec::operator = (const AliTOFQADataMakerRec& qadm )
66{
67 //
68 // assignment operator.
69 //
70 this->~AliTOFQADataMakerRec();
71 new(this) AliTOFQADataMakerRec(qadm);
72 return *this;
73}
74
75//____________________________________________________________________________
76void AliTOFQADataMakerRec::InitRaws()
77{
78 //
79 // create Raws histograms in Raws subdir
80 //
135306ea 81
7d297381 82 const Bool_t expert = kTRUE ;
83 const Bool_t saveCorr = kTRUE ;
84 const Bool_t image = kTRUE ;
85
5561a41b 86 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ;
87 h0->Sumw2() ;
88 h0->GetXaxis()->SetTitle("TOF raw number [10 power]");
7d297381 89 Add2RawsList(h0, 0, !expert, image, !saveCorr) ;
04236e67 90
91 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
92 h1->Sumw2() ;
5561a41b 93 h1->GetXaxis()->SetTitle("Measured TOF time [ns]");
7d297381 94 Add2RawsList(h1, 1, !expert, image, !saveCorr) ;
04236e67 95
96 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
97 h2->Sumw2() ;
5561a41b 98 h2->GetXaxis()->SetTitle("Measured TOT [ns]");
99 h2->GetYaxis()->SetTitle("Measured TOF time [ns]");
7d297381 100 Add2RawsList(h2, 2, !expert, image, !saveCorr) ;
04236e67 101
102 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
103 h3->Sumw2() ;
5561a41b 104 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
105 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
106 h3->GetYaxis()->SetTitleOffset(1.15);
7d297381 107 Add2RawsList(h3, 3, !expert, image, !saveCorr) ;
04236e67 108
109}
110
111//____________________________________________________________________________
112void AliTOFQADataMakerRec::InitRecPoints()
113{
114 //
115 // create RecPoints histograms in RecPoints subdir
116 //
135306ea 117
7d297381 118 const Bool_t expert = kTRUE ;
119 const Bool_t image = kTRUE ;
120
5561a41b 121 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ;
122 h0->Sumw2() ;
123 h0->GetXaxis()->SetTitle("TOF recPoint number [10 power]");
7d297381 124 Add2RecPointsList(h0, 0, !expert, image) ;
04236e67 125
126 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
127 h1->Sumw2() ;
5561a41b 128 h1->GetXaxis()->SetTitle("Calibrated TOF time [ns]");
7d297381 129 Add2RecPointsList(h1, 1, !expert, image) ;
04236e67 130
131 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
132 h2->Sumw2() ;
5561a41b 133 h2->GetXaxis()->SetTitle("Measured TOT [ns]");
134 h2->GetYaxis()->SetTitle("Measured TOF time [ns]");
7d297381 135 Add2RecPointsList(h2, 2, !expert, image) ;
04236e67 136
137 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
138 h3->Sumw2() ;
5561a41b 139 h3->GetXaxis()->SetTitle("Measured TOT [ns]");
7d297381 140 Add2RecPointsList(h3, 3, !expert, image) ;
04236e67 141
0ea3c44e 142 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta",183, -0.5, 182.5,865,-0.5,864.5) ;
04236e67 143 h4->Sumw2() ;
0ea3c44e 144 h4->GetXaxis()->SetTitle("2*strip+padz (eta)");
145 h4->GetYaxis()->SetTitle("48*sector+padx (phi)");
5561a41b 146 h4->GetYaxis()->SetTitleOffset(1.15);
7d297381 147 Add2RecPointsList(h4, 4, !expert, image) ;
04236e67 148
149}
150
151//____________________________________________________________________________
152void AliTOFQADataMakerRec::InitESDs()
153{
154 //
155 //create ESDs histograms in ESDs subdir
156 //
135306ea 157
7d297381 158 const Bool_t expert = kTRUE ;
159 const Bool_t image = kTRUE ;
04236e67 160 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
161 h0->Sumw2() ;
5561a41b 162 h0->GetXaxis()->SetTitle("Number of TOF matched ESD tracks [10 power]");
7d297381 163 Add2ESDsList(h0, 0, !expert, image) ;
04236e67 164
165 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
166 h1->Sumw2() ;
5561a41b 167 h1->GetXaxis()->SetTitle("Calibrated TOF time [ns]");
7d297381 168 Add2ESDsList(h1, 1, !expert, image) ;
04236e67 169
170 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
171 h2->Sumw2() ;
5561a41b 172 h2->GetXaxis()->SetTitle("Measured TOF time [ns]");
7d297381 173 Add2ESDsList(h2, 2, !expert, image) ;
04236e67 174
175 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
176 h3->Sumw2() ;
5561a41b 177 h3->GetXaxis()->SetTitle("Measured TOT [ns]");
7d297381 178 Add2ESDsList(h3, 3, !expert, image) ;
04236e67 179
0ea3c44e 180 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID flag (%)", 101, 0., 101.) ;
04236e67 181 h4->Sumw2() ;
5561a41b 182 h4->GetXaxis()->SetTitle("Fraction of TOF matched ESD tracks with good flag [%]");
7d297381 183 Add2ESDsList(h4, 4, !expert, image) ;
04236e67 184}
185
186//____________________________________________________________________________
187void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
188{
189 //
190 // makes data from Raws
191 //
192
193 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
194 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
195
196
197 Int_t ntof = 0 ;
198 Int_t in[5];
199 Int_t out[5];
200
201 TClonesArray * clonesRawData;
202 AliTOFRawStream tofInput(rawReader);
203 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
204 rawReader->Reset();
205 tofInput.LoadRawData(iDDL);
206 clonesRawData = (TClonesArray*)tofInput.GetRawData();
207 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
208 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
209 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
210 ntof++;
211 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
212 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
213
214 tofInput.EquipmentId2VolumeId(iDDL,
215 tofRawDatum->GetTRM(),
216 tofRawDatum->GetTRMchain(),
217 tofRawDatum->GetTDC(),
218 tofRawDatum->GetTDCchannel(),
219 in);
220
221 GetMapIndeces(in,out);
222 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
223
224 } // while loop
225
226 clonesRawData->Clear();
227
228 } // DDL Loop
229
230 Int_t nentries=ntof;
231 if(nentries<=0){
232 GetRawsData(0)->Fill(-1.) ;
233 }else{
234 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
235 }
236}
237
238//____________________________________________________________________________
239void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
240{
241 //
242 // Make data from Clusters
243 //
244
245 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
246 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
247
248 Int_t in[5];
249 Int_t out[5];
250
251 TBranch *branch=clustersTree->GetBranch("TOF");
252 if (!branch) {
253 AliError("can't get the branch with the TOF clusters !");
254 return;
255 }
256
b12e6fe4 257 static TClonesArray dummy("AliTOFcluster",10000);
258 dummy.Clear();
259 TClonesArray *clusters=&dummy;
04236e67 260 branch->SetAddress(&clusters);
261
262 // Import the tree
263 clustersTree->GetEvent(0);
264
265 Int_t nentries=clusters->GetEntriesFast();
266 if(nentries<=0){
267 GetRecPointsData(0)->Fill(-1.) ;
268 }else{
269 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
270 }
271
272 TIter next(clusters) ;
273 AliTOFcluster * c ;
274 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
275 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
276 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
277 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
278
279 in[0] = c->GetDetInd(0);
280 in[1] = c->GetDetInd(1);
281 in[2] = c->GetDetInd(2);
282 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
283 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
284
285 GetMapIndeces(in,out);
286 GetRecPointsData(4)->Fill(out[0],out[1]);
287
288 }
289}
290
291//____________________________________________________________________________
292void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
293{
294 //
295 // make QA data from ESDs
296 //
297 Int_t ntrk = esd->GetNumberOfTracks() ;
298 Int_t ntof=0;
299 Int_t ntofpid=0;
300 while (ntrk--) {
301 AliESDtrack *track=esd->GetTrack(ntrk);
302 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
303 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
304 Double_t tofToT=track->GetTOFsignalToT(); //in ns
305 if(!(tofTime>0))continue;
306 ntof++;
307 GetESDsData(1)->Fill(tofTime);
308 GetESDsData(2)->Fill(tofTimeRaw);
309 GetESDsData(3)->Fill(tofToT);
310 //check how many tracks where ESD PID is ok
311 UInt_t status=track->GetStatus();
312 if (((status&AliESDtrack::kESDpid)==0) ||
313 ((status&AliESDtrack::kTOFpid)==0)) continue;
314 ntofpid++;
315 }
316
317 Int_t nentries=ntof;
318 if(nentries<=0){
319 GetESDsData(0)->Fill(-1.) ;
320 }else{
321 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
322 }
323
0ea3c44e 324 Float_t ratio = (Float_t)ntofpid/(Float_t)ntof*100.;
325 if(ntof>0)GetESDsData(4)->Fill(ratio) ;
04236e67 326
327}
328
329//____________________________________________________________________________
330void AliTOFQADataMakerRec::StartOfDetectorCycle()
331{
332 //
333 //Detector specific actions at start of cycle
334 //to be implemented
335}
336
337//____________________________________________________________________________
4e25ac79 338void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
04236e67 339{
340 //Detector specific actions at end of cycle
341 // do the QA checking
342
4e25ac79 343 AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;
04236e67 344}
345//____________________________________________________________________________
346void AliTOFQADataMakerRec::GetMapIndeces(Int_t* in , Int_t* out)
347{
348 //
349 //return appropriate indeces for the theta-phi map
350 //
351
352 Int_t npadX = AliTOFGeometry::NpadX();
353 Int_t npadZ = AliTOFGeometry::NpadZ();
354 Int_t nStripA = AliTOFGeometry::NStripA();
355 Int_t nStripB = AliTOFGeometry::NStripB();
356 Int_t nStripC = AliTOFGeometry::NStripC();
357
358 Int_t isector = in[0];
359 Int_t iplate = in[1];
360 Int_t istrip = in[2];
361 Int_t ipadX = in[3];
362 Int_t ipadZ = in[4];
363
364 Int_t stripOffset = 0;
365 switch (iplate) {
366 case 0:
367 stripOffset = 0;
368 break;
369 case 1:
370 stripOffset = nStripC;
371 break;
372 case 2:
373 stripOffset = nStripC+nStripB;
374 break;
375 case 3:
376 stripOffset = nStripC+nStripB+nStripA;
377 break;
378 case 4:
379 stripOffset = nStripC+nStripB+nStripA+nStripB;
380 break;
381 default:
382 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
383 break;
384 };
385 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
386 Int_t phiindex=npadX*isector+ipadX+1;
387 out[0]=zindex;
388 out[1]=phiindex;
389
390}