]> git.uio.no Git - u/mrichter/AliRoot.git/blame - T0/AliT0QADataMaker.cxx
QA Data maker for RAW
[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.
21// All data must be mergeable objects.
22// A. Mastroserio
23//---
24
25// --- ROOT system ---
26#include <TClonesArray.h>
27#include <TFile.h>
28#include <TH1F.h>
c03351ac 29#include <TDirectory.h>
c03351ac 30// --- Standard library ---
31
32// --- AliRoot header files ---
c03351ac 33#include "AliESDEvent.h"
34#include "AliLog.h"
35#include "AliT0digit.h"
36#include "AliT0hit.h"
37#include "AliT0RecPoint.h"
38#include "AliT0QADataMaker.h"
ce44b07a 39#include "AliQAChecker.h"
77270b9e 40#include "AliRawReaderFile.h"
41#include "AliT0RawReader.h"
c03351ac 42
43ClassImp(AliT0QADataMaker)
44
45//____________________________________________________________________________
46 AliT0QADataMaker::AliT0QADataMaker() :
ce44b07a 47 AliQADataMaker(AliQA::GetDetName(AliQA::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//____________________________________________________________________________
94void AliT0QADataMaker::EndOfDetectorCycle(AliQA::TASKINDEX task, TList * list)
95{
96 //Detector specific actions at end of cycle
97 // do the QA checking
98 AliQAChecker::Instance()->Run(AliQA::kT0, task, list) ;
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);
ce44b07a 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 */
c03351ac 129}
130
131//____________________________________________________________________________
132void AliT0QADataMaker::InitDigits()
133{
134 // create Digits histograms in Digits subdir
ce44b07a 135
136 /*
137 TH2F * fhDigCFD = new TH2F("fhDigCFD", " CFD digits",25,-0.5,24.5,100,100,1000);
138 Add2DigitsList( fhDigCFD,0);
139 TH2F *fhDigLEDamp = new TH2F("fhDigLEDamp", " LED-CFD digits",25,-0.5,24.5,100,100,1000);
140 Add2DigitsList( fhDigLEDamp,1);
141 TH2F * fhDigQTC = new TH2F("fhDigQTC", " QTC digits",25,-0.5,24.5,100,100,1000);
142 Add2DigitsList( fhDigQTC,2);
143 TH1F * fhDigMean = new TH1F("hDigMean","online mean signal", 100,500,600);
144 Add2DigitsList( fhDigMean,23);
145 */
146
c03351ac 147 TString timename, ampname, qtcname;
ce44b07a 148
149 TH1F *fhDigCFD[24]; TH1F * fhDigLEDamp[24]; TH1F *fhDigQTC[24];
150
c03351ac 151 for (Int_t i=0; i<24; i++)
152 {
740f0839 153 timename ="hDigCFD";
154 ampname = "hDigLED";
155 qtcname = "hDigQTC";
c03351ac 156 timename += i;
157 ampname += i;
158 qtcname += i;
740f0839 159 fhDigCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,5000);
ce44b07a 160 Add2DigitsList( fhDigCFD[i],i);
740f0839 161 fhDigLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,120000,150000);
ce44b07a 162 Add2DigitsList( fhDigLEDamp[i],i+24);
740f0839 163 fhDigQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,500);
ce44b07a 164 Add2DigitsList( fhDigQTC[i],i+48);
165 }
166
167 TH1F* fhDigEff = new TH1F("hDigEff","digits efficiency", 25,-0.5,24.5);
168 Add2DigitsList( fhDigEff,72);
169 TH1F* fhDigMean = new TH1F("hDigMean","online mean signal", 100,500,600);
170 Add2DigitsList( fhDigMean,73);
171
c03351ac 172}
173
77270b9e 174//____________________________________________________________________________
175void AliT0QADataMaker::InitRaws()
176{
177 // create Raw histograms in Raw subdir
178 printf(" AliT0QADataMaker::InitRaws() started\n");
179 TString timename, ampname, qtcname;
180
181 TH1F *fhRawCFD[24]; TH1F * fhRawLEDamp[24]; TH1F *fhRawQTC[24];
182
183 for (Int_t i=0; i<24; i++)
184 {
185 timename ="hRawCFD";
186 ampname = "hRawLED";
187 qtcname = "hRawQTC";
188 timename += i;
189 ampname += i;
190 qtcname += i;
191 fhRawCFD[i] = new TH1F(timename.Data(), timename.Data(),100,100,5000);
192 Add2RawsList( fhRawCFD[i],i);
193 fhRawLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,120000,150000);
194 Add2RawsList( fhRawLEDamp[i],i+24);
195 fhRawQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,100,500);
196 Add2RawsList( fhRawQTC[i],i+48);
197 }
198
199 TH1F* fhRawMean = new TH1F("hRawMean","online mean signal", 100,500,600);
200 Add2DigitsList( fhRawMean,72);
201
202}
203
c03351ac 204//____________________________________________________________________________
205
206void AliT0QADataMaker::InitRecPoints()
207{
208 // create cluster histograms in RecPoint subdir
ce44b07a 209 /*
210 TH2F * fhRecCFD = new TH2F("fhRecCFD", " CFD reconstructed",25,-0.5,24.5,100,12,13);
211 Add2DigitsList( fhRecCFD,0);
212 TH2F *fhRecLEDamp = new TH2F("fhRecLEDamp", " amplitude LED reconstructed",25,-0.5,24.5,100,1000,1000);
213 Add2DigitsList( fhRecLEDamp,1);
214 TH2F * fhRecQTC = new TH2F("fhRecQTC", " amplitude QTC reconstructed",25,-0.5,24.5,100,1000,1000);
215 Add2DigitsList( fhRecQTC,2);
216 TH1F * fhRecMean = new TH1F("hRecMean"," reconstructed mean signal",100,500,600);
217 Add2DigitsList( fhRecMean,3);
218 */
219
c03351ac 220 TString timename,ampname, qtcname;
ce44b07a 221 TH1F *fhRecCFD[24]; TH1F *fhRecLEDAmp[24]; TH1F * fhRecQTC[24];
c03351ac 222 for (Int_t i=0; i<24; i++)
223 {
740f0839 224 timename ="hRecCFD";
225 ampname = "hRecLED";
226 qtcname = "hRecQTC";
c03351ac 227 timename += i;
228 ampname += i;
229 qtcname += i;
740f0839 230 fhRecCFD[i] = new TH1F(timename.Data(), timename.Data(),100,0,1000);
ce44b07a 231 Add2RecPointsList ( fhRecCFD[i],i);
740f0839 232 fhRecLEDAmp[i] = new TH1F(ampname.Data(), ampname.Data(),100,0,200);
ce44b07a 233 Add2RecPointsList ( fhRecLEDAmp[i],i+24);
740f0839 234 fhRecQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),100,0,200);
ce44b07a 235 Add2RecPointsList ( fhRecQTC[i],i+48);
236 }
237
238 TH1F *fhRecEff = new TH1F("hRecEff","Efficiency rec.points",25,-0.5,24.5);
239 Add2RecPointsList ( fhRecEff,72);
240 TH1F * fhRecMean = new TH1F("hRecMean"," reconstructed mean signal",100,500,600);
241 Add2RecPointsList( fhRecMean,73);
242
c03351ac 243}
244//____________________________________________________________________________
245void AliT0QADataMaker::InitESDs()
246{
247 //create ESDs histograms in ESDs subdir
740f0839 248 TH1F *fhESDMean = new TH1F("hESDmean"," ESD mean",100,0,100);
ce44b07a 249 Add2ESDsList(fhESDMean, 0) ;
250 TH1F * fhESDVertex = new TH1F("hESDvertex","EAD vertex",100,-50,50);
251 Add2ESDsList(fhESDVertex, 1) ;
c03351ac 252
253
254}
255//____________________________________________________________________________
740f0839 256
257void AliT0QADataMaker::MakeHits(TTree *hitTree)
c03351ac 258{
259 //fills QA histos for Hits
740f0839 260 TClonesArray * hits = new TClonesArray("AliT0hit", 1000);
261
262 TBranch * branch = hitTree->GetBranch("T0") ;
263 if ( ! branch ) {
264 AliWarning("T0 branch in Hit Tree not found") ;
c03351ac 265 } else {
740f0839 266
267 if (branch) {
268 branch->SetAddress(&hits);
269 }else{
270 AliError("Branch T0 hit not found");
271 exit(111);
272 }
273 Int_t ntracks = (Int_t) hitTree->GetEntries();
274
275 if (ntracks<=0) return;
276 // Start loop on tracks in the hits containers
277 for (Int_t track=0; track<ntracks;track++) {
278 branch->GetEntry(track);
279 Int_t nhits = hits->GetEntriesFast();
280 for (Int_t ihit=0;ihit<nhits;ihit++)
281 {
282 AliT0hit * startHit = (AliT0hit*) hits->UncheckedAt(ihit);
283 if (!startHit) {
284 AliError("The unchecked hit doesn't exist");
285 break;
286 }
287 Int_t pmt=startHit->Pmt();
288 GetHitsData(pmt)->Fill(startHit->Time()) ;
289 }
ce44b07a 290 }
740f0839 291 }
c03351ac 292}
293
294//____________________________________________________________________________
740f0839 295void AliT0QADataMaker::MakeDigits( TTree *digitsTree)
c03351ac 296{
297 //fills QA histos for Digits
ce44b07a 298
c03351ac 299 TArrayI *digCFD = new TArrayI(24);
300 TArrayI *digLED = new TArrayI(24);
301 TArrayI *digQT0 = new TArrayI(24);
302 TArrayI *digQT1 = new TArrayI(24);
303 Int_t refpoint=0;
304
740f0839 305 TBranch *brDigits=digitsTree->GetBranch("T0");
306 AliT0digit *fDigits = new AliT0digit() ;
307 if (brDigits) {
308 brDigits->SetAddress(&fDigits);
309 }else{
310 AliError(Form("EXEC Branch T0 digits not found"));
311 return;
c03351ac 312 }
740f0839 313
314 digitsTree->GetEvent(0);
315 digitsTree->GetEntry(0);
316 brDigits->GetEntry(0);
317 fDigits->GetTimeCFD(*digCFD);
318 fDigits->GetTimeLED(*digLED);
319 fDigits->GetQT0(*digQT0);
320 fDigits->GetQT1(*digQT1);
321 refpoint = fDigits->RefPoint();
322 for (Int_t i=0; i<24; i++)
323 {
324 if (digCFD->At(i)>0) {
325 Int_t cfd=digCFD->At(i)- refpoint;
326 GetDigitsData(i) ->Fill(cfd);
327 GetDigitsData(i+24) -> Fill(digLED->At(i) - digCFD->At(i));
328 GetDigitsData(i+48) -> Fill(digQT1->At(i) - digQT0->At(i));
329 }
330 }
331
c03351ac 332 delete digCFD;
333 delete digLED;
334 delete digQT0;
335 delete digQT1;
336
337}
338
339
77270b9e 340//____________________________________________________________________________
341void AliT0QADataMaker::MakeRaws( AliRawReader* rawReader)
342{
343 Int_t allData[110][5];
344 for (Int_t i0=0; i0<105; i0++)
345 {
346 for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;
347 }
348 //fills QA histos for RAW
349 // sprintf(filename,"/home/t0/alice/testSep07/raw/t0%i.001.raw",fRunNumber);
350 // AliRawReader *reader = new AliRawReaderDate(filename);
351 //if(!reader) AliFatal(Form("Can not opne file ",filename));
352 rawReader = new AliRawReaderFile();
353 rawReader->LoadEquipmentIdsMap("T0map.txt");
354 // reader->RequireHeader(kFALSE);
355 rawReader->RequireHeader(kTRUE);
356 AliT0RawReader *start = new AliT0RawReader(rawReader);
357
358 while (rawReader->NextEvent()) {
359 start->Next();
360 for (Int_t i=0; i<105; i++)
361 for (Int_t iHit=0; iHit<5; iHit++)
362 allData[i][iHit]= start->GetData(i,iHit);
363
364
365 for (Int_t ik = 0; ik<24; ik+=2){
366 for (Int_t iHt=0; iHt<5; iHt++){
367 Int_t cc = ik/2;
368 if(allData[cc+1][iHt]!=0){
369 GetRawsData(cc) -> Fill(allData[cc+1][iHt]-allData[0][0]);
370 if(allData[ik+25][iHt]!=0 && allData[ik+26][iHt]!=0)
371 GetRawsData(cc+48)->Fill(allData[ik+26][iHt]-allData[ik+25][iHt]);
372 if(allData[cc+13][iHt]!=0 )
373 GetRawsData(cc+24)->Fill(allData[cc+13][iHt]-allData[cc+1][iHt]);
374 }
375 }
376 }
377
378 for (Int_t ik = 24; ik<48; ik+=2) {
379 for (Int_t iHt=0; iHt<5; iHt++) {
380 Int_t cc = ik/2;
381 if(allData[cc+45][iHt]!=0) {
382 GetRawsData(cc)->Fill(allData[cc+1][iHt]-allData[0][0]);
383 if(allData[ik+57][iHt]!=0 && allData[ik+58][iHt]!=0)
384 GetRawsData(cc+48)->Fill(allData[ik+57][iHt]-allData[ik+58][iHt]);
385 if(allData[cc+57][iHt]!=0 )
386 GetRawsData(cc+48)->Fill(allData[cc+57][iHt]-allData[cc+45][iHt]);
387 }
388 }
389 }
390
391 }
392
393}
394
c03351ac 395//____________________________________________________________________________
396void AliT0QADataMaker::MakeRecPoints(TTree * clustersTree)
397{
398 //fills QA histos for clusters
399
400 AliT0RecPoint* frecpoints= new AliT0RecPoint ();
401 if (!frecpoints) {
402 AliError("Reconstruct Fill ESD >> no recpoints found");
403 return;
404 }
405 TBranch *brRec =clustersTree ->GetBranch("T0");
406 if (brRec) {
407 brRec->SetAddress(&frecpoints);
408 }else{
77270b9e 409 AliError(Form("EXEC Branch T0 rec not found "));
410 return;
c03351ac 411 }
412
413 brRec->GetEntry(0);
414
415 for ( Int_t i=0; i<24; i++) {
ce44b07a 416 GetRecPointsData(i) -> Fill(frecpoints -> GetTime(i));
417 GetRecPointsData(i+24) -> Fill(frecpoints -> GetAmp(i));
418 GetRecPointsData(i+48) -> Fill(frecpoints->AmpLED(i));
419 // if(frecpoints -> GetTime(i) > 0) fhRecEff->Fill(i);
c03351ac 420 }
ce44b07a 421 GetRecPointsData(72) ->Fill(frecpoints->GetMeanTime());
c03351ac 422
423}
424
425//____________________________________________________________________________
426void AliT0QADataMaker::MakeESDs(AliESDEvent * esd)
427{
428 //fills QA histos for ESD
429
ce44b07a 430 GetESDsData(0) -> Fill(esd->GetT0());
431 GetESDsData(1)-> Fill(esd->GetT0zVertex());
c03351ac 432
433}
434