vertex histograms X axis in cm
[u/mrichter/AliRoot.git] / T0 / AliT0QADataMakerRec.cxx
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 //  Alla.Maevskaya@cern.ch
22 //---
23
24 // --- ROOT system ---
25 #include <TClonesArray.h>
26 #include <TFile.h> 
27 #include <TH1F.h> 
28 #include <TH2F.h> 
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 #include "AliT0RecoParam.h"
42 #include "THnSparse.h"
43
44 #include "Riostream.h"
45 ClassImp(AliT0QADataMakerRec)
46            
47 //____________________________________________________________________________ 
48   AliT0QADataMakerRec::AliT0QADataMakerRec() : 
49 AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kT0), 
50                   "T0 Quality Assurance Data Maker"),
51   fnEventCal(0),
52   fnEventPhys(0)
53
54 {
55   // ctor
56   for (Int_t i=0; i<6; i++) {
57     fNumTriggers[i]=0;
58     fNumTriggersCal[i]=0;
59     fTrEffCal[i] = 0;
60     fTrEffPhys[i] = 0;
61
62   }
63   for (Int_t i=0; i<24; i++)
64     {
65       feffC[i]=0;
66       feffA[i]=0;
67       feffqtc[i]=0;
68    }
69 }
70
71 //____________________________________________________________________________ 
72 AliT0QADataMakerRec::AliT0QADataMakerRec(const AliT0QADataMakerRec& qadm) :
73   AliQADataMakerRec(),
74   fnEventCal(0),
75   fnEventPhys(0)
76
77   
78 {
79   //copy ctor 
80  SetName((const char*)qadm.GetName()) ; 
81   SetTitle((const char*)qadm.GetTitle()); 
82 }
83
84 //__________________________________________________________________
85 AliT0QADataMakerRec& AliT0QADataMakerRec::operator = (const AliT0QADataMakerRec& qadm )
86 {
87   // Equal operator.
88   this->~AliT0QADataMakerRec();
89   new(this) AliT0QADataMakerRec(qadm);
90   return *this;
91 }
92 //____________________________________________________________________________
93 void AliT0QADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
94 {
95   //Detector specific actions at end of cycle
96   // do the QA checking
97   AliQAChecker::Instance()->Run(AliQAv1::kT0, task, list) ;
98   
99   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
100     if (! IsValidEventSpecie(specie, list)) 
101       continue ;
102     SetEventSpecie(AliRecoParam::ConvertIndex(specie)) ; 
103     if ( task == AliQAv1::kRAWS ) {
104       GetRawsData(0)->SetLabelSize(0.02);
105       const Char_t *triggers[6] = {"mean", "vertex","ORA","ORC","central","semi-central"};
106       for (Int_t itr=0; itr<6; itr++) {
107         if ( fnEventCal>0) 
108           fTrEffCal[itr] = Float_t (fNumTriggersCal[itr])/Float_t (fnEventCal);
109         if ( fnEventPhys>0) 
110           fTrEffPhys[itr] = Float_t (fNumTriggers[itr])/Float_t (fnEventPhys);
111
112         GetRawsData(420)->Fill(triggers[itr], fTrEffCal[itr]);
113         GetRawsData(420)->SetBinContent(itr+1, fTrEffCal[itr]);
114         GetRawsData(97)->Fill(triggers[itr], fTrEffPhys[itr]);
115         GetRawsData(97)->SetBinContent(itr+1, fTrEffPhys[itr]);
116       } 
117       Float_t effic=0;
118       for(Int_t ik=0; ik<24; ik++)
119         {  
120           effic=0;
121           if ( fnEventCal>0) effic = Float_t(feffC[ik])/Float_t(fnEventCal);
122           GetRawsData(205)->SetBinContent(ik+1,effic) ;
123           effic=0;
124           if ( fnEventCal>0) effic = Float_t(feffA[ik])/Float_t(fnEventCal);
125           GetRawsData(206)->SetBinContent(ik+1,effic );
126           effic=0;
127           if ( fnEventCal>0) effic = Float_t(feffqtc[ik])/Float_t(fnEventCal);
128           GetRawsData(207)->SetBinContent(ik+1, effic);
129         }
130       
131       
132     }
133     
134   }
135
136 }
137 //____________________________________________________________________________
138 void AliT0QADataMakerRec::StartOfDetectorCycle()
139 {
140   //Detector specific actions at start of cycle
141
142
143 }
144  
145 //____________________________________________________________________________ 
146 void AliT0QADataMakerRec::InitRaws()
147 {
148   // create Raw histograms in Raw subdir
149   const Bool_t expert   = kTRUE ; 
150   const Bool_t saveCorr = kTRUE ; 
151   const Bool_t image    = kTRUE ; 
152   Float_t low[500];
153   Float_t high[500];
154
155   
156   for (Int_t i=0; i<500; i++){
157     //    low[i]  = GetRecoParam()->GetLow(i);
158     ///   high[i]  = GetRecoParam()->GetHigh(i);
159     low[i] = 0;
160     high[i] = 10000;
161
162   }
163
164   TString timename, ampname, qtcname, ledname;
165   TString timeCalname, ampCalname, ledCalname, qtcCalname;
166   TString qt1name, qt0name, qt1Calname, qt0Calname;
167   TString nhits;
168
169   TH1F* fhRefPoint = new TH1F("hRefPoint","Ref Point", 20000, 575000 ,595000);
170   Add2RawsList( fhRefPoint,0, expert, !image, !saveCorr);
171
172   TH1F* fhRefPointcal = new TH1F("hRefPointcal","Ref Point laser", 10000, 18000 ,28000);
173   Add2RawsList( fhRefPointcal,358, expert, !image, !saveCorr);
174
175   TH1F *fhRawCFD[24]; 
176   TH1F * fhRawLEDamp[24];
177   TH1F *fhRawQTC[24]; TH1F * fhRawLED[24];
178   TH1F *fhRawCFDcal[24]; TH1F * fhRawLEDampcal[24]; 
179   TH1F *fhRawCFDcalpmt[24];  
180   TH1F *fhRawCFDpmt[24];
181   TH1F *fhRawQTCcal[24];  TH1F * fhRawLEDcal[24];
182   TH1F *fhRawQT0cal[24]; TH1F *fhRawQT1cal[24];
183   TH1F *fhRawQT1[24]; TH1F *fhRawQT0[24];
184   TH1F* fhRawNhits[24];
185  
186   for (Int_t i=0; i<24; i++)
187     {
188       timename ="hRawCFD";
189       ledname = "hRawLED";
190       qtcname = "hRawQTC";
191       qt0name = "hRawQT0_";
192       qt1name = "hRawQT1_";
193       ampname = "hRawLEDminCFD";
194       nhits = "hRawNhits";
195       timename += i+1;
196       ampname += i+1;
197       qtcname += i+1;
198       qt0name += i+1;
199       qt1name += i+1;
200       ledname += i+1;
201       nhits   += i+1;
202       // fhRawCFD[i] = new THnSparseF(timename.Data(), Form("%s;CFD [#channels];Counts", timename.Data()),1,spabins,spaxmin,spaxmax);
203       fhRawCFD[i] = new TH1F(timename.Data(), Form("%s;CFD [#channels];Counts", timename.Data()),Int_t(high[i+1]-low[i+1]),low[i+1],high[i+1]);
204         Add2RawsList( fhRawCFD[i],i+1, expert, !image, !saveCorr);
205         fhRawLED[i] = new TH1F(ledname.Data(),  Form("%s;LED[#channels];Counts", ledname.Data()),Int_t(high[i+24+1]-low[i+24+1]),low[i+24+1],high[i]);
206       Add2RawsList( fhRawLED[i],i+24+1, expert, !image, !saveCorr);
207       fhRawLEDamp[i] = new TH1F(ampname.Data(),  Form("%s;LED-CFD [#channels];Counts", ampname.Data()),1000,0,1000);
208      Add2RawsList( fhRawLEDamp[i],i+48+1, expert, !image, !saveCorr);
209       fhRawQTC[i] = new TH1F(qtcname.Data(),  Form("%s;QTC[#channels];Counts", qtcname.Data()),10000,0,10000);
210       Add2RawsList( fhRawQTC[i],i+72+1, expert, !image, !saveCorr);
211       fhRawQT1[i] = new TH1F(qt1name.Data(),  Form("%s;QT1[#channels];Counts", qtcname.Data()),Int_t(high[270+i]-low[270+i]),low[270+i],high[270+i]);
212        Add2RawsList( fhRawQT1[i],270+i, expert, !image, !saveCorr);
213        fhRawQT0[i] = new TH1F(qt0name.Data(),  Form("%s;QT0[#channels];Counts", qtcname.Data()),Int_t(high[270+24+i]-low[270+24+i]),low[270+24+i],high[270+24+i]);
214      Add2RawsList( fhRawQT0[i],270+24+i, expert, !image, !saveCorr);
215
216       fhRawNhits[i] = new TH1F(nhits.Data(),  Form("%s;#Hits;Events", nhits.Data()),10, 0, 10);
217      Add2RawsList( fhRawNhits[i],244+i, expert, !image, !saveCorr);
218
219     }
220   TH1F* fhRawTrigger = new TH1F("hRawTrigger"," phys triggers;Trigger #;Counts",5,0,5);
221   Add2RawsList(fhRawTrigger ,97, expert, !image, !saveCorr);
222
223   TH1F* fhRawMean = new TH1F("hRawMean","online mean signal, physics event;",Int_t(high[98]-low[98]),low[98],high[98]);
224   Add2RawsList( fhRawMean,98, expert, !image, !saveCorr);
225
226   TH1F* fhRawVertex = new TH1F("hRawVertex","online vertex signal; counts",Int_t(high[100]-low[99]),low[99],high[99]);
227   Add2RawsList( fhRawVertex,99, expert, !image, !saveCorr);
228
229   TH1F* fhRawORA = new TH1F("hRawORA","online OR A; counts",Int_t(high[100]-low[100]),low[100],high[100]);
230   Add2RawsList( fhRawORA,100, expert, !image, !saveCorr);
231   TH1F* fhRawORC = new TH1F("hRawORC","online OR C;counts",Int_t( high[101]-low[101]),low[101],high[101]);
232   Add2RawsList( fhRawORC,101, expert, !image, !saveCorr);
233
234
235   for (Int_t i=0; i<24; i++)
236     {
237       // for events with trigger CALIBRATION_EVENT
238       timeCalname ="hRawCFDcal";
239       ledCalname = "hRawLEDcal";
240       ampCalname = "hRawLEDminCFDcal";
241       qtcCalname = "hRawQTCcal";
242       qt0Calname = "hRawQT0cal";
243       qt1Calname = "hRawQT1cal";
244       timeCalname += i+1;
245       ledCalname += i+1;
246       ampCalname += i+1;
247       qtcCalname += i+1;
248       qt0Calname += i+1;
249       qt1Calname += i+1;
250  
251       fhRawCFDcal[i] = new TH1F(timeCalname.Data(),  Form("%s;Time ;Counts", timeCalname.Data()),Int_t(high[101+i+1]-low[101+i+1]),low[101+i+1],high[101+i+1]);
252       Add2RawsList( fhRawCFDcal[i],101+i+1, expert, !image, !saveCorr);
253  
254       fhRawLEDcal[i] = new TH1F(ledCalname.Data(),  Form("%s;Time ;Counts", ledCalname.Data()),Int_t(high[101+i+24+1]-low[101+i+24+1]),low[101+i+24+1],high[101+i+24+1]);
255       Add2RawsList( fhRawLEDcal[i],101+i+24+1, expert, !image, !saveCorr);
256
257       fhRawLEDampcal[i] = new TH1F(ampCalname.Data(), Form("%s;Amplitude [ADC counts];Counts", ampCalname.Data()),1000,0,1000);
258       Add2RawsList( fhRawLEDampcal[i],101+i+48+1, expert, !image, !saveCorr);
259
260       fhRawQTCcal[i] = new TH1F(qtcCalname.Data(), Form("%s;Charge ;Counts",qtcCalname.Data()),10000,0,10000);
261       Add2RawsList( fhRawQTCcal[i],101+i+72+1, expert, !image, !saveCorr);
262
263       fhRawQT0cal[i] = new TH1F(qt0Calname.Data(), Form("%s;Charge ;Counts",qt0Calname.Data()),Int_t(high[371+i]-low[371+i]),low[371+i],high[371+i]);
264       Add2RawsList( fhRawQT0cal[i],371+i, expert, !image, !saveCorr);
265
266       fhRawQT1cal[i] = new TH1F(qt1Calname.Data(), Form("%s;Charge ;Counts",qt1Calname.Data()),Int_t(high[i+371+24]-low[i+371+24]),low[i+371+24],high[i+371+24]);
267       Add2RawsList( fhRawQT1cal[i],i+371+24, expert, !image, !saveCorr);
268
269       }
270
271   //from PMT1 (equalizing)
272   for (Int_t i=0; i<24; i++)
273     {
274       // for events with trigger CALIBRATION_EVENT
275       timeCalname ="hRawCFDcalpmt";
276       timename ="hRawCFDpmt";
277       timeCalname += i+1;
278       ledCalname += i+1;
279       timename += i+1;
280       ledname += i+1;
281       fhRawCFDcalpmt[i] = new TH1F(timeCalname.Data(),  Form("%s;Time;Counts", timeCalname.Data()),2000,-1000,1000);
282        Add2RawsList( fhRawCFDcalpmt[i],321+i , expert, !image, !saveCorr);
283
284       fhRawCFDpmt[i] = new TH1F(timename.Data(),  Form("%s;Time;Counts", timename.Data()),2000,-1000,1000);
285       Add2RawsList( fhRawCFDpmt[i],220+i, expert, !image, !saveCorr);
286      }
287
288   TH1F* fhRawTriggerCal = new TH1F("hRawTriggerCal"," laser triggers",6,0,6);
289   Add2RawsList(fhRawTriggerCal ,420 , !expert, image, !saveCorr);
290  
291   TH1F* fhRawMeanCal = new TH1F("hRawMeanCal","online mean signal, calibration event",Int_t(high[198]-low[198]),low[198],high[198]);
292   Add2RawsList( fhRawMeanCal,198, expert, !image, !saveCorr);
293  
294   TH1F* fhRawVertexCal = new TH1F("hRawVertexCal","online vertex signal, calibration event ",Int_t( high[199]-low[199]),low[199],high[199] );
295    Add2RawsList( fhRawVertexCal,199, expert, !image, !saveCorr);
296  
297  
298    TH1F* fhRawORAcal = new TH1F("hRawORAcal","laser OR A; counts",Int_t( high[200]-low[200]),low[200],high[200]);
299    Add2RawsList( fhRawORAcal,200, expert, !image, !saveCorr );
300  
301  
302    TH1F* fhRawORCcal = new TH1F("hRawORCcal","laserOR C;counts ",Int_t( high[201]-low[201]),low[201],high[201]);
303    Add2RawsList( fhRawORCcal,201, expert, !image, !saveCorr);
304  
305
306   //multiplicity trigger
307    TH1F* fhMultcal = new TH1F("hMultcal","full mulltiplicity;Multiplicity;Entries",Int_t( high[202]-low[202]),low[202],high[202]);
308   Add2RawsList( fhMultcal,202, expert, !image, !saveCorr );
309    TH1F* fhMultScal = new TH1F("hMultSemical","full multiplicity with semi-central trigger;Multiplicity;Entries",
310                                Int_t( high[203]-low[203]),low[203],high[203] );
311   Add2RawsList( fhMultScal,203, expert, !image, !saveCorr);
312   TH1F* fhMultCcal = new TH1F("hMultCentrcal","full multiplicity with central trigger;Multiplicity;Entries", 
313                               Int_t( high[204]-low[204]),low[204],high[204]);
314   Add2RawsList( fhMultCcal,204, expert, !image, !saveCorr);
315  
316   TH1F* fhMult = new TH1F("hMult","full mulltiplicity;Multiplicity;Entries", high[216]-low[216],low[216],high[216]);
317   Add2RawsList( fhMult,216, expert, !image, !saveCorr );
318    TH1F* fhMultS = new TH1F("hMultSemi","full multiplicity with semi-central trigger;Multiplicity;Entries",
319                             Int_t( high[217]-low[217]),low[217],high[217] );
320   Add2RawsList( fhMultS,217, expert, !image, !saveCorr);
321   TH1F* fhMultC = new TH1F("hMultCentr","full multiplicity with central trigger;Multiplicity;Entries", 
322                              high[218]-low[218],low[218],high[218]);
323   Add2RawsList( fhMultC,218, expert, !image, !saveCorr);
324
325   TH1F* fhEffCFD = new TH1F("hEffCFD","#PMT; #CFD counts/nEvents",24, 0 ,24); 
326   Add2RawsList( fhEffCFD,205, !expert, image, !saveCorr);
327  
328   TH1F* fhEffLED = new TH1F("hEffLED","#PMT; #LED counts/nEvent",24, 0 ,24);
329   Add2RawsList( fhEffLED,206, !expert, image, !saveCorr);
330
331   TH1F* fhEffQTC = new TH1F("hEffQTC","#PMT; QTC efficiency%s;",24, 0 ,24);
332   Add2RawsList( fhEffQTC,207, !expert, image, !saveCorr);
333
334   
335   TH2F* fhCFDcal = new TH2F("hCFDcal","CFD laser; #PMT; CFD {#channnels}",25, 0 ,25,Int_t(high[208]-low[208]),low[208],high[208]);
336   fhCFDcal->SetOption("COLZ");
337   Add2RawsList( fhCFDcal,208, !expert, image, !saveCorr);
338
339
340   TH2F* fhLEDcal = new TH2F("hLEDcal","LED laser; #PMT; LED [#channnels]",25, 0 ,25,Int_t( high[209]-low[209]),low[209],high[209]);
341   fhLEDcal->SetOption("COLZ");
342   Add2RawsList( fhLEDcal,209, !expert, image, !saveCorr);
343
344   TH2F* fhQTCcal = new TH2F("hQTCcal","QTC laser; #PMT; QTC [#channnels]",25, 0 ,25,Int_t( high[209]-low[209]),low[209],high[209]);
345   fhQTCcal->SetOption("COLZ");
346   Add2RawsList( fhQTCcal,210, !expert, image, !saveCorr);
347
348
349   TH1F* fhNumPMTA= new TH1F("hNumPMTA","number of PMT hitted per event",13, 0 ,13);
350   Add2RawsList(fhNumPMTA ,211, expert, !image, !saveCorr);
351
352   TH1F* fhNumPMTC= new TH1F("hNumPMTC","number of PMT hitted per event",13, 0 ,13);
353   Add2RawsList(fhNumPMTC ,212, expert, !image, !saveCorr);
354
355   TH1F* fhHitsOrA= new TH1F("fhHitsOrA","T0_OR A hit multiplicitie",10, 0 ,10);
356   Add2RawsList( fhHitsOrA,213, expert, !image, !saveCorr);
357
358   TH1F* fhHitsOrC= new TH1F("fhHitsOrC","T0_OR C hit multiplicitie",10, 0 ,10);
359   Add2RawsList(fhHitsOrC ,214, expert, !image, !saveCorr);
360
361
362   TH1F* fhOrCminOrA= new TH1F("fhOrCminOrA","T0_OR C - T0_OR A",10000,-5000,5000);
363   Add2RawsList( fhOrCminOrA,215, expert, !image, !saveCorr);
364
365   TH1F* fhOrCminOrAcal= new TH1F("fhOrCminOrAcal","T0_OR C - T0_OR A",10000,-5000,5000);
366   Add2RawsList( fhOrCminOrAcal,219, expert, !image, !saveCorr);
367
368   TH1F* fhOrCminOrATvdcOn= new TH1F("fhOrCminOrATvdcOn","T0_OR C - T0_OR A TVDC on",10000,-5000,5000);
369   Add2RawsList( fhOrCminOrATvdcOn,350, expert, !image, !saveCorr);
370
371   TH1F* fhOrCminOrATvdcOncal= new TH1F("fhOrCminOrATvdcOncal","T0_OR C - T0_OR A TVDC on laser",10000,-5000,5000);
372   Add2RawsList( fhOrCminOrATvdcOncal,351, expert, !image, !saveCorr);
373
374   TH1F* fhOrCminOrATvdcOff= new TH1F("fhOrCminOrATvdcOff","T0_OR C - T0_OR A TVDC off",10000,-5000,5000);
375   Add2RawsList( fhOrCminOrATvdcOff,352, expert, !image, !saveCorr);
376
377   TH1F* fhOrCminOrATvdcOffcal= new TH1F("fhOrCminOrATvdcOffcal","T0_OR C - T0_OR ATVDC off laser",10000,-5000,5000);
378   Add2RawsList( fhOrCminOrATvdcOffcal,353, expert, !image, !saveCorr);
379
380   TH1F* fhCFD1abs= new TH1F("fhCFD1abs"," CFD 1 pure ( L1) ", 20000, 575000, 595000 );
381   Add2RawsList(fhCFD1abs ,354, expert, !image, !saveCorr);
382
383   TH1F* fhCFD2abs= new TH1F("fhCFD2abs"," CFD 2 pure ( L1)  ", 20000, 575000, 595000 );
384   Add2RawsList( fhCFD2abs,355, expert, !image, !saveCorr);
385
386   TH1F* fhCFD1abscal= new TH1F("fhCFD1abscal"," CFD 1 pure ( L1)laser ", 10000, 18000 ,28000 );
387   Add2RawsList(fhCFD1abscal,356, expert, !image, !saveCorr);
388
389   TH1F* fhCFD2abscal= new TH1F("fhCFD2abscal"," CFD 2 pure ( L1)laser ", 10000, 18000 ,28000 );
390   Add2RawsList( fhCFD2abscal,357, expert, !image, !saveCorr);
391
392  const Char_t *triggers[6] = {"mean", "vertex","ORA","ORC","central","semi-central"};
393   for (Int_t itr=0; itr<6; itr++) {
394     GetRawsData(420)->Fill(triggers[itr], fNumTriggersCal[itr]);
395     GetRawsData(420)->SetBinContent(itr+1, fNumTriggersCal[itr]);
396     GetRawsData(97)->Fill(triggers[itr], fNumTriggers[itr]);
397     GetRawsData(97)->SetBinContent(itr+1, fNumTriggers[itr]);
398   }  
399 }
400
401 //____________________________________________________________________________ 
402 void AliT0QADataMakerRec::InitDigits()
403 {
404   // create Digits histograms in Digits subdir
405   const Bool_t expert   = kTRUE ; 
406   const Bool_t image    = kTRUE ; 
407   
408   TH2F * fhDigCFD = new TH2F("fhDigCFD", " CFD digits; #PMT; CFD digits[#channels]",25,-0.5,24.5,100,0,1000);
409   fhDigCFD->SetOption("COLZ");
410   Add2DigitsList( fhDigCFD,0, !expert, image);
411   TH2F *fhDigLEDamp = new TH2F("fhDigLEDamp", " LED-CFD digits; #PMT; LED-CFD amplitude ",25,-0.5,24.5,100,100,1000);
412   fhDigLEDamp->SetOption("COLZ");
413   Add2DigitsList( fhDigLEDamp,1, !expert, !image);
414   TH2F * fhDigQTC = new TH2F("fhDigQTC", " QTC digits; #PMT; QTC amplitude",25,-0.5,24.5,100,100,10000);
415   fhDigQTC->SetOption("COLZ");
416   Add2DigitsList( fhDigQTC,2, !expert, !image);}
417
418 //____________________________________________________________________________ 
419
420 void AliT0QADataMakerRec::InitRecPoints()
421 {
422   // create cluster histograms in RecPoint subdir
423   const Bool_t expert   = kTRUE ; 
424   const Bool_t image    = kTRUE ; 
425
426   TH2F* fhRecCFD = new TH2F("hRecCFD"," CFD time;#PMT; CFD Time [ns];",24, 0 ,24, 
427                               100,-50,50);
428   fhRecCFD->SetOption("COLZ");
429   Add2RecPointsList ( fhRecCFD,0, !expert, image);
430
431   TH2F* fhRecAmpDiff = new TH2F("hRecAmpDiff"," LED-CFD  min QTC amplitude;#PMT; difference [MIPs];",
432                                 24, 0 ,24, 200,-10,10);
433   fhRecAmpDiff->SetOption("COLZ");
434   Add2RecPointsList (fhRecAmpDiff, 1, !expert, image);
435   
436   TH1F *fhMean = new TH1F("hMean","online - rec mean;online - rec mean[#channels];",2000, -1000, 1000);
437   Add2RecPointsList ( fhMean,2, !expert, image);
438
439 }
440
441 //____________________________________________________________________________
442 void AliT0QADataMakerRec::InitESDs()
443 {
444   //create ESDs histograms in ESDs subdir
445   const Bool_t expert   = kTRUE ; 
446   const Bool_t image    = kTRUE ; 
447   
448   TH1F *fhESDMean = new TH1F("hESDmean"," ESD mean; mean time[%channels]",1000,0,1000);
449   Add2ESDsList(fhESDMean, 0, !expert, image) ;
450   TH1F * fhESDVertex = new TH1F("hESDvertex","ESDvertex; vertex[cm];",82,-30,30);
451   Add2ESDsList(fhESDVertex, 1, !expert, image) ;
452   
453
454 }
455
456 //____________________________________________________________________________
457 void AliT0QADataMakerRec::MakeRaws( AliRawReader* rawReader)
458 {
459
460   rawReader->Reset() ; 
461   //fills QA histos for RAW
462   Int_t shift=0;
463   // Int_t refPointParam = GetRecoParam()->GetRefPoint();
464   Int_t refpoint = 0;
465   Int_t refPointParam = 0;
466
467   AliT0RawReader *start = new AliT0RawReader(rawReader);
468   
469   if (! start->Next())
470     AliDebug(AliQAv1::GetQADebugLevel(),Form(" no raw data found!!"));
471   else
472     {  
473       
474       UInt_t type =rawReader->GetType();
475       if (type == 8){ shift=101; fnEventCal++;} 
476       if (type == 7){ shift=0;   fnEventPhys++;}
477       Int_t allData[110][5];
478       for (Int_t i0=0; i0<105; i0++)
479         {
480           for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;
481         }
482       for (Int_t i=0; i<105; i++) 
483         for (Int_t iHit=0; iHit<5; iHit++)
484           allData[i][iHit]= start->GetData(i,iHit);
485       
486       if ( type == 7  && allData[0][0] > 0 ) GetRawsData(0) -> Fill( allData[0][0]);
487       if ( type == 8  && allData[0][0] > 0 ) GetRawsData(358) -> Fill( allData[0][0]);
488  
489       refpoint = allData[refPointParam][0];
490       if (refPointParam <  0 ) refpoint=0; 
491       if (refPointParam == 0 ) refpoint = allData[0][0] - 5000;
492
493       Int_t numPmtC=0;    
494       for (Int_t ik = 0; ik<12; ik++)
495         {
496         //      for (Int_t iHt=0; iHt<1; iHt++){
497
498         Int_t nhitsPMT=0;
499         if(allData[ik+1][0]>0 && type == 7  ) numPmtC++;
500         for (Int_t iHt=0; iHt<5; iHt++){
501           //cfd
502           if(allData[ik+1][iHt]>0) {
503             GetRawsData(shift+ik+1) -> Fill(allData[ik+1][iHt]-refpoint);
504             if(allData[1][0]>0) 
505             GetRawsData(shift+ik+220) -> Fill(allData[ik+1][iHt]-allData[1][0]);
506             //      cout<<"C  cfd "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+1][iHt]-refpoint<<endl;
507             if(type == 8 && iHt==0 ) {
508               feffC[ik]++;
509               GetRawsData(208)->Fill(ik+1, allData[ik+1][iHt]-refpoint);
510             } 
511             if(type == 7  )  nhitsPMT++;
512             
513           }
514           //led
515           if(allData[ik+13][iHt] > 0) { 
516             GetRawsData(shift+ik+24+1)->  Fill(allData[ik+13][iHt]-refpoint);
517             //      cout<<"C  led "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+13][iHt]-refpoint<<endl;
518             if(type == 8   && iHt==0) {
519               feffA[ik]++;
520               GetRawsData(209)->Fill(ik+1, allData[ik+13][iHt]-refpoint);
521             }
522           }
523           //led -cfd
524
525           if(allData[ik+13][iHt] > 0 && allData[ik+1][iHt] >0 )
526             GetRawsData(shift+ik+48+1)->
527               Fill(allData[ik+13][iHt]-allData[ik+1][iHt]);
528
529           //qtc
530           if(allData[2*ik+25][iHt] > 0 || allData[2*ik+26][iHt] > 0) {
531             GetRawsData(shift+ik+72+1)->
532               Fill(allData[2*ik+25][iHt]-allData[2*ik+26][iHt]);
533             GetRawsData(shift+ik+270)->Fill(allData[2*ik+26][iHt] - refpoint);
534             GetRawsData(shift+ik+24+270)->Fill(allData[2*ik+25][iHt] - refpoint);
535
536             if(type == 8  && iHt==0 ) {
537               feffqtc[ik]++;
538               GetRawsData(210)->Fill(allData[2*ik+25][iHt]-allData[2*ik+26][iHt]);
539             }
540           }
541         }
542         if(type == 7  ) GetRawsData(ik+244)->Fill(nhitsPMT);
543       }
544       if(type == 7  ) GetRawsData(212)->Fill(numPmtC);
545       Int_t numPmtA=0;    
546        for (Int_t ik = 12; ik<24; ik++) {
547         //      for (Int_t iHt=0; iHt<1; iHt++) {
548         if(allData[ik+45][0]>0 && type == 7 ) numPmtA++;
549         Int_t nhitsPMT=0;
550         for (Int_t iHt=0; iHt<5; iHt++) {
551           if(allData[ik+45][iHt]>0) {
552             //cfd
553             GetRawsData(shift+ik+1)->
554               Fill(allData[ik+45][iHt]-refpoint);
555             if(allData[57][0]>0) 
556             GetRawsData(shift+ik+220) -> Fill(allData[ik+45][iHt]-allData[57][0]);
557
558             //      cout<<"A  cfd "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+1][iHt]-refpoint<<endl;
559             if(type == 8  ) {
560               feffC[ik]++;
561               GetRawsData(208)->Fill(ik+1, allData[ik+45][iHt]-refpoint);
562             } 
563             if(type == 7  )   nhitsPMT++;
564             
565
566           }
567           //led
568           if(allData[ik+57][iHt] > 0 ) {
569             GetRawsData(shift+ik+24+1)->Fill(allData[ik+57][iHt]-refpoint);
570             //   cout<<"C  led "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+13][iHt]-refpoint<<endl;
571             if(type == 8  ) {
572               feffA[ik]++;
573               GetRawsData(209)->Fill(ik+1, allData[ik+57][iHt]-refpoint);
574             }
575           }
576             //qtc         
577           if(allData[2*ik+57][iHt]>0 || allData[2*ik+58][iHt]>0)
578             {
579               GetRawsData(shift+ik+72+1)-> Fill(allData[2*ik+57][iHt]-allData[2*ik+58][iHt]);
580               GetRawsData(shift+ik+270)->Fill(allData[2*ik+58][iHt]-refpoint);
581               GetRawsData(shift+ik+24+270)->Fill(allData[2*ik+57][iHt]-refpoint);
582               if(type == 8  ){
583                 feffqtc[ik]++;
584                 GetRawsData(210)->Fill(allData[2*ik+57][iHt]-allData[2*ik+58][iHt]);
585               }
586             } 
587           //led-cfd
588           if(allData[ik+57][iHt] > 0 &&allData[ik+45][iHt]>0)
589             GetRawsData(shift+ik+48+1)->
590               Fill(allData[ik+57][iHt]-allData[ik+45][iHt]);
591         }
592         if(type == 7  ) GetRawsData(ik+244)->Fill(nhitsPMT);
593
594       }
595        if(type == 7  ) GetRawsData(211)->Fill(numPmtA);
596
597       Int_t trChannel[6] = {49,50,51,52,55,56};  
598  
599       Float_t ch2cm = 24.4*0.029979;     
600       if(type == 7)
601         {
602           Int_t nhitsOrA=0;
603           Int_t nhitsOrC=0;
604           for (Int_t iHt=0; iHt<5; iHt++) {
605             // pure CFD1 & CFD2 for trigger needs
606             if(allData[1][iHt]>0) GetRawsData(354)->Fill(allData[1][iHt]);
607             if(allData[2][iHt]>0) GetRawsData(355)->Fill(allData[2][iHt]);
608
609             //orA-orC phys tvdc 1 
610             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]>0)
611               GetRawsData(350)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
612             //orA-orC phys tvdc 0 
613             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]<=0)
614               GetRawsData(352)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
615             for (Int_t itr=0; itr<6; itr++) {
616               if (allData[trChannel[itr]][iHt] >0) {
617                 fNumTriggers[itr]++;
618                 GetRawsData(98+itr)->Fill(allData[trChannel[itr]][iHt]-refpoint);
619               }
620             }
621
622             if(allData[51][iHt] >0) nhitsOrA++;
623             if(allData[52][iHt] >0) nhitsOrC++;
624             
625             if(allData[53][iHt]>0 && allData[54][iHt]>0) {
626               GetRawsData(216)->Fill(allData[53][iHt]-allData[54][iHt]);
627               if(allData[55][iHt]>0) GetRawsData(216)->Fill(allData[53][iHt]-allData[54][iHt]);
628               if(allData[56][iHt]>0) GetRawsData(218)->Fill(allData[53][iHt]-allData[54][iHt]);
629             }
630             if(allData[51][iHt]>0 && allData[52][iHt]>0)
631               GetRawsData(215)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
632           }
633           GetRawsData(213)->Fill(nhitsOrA);
634           GetRawsData(214)->Fill(nhitsOrC);
635           
636         }
637       
638       if(type == 8)
639           {
640             for (Int_t iHt=0; iHt<5; iHt++) {
641               //pure CFD 1 & 2
642             if(allData[1][iHt]>0) GetRawsData(356)->Fill(allData[1][iHt]);
643             if(allData[2][iHt]>0) GetRawsData(357)->Fill(allData[2][iHt]);
644
645               //orA-orC laser
646             if(allData[51][iHt]>0 && allData[52][iHt]>0)
647               GetRawsData(219)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
648             //orA-orC laser tvdc 1 
649             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]>0)
650               GetRawsData(351)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
651             //orA-orC laser tvdc 0 
652             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]<=0)
653               GetRawsData(353)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
654             //trigger laser
655               for (Int_t itr=0; itr<6; itr++) {
656                 if(allData[trChannel[itr]][iHt]>0)
657                   {
658                     GetRawsData(198+itr)->
659                       Fill(allData[trChannel[itr]][iHt]-refpoint);
660                     fNumTriggersCal[itr]++;
661                   }
662               }
663               //mult trigger signals laser
664               if(allData[53][iHt]>0 && allData[54][iHt]>0) {
665                 GetRawsData(202)->Fill(allData[53][iHt]-allData[54][iHt]);
666                 if(allData[55][iHt]>0) GetRawsData(202)->Fill(allData[53][iHt]-allData[54][iHt]);
667                 if(allData[56][iHt]>0) GetRawsData(204)->Fill(allData[53][iHt]-allData[54][iHt]);
668               }
669             }
670           } 
671       
672            delete start;
673     }
674 }
675
676
677
678 //____________________________________________________________________________
679 void AliT0QADataMakerRec::MakeDigits( TTree *digitsTree)
680 {
681   //fills QA histos for Digits
682
683   TArrayI *digCFD = new TArrayI(24);
684   TArrayI *digLED = new TArrayI(24);
685   TArrayI *digQT0 = new TArrayI(24);
686   TArrayI *digQT1 = new TArrayI(24);
687   Int_t refpoint=0;
688   
689   TBranch *brDigits=digitsTree->GetBranch("T0");
690   AliT0digit *fDigits = new AliT0digit() ;
691   if (brDigits) {
692     brDigits->SetAddress(&fDigits);
693   }else{
694     AliError(Form("EXEC Branch T0 digits not found"));
695     return;
696   }
697   digitsTree->GetEvent(0);
698   digitsTree->GetEntry(0);
699   brDigits->GetEntry(0);
700   fDigits->GetTimeCFD(*digCFD);
701   fDigits->GetTimeLED(*digLED);
702   fDigits->GetQT0(*digQT0);
703   fDigits->GetQT1(*digQT1);
704   refpoint = fDigits->RefPoint();
705   for (Int_t i=0; i<24; i++)
706     {
707     if (digCFD->At(i)>0) {
708       Int_t cfd=digCFD->At(i)- refpoint;
709       GetDigitsData(0) ->Fill(i,cfd);
710       GetDigitsData(1) -> Fill(i, (digLED->At(i) - digCFD->At(i)));
711       GetDigitsData(2) -> Fill(i, (digQT1->At(i) - digQT0->At(i)));
712     }
713     }  
714   
715   delete digCFD;
716   delete digLED;
717   delete digQT0;
718   delete digQT1;
719   
720 }
721
722 //____________________________________________________________________________
723 void AliT0QADataMakerRec::MakeRecPoints(TTree * clustersTree)
724 {
725   //fills QA histos for clusters
726
727   AliT0RecPoint* frecpoints= new AliT0RecPoint ();
728   if (!frecpoints) {
729     AliError(":MakeRecPoints >> no recpoints found");
730     return;
731   }
732   TBranch *brRec =clustersTree ->GetBranch("T0");
733   if (brRec) {
734     brRec->SetAddress(&frecpoints);
735   }else{
736     AliError(Form("EXEC Branch T0 rec not found "));
737     return;
738   } 
739
740   brRec->GetEntry(0);
741   
742   for ( Int_t i=0; i<24; i++) {
743     if(i<12)
744       GetRecPointsData(0) -> Fill(i, frecpoints -> GetTime(i) - frecpoints -> GetTime(0)); 
745     if(i>11)
746       GetRecPointsData(0) -> Fill(i,  frecpoints -> GetTime(i) - frecpoints -> GetTime(12)); 
747     GetRecPointsData(1) -> Fill( i, frecpoints -> GetAmp(i) - frecpoints->AmpLED(i));
748   }
749   Double_t mmm=frecpoints->GetOnlineMean()- frecpoints->GetMeanTime();
750   GetRecPointsData(2) ->Fill(mmm);
751   
752 }
753
754 //____________________________________________________________________________
755 void AliT0QADataMakerRec::MakeESDs(AliESDEvent * esd)
756 {
757   //fills QA histos for ESD
758   
759   GetESDsData(0) -> Fill(esd->GetT0());
760   GetESDsData(1)-> Fill(esd->GetT0zVertex());
761   
762 }