]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFQADataMakerRec.cxx
Change to extended data arrays for all MCM channels and rename GetDataB to GetDataBits
[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"
44ed7a66 41#include "AliTOFDigit.h"
04236e67 42
43ClassImp(AliTOFQADataMakerRec)
44
45//____________________________________________________________________________
46 AliTOFQADataMakerRec::AliTOFQADataMakerRec() :
4e25ac79 47 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kTOF), "TOF Quality Assurance Data Maker")
04236e67 48{
49 //
50 // ctor
51 //
52}
53
54//____________________________________________________________________________
55AliTOFQADataMakerRec::AliTOFQADataMakerRec(const AliTOFQADataMakerRec& qadm) :
56 AliQADataMakerRec()
57{
58 //
59 //copy ctor
60 //
61 SetName((const char*)qadm.GetName()) ;
62 SetTitle((const char*)qadm.GetTitle());
63}
64
65//__________________________________________________________________
66AliTOFQADataMakerRec& AliTOFQADataMakerRec::operator = (const AliTOFQADataMakerRec& qadm )
67{
68 //
69 // assignment operator.
70 //
71 this->~AliTOFQADataMakerRec();
72 new(this) AliTOFQADataMakerRec(qadm);
73 return *this;
74}
75
76//____________________________________________________________________________
77void AliTOFQADataMakerRec::InitRaws()
78{
79 //
80 // create Raws histograms in Raws subdir
81 //
135306ea 82
7d297381 83 const Bool_t expert = kTRUE ;
84 const Bool_t saveCorr = kTRUE ;
85 const Bool_t image = kTRUE ;
86
5561a41b 87 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ;
88 h0->Sumw2() ;
89 h0->GetXaxis()->SetTitle("TOF raw number [10 power]");
7d297381 90 Add2RawsList(h0, 0, !expert, image, !saveCorr) ;
04236e67 91
92 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
93 h1->Sumw2() ;
5561a41b 94 h1->GetXaxis()->SetTitle("Measured TOF time [ns]");
7d297381 95 Add2RawsList(h1, 1, !expert, image, !saveCorr) ;
04236e67 96
97 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
98 h2->Sumw2() ;
5561a41b 99 h2->GetXaxis()->SetTitle("Measured TOT [ns]");
100 h2->GetYaxis()->SetTitle("Measured TOF time [ns]");
7d297381 101 Add2RawsList(h2, 2, !expert, image, !saveCorr) ;
04236e67 102
103 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
104 h3->Sumw2() ;
5561a41b 105 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
106 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
107 h3->GetYaxis()->SetTitleOffset(1.15);
7d297381 108 Add2RawsList(h3, 3, !expert, image, !saveCorr) ;
04236e67 109
110}
111
44ed7a66 112//____________________________________________________________________________
113void AliTOFQADataMakerRec::InitDigits()
114{
115 //
116 // create Digits histograms in Digits subdir
117 //
118
119 const Bool_t expert = kTRUE ;
120 const Bool_t image = kTRUE ;
121
122 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits ",301, -1.02, 5.) ;
123 h0->Sumw2() ;
124 h0->GetXaxis()->SetTitle("TOF digit number [10 power]");
125 Add2DigitsList(h0, 0, !expert, image) ;
126
127 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
128 h1->Sumw2() ;
129 h1->GetXaxis()->SetTitle("Digitized TOF time [ns]");
130 Add2DigitsList(h1, 1, !expert, image) ;
131
132 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ;
133 h2->Sumw2() ;
134 h2->GetYaxis()->SetTitle("Digitized TOF time [ns]");
135 Add2DigitsList(h2, 2, !expert, image) ;
136
137 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
138 h3->Sumw2() ;
139 h3->GetXaxis()->SetTitle("2*strip+padz (eta)");
140 h3->GetYaxis()->SetTitle("48*sector+padx (phi)");
141 h3->GetYaxis()->SetTitleOffset(1.15);
142 Add2DigitsList(h3, 3, !expert, image) ;
143
144}
145
04236e67 146//____________________________________________________________________________
147void AliTOFQADataMakerRec::InitRecPoints()
148{
149 //
150 // create RecPoints histograms in RecPoints subdir
151 //
135306ea 152
7d297381 153 const Bool_t expert = kTRUE ;
154 const Bool_t image = kTRUE ;
155
5561a41b 156 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ;
157 h0->Sumw2() ;
158 h0->GetXaxis()->SetTitle("TOF recPoint number [10 power]");
7d297381 159 Add2RecPointsList(h0, 0, !expert, image) ;
04236e67 160
161 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
162 h1->Sumw2() ;
5561a41b 163 h1->GetXaxis()->SetTitle("Calibrated TOF time [ns]");
7d297381 164 Add2RecPointsList(h1, 1, !expert, image) ;
04236e67 165
166 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
167 h2->Sumw2() ;
5561a41b 168 h2->GetXaxis()->SetTitle("Measured TOT [ns]");
169 h2->GetYaxis()->SetTitle("Measured TOF time [ns]");
7d297381 170 Add2RecPointsList(h2, 2, !expert, image) ;
04236e67 171
172 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
173 h3->Sumw2() ;
5561a41b 174 h3->GetXaxis()->SetTitle("Measured TOT [ns]");
7d297381 175 Add2RecPointsList(h3, 3, !expert, image) ;
04236e67 176
0ea3c44e 177 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF phi-eta",183, -0.5, 182.5,865,-0.5,864.5) ;
04236e67 178 h4->Sumw2() ;
0ea3c44e 179 h4->GetXaxis()->SetTitle("2*strip+padz (eta)");
180 h4->GetYaxis()->SetTitle("48*sector+padx (phi)");
5561a41b 181 h4->GetYaxis()->SetTitleOffset(1.15);
7d297381 182 Add2RecPointsList(h4, 4, !expert, image) ;
04236e67 183
184}
185
186//____________________________________________________________________________
187void AliTOFQADataMakerRec::InitESDs()
188{
189 //
190 //create ESDs histograms in ESDs subdir
191 //
135306ea 192
7d297381 193 const Bool_t expert = kTRUE ;
194 const Bool_t image = kTRUE ;
04236e67 195 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
196 h0->Sumw2() ;
5561a41b 197 h0->GetXaxis()->SetTitle("Number of TOF matched ESD tracks [10 power]");
7d297381 198 Add2ESDsList(h0, 0, !expert, image) ;
04236e67 199
200 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
201 h1->Sumw2() ;
5561a41b 202 h1->GetXaxis()->SetTitle("Calibrated TOF time [ns]");
7d297381 203 Add2ESDsList(h1, 1, !expert, image) ;
04236e67 204
205 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
206 h2->Sumw2() ;
5561a41b 207 h2->GetXaxis()->SetTitle("Measured TOF time [ns]");
7d297381 208 Add2ESDsList(h2, 2, !expert, image) ;
04236e67 209
210 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
211 h3->Sumw2() ;
5561a41b 212 h3->GetXaxis()->SetTitle("Measured TOT [ns]");
7d297381 213 Add2ESDsList(h3, 3, !expert, image) ;
04236e67 214
0ea3c44e 215 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID flag (%)", 101, 0., 101.) ;
04236e67 216 h4->Sumw2() ;
5561a41b 217 h4->GetXaxis()->SetTitle("Fraction of TOF matched ESD tracks with good flag [%]");
7d297381 218 Add2ESDsList(h4, 4, !expert, image) ;
04236e67 219}
220
221//____________________________________________________________________________
222void AliTOFQADataMakerRec::MakeRaws(AliRawReader* rawReader)
223{
224 //
225 // makes data from Raws
226 //
227
228 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
229 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
230
231
232 Int_t ntof = 0 ;
233 Int_t in[5];
234 Int_t out[5];
235
236 TClonesArray * clonesRawData;
237 AliTOFRawStream tofInput(rawReader);
238 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
239 rawReader->Reset();
240 tofInput.LoadRawData(iDDL);
241 clonesRawData = (TClonesArray*)tofInput.GetRawData();
242 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
243 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
244 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
245 ntof++;
246 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
247 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
248
249 tofInput.EquipmentId2VolumeId(iDDL,
250 tofRawDatum->GetTRM(),
251 tofRawDatum->GetTRMchain(),
252 tofRawDatum->GetTDC(),
253 tofRawDatum->GetTDCchannel(),
254 in);
255
256 GetMapIndeces(in,out);
257 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
258
259 } // while loop
260
261 clonesRawData->Clear();
262
263 } // DDL Loop
264
265 Int_t nentries=ntof;
266 if(nentries<=0){
267 GetRawsData(0)->Fill(-1.) ;
268 }else{
269 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
270 }
271}
272
273//____________________________________________________________________________
44ed7a66 274void AliTOFQADataMakerRec::MakeDigits(TClonesArray * digits)
275{
276 //
277 // makes data from Digits
278 //
279 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
280 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
281 Int_t in[5];
282 Int_t out[5];
283
284 Int_t nentries=digits->GetEntriesFast();
285 if(nentries<=0){
286 GetDigitsData(0)->Fill(-1.) ;
287 }else{
288 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
289 }
290
291 TIter next(digits) ;
292 AliTOFdigit * digit ;
293 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
294
295 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
296 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
297
298 in[0] = digit->GetSector();
299 in[1] = digit->GetPlate();
300 in[2] = digit->GetStrip();
301 in[3] = digit->GetPadx();
302 in[4]= digit->GetPadz();
303 GetMapIndeces(in,out);
304 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
305 }
306
307}
308
309//____________________________________________________________________________
310void AliTOFQADataMakerRec::MakeDigits(TTree * digitTree)
311{
312 //
313 // makes data from Digit Tree
314 //
315 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
316
317 TBranch * branch = digitTree->GetBranch("TOF") ;
318 if ( ! branch ) {
319 AliError("TOF branch in Digit Tree not found") ;
320 return;
321 }
322 branch->SetAddress(&digits) ;
323 branch->GetEntry(0) ;
324 MakeDigits(digits) ;
325}
326
327//____________________________________________________________________________
04236e67 328void AliTOFQADataMakerRec::MakeRecPoints(TTree * clustersTree)
329{
330 //
331 // Make data from Clusters
332 //
333
334 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
335 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
336
337 Int_t in[5];
338 Int_t out[5];
339
340 TBranch *branch=clustersTree->GetBranch("TOF");
341 if (!branch) {
342 AliError("can't get the branch with the TOF clusters !");
343 return;
344 }
345
b12e6fe4 346 static TClonesArray dummy("AliTOFcluster",10000);
347 dummy.Clear();
348 TClonesArray *clusters=&dummy;
04236e67 349 branch->SetAddress(&clusters);
350
351 // Import the tree
352 clustersTree->GetEvent(0);
353
354 Int_t nentries=clusters->GetEntriesFast();
355 if(nentries<=0){
356 GetRecPointsData(0)->Fill(-1.) ;
357 }else{
358 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
359 }
360
361 TIter next(clusters) ;
362 AliTOFcluster * c ;
363 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
364 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
365 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
366 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
367
368 in[0] = c->GetDetInd(0);
369 in[1] = c->GetDetInd(1);
370 in[2] = c->GetDetInd(2);
371 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
372 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
373
374 GetMapIndeces(in,out);
375 GetRecPointsData(4)->Fill(out[0],out[1]);
376
377 }
378}
379
380//____________________________________________________________________________
381void AliTOFQADataMakerRec::MakeESDs(AliESDEvent * esd)
382{
383 //
384 // make QA data from ESDs
385 //
386 Int_t ntrk = esd->GetNumberOfTracks() ;
387 Int_t ntof=0;
388 Int_t ntofpid=0;
389 while (ntrk--) {
390 AliESDtrack *track=esd->GetTrack(ntrk);
391 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
392 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
393 Double_t tofToT=track->GetTOFsignalToT(); //in ns
394 if(!(tofTime>0))continue;
395 ntof++;
396 GetESDsData(1)->Fill(tofTime);
397 GetESDsData(2)->Fill(tofTimeRaw);
398 GetESDsData(3)->Fill(tofToT);
399 //check how many tracks where ESD PID is ok
400 UInt_t status=track->GetStatus();
401 if (((status&AliESDtrack::kESDpid)==0) ||
402 ((status&AliESDtrack::kTOFpid)==0)) continue;
403 ntofpid++;
404 }
405
406 Int_t nentries=ntof;
407 if(nentries<=0){
408 GetESDsData(0)->Fill(-1.) ;
409 }else{
410 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
411 }
412
7d53ce61 413 if(ntof>0) {
414 Float_t ratio = (Float_t)ntofpid/(Float_t)ntof*100.;
415 GetESDsData(4)->Fill(ratio) ;
416 }
04236e67 417
418}
419
420//____________________________________________________________________________
421void AliTOFQADataMakerRec::StartOfDetectorCycle()
422{
423 //
424 //Detector specific actions at start of cycle
425 //to be implemented
426}
427
428//____________________________________________________________________________
4e25ac79 429void AliTOFQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
04236e67 430{
431 //Detector specific actions at end of cycle
432 // do the QA checking
433
4e25ac79 434 AliQAChecker::Instance()->Run(AliQAv1::kTOF, task, list) ;
04236e67 435}
436//____________________________________________________________________________
437void AliTOFQADataMakerRec::GetMapIndeces(Int_t* in , Int_t* out)
438{
439 //
440 //return appropriate indeces for the theta-phi map
441 //
442
443 Int_t npadX = AliTOFGeometry::NpadX();
444 Int_t npadZ = AliTOFGeometry::NpadZ();
445 Int_t nStripA = AliTOFGeometry::NStripA();
446 Int_t nStripB = AliTOFGeometry::NStripB();
447 Int_t nStripC = AliTOFGeometry::NStripC();
448
449 Int_t isector = in[0];
450 Int_t iplate = in[1];
451 Int_t istrip = in[2];
452 Int_t ipadX = in[3];
453 Int_t ipadZ = in[4];
454
455 Int_t stripOffset = 0;
456 switch (iplate) {
457 case 0:
458 stripOffset = 0;
459 break;
460 case 1:
461 stripOffset = nStripC;
462 break;
463 case 2:
464 stripOffset = nStripC+nStripB;
465 break;
466 case 3:
467 stripOffset = nStripC+nStripB+nStripA;
468 break;
469 case 4:
470 stripOffset = nStripC+nStripB+nStripA+nStripB;
471 break;
472 default:
473 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
474 break;
475 };
476 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
477 Int_t phiindex=npadX*isector+ipadX+1;
478 out[0]=zindex;
479 out[1]=phiindex;
480
481}