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