]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFQADataMakerRec.cxx
adding Mihaela's macros to be used for the analysis train...
[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() :
46 AliQADataMakerRec(AliQA::GetDetName(AliQA::kTOF), "TOF Quality Assurance Data Maker")
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
82 Bool_t expert = kFALSE;
83
04236e67 84 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ; h0->Sumw2() ;
135306ea 85 Add2RawsList(h0, 0, expert) ;
04236e67 86
87 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
88 h1->Sumw2() ;
135306ea 89 Add2RawsList(h1, 1, expert) ;
04236e67 90
91 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
92 h2->Sumw2() ;
135306ea 93 Add2RawsList(h2, 2, expert) ;
04236e67 94
95 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
96 h3->Sumw2() ;
135306ea 97 Add2RawsList(h3, 3, expert) ;
04236e67 98
99}
100
101//____________________________________________________________________________
102void AliTOFQADataMakerRec::InitRecPoints()
103{
104 //
105 // create RecPoints histograms in RecPoints subdir
106 //
135306ea 107
108 Bool_t expert = kFALSE;
109
04236e67 110 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ; h0->Sumw2() ;
135306ea 111 Add2RecPointsList(h0, 0, expert) ;
04236e67 112
113 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
114 h1->Sumw2() ;
135306ea 115 Add2RecPointsList(h1, 1, expert) ;
04236e67 116
117 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
118 h2->Sumw2() ;
135306ea 119 Add2RecPointsList(h2, 2, expert) ;
04236e67 120
121 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
122 h3->Sumw2() ;
135306ea 123 Add2RecPointsList(h3, 3, expert) ;
04236e67 124
0ea3c44e 125 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta",183, -0.5, 182.5,865,-0.5,864.5) ;
04236e67 126 h4->Sumw2() ;
0ea3c44e 127 h4->GetXaxis()->SetTitle("2*strip+padz (eta)");
128 h4->GetYaxis()->SetTitle("48*sector+padx (phi)");
129
135306ea 130 Add2RecPointsList(h4, 4, expert) ;
04236e67 131
132}
133
134//____________________________________________________________________________
135void AliTOFQADataMakerRec::InitESDs()
136{
137 //
138 //create ESDs histograms in ESDs subdir
139 //
135306ea 140
141 Bool_t expert = kFALSE;
142
04236e67 143 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
144 h0->Sumw2() ;
135306ea 145 Add2ESDsList(h0, 0, expert) ;
04236e67 146
147 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
148 h1->Sumw2() ;
135306ea 149 Add2ESDsList(h1, 1, expert) ;
04236e67 150
151 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
152 h2->Sumw2() ;
135306ea 153 Add2ESDsList(h2, 2, expert) ;
04236e67 154
155 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
156 h3->Sumw2() ;
135306ea 157 Add2ESDsList(h3, 3, expert) ;
04236e67 158
0ea3c44e 159 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID flag (%)", 101, 0., 101.) ;
04236e67 160 h4->Sumw2() ;
135306ea 161 Add2ESDsList(h4, 4, expert) ;
04236e67 162}
163
164//____________________________________________________________________________
165void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
166{
167 //
168 // makes data from Raws
169 //
170
171 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
172 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
173
174
175 Int_t ntof = 0 ;
176 Int_t in[5];
177 Int_t out[5];
178
179 TClonesArray * clonesRawData;
180 AliTOFRawStream tofInput(rawReader);
181 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
182 rawReader->Reset();
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;
188 ntof++;
189 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
190 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
191
192 tofInput.EquipmentId2VolumeId(iDDL,
193 tofRawDatum->GetTRM(),
194 tofRawDatum->GetTRMchain(),
195 tofRawDatum->GetTDC(),
196 tofRawDatum->GetTDCchannel(),
197 in);
198
199 GetMapIndeces(in,out);
200 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
201
202 } // while loop
203
204 clonesRawData->Clear();
205
206 } // DDL Loop
207
208 Int_t nentries=ntof;
209 if(nentries<=0){
210 GetRawsData(0)->Fill(-1.) ;
211 }else{
212 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
213 }
214}
215
216//____________________________________________________________________________
217void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
218{
219 //
220 // Make data from Clusters
221 //
222
223 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
224 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
225
226 Int_t in[5];
227 Int_t out[5];
228
229 TBranch *branch=clustersTree->GetBranch("TOF");
230 if (!branch) {
231 AliError("can't get the branch with the TOF clusters !");
232 return;
233 }
234
b12e6fe4 235 static TClonesArray dummy("AliTOFcluster",10000);
236 dummy.Clear();
237 TClonesArray *clusters=&dummy;
04236e67 238 branch->SetAddress(&clusters);
239
240 // Import the tree
241 clustersTree->GetEvent(0);
242
243 Int_t nentries=clusters->GetEntriesFast();
244 if(nentries<=0){
245 GetRecPointsData(0)->Fill(-1.) ;
246 }else{
247 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
248 }
249
250 TIter next(clusters) ;
251 AliTOFcluster * c ;
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);
256
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
262
263 GetMapIndeces(in,out);
264 GetRecPointsData(4)->Fill(out[0],out[1]);
265
266 }
267}
268
269//____________________________________________________________________________
270void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
271{
272 //
273 // make QA data from ESDs
274 //
275 Int_t ntrk = esd->GetNumberOfTracks() ;
276 Int_t ntof=0;
277 Int_t ntofpid=0;
278 while (ntrk--) {
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;
284 ntof++;
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;
292 ntofpid++;
293 }
294
295 Int_t nentries=ntof;
296 if(nentries<=0){
297 GetESDsData(0)->Fill(-1.) ;
298 }else{
299 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
300 }
301
0ea3c44e 302 Float_t ratio = (Float_t)ntofpid/(Float_t)ntof*100.;
303 if(ntof>0)GetESDsData(4)->Fill(ratio) ;
04236e67 304
305}
306
307//____________________________________________________________________________
308void AliTOFQADataMakerRec::StartOfDetectorCycle()
309{
310 //
311 //Detector specific actions at start of cycle
312 //to be implemented
313}
314
315//____________________________________________________________________________
57acd2d2 316void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray ** list)
04236e67 317{
318 //Detector specific actions at end of cycle
319 // do the QA checking
320
321 AliQAChecker::Instance()->Run(AliQA::kTOF, task, list) ;
322}
323//____________________________________________________________________________
324void AliTOFQADataMakerRec::GetMapIndeces(Int_t* in , Int_t* out)
325{
326 //
327 //return appropriate indeces for the theta-phi map
328 //
329
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();
335
336 Int_t isector = in[0];
337 Int_t iplate = in[1];
338 Int_t istrip = in[2];
339 Int_t ipadX = in[3];
340 Int_t ipadZ = in[4];
341
342 Int_t stripOffset = 0;
343 switch (iplate) {
344 case 0:
345 stripOffset = 0;
346 break;
347 case 1:
348 stripOffset = nStripC;
349 break;
350 case 2:
351 stripOffset = nStripC+nStripB;
352 break;
353 case 3:
354 stripOffset = nStripC+nStripB+nStripA;
355 break;
356 case 4:
357 stripOffset = nStripC+nStripB+nStripA+nStripB;
358 break;
359 default:
360 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
361 break;
362 };
363 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
364 Int_t phiindex=npadX*isector+ipadX+1;
365 out[0]=zindex;
366 out[1]=phiindex;
367
368}