adding Mihaela's macros to be used for the analysis train...
[u/mrichter/AliRoot.git] / T0 / AliT0QADataMakerRec.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/* $Id$ */
18
19//---
20// Produces the data needed to calculate the quality assurance.
1d7681da 21// Alla.Maevskaya@cern.ch
04236e67 22//---
23
24// --- ROOT system ---
25#include <TClonesArray.h>
26#include <TFile.h>
27#include <TH1F.h>
1d7681da 28#include <TH2F.h>
04236e67 29#include <TDirectory.h>
30// --- Standard library ---
31
32// --- AliRoot header files ---
33#include "AliESDEvent.h"
34#include "AliLog.h"
35#include "AliT0digit.h"
36#include "AliT0hit.h"
37#include "AliT0RecPoint.h"
38#include "AliT0QADataMakerRec.h"
39#include "AliQAChecker.h"
40#include "AliT0RawReader.h"
41
1d7681da 42#include "Riostream.h"
04236e67 43ClassImp(AliT0QADataMakerRec)
44
45//____________________________________________________________________________
46 AliT0QADataMakerRec::AliT0QADataMakerRec() :
3c85c814 47AliQADataMakerRec(AliQA::GetDetName(AliQA::kT0),
48 "T0 Quality Assurance Data Maker"),
49 fnEvent(0)
04236e67 50
51{
52 // ctor
1d7681da 53 for (Int_t i=0; i<6; i++) {
54 fNumTriggers[i]=0;
55 fNumTriggersCal[i]=0;
04236e67 56 }
b9024d69 57 for (Int_t i=0; i<24; i++)
58 {
59 feffC[i]=0;
60 feffA[i]=0;
61 }
04236e67 62}
63
64//____________________________________________________________________________
65AliT0QADataMakerRec::AliT0QADataMakerRec(const AliT0QADataMakerRec& qadm) :
3c85c814 66 AliQADataMakerRec(),
67 fnEvent(0)
68
04236e67 69{
70 //copy ctor
1d7681da 71 SetName((const char*)qadm.GetName()) ;
04236e67 72 SetTitle((const char*)qadm.GetTitle());
73}
74
75//__________________________________________________________________
76AliT0QADataMakerRec& AliT0QADataMakerRec::operator = (const AliT0QADataMakerRec& qadm )
77{
78 // Equal operator.
79 this->~AliT0QADataMakerRec();
80 new(this) AliT0QADataMakerRec(qadm);
81 return *this;
82}
83//____________________________________________________________________________
57acd2d2 84void AliT0QADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray ** list)
04236e67 85{
86 //Detector specific actions at end of cycle
87 // do the QA checking
c4b97145 88 AliQAChecker::Instance()->Run(AliQA::kT0, task, list) ;
57acd2d2 89 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
90 SetEventSpecie(specie) ;
91 if ( task == AliQA::kRAWS ) {
92 const Char_t *triggers[6] = {"mean", "vertex","ORA","ORC","central","semi-central"};
93 for (Int_t itr=0; itr<6; itr++) {
94 GetRawsData(197)->Fill(triggers[itr], fNumTriggersCal[itr]);
95 GetRawsData(197)->SetBinContent(itr+1, fNumTriggersCal[itr]);
96 }
97 GetRawsData(205)->SetOption("COLZ");
98 GetRawsData(206)->SetOption("COLZ");
99 GetRawsData(207)->SetOption("COLZ");
100 GetRawsData(205)->GetXaxis()->SetTitle("#PMT");
101 GetRawsData(206)->GetXaxis()->SetTitle("#PMT");
102 GetRawsData(205)->GetYaxis()->SetTitle("NeventsReg/Nevents");
103 GetRawsData(206)->GetYaxis()->SetTitle("NeventsReg/Nevents");
104 GetRawsData(207)->GetXaxis()->SetTitle("#PMT");
105 GetRawsData(207)->GetYaxis()->SetTitle("Charge, #channels");
106 }
107 if ( task == AliQA::kRECPOINTS) {
108 GetRecPointsData(0)->SetOption("COLZ");
109 GetRecPointsData(1)->SetOption("COLZ");
110 GetRecPointsData(0)->GetXaxis()->SetTitle("#PMT");
111 GetRecPointsData(1)->GetXaxis()->SetTitle("#PMT");
112 GetRecPointsData(0)->GetYaxis()->SetTitle("CFD time");
113 GetRecPointsData(1)->GetYaxis()->SetTitle("Charge, #channels");
114 }
115 }
04236e67 116}
117
118//____________________________________________________________________________
119void AliT0QADataMakerRec::StartOfDetectorCycle()
120{
121 //Detector specific actions at start of cycle
b9024d69 122 fnEvent=0;
04236e67 123
124}
125
126//____________________________________________________________________________
127void AliT0QADataMakerRec::InitRaws()
128{
129 // create Raw histograms in Raw subdir
1d7681da 130 TString timename, ampname, qtcname, ledname;
131 TString timeCalname, ampCalname, ledCalname, qtcCalname;
04236e67 132
86c020af 133 TH1F* fhRefPoint = new TH1F("hRefPoint","Ref Point", 10,1252170, 1252180);
134 Add2RawsList( fhRefPoint,0);
135
1d7681da 136 TH1F *fhRawCFD[24]; TH1F * fhRawLEDamp[24];
137 TH1F *fhRawQTC[24]; TH1F * fhRawLED[24];
138 TH1F *fhRawCFDcal[24]; TH1F * fhRawLEDampcal[24];
139 TH1F *fhRawQTCcal[24]; TH1F * fhRawLEDcal[24];
86c020af 140
04236e67 141 for (Int_t i=0; i<24; i++)
142 {
143 timename ="hRawCFD";
1d7681da 144 ledname = "hRawLED";
04236e67 145 qtcname = "hRawQTC";
1d7681da 146 ampname = "hRawLEDminCFD";
04236e67 147 timename += i;
148 ampname += i;
149 qtcname += i;
1d7681da 150 ledname += i;
151 fhRawCFD[i] = new TH1F(timename.Data(), timename.Data(),500,-250,250);
86c020af 152 Add2RawsList( fhRawCFD[i],i+1);
1d7681da 153 fhRawLED[i] = new TH1F(ledname.Data(), ledname.Data(),2000,-1000,1000);
154 Add2RawsList( fhRawLED[i],i+24+1);
446d6ec4 155 fhRawLEDamp[i] = new TH1F(ampname.Data(), ampname.Data(),100,300,600);
1d7681da 156 Add2RawsList( fhRawLEDamp[i],i+48+1);
86c020af 157 fhRawQTC[i] = new TH1F(qtcname.Data(), qtcname.Data(),1500,1000,7000);
1d7681da 158 Add2RawsList( fhRawQTC[i],i+72+1);
04236e67 159 }
b9024d69 160 // const Bool_t saveForCorr = kTRUE;
161 const Bool_t saveForCorr = kFALSE;
1d7681da 162 TH1F* fhRawTrigger = new TH1F("hRawTrigger"," phys triggers",5,0,5);
163 Add2RawsList(fhRawTrigger ,97);
164
86c020af 165 TH1F* fhRawMean = new TH1F("hRawMean","online mean signal", 100,2400,2500);
1d7681da 166 Add2RawsList( fhRawMean,98);
86c020af 167 TH1F* fhRawVertex = new TH1F("hRawVertex","online vertex signal", 100,0,600);
1d7681da 168 Add2RawsList( fhRawVertex,99);
86c020af 169 TH1F* fhRawORA = new TH1F("hRawORA","online OR A", 100,2500,2800);
1d7681da 170 Add2RawsList( fhRawORA,100);
86c020af 171 TH1F* fhRawORC = new TH1F("hRawORC","online OR C", 100,2000,2300);
1d7681da 172 Add2RawsList( fhRawORC,101);
173
5ed41460 174 for (Int_t i=0; i<24; i++)
175 {
176 // for events with trigger CALIBRATION_EVENT
177 timeCalname ="hRawCFDcal";
1d7681da 178 ledCalname = "hRawLEDcal";
179 ampCalname = "hRawLEDminCFDcal";
5ed41460 180 qtcCalname = "hRawQTCcal";
181 timeCalname += i;
1d7681da 182 ledCalname += i;
5ed41460 183 ampCalname += i;
184 qtcCalname += i;
1d7681da 185 fhRawCFDcal[i] = new TH1F(timeCalname.Data(), timeCalname.Data(),2000,-1000,1000);
186 Add2RawsList( fhRawCFDcal[i],101+i+1);
187 fhRawLEDcal[i] = new TH1F(ledCalname.Data(), ledCalname.Data(),2000,-1000,1000);
188 Add2RawsList( fhRawLEDcal[i],101+i+24+1);
189 fhRawLEDampcal[i] = new TH1F(ampCalname.Data(), ampCalname.Data(),300,300,600);
190 Add2RawsList( fhRawLEDampcal[i],101+i+48+1);
5ed41460 191 fhRawQTCcal[i] = new TH1F(qtcCalname.Data(), qtcCalname.Data(),1000,0,7000);
1d7681da 192 Add2RawsList( fhRawQTCcal[i],101+i+72+1);
5ed41460 193 }
1d7681da 194
195 TH1F* fhRawTriggerCal = new TH1F("hRawTriggerCal"," laser triggers",6,0,6);
c4b97145 196 Add2RawsList(fhRawTriggerCal ,197 ,saveForCorr);
1d7681da 197
5ed41460 198 TH1F* fhRawMeanCal = new TH1F("hRawMeanCal","online mean signal, calibration event",
54f32a55 199 10000,0,10000);
1d7681da 200 Add2RawsList( fhRawMeanCal,198);
5ed41460 201 TH1F* fhRawVertexCal = new TH1F("hRawVertexCal","online vertex signal, calibration even ",
54f32a55 202 10000,0,10000);
1d7681da 203 Add2RawsList( fhRawVertexCal,199);
54f32a55 204 TH1F* fhRawORAcal = new TH1F("hRawORAcal","online OR A", 10000,0,10000);
1d7681da 205 Add2RawsList( fhRawORAcal,200 );
54f32a55 206 TH1F* fhRawORCcal = new TH1F("hRawORCcal","online OR C", 10000,0,10000);
1d7681da 207 Add2RawsList( fhRawORCcal,201);
54f32a55 208 TH1F* fhMultcal = new TH1F("hMultcal","full mulltiplicity", 10000,0,10000);
1d7681da 209 Add2RawsList( fhMultcal,202 );
5ed41460 210 TH1F* fhMultScal = new TH1F("hMultScal","full multiplicity with semi-central trigger",
54f32a55 211 10000,0,10000);
1d7681da 212 Add2RawsList( fhMultScal,203);
5ed41460 213 TH1F* fhMultCcal = new TH1F("hMultCcal","full multiplicity with central trigger",
214 1000,0,10000);
1d7681da 215 Add2RawsList( fhMultCcal,204);
216
b9024d69 217 // TH2F* fhEffCFD = new TH2F("hEffCFD"," CFD time",24, 0 ,24,
218 // 100,-500,500);
219 TH2F* fhEffCFD = new TH2F("hEffCFD"," CFD time",24, 0 ,24, 50, 0,5);
220
c4b97145 221 Add2RawsList( fhEffCFD,205, saveForCorr);
1d7681da 222 TH2F* fhEffLED = new TH2F("hEffLED","LED time",24, 0 ,24,
b9024d69 223 100, 0, 5);
224 //100,-500,500);
225
c4b97145 226 Add2RawsList( fhEffLED,206, saveForCorr);
1d7681da 227 TH2F* fhEffQTC = new TH2F("hEffQTC","QTC amplitude",24, 0 ,24,
228 100,0,7000);
c4b97145 229 Add2RawsList( fhEffQTC,207, saveForCorr);
b9024d69 230 //yeys guide line
231 // TH2F* fhLineQTC = new TH2F("hLineQTC","QTC amplitude boeder",24, 0 ,24,
232 // 100,0,7000);
233// Add2RawsList( fhLineQTC,208, saveForCorr);
04236e67 234}
235
236//____________________________________________________________________________
237
238void AliT0QADataMakerRec::InitRecPoints()
239{
240 // create cluster histograms in RecPoint subdir
1d7681da 241
242
1d7681da 243
b9024d69 244 TH2F* fhRecCFD = new TH2F("hRecCFD"," CFD time",24, 0 ,24,
245 100,-50,50);
246 Add2RecPointsList ( fhRecCFD,0);
247
248 TH2F* fhRecAmpDiff = new TH2F("hRecAmpDiff"," LED-CFD min QTC amplitude",
249 24, 0 ,24, 200,-10,10);
250 Add2RecPointsList (fhRecAmpDiff, 1);
04236e67 251
b9024d69 252 TH1F *fhMean = new TH1F("hMean","online - rec mean",1000, -5000, 5000);
253 Add2RecPointsList ( fhMean,2);
254 }
04236e67 255
256//____________________________________________________________________________
257void AliT0QADataMakerRec::InitESDs()
258{
259 //create ESDs histograms in ESDs subdir
f6c2d5e2 260
446d6ec4 261 TH1F *fhESDMean = new TH1F("hESDmean"," ESD mean",100,2400,2500);
04236e67 262 Add2ESDsList(fhESDMean, 0) ;
1d7681da 263 TH1F * fhESDVertex = new TH1F("hESDvertex","ESD vertex",100,-50,50);
04236e67 264 Add2ESDsList(fhESDVertex, 1) ;
c724dd64 265
04236e67 266
267}
268
269//____________________________________________________________________________
270void AliT0QADataMakerRec::MakeRaws( AliRawReader* rawReader)
271{
78328afd 272 rawReader->Reset() ;
04236e67 273 //fills QA histos for RAW
5ed41460 274 Int_t shift=0;
b9024d69 275 Float_t effic ;
276
86c020af 277 AliT0RawReader *start = new AliT0RawReader(rawReader);
278 // start->Next();
279 if (! start->Next())
280 AliDebug(1,Form(" no raw data found!!"));
281 else
282 {
b9024d69 283 fnEvent++;
284
5ed41460 285 UInt_t type =rawReader->GetType();
286 // cout<<" !!!!! new event type = "<<type<<endl;
86c020af 287 Int_t allData[110][5];
288 for (Int_t i0=0; i0<105; i0++)
289 {
290 for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;
04236e67 291 }
86c020af 292 for (Int_t i=0; i<105; i++)
293 for (Int_t iHit=0; iHit<5; iHit++)
294 allData[i][iHit]= start->GetData(i,iHit);
295
1d7681da 296 if (allData[0][0]>0) GetRawsData(0) -> Fill( allData[0][0]);
297 // allData[0][0] = allData[0][0] - 7000;
298 if (type == 8) shift=101;
f6c2d5e2 299 if (type == 7) shift=0;
1d7681da 300
86c020af 301 for (Int_t ik = 0; ik<12; ik++){
302 for (Int_t iHt=0; iHt<5; iHt++){
1d7681da 303 //cfd
304 if(allData[ik+1][iHt]>0)
305 GetRawsData(shift+ik+1) ->
306 Fill(allData[ik+1][iHt]-allData[1][0]);
307 //led
308 if(allData[ik+13][iHt] > 0 && allData[13][iHt]>0)
309 GetRawsData(shift+ik+24+1)->
310 Fill(allData[ik+13][iHt]-allData[13][iHt]);
311 //led -cfd
312
313 if(allData[ik+13][iHt] > 0 && allData[ik+1][iHt] >0 )
314 GetRawsData(shift+ik+48+1)->
315 Fill(allData[ik+13][iHt]-allData[ik+1][iHt]);
316 //qtc
317 if(allData[2*ik+25][iHt] > 0 && allData[2*ik+26][iHt] > 0)
318 GetRawsData(shift+ik+72+1)->
319 Fill(allData[2*ik+25][iHt]-allData[2*ik+26][iHt]);
320
5ed41460 321
b9024d69 322 if(type == 8 && allData[ik+1][iHt]>0 ) feffC[ik]++;
323 if(type == 8 && allData[ik+13][iHt]>0 ) feffA[ik]++;
324 // GetRawsData(206)->Fill(ik,allData[ik+13][iHt]-allData[13][0]);
1d7681da 325 if(type == 8 && (allData[2*ik+25][iHt]>0 && allData[2*ik+26][iHt]>0) )
326 GetRawsData(207)->Fill(ik,allData[2*ik+25][iHt]-allData[2*ik+26][iHt]);
04236e67 327 }
b9024d69 328 effic = Float_t(feffC[ik])/Float_t(fnEvent);
329 GetRawsData(205)->Fill(ik,effic );
330 effic = Float_t(feffA[ik])/Float_t(fnEvent);
331 GetRawsData(206)->Fill(ik,effic );
332 // printf("CFD efficiency for PMT %i = %f \n", ik, effic);
86c020af 333 }
86c020af 334 for (Int_t ik = 12; ik<24; ik++) {
335 for (Int_t iHt=0; iHt<5; iHt++) {
1d7681da 336 if(allData[ik+45][iHt]>0)
337 //cfd
338 GetRawsData(shift+ik+1)->
339 Fill(allData[ik+45][iHt]-allData[57][0]);
340 //qtc
341 if(allData[2*ik+57][iHt]>0 && allData[2*ik+58][iHt]>0)
342 GetRawsData(shift+ik+72+1)->
343 Fill(allData[2*ik+57][iHt]-allData[2*ik+58][iHt]);
344 //led
345 if(allData[ik+57][iHt] > 0 )
346 GetRawsData(shift+ik+24+1)->
347 Fill(allData[ik+57][iHt]-allData[69][iHt]);
348 //led-cfd
349 if(allData[ik+57][iHt] > 0 &&allData[ik+45][iHt]>0)
350 GetRawsData(shift+ik+48+1)->
351 Fill(allData[ik+57][iHt]-allData[ik+45][iHt]);
352
b9024d69 353 if(type == 8 && allData[ik+45][iHt]>0 ) feffC[ik]++;
354
355 if(type == 8 && allData[ik+57][iHt]>0 ) feffA[ik]++;
356 // GetRawsData(206)->Fill(ik,allData[ik+57][iHt]-allData[69][0]);
357 if(type == 8 && (allData[2*ik+57][iHt]>0 && allData[2*ik+58][iHt]>0) )
358 GetRawsData(207)->Fill(ik,allData[2*ik+57][iHt]-allData[2*ik+58][iHt]);
86c020af 359 }
b9024d69 360 effic = Float_t(feffC[ik])/Float_t(fnEvent);
361 GetRawsData(205)->Fill(ik,effic );
362 effic = Float_t(feffA[ik])/Float_t(fnEvent);
363 GetRawsData(206)->Fill(ik,effic );
364 // printf("CFD efficiency for PMT %i = %f \n", ik, effic); }
86c020af 365 }
b9024d69 366
1d7681da 367 Int_t trChannel[6] = {49,50,51,52,55,56};
f6c2d5e2 368 if(type == 7)
5ed41460 369 {
1d7681da 370 for (Int_t iHt=0; iHt<6; iHt++) {
371 for (Int_t itr=0; itr<6; itr++) {
372 if(allData[trChannel[itr]][iHt]>0) fNumTriggers[itr]++;
373 }
f6c2d5e2 374 }
5ed41460 375 }
376 if(type == 8)
377 {
f6c2d5e2 378 for (Int_t iHt=0; iHt<5; iHt++) {
1d7681da 379 for (Int_t itr=0; itr<6; itr++) {
380 if(allData[trChannel[itr]][iHt]>0)
381 {
382
383 GetRawsData(198+itr)->Fill(allData[trChannel[itr]][iHt]-allData[1][0]);
384
385 fNumTriggersCal[itr]++;
386 }
387 }
b9024d69 388 if(allData[53][iHt]>0 && allData[54][iHt]>0)
389 GetRawsData(204)->Fill(allData[53][iHt]-allData[54][iHt]);
f6c2d5e2 390 }
1d7681da 391 }
392
b9024d69 393
1d7681da 394
86c020af 395 delete start;
b9024d69 396 }
86c020af 397 }
1d7681da 398
399
04236e67 400
401//____________________________________________________________________________
402void AliT0QADataMakerRec::MakeRecPoints(TTree * clustersTree)
403{
404 //fills QA histos for clusters
405
446d6ec4 406 AliT0RecPoint* frecpoints= new AliT0RecPoint ();
04236e67 407 if (!frecpoints) {
408 AliError("Reconstruct Fill ESD >> no recpoints found");
409 return;
410 }
411 TBranch *brRec =clustersTree ->GetBranch("T0");
412 if (brRec) {
413 brRec->SetAddress(&frecpoints);
414 }else{
415 AliError(Form("EXEC Branch T0 rec not found "));
416 return;
417 }
418
419 brRec->GetEntry(0);
b9024d69 420
04236e67 421 for ( Int_t i=0; i<24; i++) {
1d7681da 422 if(i<12)
b9024d69 423 GetRecPointsData(0) -> Fill(i, frecpoints -> GetTime(i) - frecpoints -> GetTime(0));
1d7681da 424 if(i>11)
b9024d69 425 GetRecPointsData(0) -> Fill(i, frecpoints -> GetTime(i) - frecpoints -> GetTime(12));
426 GetRecPointsData(1) -> Fill( i, frecpoints -> GetAmp(i) - frecpoints->AmpLED(i));
04236e67 427 }
b9024d69 428 Double_t mmm=frecpoints->GetOnlineMean()- frecpoints->GetMeanTime();
429 GetRecPointsData(2) ->Fill(mmm);
430 // printf(" AliT0QADataMakerRec: diff mean %f \n",mmm );
431 // GetRecPointsData(73) ->Fill(frecpoints->GetMeanTime());
04236e67 432
b9024d69 433
434
04236e67 435}
436
437//____________________________________________________________________________
438void AliT0QADataMakerRec::MakeESDs(AliESDEvent * esd)
439{
440 //fills QA histos for ESD
441
442 GetESDsData(0) -> Fill(esd->GetT0());
443 GetESDsData(1)-> Fill(esd->GetT0zVertex());
444
445}