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