Removing useless flag.
[u/mrichter/AliRoot.git] / T0 / AliT0QADataMaker.cxx
CommitLineData
c03351ac 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/* $Id$ */
18
19//---
20// Produces the data needed to calculate the quality assurance.
3b5a30f7 21// T0 QA for Hits, Digits, RAW and RecPoints
22// Alla.Maevskaya@cern.ch
23//
c03351ac 24//---
25
26// --- ROOT system ---
27#include <TClonesArray.h>
28#include <TFile.h>
29#include <TH1F.h>
c03351ac 30#include <TDirectory.h>
c03351ac 31// --- Standard library ---
32
33// --- AliRoot header files ---
c03351ac 34#include "AliESDEvent.h"
35#include "AliLog.h"
3622a3e0 36#include "AliT0digit.h"
c03351ac 37#include "AliT0hit.h"
38#include "AliT0RecPoint.h"
39#include "AliT0QADataMaker.h"
ce44b07a 40#include "AliQAChecker.h"
77270b9e 41#include "AliT0RawReader.h"
c03351ac 42
43ClassImp(AliT0QADataMaker)
44
45//____________________________________________________________________________
46 AliT0QADataMaker::AliT0QADataMaker() :
4e25ac79 47 AliQADataMaker(AliQAv1::GetDetName(AliQAv1::kT0), "T0 Quality Assurance Data Maker")
c03351ac 48
49{
50 // ctor
ce44b07a 51 /*
c03351ac 52 for(Int_t i=0; i<24; i++) {
53 fhHitsTime[i]=0x0;
54 fhDigCFD[i]=0x0;
55 fhDigLEDamp[i]=0x0;
56 fhRecCFD[i]=0x0;
57 fhRecLEDamp[i]=0x0;
58 fhRecQTC[i]=0x0;
59 }
ce44b07a 60 */
c03351ac 61 // fDetectorDir = fOutput->GetDirectory(GetName()) ;
62// if (!fDetectorDir)
63// fDetectorDir = fOutput->mkdir(GetName()) ;
64}
65
66//____________________________________________________________________________
67AliT0QADataMaker::AliT0QADataMaker(const AliT0QADataMaker& qadm) :
ce44b07a 68 AliQADataMaker()
c03351ac 69{
70 //copy ctor
ce44b07a 71 /*
c03351ac 72 for(Int_t i=0; i<24; i++) {
73 fhHitsTime[i]=0x0;
74 fhDigCFD[i]=0x0;
75 fhDigLEDamp[i]=0x0;
76 fhRecCFD[i]=0x0;
77 fhRecLEDamp[i]=0x0;
78 fhRecQTC[i]=0x0;
79 }
ce44b07a 80 */
c03351ac 81 SetName((const char*)qadm.GetName()) ;
82 SetTitle((const char*)qadm.GetTitle());
83}
84
85//__________________________________________________________________
86AliT0QADataMaker& AliT0QADataMaker::operator = (const AliT0QADataMaker& qadm )
87{
88 // Equal operator.
89 this->~AliT0QADataMaker();
90 new(this) AliT0QADataMaker(qadm);
91 return *this;
92}
ce44b07a 93//____________________________________________________________________________
4e25ac79 94void AliT0QADataMaker::EndOfDetectorCycle(AliQAv1::TASKINDEX task, TObjArray * list)
ce44b07a 95{
96 //Detector specific actions at end of cycle
97 // do the QA checking
4e25ac79 98 AliQAChecker::Instance()->Run(AliQAv1::kT0, task, list) ;
ce44b07a 99}
100
101//____________________________________________________________________________
102void AliT0QADataMaker::StartOfDetectorCycle()
103{
104 //Detector specific actions at start of cycle
105
106}
c03351ac 107
108//____________________________________________________________________________
109void AliT0QADataMaker::InitHits()
110{
111 // create Hits histograms in Hits subdir
112 TString timename;
ce44b07a 113 TH1F * fhHitsTime[24];
c03351ac 114 for (Int_t i=0; i<24; i++)
115 {
740f0839 116 timename ="hHitTime";
c03351ac 117 timename += i;
740f0839 118 if(i<12) fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,2000,3000);
ce44b07a 119 else
740f0839 120 fhHitsTime[i] = new TH1F(timename.Data(),timename.Data(),100,12000,13000);
4edbc5bc 121 Add2HitsList( fhHitsTime[i],i);
c03351ac 122 }
ce44b07a 123 /*
124 TH2F *fhHitsEffA = new TH2F("hHitsEffA", "Hits Efficiency A side", 25,-0.5,24.5, 100,12,13 );
125 Add2HitsList(fhHitsEffA,0);
126 TH2F *fhHitsEffC = new TH2F("hHitsEffC", "Hits Efficiency C side", 25,-0.5,24.5, 100,2,3 );
127 Add2HitsList(fhHitsEffC,1);
128 */
92664bc8 129 //
130 ClonePerTrigClass(AliQAv1::kHITS); // this should be the last line
c03351ac 131}
132
133//____________________________________________________________________________
134void AliT0QADataMaker::InitDigits()
135{
136 // create Digits histograms in Digits subdir
ce44b07a 137
138 /*
139 TH2F * fhDigCFD = new TH2F("fhDigCFD", " CFD digits",25,-0.5,24.5,100,100,1000);
140 Add2DigitsList( fhDigCFD,0);
141 TH2F *fhDigLEDamp = new TH2F("fhDigLEDamp", " LED-CFD digits",25,-0.5,24.5,100,100,1000);
142 Add2DigitsList( fhDigLEDamp,1);
143 TH2F * fhDigQTC = new TH2F("fhDigQTC", " QTC digits",25,-0.5,24.5,100,100,1000);
144 Add2DigitsList( fhDigQTC,2);
145 TH1F * fhDigMean = new TH1F("hDigMean","online mean signal", 100,500,600);
146 Add2DigitsList( fhDigMean,23);
147 */
148
c03351ac 149 TString timename, ampname, qtcname;
ce44b07a 150
151 TH1F *fhDigCFD[24]; TH1F * fhDigLEDamp[24]; TH1F *fhDigQTC[24];
152
c03351ac 153 for (Int_t i=0; i<24; i++)
154 {
740f0839 155 timename ="hDigCFD";
156 ampname = "hDigLED";
157 qtcname = "hDigQTC";
c03351ac 158 timename += i;
159 ampname += i;
160 qtcname += i;
740f0839 161 fhDigCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,5000);
ce44b07a 162 Add2DigitsList( fhDigCFD[i],i);
740f0839 163 fhDigLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,120000,150000);
ce44b07a 164 Add2DigitsList( fhDigLEDamp[i],i+24);
740f0839 165 fhDigQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,500);
ce44b07a 166 Add2DigitsList( fhDigQTC[i],i+48);
167 }
168
169 TH1F* fhDigEff = new TH1F("hDigEff","digits efficiency", 25,-0.5,24.5);
170 Add2DigitsList( fhDigEff,72);
171 TH1F* fhDigMean = new TH1F("hDigMean","online mean signal", 100,500,600);
172 Add2DigitsList( fhDigMean,73);
92664bc8 173 //
174 ClonePerTrigClass(AliQAv1::kDIGITS); // this should be the last line
c03351ac 175}
176
177//____________________________________________________________________________
77270b9e 178void AliT0QADataMaker::InitRaws()
179{
180 // create Raw histograms in Raw subdir
181 printf(" AliT0QADataMaker::InitRaws() started\n");
182 TString timename, ampname, qtcname;
183
184 TH1F *fhRawCFD[24]; TH1F * fhRawLEDamp[24]; TH1F *fhRawQTC[24];
185
186 for (Int_t i=0; i<24; i++)
187 {
188 timename ="hRawCFD";
189 ampname = "hRawLED";
190 qtcname = "hRawQTC";
191 timename += i;
192 ampname += i;
193 qtcname += i;
194 fhRawCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,5000);
195 Add2RawsList( fhRawCFD[i],i);
196 fhRawLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,120000,150000);
197 Add2RawsList( fhRawLEDamp[i],i+24);
198 fhRawQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,500);
199 Add2RawsList( fhRawQTC[i],i+48);
200 }
201
202 TH1F* fhRawMean = new TH1F("hRawMean","online mean signal", 100,500,600);
9c5bb179 203 Add2RawsList( fhRawMean,72);
92664bc8 204 //
205 ClonePerTrigClass(AliQAv1::kRAWS); // this should be the last line
77270b9e 206}
207
208//____________________________________________________________________________
c03351ac 209
210void AliT0QADataMaker::InitRecPoints()
211{
212 // create cluster histograms in RecPoint subdir
ce44b07a 213 /*
3b5a30f7 214 TH2F * fhRecCFD = new TH2F("fhRecCFD", " CFD reconstructed",25,-0.5,24.5,100,12,13);
215 Add2DigitsList( fhRecCFD,0);
216 TH2F *fhRecLEDamp = new TH2F("fhRecLEDamp", " amplitude LED reconstructed",25,-0.5,24.5,100,1000,1000);
217 Add2DigitsList( fhRecLEDamp,1);
218 TH2F * fhRecQTC = new TH2F("fhRecQTC", " amplitude QTC reconstructed",25,-0.5,24.5,100,1000,1000);
219 Add2DigitsList( fhRecQTC,2);
220 TH1F * fhRecMean = new TH1F("hRecMean"," reconstructed mean signal",100,500,600);
221 Add2DigitsList( fhRecMean,3);
ce44b07a 222 */
223
c03351ac 224 TString timename,ampname, qtcname;
ce44b07a 225 TH1F *fhRecCFD[24]; TH1F *fhRecLEDAmp[24]; TH1F * fhRecQTC[24];
c03351ac 226 for (Int_t i=0; i<24; i++)
227 {
740f0839 228 timename ="hRecCFD";
229 ampname = "hRecLED";
230 qtcname = "hRecQTC";
c03351ac 231 timename += i;
232 ampname += i;
233 qtcname += i;
740f0839 234 fhRecCFD[i] = new TH1F(timename.Data(), timename.Data(),100,0,1000);
ce44b07a 235 Add2RecPointsList ( fhRecCFD[i],i);
740f0839 236 fhRecLEDAmp[i] = new TH1F(ampname.Data(), ampname.Data(),100,0,200);
ce44b07a 237 Add2RecPointsList ( fhRecLEDAmp[i],i+24);
740f0839 238 fhRecQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,0,200);
ce44b07a 239 Add2RecPointsList ( fhRecQTC[i],i+48);
240 }
3b5a30f7 241
ce44b07a 242 TH1F *fhRecEff = new TH1F("hRecEff","Efficiency rec.points",25,-0.5,24.5);
3b5a30f7 243 Add2RecPointsList ( fhRecEff,72);
ce44b07a 244 TH1F * fhRecMean = new TH1F("hRecMean"," reconstructed mean signal",100,500,600);
3b5a30f7 245 Add2RecPointsList( fhRecMean,73);
92664bc8 246 //
247 ClonePerTrigClass(AliQAv1::kRECPOINTS); // this should be the last line
c03351ac 248}
249//____________________________________________________________________________
250void AliT0QADataMaker::InitESDs()
251{
252 //create ESDs histograms in ESDs subdir
740f0839 253 TH1F *fhESDMean = new TH1F("hESDmean"," ESD mean",100,0,100);
ce44b07a 254 Add2ESDsList(fhESDMean, 0) ;
3b5a30f7 255 TH1F * fhESDVertex = new TH1F("hESDvertex","EAD vertex",100,-50,50);
ce44b07a 256 Add2ESDsList(fhESDVertex, 1) ;
92664bc8 257 //
258 ClonePerTrigClass(AliQAv1::kESDS); // this should be the last line
c03351ac 259}
260//____________________________________________________________________________
740f0839 261
262void AliT0QADataMaker::MakeHits(TTree *hitTree)
c03351ac 263{
264 //fills QA histos for Hits
740f0839 265 TClonesArray * hits = new TClonesArray("AliT0hit", 1000);
266
267 TBranch * branch = hitTree->GetBranch("T0") ;
268 if ( ! branch ) {
269 AliWarning("T0 branch in Hit Tree not found") ;
c03351ac 270 } else {
740f0839 271
272 if (branch) {
273 branch->SetAddress(&hits);
274 }else{
275 AliError("Branch T0 hit not found");
276 exit(111);
277 }
278 Int_t ntracks = (Int_t) hitTree->GetEntries();
279
280 if (ntracks<=0) return;
281 // Start loop on tracks in the hits containers
282 for (Int_t track=0; track<ntracks;track++) {
283 branch->GetEntry(track);
284 Int_t nhits = hits->GetEntriesFast();
285 for (Int_t ihit=0;ihit<nhits;ihit++)
286 {
287 AliT0hit * startHit = (AliT0hit*) hits->UncheckedAt(ihit);
288 if (!startHit) {
289 AliError("The unchecked hit doesn't exist");
290 break;
291 }
292 Int_t pmt=startHit->Pmt();
92664bc8 293 FillHitsData(pmt-1,startHit->Time()) ;
740f0839 294 }
ce44b07a 295 }
740f0839 296 }
92664bc8 297 //
298 IncEvCountCycleHits();
299 IncEvCountTotalHits();
300 //
c03351ac 301}
302
303//____________________________________________________________________________
740f0839 304void AliT0QADataMaker::MakeDigits( TTree *digitsTree)
c03351ac 305{
306 //fills QA histos for Digits
ce44b07a 307
c03351ac 308 TArrayI *digCFD = new TArrayI(24);
309 TArrayI *digLED = new TArrayI(24);
310 TArrayI *digQT0 = new TArrayI(24);
311 TArrayI *digQT1 = new TArrayI(24);
312 Int_t refpoint=0;
313
740f0839 314 TBranch *brDigits=digitsTree->GetBranch("T0");
315 AliT0digit *fDigits = new AliT0digit() ;
316 if (brDigits) {
317 brDigits->SetAddress(&fDigits);
318 }else{
319 AliError(Form("EXEC Branch T0 digits not found"));
92664bc8 320 delete digCFD;
321 delete digLED;
322 delete digQT0;
323 delete digQT1;
324 return;
c03351ac 325 }
740f0839 326
327 digitsTree->GetEvent(0);
328 digitsTree->GetEntry(0);
329 brDigits->GetEntry(0);
330 fDigits->GetTimeCFD(*digCFD);
331 fDigits->GetTimeLED(*digLED);
332 fDigits->GetQT0(*digQT0);
333 fDigits->GetQT1(*digQT1);
334 refpoint = fDigits->RefPoint();
335 for (Int_t i=0; i<24; i++)
336 {
337 if (digCFD->At(i)>0) {
338 Int_t cfd=digCFD->At(i)- refpoint;
92664bc8 339 FillDigitsData(i,cfd);
340 FillDigitsData(i+24, digLED->At(i) - digCFD->At(i));
341 FillDigitsData(i+48, digQT1->At(i) - digQT0->At(i));
740f0839 342 }
343 }
344
c03351ac 345 delete digCFD;
346 delete digLED;
347 delete digQT0;
348 delete digQT1;
92664bc8 349 //
350 IncEvCountCycleDigits();
351 IncEvCountTotalDigits();
352 //
c03351ac 353}
354
355
356//____________________________________________________________________________
77270b9e 357void AliT0QADataMaker::MakeRaws( AliRawReader* rawReader)
358{
359 Int_t allData[110][5];
360 for (Int_t i0=0; i0<105; i0++)
361 {
362 for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;
363 }
364 //fills QA histos for RAW
c0adb305 365
366 AliT0RawReader *start = new AliT0RawReader(rawReader);
3b5a30f7 367 start->Next();
368 for (Int_t i=0; i<105; i++)
369 for (Int_t iHit=0; iHit<5; iHit++)
370 allData[i][iHit]= start->GetData(i,iHit);
371
77270b9e 372
3b5a30f7 373 for (Int_t ik = 0; ik<24; ik+=2){
374 for (Int_t iHt=0; iHt<5; iHt++){
375 Int_t cc = ik/2;
77270b9e 376 if(allData[cc+1][iHt]!=0){
92664bc8 377 FillRawsData(cc,allData[cc+1][iHt]-allData[0][0]);
77270b9e 378 if(allData[ik+25][iHt]!=0 && allData[ik+26][iHt]!=0)
92664bc8 379 FillRawsData(cc+48,allData[ik+26][iHt]-allData[ik+25][iHt]);
77270b9e 380 if(allData[cc+13][iHt]!=0 )
92664bc8 381 FillRawsData(cc+24,allData[cc+13][iHt]-allData[cc+1][iHt]);
77270b9e 382 }
3b5a30f7 383 }
384 }
77270b9e 385
3b5a30f7 386 for (Int_t ik = 24; ik<48; ik+=2) {
387 for (Int_t iHt=0; iHt<5; iHt++) {
388 Int_t cc = ik/2;
389 if(allData[cc+45][iHt]!=0) {
92664bc8 390 FillRawsData(cc,allData[cc+1][iHt]-allData[0][0]);
3b5a30f7 391 if(allData[ik+57][iHt]!=0 && allData[ik+58][iHt]!=0)
92664bc8 392 FillRawsData(cc+48,allData[ik+57][iHt]-allData[ik+58][iHt]);
3b5a30f7 393 if(allData[cc+57][iHt]!=0 )
92664bc8 394 FillRawsData(cc+48,allData[cc+57][iHt]-allData[cc+45][iHt]);
77270b9e 395 }
3b5a30f7 396 }
397 }
c0adb305 398 delete start;
92664bc8 399 //
400 IncEvCountCycleRaws();
401 IncEvCountTotalRaws();
402 //
77270b9e 403}
404
405//____________________________________________________________________________
c03351ac 406void AliT0QADataMaker::MakeRecPoints(TTree * clustersTree)
407{
408 //fills QA histos for clusters
409
410 AliT0RecPoint* frecpoints= new AliT0RecPoint ();
411 if (!frecpoints) {
412 AliError("Reconstruct Fill ESD >> no recpoints found");
413 return;
414 }
415 TBranch *brRec =clustersTree ->GetBranch("T0");
416 if (brRec) {
417 brRec->SetAddress(&frecpoints);
418 }else{
77270b9e 419 AliError(Form("EXEC Branch T0 rec not found "));
420 return;
c03351ac 421 }
422
423 brRec->GetEntry(0);
424
425 for ( Int_t i=0; i<24; i++) {
92664bc8 426 FillRecPointsData(i,frecpoints -> GetTime(i));
427 FillRecPointsData(i+24,frecpoints -> GetAmp(i));
428 FillRecPointsData(i+48,frecpoints->AmpLED(i));
ce44b07a 429 // if(frecpoints -> GetTime(i) > 0) fhRecEff->Fill(i);
c03351ac 430 }
92664bc8 431 FillRecPointsData(72,frecpoints->GetMeanTime());
432 //
433 IncEvCountCycleRecPoints();
434 IncEvCountTotalRecPoints();
435 //
c03351ac 436}
437
438//____________________________________________________________________________
439void AliT0QADataMaker::MakeESDs(AliESDEvent * esd)
440{
441 //fills QA histos for ESD
442
92664bc8 443 FillESDsData(0,esd->GetT0());
444 FillESDsData(1,esd->GetT0zVertex());
445 //
446 IncEvCountCycleESDs();
447 IncEvCountTotalESDs();
c03351ac 448}
449