improved monitoring
[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   TH1F* fhOrCminOrA= new TH1F("fhOrCminOrA","T0_OR C - T0_OR A",Int_t( high[215]-low[215]),low[215],high[215]);
362   Add2RawsList( fhOrCminOrA,215, expert, !image, !saveCorr);
363
364   TH1F* fhOrCminOrAcal= new TH1F("fhOrCminOrAcal","T0_OR C - T0_OR A",Int_t( high[219]-low[219]),low[219],high[219]);
365   Add2RawsList( fhOrCminOrAcal,219, expert, !image, !saveCorr);
366
367   TH1F* fhOrCminOrATvdcOn= new TH1F("fhOrCminOrATvdcOn","T0_OR C - T0_OR A TVDC on",Int_t( high[350]-low[350]),low[350],high[350]);
368   Add2RawsList( fhOrCminOrATvdcOn,350, expert, !image, !saveCorr);
369
370   TH1F* fhOrCminOrATvdcOncal= new TH1F("fhOrCminOrATvdcOncal","T0_OR C - T0_OR A TVDC on laser",Int_t( high[351]-low[351]),low[351],high[351]);
371   Add2RawsList( fhOrCminOrATvdcOncal,351, expert, !image, !saveCorr);
372
373   TH1F* fhOrCminOrATvdcOff= new TH1F("fhOrCminOrATvdcOff","T0_OR C - T0_OR A TVDC off",Int_t( high[352]-low[352]),low[352],high[352]);
374   Add2RawsList( fhOrCminOrATvdcOff,352, expert, !image, !saveCorr);
375
376   TH1F* fhOrCminOrATvdcOffcal= new TH1F("fhOrCminOrATvdcOffcal","T0_OR C - T0_OR ATVDC off laser",Int_t( high[353]-low[353]),low[353],high[353]);
377   Add2RawsList( fhOrCminOrATvdcOffcal,353, expert, !image, !saveCorr);
378
379   TH1F* fhCFD1abs= new TH1F("fhCFD1abs"," CFD 1 pure ( L1) ", 20000, 575000, 595000 );
380   Add2RawsList(fhCFD1abs ,354, expert, !image, !saveCorr);
381
382   TH1F* fhCFD2abs= new TH1F("fhCFD2abs"," CFD 2 pure ( L1)  ", 20000, 575000, 595000 );
383   Add2RawsList( fhCFD2abs,355, expert, !image, !saveCorr);
384
385   TH1F* fhCFD1abscal= new TH1F("fhCFD1abscal"," CFD 1 pure ( L1)laser ", 10000, 18000 ,28000 );
386   Add2RawsList(fhCFD1abscal,356, expert, !image, !saveCorr);
387
388   TH1F* fhCFD2abscal= new TH1F("fhCFD2abscal"," CFD 2 pure ( L1)laser ", 10000, 18000 ,28000 );
389   Add2RawsList( fhCFD2abscal,357, expert, !image, !saveCorr);
390
391  const Char_t *triggers[6] = {"mean", "vertex","ORA","ORC","central","semi-central"};
392   for (Int_t itr=0; itr<6; itr++) {
393     GetRawsData(420)->Fill(triggers[itr], fNumTriggersCal[itr]);
394     GetRawsData(420)->SetBinContent(itr+1, fNumTriggersCal[itr]);
395     GetRawsData(97)->Fill(triggers[itr], fNumTriggers[itr]);
396     GetRawsData(97)->SetBinContent(itr+1, fNumTriggers[itr]);
397   }  
398 }
399
400 //____________________________________________________________________________ 
401 void AliT0QADataMakerRec::InitDigits()
402 {
403   // create Digits histograms in Digits subdir
404   const Bool_t expert   = kTRUE ; 
405   const Bool_t image    = kTRUE ; 
406   
407   TH2F * fhDigCFD = new TH2F("fhDigCFD", " CFD digits; #PMT; CFD digits[#channels]",25,-0.5,24.5,100,0,1000);
408   fhDigCFD->SetOption("COLZ");
409   Add2DigitsList( fhDigCFD,0, !expert, image);
410   TH2F *fhDigLEDamp = new TH2F("fhDigLEDamp", " LED-CFD digits; #PMT; LED-CFD amplitude ",25,-0.5,24.5,100,100,1000);
411   fhDigLEDamp->SetOption("COLZ");
412   Add2DigitsList( fhDigLEDamp,1, !expert, !image);
413   TH2F * fhDigQTC = new TH2F("fhDigQTC", " QTC digits; #PMT; QTC amplitude",25,-0.5,24.5,100,100,10000);
414   fhDigQTC->SetOption("COLZ");
415   Add2DigitsList( fhDigQTC,2, !expert, !image);}
416
417 //____________________________________________________________________________ 
418
419 void AliT0QADataMakerRec::InitRecPoints()
420 {
421   // create cluster histograms in RecPoint subdir
422   const Bool_t expert   = kTRUE ; 
423   const Bool_t image    = kTRUE ; 
424
425   TH2F* fhRecCFD = new TH2F("hRecCFD"," CFD time;#PMT; CFD Time [ns];",24, 0 ,24, 
426                               100,-50,50);
427   fhRecCFD->SetOption("COLZ");
428   Add2RecPointsList ( fhRecCFD,0, !expert, image);
429
430   TH2F* fhRecAmpDiff = new TH2F("hRecAmpDiff"," LED-CFD  min QTC amplitude;#PMT; difference [MIPs];",
431                                 24, 0 ,24, 200,-10,10);
432   fhRecAmpDiff->SetOption("COLZ");
433   Add2RecPointsList (fhRecAmpDiff, 1, !expert, image);
434   
435   TH1F *fhMean = new TH1F("hMean","online - rec mean;online - rec mean[#channels];",2000, -1000, 1000);
436   Add2RecPointsList ( fhMean,2, !expert, image);
437
438 }
439
440 //____________________________________________________________________________
441 void AliT0QADataMakerRec::InitESDs()
442 {
443   //create ESDs histograms in ESDs subdir
444   const Bool_t expert   = kTRUE ; 
445   const Bool_t image    = kTRUE ; 
446   
447   TH1F *fhESDMean = new TH1F("hESDmean"," ESD mean; mean time[%channels]",1000,0,1000);
448   Add2ESDsList(fhESDMean, 0, !expert, image) ;
449   TH1F * fhESDVertex = new TH1F("hESDvertex","ESDvertex; vertex[cm];",82,-30,30);
450   Add2ESDsList(fhESDVertex, 1, !expert, image) ;
451   
452
453 }
454
455 //____________________________________________________________________________
456 void AliT0QADataMakerRec::MakeRaws( AliRawReader* rawReader)
457 {
458
459   rawReader->Reset() ; 
460   //fills QA histos for RAW
461   Int_t shift=0;
462   // Int_t refPointParam = GetRecoParam()->GetRefPoint();
463   Int_t refpoint = 0;
464   Int_t refPointParam = 0;
465
466   AliT0RawReader *start = new AliT0RawReader(rawReader);
467   
468   if (! start->Next())
469     AliDebug(AliQAv1::GetQADebugLevel(),Form(" no raw data found!!"));
470   else
471     {  
472       
473       UInt_t type =rawReader->GetType();
474       if (type == 8){ shift=101; fnEventCal++;} 
475       if (type == 7){ shift=0;   fnEventPhys++;}
476       Int_t allData[110][5];
477       for (Int_t i0=0; i0<105; i0++)
478         {
479           for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;
480         }
481       for (Int_t i=0; i<105; i++) 
482         for (Int_t iHit=0; iHit<5; iHit++)
483           allData[i][iHit]= start->GetData(i,iHit);
484       
485       if ( type == 7  && allData[0][0] > 0 ) GetRawsData(0) -> Fill( allData[0][0]);
486       if ( type == 8  && allData[0][0] > 0 ) GetRawsData(358) -> Fill( allData[0][0]);
487  
488       refpoint = allData[refPointParam][0];
489       if (refPointParam <  0 ) refpoint=0; 
490       if (refPointParam == 0 ) refpoint = allData[0][0] - 5000;
491
492       Int_t numPmtC=0;    
493       for (Int_t ik = 0; ik<12; ik++)
494         {
495         //      for (Int_t iHt=0; iHt<1; iHt++){
496
497         Int_t nhitsPMT=0;
498         if(allData[ik+1][0]>0 && type == 7  ) numPmtC++;
499         for (Int_t iHt=0; iHt<5; iHt++){
500           //cfd
501           if(allData[ik+1][iHt]>0) {
502             GetRawsData(shift+ik+1) -> Fill(allData[ik+1][iHt]-refpoint);
503             if(allData[1][0]>0) 
504             GetRawsData(shift+ik+220) -> Fill(allData[ik+1][iHt]-allData[1][0]);
505             //      cout<<"C  cfd "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+1][iHt]-refpoint<<endl;
506             if(type == 8 && iHt==0 ) {
507               feffC[ik]++;
508               GetRawsData(208)->Fill(ik+1, allData[ik+1][iHt]-refpoint);
509             } 
510             if(type == 7  )  nhitsPMT++;
511             
512           }
513           //led
514           if(allData[ik+13][iHt] > 0) { 
515             GetRawsData(shift+ik+24+1)->  Fill(allData[ik+13][iHt]-refpoint);
516             //      cout<<"C  led "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+13][iHt]-refpoint<<endl;
517             if(type == 8   && iHt==0) {
518               feffA[ik]++;
519               GetRawsData(209)->Fill(ik+1, allData[ik+13][iHt]-refpoint);
520             }
521           }
522           //led -cfd
523
524           if(allData[ik+13][iHt] > 0 && allData[ik+1][iHt] >0 )
525             GetRawsData(shift+ik+48+1)->
526               Fill(allData[ik+13][iHt]-allData[ik+1][iHt]);
527
528           //qtc
529           if(allData[2*ik+25][iHt] > 0 || allData[2*ik+26][iHt] > 0) {
530             GetRawsData(shift+ik+72+1)->
531               Fill(allData[2*ik+25][iHt]-allData[2*ik+26][iHt]);
532             GetRawsData(shift+ik+270)->Fill(allData[2*ik+26][iHt] - refpoint);
533             GetRawsData(shift+ik+24+270)->Fill(allData[2*ik+25][iHt] - refpoint);
534
535             if(type == 8  && iHt==0 ) {
536               feffqtc[ik]++;
537               GetRawsData(210)->Fill(allData[2*ik+25][iHt]-allData[2*ik+26][iHt]);
538             }
539           }
540         }
541         if(type == 7  ) GetRawsData(ik+244)->Fill(nhitsPMT);
542       }
543       if(type == 7  ) GetRawsData(212)->Fill(numPmtC);
544       Int_t numPmtA=0;    
545        for (Int_t ik = 12; ik<24; ik++) {
546         //      for (Int_t iHt=0; iHt<1; iHt++) {
547         if(allData[ik+45][0]>0 && type == 7 ) numPmtA++;
548         Int_t nhitsPMT=0;
549         for (Int_t iHt=0; iHt<5; iHt++) {
550           if(allData[ik+45][iHt]>0) {
551             //cfd
552             GetRawsData(shift+ik+1)->
553               Fill(allData[ik+45][iHt]-refpoint);
554             if(allData[57][0]>0) 
555             GetRawsData(shift+ik+220) -> Fill(allData[ik+45][iHt]-allData[57][0]);
556
557             //      cout<<"A  cfd "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+1][iHt]-refpoint<<endl;
558             if(type == 8  ) {
559               feffC[ik]++;
560               GetRawsData(208)->Fill(ik+1, allData[ik+45][iHt]-refpoint);
561             } 
562             if(type == 7  )   nhitsPMT++;
563             
564
565           }
566           //led
567           if(allData[ik+57][iHt] > 0 ) {
568             GetRawsData(shift+ik+24+1)->Fill(allData[ik+57][iHt]-refpoint);
569             //   cout<<"C  led "<<ik<<" "<<iHt<<" "<<allData[ik+1][iHt]<<" -RF "<<refpoint<<"  "<<allData[ik+13][iHt]-refpoint<<endl;
570             if(type == 8  ) {
571               feffA[ik]++;
572               GetRawsData(209)->Fill(ik+1, allData[ik+57][iHt]-refpoint);
573             }
574           }
575             //qtc         
576           if(allData[2*ik+57][iHt]>0 || allData[2*ik+58][iHt]>0)
577             {
578               GetRawsData(shift+ik+72+1)-> Fill(allData[2*ik+57][iHt]-allData[2*ik+58][iHt]);
579               GetRawsData(shift+ik+270)->Fill(allData[2*ik+58][iHt]-refpoint);
580               GetRawsData(shift+ik+24+270)->Fill(allData[2*ik+57][iHt]-refpoint);
581               if(type == 8  ){
582                 feffqtc[ik]++;
583                 GetRawsData(210)->Fill(allData[2*ik+57][iHt]-allData[2*ik+58][iHt]);
584               }
585             } 
586           //led-cfd
587           if(allData[ik+57][iHt] > 0 &&allData[ik+45][iHt]>0)
588             GetRawsData(shift+ik+48+1)->
589               Fill(allData[ik+57][iHt]-allData[ik+45][iHt]);
590         }
591         if(type == 7  ) GetRawsData(ik+244)->Fill(nhitsPMT);
592
593       }
594        if(type == 7  ) GetRawsData(211)->Fill(numPmtA);
595
596       Int_t trChannel[6] = {49,50,51,52,55,56};  
597        
598       if(type == 7)
599         {
600           Int_t nhitsOrA=0;
601           Int_t nhitsOrC=0;
602           for (Int_t iHt=0; iHt<5; iHt++) {
603             // pure CFD1 & CFD2 for trigger needs
604             if(allData[1][iHt]>0) GetRawsData(354)->Fill(allData[1][iHt]);
605             if(allData[2][iHt]>0) GetRawsData(355)->Fill(allData[2][iHt]);
606
607             //orA-orC phys tvdc 1 
608             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]>0)
609               GetRawsData(350)->Fill(allData[52][iHt]-allData[51][iHt]);
610             //orA-orC phys tvdc 0 
611             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]<=0)
612               GetRawsData(352)->Fill(allData[52][iHt]-allData[51][iHt]);
613             for (Int_t itr=0; itr<6; itr++) {
614               if (allData[trChannel[itr]][iHt] >0) {
615                 fNumTriggers[itr]++;
616                 GetRawsData(98+itr)->Fill(allData[trChannel[itr]][iHt]-refpoint);
617               }
618             }
619
620             if(allData[51][iHt] >0) nhitsOrA++;
621             if(allData[52][iHt] >0) nhitsOrC++;
622             
623             if(allData[53][iHt]>0 && allData[54][iHt]>0) {
624               GetRawsData(216)->Fill(allData[53][iHt]-allData[54][iHt]);
625               if(allData[55][iHt]>0) GetRawsData(216)->Fill(allData[53][iHt]-allData[54][iHt]);
626               if(allData[56][iHt]>0) GetRawsData(218)->Fill(allData[53][iHt]-allData[54][iHt]);
627             }
628             if(allData[51][iHt]>0 && allData[52][iHt]>0)
629               GetRawsData(215)->Fill(allData[52][iHt]-allData[51][iHt]);
630           }
631           GetRawsData(213)->Fill(nhitsOrA);
632           GetRawsData(214)->Fill(nhitsOrC);
633           
634         }
635       
636       if(type == 8)
637           {
638             for (Int_t iHt=0; iHt<5; iHt++) {
639               //pure CFD 1 & 2
640             if(allData[1][iHt]>0) GetRawsData(356)->Fill(allData[1][iHt]);
641             if(allData[2][iHt]>0) GetRawsData(357)->Fill(allData[2][iHt]);
642
643               //orA-orC laser
644             if(allData[51][iHt]>0 && allData[52][iHt]>0)
645               GetRawsData(219)->Fill(allData[52][iHt]-allData[51][iHt]);
646             //orA-orC laser tvdc 1 
647             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]>0)
648               GetRawsData(351)->Fill(allData[52][iHt]-allData[51][iHt]);
649             //orA-orC laser tvdc 0 
650             if((allData[51][iHt]>0 && allData[52][iHt]>0) && allData[50][iHt]<=0)
651               GetRawsData(353)->Fill(allData[52][iHt]-allData[51][iHt]);
652             //trigger laser
653               for (Int_t itr=0; itr<6; itr++) {
654                 if(allData[trChannel[itr]][iHt]>0)
655                   {
656                     
657                     GetRawsData(198+itr)->
658                       Fill(allData[trChannel[itr]][iHt]-refpoint);
659                     fNumTriggersCal[itr]++;
660                   }
661               }
662               //mult trigger signals laser
663               if(allData[53][iHt]>0 && allData[54][iHt]>0) {
664                 GetRawsData(202)->Fill(allData[53][iHt]-allData[54][iHt]);
665                 if(allData[55][iHt]>0) GetRawsData(202)->Fill(allData[53][iHt]-allData[54][iHt]);
666                 if(allData[56][iHt]>0) GetRawsData(204)->Fill(allData[53][iHt]-allData[54][iHt]);
667               }
668             }
669           } 
670       
671            delete start;
672     }
673 }
674
675
676
677 //____________________________________________________________________________
678 void AliT0QADataMakerRec::MakeDigits( TTree *digitsTree)
679 {
680   //fills QA histos for Digits
681
682   TArrayI *digCFD = new TArrayI(24);
683   TArrayI *digLED = new TArrayI(24);
684   TArrayI *digQT0 = new TArrayI(24);
685   TArrayI *digQT1 = new TArrayI(24);
686   Int_t refpoint=0;
687   
688   TBranch *brDigits=digitsTree->GetBranch("T0");
689   AliT0digit *fDigits = new AliT0digit() ;
690   if (brDigits) {
691     brDigits->SetAddress(&fDigits);
692   }else{
693     AliError(Form("EXEC Branch T0 digits not found"));
694     return;
695   }
696   digitsTree->GetEvent(0);
697   digitsTree->GetEntry(0);
698   brDigits->GetEntry(0);
699   fDigits->GetTimeCFD(*digCFD);
700   fDigits->GetTimeLED(*digLED);
701   fDigits->GetQT0(*digQT0);
702   fDigits->GetQT1(*digQT1);
703   refpoint = fDigits->RefPoint();
704   for (Int_t i=0; i<24; i++)
705     {
706     if (digCFD->At(i)>0) {
707       Int_t cfd=digCFD->At(i)- refpoint;
708       GetDigitsData(0) ->Fill(i,cfd);
709       GetDigitsData(1) -> Fill(i, (digLED->At(i) - digCFD->At(i)));
710       GetDigitsData(2) -> Fill(i, (digQT1->At(i) - digQT0->At(i)));
711     }
712     }  
713   
714   delete digCFD;
715   delete digLED;
716   delete digQT0;
717   delete digQT1;
718   
719 }
720
721 //____________________________________________________________________________
722 void AliT0QADataMakerRec::MakeRecPoints(TTree * clustersTree)
723 {
724   //fills QA histos for clusters
725
726   AliT0RecPoint* frecpoints= new AliT0RecPoint ();
727   if (!frecpoints) {
728     AliError(":MakeRecPoints >> no recpoints found");
729     return;
730   }
731   TBranch *brRec =clustersTree ->GetBranch("T0");
732   if (brRec) {
733     brRec->SetAddress(&frecpoints);
734   }else{
735     AliError(Form("EXEC Branch T0 rec not found "));
736     return;
737   } 
738
739   brRec->GetEntry(0);
740   
741   for ( Int_t i=0; i<24; i++) {
742     if(i<12)
743       GetRecPointsData(0) -> Fill(i, frecpoints -> GetTime(i) - frecpoints -> GetTime(0)); 
744     if(i>11)
745       GetRecPointsData(0) -> Fill(i,  frecpoints -> GetTime(i) - frecpoints -> GetTime(12)); 
746     GetRecPointsData(1) -> Fill( i, frecpoints -> GetAmp(i) - frecpoints->AmpLED(i));
747   }
748   Double_t mmm=frecpoints->GetOnlineMean()- frecpoints->GetMeanTime();
749   GetRecPointsData(2) ->Fill(mmm);
750   
751 }
752
753 //____________________________________________________________________________
754 void AliT0QADataMakerRec::MakeESDs(AliESDEvent * esd)
755 {
756   //fills QA histos for ESD
757   
758   GetESDsData(0) -> Fill(esd->GetT0());
759   GetESDsData(1)-> Fill(esd->GetT0zVertex());
760   
761 }