calculating number of calibration evetns according signal on RP
[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, 25000 ,45000);
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[210]-low[210]),low[210],high[210]);
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, 0, 50000 );
381   Add2RawsList(fhCFD1abs ,354, expert, !image, !saveCorr);
382
383   TH1F* fhCFD2abs= new TH1F("fhCFD2abs"," CFD 2 pure ( L1)  ", 20000, 0, 50000 );
384   Add2RawsList( fhCFD2abs,355, expert, !image, !saveCorr);
385
386   TH1F* fhCFD1abscal= new TH1F("fhCFD1abscal"," CFD 1 pure ( L1)laser ", 20000,0 ,50000 );
387   Add2RawsList(fhCFD1abscal,356, expert, !image, !saveCorr);
388
389   TH1F* fhCFD2abscal= new TH1F("fhCFD2abscal"," CFD 2 pure ( L1)laser ", 20000, 0 ,50000 );
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   TH1F* fhT0meancal= new TH1F("fhT0meancal"," (OrA+OrC)/2 in ns Laser",  1000,-100,100) ;
401   Add2RawsList(fhT0meancal,421, expert, !image, !saveCorr);
402   TH1F* fhOrAnscal= new TH1F("fhOrAnscal"," OrA in ns Laser",  1000,-100,100) ;
403   Add2RawsList(fhOrAnscal,422, expert, !image, !saveCorr);
404   TH1F* fhOrCnscal= new TH1F("fhOrCnscal"," OrC in ns Laser",  1000,-100,100) ;
405   Add2RawsList(fhOrCnscal,423, expert, !image, !saveCorr);
406
407   TH1F* fhT0meanphys= new TH1F("fhT0meanphys"," (OrA+OrC)/2 in ns Physics", 1000,-100,100) ;
408   Add2RawsList(fhT0meanphys,424, expert, !image, !saveCorr);
409   TH1F* fhOrAnsphys= new TH1F("fhOrAnsphys"," OrA in ns Physics", 1000,-100,100) ;
410   Add2RawsList(fhOrAnsphys,425, expert, !image, !saveCorr);
411   TH1F* fhOrCnsphys= new TH1F("fhOrCnsphys"," OrC in ns Physics",  1000,-100,100) ;
412   Add2RawsList(fhOrCnsphys,426, expert, !image, !saveCorr);
413
414 }
415
416 //____________________________________________________________________________ 
417 void AliT0QADataMakerRec::InitDigits()
418 {
419   // create Digits histograms in Digits subdir
420   const Bool_t expert   = kTRUE ; 
421   const Bool_t image    = kTRUE ; 
422   
423   TH2F * fhDigCFD = new TH2F("fhDigCFD", " CFD digits; #PMT; CFD digits[#channels]",25,-0.5,24.5,100,0,1000);
424   fhDigCFD->SetOption("COLZ");
425   Add2DigitsList( fhDigCFD,0, !expert, image);
426   TH2F *fhDigLEDamp = new TH2F("fhDigLEDamp", " LED-CFD digits; #PMT; LED-CFD amplitude ",25,-0.5,24.5,100,100,1000);
427   fhDigLEDamp->SetOption("COLZ");
428   Add2DigitsList( fhDigLEDamp,1, !expert, !image);
429   TH2F * fhDigQTC = new TH2F("fhDigQTC", " QTC digits; #PMT; QTC amplitude",25,-0.5,24.5,100,100,10000);
430   fhDigQTC->SetOption("COLZ");
431   Add2DigitsList( fhDigQTC,2, !expert, !image);
432
433
434 }
435
436 //____________________________________________________________________________ 
437
438 void AliT0QADataMakerRec::InitRecPoints()
439 {
440   // create cluster histograms in RecPoint subdir
441   const Bool_t expert   = kTRUE ; 
442   const Bool_t image    = kTRUE ; 
443
444   TH2F* fhRecCFD = new TH2F("hRecCFD"," CFD time;#PMT; CFD Time [ns];",24, 0 ,24, 
445                               100,-50,50);
446   fhRecCFD->SetOption("COLZ");
447   Add2RecPointsList ( fhRecCFD,0, !expert, image);
448
449   TH2F* fhRecAmpDiff = new TH2F("hRecAmpDiff"," LED-CFD  min QTC amplitude;#PMT; difference [MIPs];",
450                                 24, 0 ,24, 200,-10,10);
451   fhRecAmpDiff->SetOption("COLZ");
452   Add2RecPointsList (fhRecAmpDiff, 1, !expert, image);
453   
454   TH1F *fhMean = new TH1F("hMean","online - rec mean;online - rec mean[#channels];",2000, -1000, 1000);
455   Add2RecPointsList ( fhMean,2, !expert, image);
456
457 }
458
459 //____________________________________________________________________________
460 void AliT0QADataMakerRec::InitESDs()
461 {
462   //create ESDs histograms in ESDs subdir
463   const Bool_t expert   = kTRUE ; 
464   const Bool_t image    = kTRUE ; 
465   
466   TH1F *fhESDMean = new TH1F("hESDmean"," ESD mean; mean time[%channels]",1000,0,1000);
467   Add2ESDsList(fhESDMean, 0, expert, !image) ;
468   TH1F * fhESDVertex = new TH1F("hESDvertex","ESDvertex; vertex[cm];",82,-30,30);
469   Add2ESDsList(fhESDVertex, 1, expert, !image) ;
470   
471   TH1F * fhESDResolution = new TH1F("hESDResolution","(T0A-T0C)/2 corrected by SPD vertex; ns",400,-5,5);
472   Add2ESDsList(fhESDResolution, 2, !expert, image) ;
473
474 }
475
476 //____________________________________________________________________________
477 void AliT0QADataMakerRec::MakeRaws( AliRawReader* rawReader)
478 {
479
480   Float_t latencyHPTDC = 9000;
481   Float_t latencyL1    = 8.19754744000000028e+03;
482   Float_t latencyL1C   = 8.19707652000000053e+03;
483   Float_t latencyL1A   = 8.19801836000000003e+03;
484   /*
485 // 2009 latency
486   Float_t latencyHPTDC = 22000;
487   Float_t latencyL1    = 7.76597940000000017e+03;
488   Float_t latencyL1C    = 7.76528399999999965e+03;
489   Float_t latencyL1A    = 7.76667480000000069e+03;
490   */
491
492
493   rawReader->Reset() ; 
494   //fills QA histos for RAW
495   Int_t shift=0;
496   // Int_t refPointParam = GetRecoParam()->GetRefPoint();
497   Int_t refpoint = 0;
498   Int_t refPointParam = 0;
499
500   AliT0RawReader *start = new AliT0RawReader(rawReader);
501   
502   if (! start->Next())
503     AliDebug(AliQAv1::GetQADebugLevel(),Form(" no raw data found!!"));
504   else
505     {  
506       
507       UInt_t type =rawReader->GetType();
508       if (type == 8){ shift=101; } 
509       if (type == 7){ shift=0;   fnEventPhys++;}
510       Int_t allData[110][5];
511       for (Int_t i0=0; i0<105; i0++)
512         {
513           for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;
514         }
515       for (Int_t i=0; i<105; i++) 
516         for (Int_t iHit=0; iHit<5; iHit++)
517           allData[i][iHit]= start->GetData(i,iHit);
518       
519       if ( type == 7  && allData[0][0] > 0 ) GetRawsData(0) -> Fill( allData[0][0]);
520       if ( type == 8  && allData[0][0] > 0 ) { 
521         GetRawsData(358) -> Fill( allData[0][0]);
522         fnEventCal++;
523         }
524  
525       refpoint = allData[refPointParam][0];
526       if (refPointParam <  0 ) refpoint=0; 
527       if (refPointParam == 0 ) refpoint = allData[0][0] - 5000;
528
529       Int_t numPmtC=0;    
530       for (Int_t ik = 0; ik<12; ik++)
531         {
532         //      for (Int_t iHt=0; iHt<1; iHt++){
533
534         Int_t nhitsPMT=0;
535         if(allData[ik+1][0]>0 && type == 7  ) numPmtC++;
536         for (Int_t iHt=0; iHt<5; iHt++){
537           //cfd
538           if(allData[ik+1][iHt]>0) {
539             GetRawsData(shift+ik+1) -> Fill(allData[ik+1][iHt]-refpoint);
540             if(allData[1][0]>0) 
541             GetRawsData(shift+ik+220) -> Fill(allData[ik+1][iHt]-allData[1][0]);
542             //      cout<<"C  cfd "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+1][iHt]-refpoint<<endl;
543             if(type == 8 && iHt==0 ) {
544               feffC[ik]++;
545               GetRawsData(208)->Fill(ik+1, allData[ik+1][iHt]-refpoint);
546             } 
547             if(type == 7  )  nhitsPMT++;
548             
549           }
550           //led
551           if(allData[ik+13][iHt] > 0) { 
552             GetRawsData(shift+ik+24+1)->  Fill(allData[ik+13][iHt]-refpoint);
553             //      cout<<"C  led "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+13][iHt]-refpoint<<endl;
554             if(type == 8   && iHt==0) {
555               feffA[ik]++;
556               GetRawsData(209)->Fill(ik+1, allData[ik+13][iHt]-refpoint);
557             }
558           }
559           //led -cfd
560
561           if(allData[ik+13][iHt] > 0 && allData[ik+1][iHt] >0 )
562             GetRawsData(shift+ik+48+1)->
563               Fill(allData[ik+13][iHt]-allData[ik+1][iHt]);
564
565           //qtc
566           if(allData[2*ik+25][iHt] > 0 || allData[2*ik+26][iHt] > 0) {
567             GetRawsData(shift+ik+72+1)->
568               Fill(allData[2*ik+25][iHt]-allData[2*ik+26][iHt]);
569             GetRawsData(shift+ik+270)->Fill(allData[2*ik+26][iHt] - refpoint);
570             GetRawsData(shift+ik+24+270)->Fill(allData[2*ik+25][iHt] - refpoint);
571
572             if(type == 8   ) {
573               feffqtc[ik]++;
574               GetRawsData(210)->Fill(ik+1, allData[2*ik+25][iHt]-allData[2*ik+26][iHt]);
575             }
576           }
577         }
578         if(type == 7  ) GetRawsData(ik+244)->Fill(nhitsPMT);
579       }
580       if(type == 7  ) GetRawsData(212)->Fill(numPmtC);
581       Int_t numPmtA=0;    
582        for (Int_t ik = 12; ik<24; ik++) {
583         //      for (Int_t iHt=0; iHt<1; iHt++) {
584         if(allData[ik+45][0]>0 && type == 7 ) numPmtA++;
585         Int_t nhitsPMT=0;
586         for (Int_t iHt=0; iHt<5; iHt++) {
587           if(allData[ik+45][iHt]>0) {
588             //cfd
589             GetRawsData(shift+ik+1)->
590               Fill(allData[ik+45][iHt]-refpoint);
591             if(allData[57][0]>0) 
592             GetRawsData(shift+ik+220) -> Fill(allData[ik+45][iHt]-allData[57][0]);
593
594             //      cout<<"A  cfd "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+1][iHt]-refpoint<<endl;
595             if(type == 8  ) {
596               feffC[ik]++;
597               GetRawsData(208)->Fill(ik+1, allData[ik+45][iHt]-refpoint);
598             } 
599             if(type == 7  )   nhitsPMT++;
600             
601
602           }
603           //led
604           if(allData[ik+57][iHt] > 0 ) {
605             GetRawsData(shift+ik+24+1)->Fill(allData[ik+57][iHt]-refpoint);
606             //   cout<<"C  led "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+13][iHt]-refpoint<<endl;
607             if(type == 8  ) {
608               feffA[ik]++;
609               GetRawsData(209)->Fill(ik+1, allData[ik+57][iHt]-refpoint);
610             }
611           }
612             //qtc         
613           if(allData[2*ik+57][iHt]>0 || allData[2*ik+58][iHt]>0)
614             {
615               GetRawsData(shift+ik+72+1)-> Fill(allData[2*ik+57][iHt]-allData[2*ik+58][iHt]);
616               GetRawsData(shift+ik+270)->Fill(allData[2*ik+58][iHt]-refpoint);
617               GetRawsData(shift+ik+24+270)->Fill(allData[2*ik+57][iHt]-refpoint);
618               if(type == 8  ){
619                 feffqtc[ik]++;
620                 GetRawsData(210)->Fill(ik+1, allData[2*ik+57][iHt]-allData[2*ik+58][iHt]);
621               }
622             } 
623           //led-cfd
624           if(allData[ik+57][iHt] > 0 &&allData[ik+45][iHt]>0)
625             GetRawsData(shift+ik+48+1)->
626               Fill(allData[ik+57][iHt]-allData[ik+45][iHt]);
627         }
628         if(type == 7  ) GetRawsData(ik+244)->Fill(nhitsPMT);
629
630       }
631        if(type == 7  ) GetRawsData(211)->Fill(numPmtA);
632
633       Int_t trChannel[6] = {49,50,51,52,55,56};  
634  
635       Float_t ch2cm = 24.4*0.029979;     
636       if(type == 7)
637         {
638           Int_t nhitsOrA=0;
639           Int_t nhitsOrC=0;
640           for (Int_t iHt=0; iHt<5; iHt++) {
641             // pure CFD1 & CFD2 for trigger needs
642             if(allData[1][iHt]>0) GetRawsData(354)->Fill(allData[1][iHt]);
643             if(allData[2][iHt]>0) GetRawsData(355)->Fill(allData[2][iHt]);
644
645             //orA-orC phys tvdc 1 
646             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]>0)
647               GetRawsData(350)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
648             //orA-orC phys tvdc 0 
649             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]<=0)
650               GetRawsData(352)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
651             for (Int_t itr=0; itr<6; itr++) {
652               if (allData[trChannel[itr]][iHt] >0) {
653                 fNumTriggers[itr]++;
654                 GetRawsData(98+itr)->Fill(allData[trChannel[itr]][iHt]-refpoint);
655               }
656             }
657             if(allData[51][iHt]>0 && allData[52][iHt]>0) {
658               GetRawsData(424) ->Fill(24.4*0.001*(allData[51][iHt]+allData[52][iHt])/2.-latencyHPTDC+latencyL1);
659             }
660             if(allData[51][iHt]>0 ) {
661                GetRawsData(425) ->Fill(24.4*0.001*allData[51][iHt]-latencyHPTDC+latencyL1A);
662             }
663             if(allData[52][iHt]>0 ) { 
664                   GetRawsData(426) ->Fill(24.4*0.001*allData[52][iHt]-latencyHPTDC + latencyL1C);
665             }
666                   
667
668             if(allData[51][iHt] >0) nhitsOrA++;
669             if(allData[52][iHt] >0) nhitsOrC++;
670             
671             if(allData[53][iHt]>0 && allData[54][iHt]>0) {
672               GetRawsData(216)->Fill(allData[53][iHt]-allData[54][iHt]);
673               if(allData[55][iHt]>0) GetRawsData(216)->Fill(allData[53][iHt]-allData[54][iHt]);
674               if(allData[56][iHt]>0) GetRawsData(218)->Fill(allData[53][iHt]-allData[54][iHt]);
675             }
676             if(allData[51][iHt]>0 && allData[52][iHt]>0)
677               GetRawsData(215)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
678             
679           }
680           GetRawsData(213)->Fill(nhitsOrA);
681           GetRawsData(214)->Fill(nhitsOrC);
682           
683         }
684       
685       if(type == 8)
686           {
687             for (Int_t iHt=0; iHt<5; iHt++) {
688               //pure CFD 1 & 2
689             if(allData[1][iHt]>0) GetRawsData(356)->Fill(allData[1][iHt]);
690             if(allData[2][iHt]>0) GetRawsData(357)->Fill(allData[2][iHt]);
691
692               //orA-orC laser
693             if(allData[51][iHt]>0 && allData[52][iHt]>0)
694               GetRawsData(219)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
695             
696             //orA-orC laser tvdc 1 
697             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]>0)
698               GetRawsData(351)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
699             //orA-orC laser tvdc 0 
700             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]<=0)
701               GetRawsData(353)->Fill((allData[52][iHt]-allData[51][iHt])*ch2cm);
702             //trigger laser
703               for (Int_t itr=0; itr<6; itr++) {
704                 if(allData[trChannel[itr]][iHt]>0)
705                   {
706                     GetRawsData(198+itr)->
707                       Fill(allData[trChannel[itr]][iHt]-refpoint);
708                     fNumTriggersCal[itr]++;
709                   }
710               }
711               //T0Tof in ns
712             if(allData[51][iHt]>0 && allData[52][iHt]>0)
713               GetRawsData(421) ->Fill(24.4*0.001*(allData[51][iHt]+allData[52][iHt])/2.-latencyHPTDC+latencyL1);
714               if(allData[51][iHt]>0 ) 
715                 GetRawsData(422) ->Fill(24.4*0.001*allData[51][iHt]-latencyHPTDC+latencyL1A);
716               if(allData[52][iHt]>0 ) 
717                 GetRawsData(423) ->Fill(24.4*0.001*allData[52][iHt]-latencyHPTDC+latencyL1A);
718               //mult trigger signals laser
719               if(allData[53][iHt]>0 && allData[54][iHt]>0) {
720                 GetRawsData(202)->Fill(allData[53][iHt]-allData[54][iHt]);
721                 if(allData[55][iHt]>0) GetRawsData(202)->Fill(allData[53][iHt]-allData[54][iHt]);
722                 if(allData[56][iHt]>0) GetRawsData(204)->Fill(allData[53][iHt]-allData[54][iHt]);
723               }
724             }
725           } 
726       
727            delete start;
728     }
729 }
730
731
732
733 //____________________________________________________________________________
734 void AliT0QADataMakerRec::MakeDigits( TTree *digitsTree)
735 {
736   //fills QA histos for Digits
737
738   TArrayI *digCFD = new TArrayI(24);
739   TArrayI *digLED = new TArrayI(24);
740   TArrayI *digQT0 = new TArrayI(24);
741   TArrayI *digQT1 = new TArrayI(24);
742   Int_t refpoint=0;
743   
744   TBranch *brDigits=digitsTree->GetBranch("T0");
745   AliT0digit *fDigits = new AliT0digit() ;
746   if (brDigits) {
747     brDigits->SetAddress(&fDigits);
748   }else{
749     AliError(Form("EXEC Branch T0 digits not found"));
750     return;
751   }
752   digitsTree->GetEvent(0);
753   digitsTree->GetEntry(0);
754   brDigits->GetEntry(0);
755   fDigits->GetTimeCFD(*digCFD);
756   fDigits->GetTimeLED(*digLED);
757   fDigits->GetQT0(*digQT0);
758   fDigits->GetQT1(*digQT1);
759   refpoint = fDigits->RefPoint();
760   for (Int_t i=0; i<24; i++)
761     {
762     if (digCFD->At(i)>0) {
763       Int_t cfd=digCFD->At(i)- refpoint;
764       GetDigitsData(0) ->Fill(i,cfd);
765       GetDigitsData(1) -> Fill(i, (digLED->At(i) - digCFD->At(i)));
766       GetDigitsData(2) -> Fill(i, (digQT1->At(i) - digQT0->At(i)));
767     }
768     }  
769   
770   delete digCFD;
771   delete digLED;
772   delete digQT0;
773   delete digQT1;
774   
775 }
776
777 //____________________________________________________________________________
778 void AliT0QADataMakerRec::MakeRecPoints(TTree * clustersTree)
779 {
780   //fills QA histos for clusters
781
782   AliT0RecPoint* frecpoints= new AliT0RecPoint ();
783   if (!frecpoints) {
784     AliError(":MakeRecPoints >> no recpoints found");
785     return;
786   }
787   TBranch *brRec =clustersTree ->GetBranch("T0");
788   if (brRec) {
789     brRec->SetAddress(&frecpoints);
790   }else{
791     AliError(Form("EXEC Branch T0 rec not found "));
792     return;
793   } 
794
795   brRec->GetEntry(0);
796   
797   for ( Int_t i=0; i<24; i++) {
798     if(i<12)
799       GetRecPointsData(0) -> Fill(i, frecpoints -> GetTime(i) - frecpoints -> GetTime(0)); 
800     if(i>11)
801       GetRecPointsData(0) -> Fill(i,  frecpoints -> GetTime(i) - frecpoints -> GetTime(12)); 
802     GetRecPointsData(1) -> Fill( i, frecpoints -> GetAmp(i) - frecpoints->AmpLED(i));
803   }
804   Double_t mmm=frecpoints->GetOnlineMean()- frecpoints->GetMeanTime();
805   GetRecPointsData(2) ->Fill(mmm);
806   
807 }
808
809 //____________________________________________________________________________
810 void AliT0QADataMakerRec::MakeESDs(AliESDEvent * esd)
811 {
812   //fills QA histos for ESD
813   
814   const Double32_t  *mean;
815   mean = esd->GetT0TOF();
816   Double32_t t0time= 0.001*mean[0];
817   Double32_t orA= 0.001*mean[1];
818   Double32_t orC=0.001* mean[2];
819
820   GetESDsData(0) -> Fill(t0time);
821   GetESDsData(1)-> Fill(esd->GetT0zVertex());
822   GetESDsData(2)-> Fill((orA-orC)/2.);
823   
824 }