]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFQADataMaker.cxx
pedestal values subtracted
[u/mrichter/AliRoot.git] / TOF / AliTOFQADataMaker.cxx
CommitLineData
380c04bf 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 **************************************************************************/
8fd6fd6c 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///////////////////////////////////////////////////////////////////////
380c04bf 23
24#include <TClonesArray.h>
25#include <TFile.h>
26#include <TH1I.h>
27#include <TH1F.h>
28#include <TH2F.h>
29#include "AliESDEvent.h"
30#include "AliESDtrack.h"
31#include "AliTOFcluster.h"
32#include "AliTOFdigit.h"
33#include "AliTOFSDigit.h"
34#include "AliTOFhitT0.h"
35#include "AliTOFQADataMaker.h"
693a790d 36#include "AliQAChecker.h"
380c04bf 37#include "AliRawReader.h"
38#include "AliTOFRawStream.h"
39#include "AliTOFrawData.h"
40#include "AliLog.h"
41
42ClassImp(AliTOFQADataMaker)
43
44//____________________________________________________________________________
45 AliTOFQADataMaker::AliTOFQADataMaker() :
46 AliQADataMaker(AliQA::GetDetName(AliQA::kTOF), "TOF Quality Assurance Data Maker")
47{
48 //
49 // ctor
50 //
51}
52
53//____________________________________________________________________________
54AliTOFQADataMaker::AliTOFQADataMaker(const AliTOFQADataMaker& qadm) :
55 AliQADataMaker()
56{
57 //
58 //copy ctor
59 //
60 SetName((const char*)qadm.GetName()) ;
61 SetTitle((const char*)qadm.GetTitle());
62}
63
64//__________________________________________________________________
65AliTOFQADataMaker& AliTOFQADataMaker::operator = (const AliTOFQADataMaker& qadm )
66{
67 //
68 // assignment operator.
69 //
70 this->~AliTOFQADataMaker();
71 new(this) AliTOFQADataMaker(qadm);
72 return *this;
73}
74
75//____________________________________________________________________________
76void AliTOFQADataMaker::InitHits()
77{
78 //
79 // create Hits histograms in Hits subdir
80 //
81 TH1F * h0 = new TH1F("hTOFHits", "Number of TOF Hits ",301, -1.02, 5.) ;
82 h0->Sumw2() ;
83 Add2HitsList(h0, 0) ;
84
85 TH1F * h1 = new TH1F("hTOFHitsTime", "Hits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
86 h1->Sumw2() ;
87 Add2HitsList(h1, 1) ;
88
89 TH1F * h2 = new TH1F("hTOFHitsLength", "Length Spectrum in TOF (cm)", 500, 0., 500) ;
90 h2->Sumw2() ;
91 Add2HitsList(h2, 2) ;
92
93 TH2F * h3 = new TH2F("hTOFHitsClusMap","Hits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
94 h3->Sumw2() ;
95 Add2HitsList(h3, 3) ;
96}
97
98//____________________________________________________________________________
99void AliTOFQADataMaker::InitDigits()
100{
101 //
102 // create Digits histograms in Digits subdir
103 //
104 TH1F * h0 = new TH1F("hTOFDigits", "Number of TOF Digits ",301, -1.02, 5.) ; h0->Sumw2() ;
105 Add2DigitsList(h0, 0) ;
106
107 TH1F * h1 = new TH1F("hTOFDigitsTime", "Digits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
108 h1->Sumw2() ;
109 Add2DigitsList(h1, 1) ;
110
111 TH1F * h2 = new TH1F("hTOFDigitsToT", "Digits ToT Spectrum in TOF (ns)", 500, 0., 50) ;
112 h2->Sumw2() ;
113 Add2DigitsList(h2, 2) ;
114
115 TH2F * h3 = new TH2F("hTOFDigitsClusMap","Digits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
116 h3->Sumw2() ;
117 Add2DigitsList(h3, 3) ;
118
119}
120
121//____________________________________________________________________________
122void AliTOFQADataMaker::InitSDigits()
123{
124 //
125 // create SDigits histograms in SDigits subdir
126 //
127 TH1F * h0 = new TH1F("hTOFSDigits", "Number of TOF SDigits ",301, -1.02, 5.) ; h0->Sumw2() ;
128 Add2SDigitsList(h0, 0) ;
129
130 TH1F * h1 = new TH1F("hTOFSDigitsTime", "SDigits Time Spectrum in TOF (ns)", 2000, 0., 200) ;
131 h1->Sumw2() ;
132 Add2SDigitsList(h1, 1) ;
133
134 TH2F * h2 = new TH2F("hTOFSDigitsClusMap","SDigits vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
135 h2->Sumw2() ;
136 Add2SDigitsList(h2, 2) ;
137
138}
139
140//____________________________________________________________________________
141void AliTOFQADataMaker::InitRaws()
142{
143 //
144 // create Raws histograms in Raws subdir
145 //
146 TH1F * h0 = new TH1F("hTOFRaws", "Number of TOF Raws ",301, -1.02, 5.) ; h0->Sumw2() ;
147 Add2RawsList(h0, 0) ;
148
149 TH1F * h1 = new TH1F("hTOFRawsTime", "Raws Time Spectrum in TOF (ns)", 2000, 0., 200) ;
150 h1->Sumw2() ;
151 Add2RawsList(h1, 1) ;
152
153 TH1F * h2 = new TH1F("hTOFRawsToT", "Raws ToT Spectrum in TOF (ns)", 500, 0., 50) ;
154 h2->Sumw2() ;
155 Add2RawsList(h2, 2) ;
156
157 TH2F * h3 = new TH2F("hTOFRawsClusMap","Raws vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
158 h3->Sumw2() ;
159 Add2RawsList(h3, 3) ;
160
161}
162
163//____________________________________________________________________________
164void AliTOFQADataMaker::InitRecPoints()
165{
166 //
167 // create RecPoints histograms in RecPoints subdir
168 //
169 TH1F * h0 = new TH1F("hTOFRecPoints", "Number of TOF RecPoints ",301, -1.02, 5.) ; h0->Sumw2() ;
170 Add2RecPointsList(h0, 0) ;
171
172 TH1F * h1 = new TH1F("hTOFRecPointsTime", "RecPoints Time Spectrum in TOF (ns)", 2000, 0., 200) ;
173 h1->Sumw2() ;
174 Add2RecPointsList(h1, 1) ;
175
176 TH1F * h2 = new TH1F("hTOFRecPointsRawTime", "RecPoints raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
177 h2->Sumw2() ;
178 Add2RecPointsList(h2, 2) ;
179
180 TH1F * h3 = new TH1F("hTOFRecPointsToT", "RecPoints ToT Spectrum in TOF (ns)", 500, 0., 50) ;
181 h3->Sumw2() ;
182 Add2RecPointsList(h3, 3) ;
183
184 TH2F * h4 = new TH2F("hTOFRecPointsClusMap","RecPoints vs TOF eta-phi",183, -0.5, 182.5,865,-0.5,864.5) ;
185 h4->Sumw2() ;
186 Add2RecPointsList(h4, 4) ;
187
188}
189
190//____________________________________________________________________________
191void AliTOFQADataMaker::InitESDs()
192{
193 //
194 //create ESDs histograms in ESDs subdir
195 //
196 TH1F * h0 = new TH1F("hTOFESDs", "Number of matched TOF tracks over ESDs", 250, -1., 4.) ;
197 h0->Sumw2() ;
198 Add2ESDsList(h0, 0) ;
199
200 TH1F * h1 = new TH1F("hTOFESDsTime", "Time Spectrum in TOF (ns)", 2000, 0., 200) ;
201 h1->Sumw2() ;
202 Add2ESDsList(h1, 1) ;
203
204 TH1F * h2 = new TH1F("hTOFESDsRawTime", "raw Time Spectrum in TOF (ns)", 2000, 0., 200) ;
205 h2->Sumw2() ;
206 Add2ESDsList(h2, 2) ;
207
208 TH1F * h3 = new TH1F("hTOFESDsToT", "ToT Spectrum in TOF (ns)", 500, 0., 50) ;
209 h3->Sumw2() ;
210 Add2ESDsList(h3, 3) ;
211
212 TH1F * h4 = new TH1F("hTOFESDsPID", "Fraction of matched TOF tracks with good PID glag", 100, 0., 1.) ;
213 h4->Sumw2() ;
214 Add2ESDsList(h4, 4) ;
215}
216
217
218//____________________________________________________________________________
219void AliTOFQADataMaker::MakeHits(TClonesArray * hits)
220{
221 //
222 //make QA data from Hits
223 //
224
225 Int_t in[5];
226 Int_t out[5];
227
228 Int_t nentries=hits->GetEntriesFast();
c332d0d1 229 if(nentries<=0) {
ed77256d 230 GetHitsData(0)->Fill(-1.) ;
231 } else{
232 GetHitsData(0)->Fill(TMath::Log10(nentries)) ;
233 }
380c04bf 234 TIter next(hits) ;
235 AliTOFhitT0 * hit ;
236 while ( (hit = dynamic_cast<AliTOFhitT0 *>(next())) ) {
237
238 GetHitsData(1)->Fill( hit->GetTof()*1.E9) ;//in ns
239 GetHitsData(2)->Fill( hit->GetLen()) ;//in cm
240
241 in[0] = hit->GetSector();
242 in[1] = hit->GetPlate();
243 in[2]= hit->GetStrip();
244 in[3]= hit->GetPadx();
245 in[4]= hit->GetPadz();
246 GetMapIndeces(in,out);
247 GetHitsData(3)->Fill( out[0],out[1]) ;//hit map
248 }
249
250}
251
252
253//____________________________________________________________________________
254void AliTOFQADataMaker::MakeHits(TTree * hitTree)
255{
256 //
257 // make QA data from Hit Tree
258 //
259 if(!hitTree){
260 AliError("can't get the tree with TOF hits !");
261 return;
262 }
263
264 TBranch * branch = hitTree->GetBranch("TOF") ;
265
266 if (!branch ) {
267 AliError("TOF branch in Hit Tree not found") ;
268 return;
269 }
270
271 TClonesArray * hits = new TClonesArray("AliTOFhitT0", 1000);
272 TClonesArray * dummy = new TClonesArray("AliTOFhitT0", 1000);
273 branch->SetAddress(&dummy);
274 Int_t index = 0 ;
275 for (Int_t ientry = 0 ; ientry < branch->GetEntries() ; ientry++) {
276 branch->GetEntry(ientry) ;
277 for (Int_t ihit = 0 ; ihit < dummy->GetEntries() ; ihit++) {
278 AliTOFhitT0 * hit = dynamic_cast<AliTOFhitT0 *> (dummy->At(ihit)) ;
279 new((*hits)[index]) AliTOFhitT0(*hit) ;
280 index++ ;
281 }
282 }
283
284 dummy->Delete();
285 delete dummy;
286 MakeHits(hits) ;
287
288}
289
290//____________________________________________________________________________
291void AliTOFQADataMaker::MakeDigits(TClonesArray * digits)
292{
293 //
294 // makes data from Digits
295 //
296 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
297 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
298 Int_t in[5];
299 Int_t out[5];
300
301 Int_t nentries=digits->GetEntriesFast();
c332d0d1 302 if(nentries<=0){
ed77256d 303 GetDigitsData(0)->Fill(-1.) ;
304 }else{
305 GetDigitsData(0)->Fill(TMath::Log10(nentries)) ;
306 }
307
380c04bf 308 TIter next(digits) ;
309 AliTOFdigit * digit ;
310 while ( (digit = dynamic_cast<AliTOFdigit *>(next())) ) {
311
312 GetDigitsData(1)->Fill( digit->GetTdc()*tdc2ns) ;//in ns
313 GetDigitsData(2)->Fill( digit->GetToT()*tot2ns) ;//in ns
314
315 in[0] = digit->GetSector();
316 in[1] = digit->GetPlate();
317 in[2] = digit->GetStrip();
318 in[3] = digit->GetPadx();
319 in[4]= digit->GetPadz();
320 GetMapIndeces(in,out);
321 GetDigitsData(3)->Fill( out[0],out[1]) ;//digit map
322 }
323
324}
325
326
327//____________________________________________________________________________
328void AliTOFQADataMaker::MakeDigits(TTree * digitTree)
329{
330 //
331 // makes data from Digit Tree
332 //
333 TClonesArray * digits = new TClonesArray("AliTOFdigit", 1000) ;
334
335 TBranch * branch = digitTree->GetBranch("TOF") ;
336 if ( ! branch ) {
337 AliError("TOF branch in Digit Tree not found") ;
338 return;
339 }
340 branch->SetAddress(&digits) ;
341 branch->GetEntry(0) ;
342 MakeDigits(digits) ;
343}
344
345//____________________________________________________________________________
346void AliTOFQADataMaker::MakeSDigits(TClonesArray * sdigits)
347{
348 //
349 // makes data from SDigits
350 //
351
352 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
353 Int_t in[5];
354 Int_t out[5];
355
356 Int_t nentries=sdigits->GetEntriesFast();
c332d0d1 357 if(nentries<=0){
ed77256d 358 GetSDigitsData(0)->Fill(-1.) ;
359 }else{
360 GetSDigitsData(0)->Fill(TMath::Log10(nentries)) ;
361 }
380c04bf 362
363 TIter next(sdigits) ;
364 AliTOFSDigit * sdigit ;
365 while ( (sdigit = dynamic_cast<AliTOFSDigit *>(next())) ) {
366
367 for(Int_t i=0;i<sdigit->GetNDigits();i++){
368 GetSDigitsData(1)->Fill( sdigit->GetTdc(i)*tdc2ns) ;//in ns
369 }
370
371 in[0] = sdigit->GetSector();
372 in[1] = sdigit->GetPlate();
373 in[2] = sdigit->GetStrip();
374 in[3] = sdigit->GetPadx();
375 in[4]= sdigit->GetPadz();
376 GetMapIndeces(in,out);
377 GetSDigitsData(2)->Fill( out[0],out[1]) ;//sdigit map
378 }
379}
380
381//____________________________________________________________________________
382void AliTOFQADataMaker::MakeSDigits(TTree * sdigitTree)
383{
384 //
385 // makes data from SDigit Tree
386 //
387 TClonesArray * sdigits = new TClonesArray("AliTOFSDigit", 1000) ;
388
389 TBranch * branch = sdigitTree->GetBranch("TOF") ;
390 if ( ! branch ) {
391 AliError("TOF branch in SDigit Tree not found") ;
392 return;
393 }
394 branch->SetAddress(&sdigits) ;
395 branch->GetEntry(0) ;
396 MakeSDigits(sdigits) ;
397}
398
399//____________________________________________________________________________
400void AliTOFQADataMaker::MakeRaws(AliRawReader* rawReader)
401{
402 //
403 // makes data from Raws
404 //
405
406 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
407 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
408
409
410 Int_t ntof = 0 ;
411 Int_t in[5];
412 Int_t out[5];
413
414 TClonesArray * clonesRawData;
415 AliTOFRawStream tofInput(rawReader);
416 for (Int_t iDDL = 0; iDDL < AliTOFGeometry::NDDL()*AliTOFGeometry::NSectors(); iDDL++){
417 rawReader->Reset();
418 tofInput.LoadRawData(iDDL);
419 clonesRawData = (TClonesArray*)tofInput.GetRawData();
420 for (Int_t iRawData = 0; iRawData<clonesRawData->GetEntriesFast(); iRawData++) {
421 AliTOFrawData *tofRawDatum = (AliTOFrawData*)clonesRawData->UncheckedAt(iRawData);
422 if (!tofRawDatum->GetTOT() || !tofRawDatum->GetTOF()) continue;
423 ntof++;
424 GetRawsData(1)->Fill( tofRawDatum->GetTOF()*tdc2ns) ;//in ns
425 GetRawsData(2)->Fill( tofRawDatum->GetTOT()*tot2ns) ;//in ns
426
427 tofInput.EquipmentId2VolumeId(iDDL,
428 tofRawDatum->GetTRM(),
429 tofRawDatum->GetTRMchain(),
430 tofRawDatum->GetTDC(),
431 tofRawDatum->GetTDCchannel(),
432 in);
433
434 GetMapIndeces(in,out);
435 GetRawsData(3)->Fill( out[0],out[1]) ;//raw map
436
437 } // while loop
438
439 clonesRawData->Clear();
440
441 } // DDL Loop
442
443 Int_t nentries=ntof;
c332d0d1 444 if(nentries<=0){
ed77256d 445 GetRawsData(0)->Fill(-1.) ;
446 }else{
447 GetRawsData(0)->Fill(TMath::Log10(nentries)) ;
448 }
380c04bf 449}
450
451//____________________________________________________________________________
452void AliTOFQADataMaker::MakeRecPoints(TTree * clustersTree)
453{
454 //
455 // Make data from Clusters
456 //
457
458 Double_t tdc2ns=AliTOFGeometry::TdcBinWidth()*1E-3;
459 Double_t tot2ns=AliTOFGeometry::ToTBinWidth()*1E-3;
460
461 Int_t in[5];
462 Int_t out[5];
463
464 TBranch *branch=clustersTree->GetBranch("TOF");
465 if (!branch) {
466 AliError("can't get the branch with the TOF clusters !");
467 return;
468 }
469
ed77256d 470 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
380c04bf 471 branch->SetAddress(&clusters);
380c04bf 472
ed77256d 473 // Import the tree
474 clustersTree->GetEvent(0);
475
380c04bf 476 Int_t nentries=clusters->GetEntriesFast();
c332d0d1 477 if(nentries<=0){
ed77256d 478 GetRecPointsData(0)->Fill(-1.) ;
479 }else{
480 GetRecPointsData(0)->Fill(TMath::Log10(nentries)) ;
481 }
482
380c04bf 483 TIter next(clusters) ;
484 AliTOFcluster * c ;
485 while ( (c = dynamic_cast<AliTOFcluster *>(next())) ) {
486 GetRecPointsData(1)->Fill(c->GetTDC()*tdc2ns);
487 GetRecPointsData(2)->Fill(c->GetTDCRAW()*tdc2ns);
488 GetRecPointsData(3)->Fill(c->GetToT()*tot2ns);
ed77256d 489
380c04bf 490 in[0] = c->GetDetInd(0);
491 in[1] = c->GetDetInd(1);
492 in[2] = c->GetDetInd(2);
493 in[3] = c->GetDetInd(4); //X and Z indeces inverted in RecPoints
494 in[4] = c->GetDetInd(3); //X and Z indeces inverted in RecPoints
ed77256d 495
380c04bf 496 GetMapIndeces(in,out);
497 GetRecPointsData(4)->Fill(out[0],out[1]);
ed77256d 498
380c04bf 499 }
380c04bf 500}
501
502//____________________________________________________________________________
503void AliTOFQADataMaker::MakeESDs(AliESDEvent * esd)
504{
505 //
506 // make QA data from ESDs
507 //
508 Int_t ntrk = esd->GetNumberOfTracks() ;
509 Int_t ntof=0;
510 Int_t ntofpid=0;
511 while (ntrk--) {
512 AliESDtrack *track=esd->GetTrack(ntrk);
513 Double_t tofTime=track->GetTOFsignal()*1E-3;//in ns
514 Double_t tofTimeRaw=track->GetTOFsignalRaw()*1E-3;//in ns
515 Double_t tofToT=track->GetTOFsignalToT(); //in ns
516 if(!(tofTime>0))continue;
517 ntof++;
518 GetESDsData(1)->Fill(tofTime);
519 GetESDsData(2)->Fill(tofTimeRaw);
520 GetESDsData(3)->Fill(tofToT);
521 //check how many tracks where ESD PID is ok
522 UInt_t status=track->GetStatus();
523 if (((status&AliESDtrack::kESDpid)==0) ||
524 ((status&AliESDtrack::kTOFpid)==0)) continue;
525 ntofpid++;
526 }
527
528 Int_t nentries=ntof;
c332d0d1 529 if(nentries<=0){
ed77256d 530 GetESDsData(0)->Fill(-1.) ;
531 }else{
532 GetESDsData(0)->Fill(TMath::Log10(nentries)) ;
533 }
534
380c04bf 535 if(ntof>0)GetESDsData(4)->Fill(ntofpid/ntof) ;
536
537}
538
539//____________________________________________________________________________
540void AliTOFQADataMaker::StartOfDetectorCycle()
541{
542 //
543 //Detector specific actions at start of cycle
544 //to be implemented
545}
546
693a790d 547//____________________________________________________________________________
4edbc5bc 548void AliTOFQADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TObjArray * list)
693a790d 549{
550 //Detector specific actions at end of cycle
551 // do the QA checking
552
553 AliQAChecker::Instance()->Run(AliQA::kTOF, task, list) ;
554}
380c04bf 555//____________________________________________________________________________
556void AliTOFQADataMaker::GetMapIndeces(Int_t* in , Int_t* out)
557{
558 //
559 //return appropriate indeces for the theta-phi map
560 //
561
562 Int_t npadX = AliTOFGeometry::NpadX();
563 Int_t npadZ = AliTOFGeometry::NpadZ();
564 Int_t nStripA = AliTOFGeometry::NStripA();
565 Int_t nStripB = AliTOFGeometry::NStripB();
566 Int_t nStripC = AliTOFGeometry::NStripC();
567
568 Int_t isector = in[0];
569 Int_t iplate = in[1];
570 Int_t istrip = in[2];
571 Int_t ipadX = in[3];
572 Int_t ipadZ = in[4];
573
574 Int_t stripOffset = 0;
575 switch (iplate) {
576 case 0:
577 stripOffset = 0;
578 break;
579 case 1:
580 stripOffset = nStripC;
581 break;
582 case 2:
583 stripOffset = nStripC+nStripB;
584 break;
585 case 3:
586 stripOffset = nStripC+nStripB+nStripA;
587 break;
588 case 4:
589 stripOffset = nStripC+nStripB+nStripA+nStripB;
590 break;
591 default:
592 AliError(Form("Wrong plate number in TOF (%d) !",iplate));
593 break;
594 };
595 Int_t zindex=npadZ*(istrip+stripOffset)+(ipadZ+1);
596 Int_t phiindex=npadX*isector+ipadX+1;
597 out[0]=zindex;
598 out[1]=phiindex;
599
600}