cdffd96d2d2f0f5554d4e3eb989222c71fb876a3
[u/mrichter/AliRoot.git] / VZERO / AliVZEROQADataMakerRec.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 //  Produces the data needed to calculate the quality assurance 
18 //  All data must be mergeable objects
19 //  Handles ESDs and Raws
20 //  Histos defined will be used for Raw Data control and monitoring
21
22 // --- ROOT system ---
23 #include <TClonesArray.h>
24 #include <TFile.h> 
25 #include <TH1F.h> 
26 #include <TH1I.h> 
27 #include <TH2I.h> 
28 #include <TH2D.h> 
29 #include <TGraph.h> 
30 #include <TParameter.h>
31
32 // --- Standard library ---
33
34 // --- AliRoot header files ---
35 #include "AliESDEvent.h"
36 #include "AliLog.h"
37 #include "AliCDBManager.h"
38 #include "AliCDBStorage.h"
39 #include "AliCDBEntry.h"
40 #include "AliVZEROQADataMakerRec.h"
41 #include "AliQAChecker.h"
42 #include "AliRawReader.h"
43 #include "AliVZERORawStream.h"
44 #include "AliVZEROReconstructor.h"
45 #include "event.h"
46
47
48 ClassImp(AliVZEROQADataMakerRec)
49            
50 //____________________________________________________________________________ 
51   AliVZEROQADataMakerRec::AliVZEROQADataMakerRec() : 
52         AliQADataMakerRec(AliQA::GetDetName(AliQA::kVZERO), "VZERO Quality Assurance Data Maker"),
53         fCalibData(0x0),
54     fEvent(0)
55     
56 {
57    // Constructor
58    
59    AliInfo("Construct VZERO QA Object");
60   
61    for(Int_t i=0; i<64; i++){  
62        fEven[i] = 0;   
63        fOdd[i]  = 0;  }
64   
65    for(Int_t i=0; i<128; i++){  
66        fADCmean[i] = 0.0;   }   
67 }
68
69 //____________________________________________________________________________ 
70   AliVZEROQADataMakerRec::AliVZEROQADataMakerRec(const AliVZEROQADataMakerRec& qadm) :
71   AliQADataMakerRec(),
72         fCalibData(0x0),
73     fEvent(0)
74   
75 {
76   // Copy constructor 
77   
78    SetName((const char*)qadm.GetName()) ; 
79    SetTitle((const char*)qadm.GetTitle()); 
80 }
81
82 //__________________________________________________________________
83 AliVZEROQADataMakerRec& AliVZEROQADataMakerRec::operator = (const AliVZEROQADataMakerRec& qadm )
84 {
85   // Equal operator
86   
87   this->~AliVZEROQADataMakerRec();
88   new(this) AliVZEROQADataMakerRec(qadm);
89   return *this;
90 }
91
92 //____________________________________________________________________________
93 AliVZEROCalibData* AliVZEROQADataMakerRec::GetCalibData() const
94
95 {
96
97   // Gets calibration data - not used here anymore -
98   
99   AliCDBManager *man = AliCDBManager::Instance();
100   
101   //man->SetDefaultStorage("local://$ALICE_ROOT");
102
103   AliCDBEntry *entry=0;
104   
105   entry = man->Get("VZERO/Calib/Data",fRun);
106
107   // Retrieval of data in directory VZERO/Calib/Data:
108
109   AliVZEROCalibData *calibdata = 0;
110
111   if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
112   if (!calibdata)  AliFatal("No calibration data from calibration database !");
113
114   return calibdata;
115 }
116  
117 //____________________________________________________________________________ 
118 void AliVZEROQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray ** list)
119 {
120   // Detector specific actions at end of cycle
121   // Does the QA checking
122   
123   AliQAChecker::Instance()->Run(AliQA::kVZERO, task, list) ;
124
125   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
126     SetEventSpecie(specie) ; 
127     if(task == AliQA::kRAWS){
128           int nMaxBin = GetRawsData(kPedestalTimeInt0)->GetNbinsY();
129       if(fCurrentCycle%nMaxBin==0) {
130         GetRawsData(kPedestalTimeInt0)->Reset();
131         GetRawsData(kPedestalTimeInt1)->Reset();
132         GetRawsData(kChargeEoITimeInt0)->Reset();
133         GetRawsData(kChargeEoITimeInt1)->Reset();
134       }
135       TH1D* hProj;
136       char name[50];
137       for(Int_t iChannel=0; iChannel<64; iChannel++) {
138         for(Int_t integrator=0;integrator<2;integrator++){
139           sprintf(name,"Ped_%d_%d",iChannel,integrator);
140           hProj = ((TH2I*)GetRawsData((integrator == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1)))->ProjectionY(name,iChannel+1,iChannel+1);
141           ((TH2D*)GetRawsData((integrator == 0 ? kPedestalTimeInt0 : kPedestalTimeInt1)))->Fill((double)iChannel,(double)(fCurrentCycle%nMaxBin),(double)hProj->GetMean());
142           delete hProj;
143
144           sprintf(name,"Charge_%d_%d",iChannel,integrator);
145           hProj = ((TH2I*)GetRawsData((integrator == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1)))->ProjectionY(name,iChannel+1,iChannel+1);
146           ((TH2D*)GetRawsData((integrator == 0 ? kChargeEoITimeInt0 : kChargeEoITimeInt1)))->Fill((double)iChannel,(double)(fCurrentCycle%nMaxBin),hProj->GetMean());
147           delete hProj;
148         }
149       }
150     } else if (task == AliQA::kESDS) {
151     }
152   }
153 }
154
155 //____________________________________________________________________________ 
156 void AliVZEROQADataMakerRec::InitESDs()
157 {
158   // Creates histograms to control ESDs
159   
160   Bool_t expert   = kTRUE ; 
161         
162   TH2D * h2d;
163   TH1I * h1i;
164   TH1D * h1d;
165                 
166   h1i = new TH1I("H1I_Cell_Multiplicity_V0A", "Cell Multiplicity in V0A", 35, 0, 35) ;  
167   h1i->GetXaxis()->SetTitle("Multiplicity (Nb of Cell)");
168   Add2ESDsList(h1i, kCellMultiV0A, !expert)  ;  
169                                                                                                         
170   h1i = new TH1I("H1I_Cell_Multiplicity_V0C", "Cell Multiplicity in V0C", 35, 0, 35) ;  
171   h1i->GetXaxis()->SetTitle("Multiplicity (Nb of Cell)");
172   Add2ESDsList(h1i, kCellMultiV0C, !expert)  ;  
173    
174   h1d = new TH1D("H1D_MIP_Multiplicity_V0A", "MIP Multiplicity in V0A", 1000, 0, 1000) ;  
175   h1d->GetXaxis()->SetTitle("Multiplicity (Nb of MIP)");
176   Add2ESDsList(h1d, kMIPMultiV0A, !expert)  ;  
177   
178   h1d = new TH1D("H1D_MIP_Multiplicity_V0C", "MIP Multiplicity in V0C", 1000, 0, 1000) ;  
179   h1d->GetXaxis()->SetTitle("Multiplicity (Nb of MIP)");
180   Add2ESDsList(h1d, kMIPMultiV0C, !expert)  ;  
181
182   h2d = new TH2D("H2D_MIP_Multiplicity_Channel", "MIP Multiplicity per Channel",64, 0, 64, 100, 0, 100) ;  
183   h2d->GetXaxis()->SetTitle("Channel");
184   h2d->GetYaxis()->SetTitle("Multiplicity (Nb of MIP)");
185   Add2ESDsList(h2d, kMIPMultiChannel, !expert)  ;  
186   
187   h1d = new TH1D("H1D_BBFlag_Counters", "BB Flag Counters",64, 0, 64) ;  
188   h1d->GetXaxis()->SetTitle("Channel");
189   Add2ESDsList(h1d, kBBFlag, !expert)  ;  
190   
191   h1d = new TH1D("H1D_BGFlag_Counters", "BG Flag Counters",64, 0, 64) ;  
192   h1d->GetXaxis()->SetTitle("Channel");
193   Add2ESDsList(h1d, kBGFlag, !expert)  ;  
194   
195   h2d = new TH2D("H2D_Charge_Channel", "ADC Charge per channel",64, 0, 64, 1024, 0, 1024) ;  
196   h2d->GetXaxis()->SetTitle("Channel");
197   h2d->GetYaxis()->SetTitle("Charge (ADC counts)");
198   Add2ESDsList(h2d, kChargeChannel, !expert)  ;  
199   
200   h2d = new TH2D("H2D_Time_Channel", "Time per channel",64, 0, 64, 820, 0, 410) ;  
201   h2d->GetXaxis()->SetTitle("Channel");
202   h2d->GetYaxis()->SetTitle("Time (ns)");
203   Add2ESDsList(h2d, kTimeChannel, !expert)  ;  
204   
205   h1d = new TH1D("H1D_V0A_Time", "Mean V0A Time",2048, 0., 409.6);
206   h1d->GetXaxis()->SetTitle("Time (ns)");
207   Add2ESDsList(h1d,kESDV0ATime, !expert); 
208   
209   h1d = new TH1D("H1D_V0C_Time", "Mean V0C Time",2048, 0., 409.6);
210   h1d->GetXaxis()->SetTitle("Time (ns)");
211   Add2ESDsList(h1d,kESDV0CTime, !expert); 
212   
213   h1d = new TH1D("H1D_Diff_Time", "Diff Time V0A - V0C",2*2048, -409.6, 409.6);
214   h1d->GetXaxis()->SetTitle("Diff Time V0A - V0C (ns)");
215   Add2ESDsList(h1d,kESDDiffTime, !expert); 
216         
217 }
218
219 //____________________________________________________________________________ 
220  void AliVZEROQADataMakerRec::InitRaws()
221  {
222    // Creates RAW histograms in Raws subdir
223    
224   fCalibData = GetCalibData();
225
226   Bool_t expert   = kTRUE ; 
227   Bool_t saveCorr = kTRUE ; 
228
229   char name[50] , title[100];
230   const Int_t kNintegrator  =    2;
231  
232   const Int_t kNTdcTimeBins  = 2048;
233   const Int_t kTdcTimeMin    =    0;
234   const Int_t kTdcTimeMax    = 4096;
235   const Int_t kNTdcWidthBins =  128;
236   const Int_t kTdcWidthMin   =    0;
237   const Int_t kTdcWidthMax   =  128;
238   const Int_t kNChargeBins   = 1024;
239   const Int_t kChargeMin     =    0;
240   const Int_t kChargeMax     = 1024;
241   const Int_t kNChannelBins  =   64;
242   const Int_t kChannelMin    =    0;
243   const Int_t kChannelMax    =   64;
244   const Int_t kNPedestalBins =  200;
245   const Int_t kPedestalMin   =    0;
246   const Int_t kPedestalMax   =  200;
247   const Int_t kTimeMin       =   0;
248   const Int_t kTimeMax       = 100;
249   const Int_t kNMIPBins      = 200;
250   const Int_t kMIPMin        =   0;
251   const Int_t kMIPMax        = 200;
252
253   TH2I * h2i;
254   TH2D * h2d;
255   TH1I * h1i;
256   TH1D * h1d;
257
258   int iHisto =0;
259  
260    // Creation of Cell Multiplicity Histograms
261   h1i = new TH1I("H1I_Multiplicity_V0A", "Cell Multiplicity in V0A", 35, 0, 35) ;  
262   Add2RawsList(h1i,kMultiV0A, !expert, saveCorr);   iHisto++;
263   h1i = new TH1I("H1I_Multiplicity_V0C", "Cell Multiplicity in V0C", 35, 0, 35) ;  
264   Add2RawsList(h1i,kMultiV0C, !expert, saveCorr);   iHisto++;
265  
266   // Creation of Total Charge Histograms
267   h1d = new TH1D("H1D_Charge_V0A", "Total Charge in V0A", 2048, 0, 32768) ;  
268   Add2RawsList(h1d,kChargeV0A, !expert, saveCorr);   iHisto++;
269   h1d = new TH1D("H1D_Charge_V0C", "Total Charge in V0C", 2048, 0, 32768) ;  
270   Add2RawsList(h1d,kChargeV0C, !expert, saveCorr);   iHisto++;
271   h1d = new TH1D("H1D_Charge_V0", "Total Charge in V0", 2048, 0, 65536) ;  
272   Add2RawsList(h1d,kChargeV0, !expert, saveCorr);   iHisto++;
273   
274   // Creation of MIP Histograms
275   h1d = new TH1D("H1D_MIP_V0A", "Total MIP in V0A", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
276   Add2RawsList(h1d,kRawMIPV0A, !expert, saveCorr);   iHisto++;
277   h1d = new TH1D("H1D_MIP_V0C", "Total MIP in V0C", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
278   Add2RawsList(h1d,kRawMIPV0C, !expert, saveCorr);   iHisto++;
279   h1d = new TH1D("H1D_MIP_V0", "Total MIP in V0", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
280   Add2RawsList(h1d,kRawMIPV0, !expert, saveCorr);   iHisto++;
281   h2d = new TH2D("H2D_MIP_Channel", "Nb of MIP per channel", kNChannelBins, kChannelMin, kChannelMax,kNMIPBins,kMIPMin ,kMIPMax) ;  
282   Add2RawsList(h2d,kRawMIPChannel, expert, !saveCorr);   iHisto++;
283   
284  
285  for(Int_t iInt=0;iInt<kNintegrator;iInt++){
286     // Creation of Pedestal histograms 
287     sprintf(name,"H2I_Pedestal_Int%d",iInt);
288     sprintf(title,"Pedestal (Int%d)",iInt);
289     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNPedestalBins,kPedestalMin ,kPedestalMax );
290     Add2RawsList(h2i,(iInt == 0 ? kPedestalInt0 : kPedestalInt1), expert, !saveCorr); iHisto++;
291         
292     // Creation of temporary Pedestal histo used for the mean versus time histogram. This histogram will be reset at the end of each cycle
293     sprintf(name,"H2I_Pedestal_CycleInt%d",iInt);
294     sprintf(title,"One Cycle Pedestal (Int%d)",iInt);
295     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNPedestalBins,kPedestalMin ,kPedestalMax );
296     Add2RawsList(h2i,(iInt == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1), expert, !saveCorr); iHisto++;
297                 
298     // Creation of Pedestal versus time graph.
299     sprintf(name,"H2D_Pedestal_Time_Int%d",iInt);
300     sprintf(title,"Pedestal Versus Time (Int%d)",iInt);
301     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,kTimeMax,kTimeMin ,kTimeMax );
302     Add2RawsList(h2d,(iInt == 0 ? kPedestalTimeInt0 : kPedestalTimeInt1), expert, !saveCorr); iHisto++;
303
304    // Creation of Charge EoI histograms 
305     sprintf(name,"H2I_ChargeEoI_Int%d",iInt);
306     sprintf(title,"Charge EoI (Int%d)",iInt);
307     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
308     Add2RawsList(h2i,(iInt == 0 ? kChargeEoIInt0 : kChargeEoIInt1), !expert, !saveCorr); iHisto++;
309
310    // Creation of temporary Charge EoI histograms used for the mean versus time histogram. This histogram will be reset at the end of each cycle
311     sprintf(name,"H2I_ChargeEoI_CycleInt%d",iInt);
312     sprintf(title,"One Cycle Charge EoI (Int%d)",iInt);
313     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
314     Add2RawsList(h2i,(iInt == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1), expert, !saveCorr); iHisto++;
315                 
316     // Creation of Charge EoI versus time graphs
317     sprintf(name,"H2D_ChargeEoI_Time_Int%d",iInt);
318     sprintf(title,"Charge EoI Versus Time (Int%d)",iInt);
319     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,kTimeMax,kTimeMin ,kTimeMax );
320     Add2RawsList(h2d,(iInt == 0 ? kChargeEoITimeInt0 : kChargeEoITimeInt1), expert, !saveCorr); iHisto++;
321     
322     sprintf(name,"H2I_ChargeEoI_BB_Int%d",iInt);
323     sprintf(title,"Charge EoI w/ BB Flag (Int%d)",iInt);
324     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
325     Add2RawsList(h2i,(iInt == 0 ? kChargeEoIBBInt0 : kChargeEoIBBInt1), expert, !saveCorr); iHisto++;
326     
327     sprintf(name,"H2I_ChargeEoI_BG_Int%d",iInt);
328     sprintf(title,"Charge EoI w/ BG Flag (Int%d)",iInt);
329     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
330     Add2RawsList(h2i,(iInt == 0 ?  kChargeEoIBGInt0: kChargeEoIBGInt1), expert, !saveCorr); iHisto++;
331
332     // Creation of Charge versus LHC Clock histograms 
333     sprintf(name,"H2D_ChargeVsClock_Int%d",iInt);
334     sprintf(title,"Charge Versus LHC-Clock (Int%d)",iInt);
335     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
336     Add2RawsList(h2d,(iInt == 0 ? kChargeVsClockInt0 : kChargeVsClockInt1 ), expert, !saveCorr); iHisto++;
337         
338     // Creation of Minimum Bias Charge histograms 
339     for(Int_t iBB=0;iBB<2;iBB++){
340                 for(Int_t iBG=0;iBG<2;iBG++){
341                         sprintf(name,"H2I_ChargeMB_BB%d_BG%d_Int%d",iBB,iBG,iInt);
342                         sprintf(title,"MB Charge (BB=%d, BG=%d, Int=%d)",iBB,iBG,iInt);
343                         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNChargeBins, kChargeMin, kChargeMax);
344                         int idx;
345                         if(iInt==0){
346                                 if(iBB==0){
347                                         if(iBG==0) idx = kChargeMBBB0BG0Int0;
348                                         else idx = kChargeMBBB0BG1Int0;
349                                 } else {
350                                         if(iBG==0) idx = kChargeMBBB1BG0Int0;
351                                         else idx = kChargeMBBB1BG1Int0;
352                                 }
353                         } else {
354                                 if(iBB==0){
355                                         if(iBG==0) idx = kChargeMBBB0BG0Int1;
356                                         else idx = kChargeMBBB0BG1Int1;
357                                 } else {
358                                         if(iBG==0) idx = kChargeMBBB1BG0Int1;
359                                         else idx = kChargeMBBB1BG1Int1;
360                                 }
361                         }
362                         Add2RawsList(h2i,idx, expert, !saveCorr); iHisto++;
363                 }
364     }
365         
366  }
367  
368      // Creation of Time histograms 
369         sprintf(name,"H2I_Width");
370         sprintf(title,"HPTDC Width");
371         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
372         Add2RawsList(h2i,kWidth, expert, !saveCorr); iHisto++;
373
374         sprintf(name,"H2I_Width_BB");
375         sprintf(title,"HPTDC Width w/ BB Flag condition");
376         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
377         Add2RawsList(h2i,kWidthBB, expert, !saveCorr); iHisto++;
378
379         sprintf(name,"H2I_Width_BG");
380         sprintf(title,"HPTDC Width w/ BG Flag condition");
381         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
382         Add2RawsList(h2i,kWidthBG, expert, !saveCorr); iHisto++;
383
384         sprintf(name,"H2I_HPTDCTime");
385         sprintf(title,"HPTDC Time");
386         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
387         Add2RawsList(h2i,kHPTDCTime, !expert, !saveCorr); iHisto++;
388
389         sprintf(name,"H2I_HPTDCTime_BB");
390         sprintf(title,"HPTDC Time w/ BB Flag condition");
391         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
392         Add2RawsList(h2i,kHPTDCTimeBB, expert, !saveCorr); iHisto++;
393
394         sprintf(name,"H2I_HPTDCTime_BG");
395         sprintf(title,"HPTDC Time w/ BG Flag condition");
396         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
397         Add2RawsList(h2i,kHPTDCTimeBG, expert, !saveCorr); iHisto++;
398         
399         sprintf(name,"H1D_V0A_Time");
400         sprintf(title,"V0A Time");
401         h1d = new TH1D(name, title,kNTdcTimeBins, kTdcTimeMin/10, kTdcTimeMax/10);
402         Add2RawsList(h1d,kV0ATime, !expert, saveCorr); iHisto++;
403         
404         sprintf(name,"H1D_V0C_Time");
405         sprintf(title,"V0C Time");
406         h1d = new TH1D(name, title,kNTdcTimeBins, kTdcTimeMin/10, kTdcTimeMax/10);
407         Add2RawsList(h1d,kV0CTime, !expert, saveCorr); iHisto++;
408         
409         sprintf(name,"H1D_Diff_Time");
410         sprintf(title,"Diff V0A-V0C Time");
411         h1d = new TH1D(name, title,2*kNTdcTimeBins, -kTdcTimeMax/10, kTdcTimeMax/10);
412         Add2RawsList(h1d,kDiffTime, !expert, saveCorr); iHisto++;
413         
414         // Creation of Flag versus LHC Clock histograms 
415         sprintf(name,"H2D_BBFlagVsClock");
416         sprintf(title,"BB-Flags Versus LHC-Clock");
417         h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
418         Add2RawsList(h2d,kBBFlagVsClock, expert, !saveCorr); iHisto++;
419         
420         sprintf(name,"H2D_BGFlagVsClock");
421         sprintf(title,"BG-Flags Versus LHC-Clock");
422         h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
423         Add2RawsList(h2d,kBGFlagVsClock, expert, !saveCorr); iHisto++;
424          
425         AliInfo(Form("%d Histograms has been added to the Raws List",iHisto));
426  }
427
428 //____________________________________________________________________________
429 void AliVZEROQADataMakerRec::MakeESDs(AliESDEvent * esd)
430 {
431   // Creates QA data from ESDs
432   
433   UInt_t eventType = esd->GetEventType();
434
435   switch (eventType){
436         case PHYSICS_EVENT:
437         AliESDVZERO *esdVZERO=esd->GetVZEROData();
438    
439         if (!esdVZERO) break;
440                   
441         GetESDsData(kCellMultiV0A)->Fill(esdVZERO->GetNbPMV0A());
442         GetESDsData(kCellMultiV0C)->Fill(esdVZERO->GetNbPMV0C());  
443         GetESDsData(kMIPMultiV0A)->Fill(esdVZERO->GetMTotV0A());
444         GetESDsData(kMIPMultiV0C)->Fill(esdVZERO->GetMTotV0C());  
445         
446         Float_t  timeV0A = 0., timeV0C = 0., diffTime;
447         Int_t   iTimeV0A = 0, iTimeV0C = 0;
448                 
449         for(Int_t i=0;i<64;i++) {
450                         GetESDsData(kMIPMultiChannel)->Fill((Float_t) i,(Float_t) esdVZERO->GetMultiplicity(i));
451                         GetESDsData(kChargeChannel)->Fill((Float_t) i,(Float_t) esdVZERO->GetAdc(i));
452                         if(esdVZERO->GetBBFlag(i)) GetESDsData(kBBFlag)->Fill((Float_t) i);
453                         if(esdVZERO->GetBGFlag(i)) GetESDsData(kBGFlag)->Fill((Float_t) i);
454
455                         Float_t time = (Float_t) esdVZERO->GetTime(i)/10.; //Convert in ns:  1 TDC channel = 100ps 
456                         GetESDsData(kTimeChannel)->Fill((Float_t) i,time);
457
458                         if(time>0.){
459                                 if (i<32) {
460                                         iTimeV0C++;
461                                         timeV0C += time;
462                                 }else{
463                                         iTimeV0A++;
464                                         timeV0A += time;
465                                 }
466                         }
467         }
468         if(iTimeV0A>0) timeV0A /= iTimeV0A; 
469         else timeV0A = -1.;
470         if(iTimeV0C>0) timeV0C /= iTimeV0C;
471         else timeV0C = -1.;
472         if(timeV0A<0. || timeV0C<0.) diffTime = -10000.;
473         else diffTime = timeV0A - timeV0C;
474                                 
475         GetESDsData(kESDV0ATime)->Fill(timeV0A);
476         GetESDsData(kESDV0CTime)->Fill(timeV0C);
477         GetESDsData(kESDDiffTime)->Fill(diffTime);
478                 
479         break;
480         }  
481   
482 }
483
484 //____________________________________________________________________________
485  void AliVZEROQADataMakerRec::MakeRaws(AliRawReader* rawReader)
486  {
487   // Fills histograms with Raws, computes average ADC values dynamically (pedestal subtracted)
488                   
489   rawReader->Reset() ; 
490   AliVZERORawStream* rawStream  = new AliVZERORawStream(rawReader); 
491   rawStream->Next();
492   
493   eventTypeType eventType = rawReader->GetType();
494
495   Int_t    mulV0A = 0 ; 
496   Int_t    mulV0C = 0 ; 
497   Double_t timeV0A =0., timeV0C = 0.;
498   UInt_t   itimeV0A=0, itimeV0C=0;
499   Double_t chargeV0A=0., chargeV0C=0.;
500   Double_t mipV0A=0., mipV0C=0.;
501
502   Double_t diffTime=-100000.;
503
504   
505   switch (eventType){
506        case PHYSICS_EVENT:
507        Int_t  iFlag=0;
508        Int_t  pedestal;
509        Int_t  integrator;
510        Bool_t BBFlag;    
511        Bool_t BGFlag;    
512        UInt_t time, width;
513        Int_t  MBCharge, charge;
514        Int_t  offlineCh;
515        TH1D * hProj;
516
517        for(Int_t iChannel=0; iChannel<64; iChannel++) { // BEGIN : Loop over channels
518                    
519            offlineCh = rawStream->GetOfflineChannel(iChannel);
520                    
521            // Fill Pedestal histograms
522            
523            for(Int_t j=15; j<21; j++) {
524                        if((rawStream->GetBGFlag(iChannel,j) || rawStream->GetBBFlag(iChannel,j))) iFlag++;
525            }
526
527            if(iFlag == 0){ //No Flag found
528                        for(Int_t j=15; j<21; j++){
529                                pedestal=rawStream->GetPedestal(iChannel, j);
530                                integrator = rawStream->GetIntegratorFlag(iChannel, j);
531
532                                GetRawsData((integrator == 0 ? kPedestalInt0 : kPedestalInt1))->Fill(offlineCh,pedestal);
533                                GetRawsData((integrator == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1))->Fill(offlineCh,pedestal);
534                        }
535             }
536
537            // Fill Charge EoI histograms
538            
539            // Look for the maximum in the LHC clock train
540            charge = 0;
541            Int_t iClock  = 0;
542            Int_t iCharge = 0;
543            for(Int_t iEvent=0; iEvent<21; iEvent++){
544                iCharge = rawStream->GetPedestal(iChannel,iEvent);
545                if(iCharge>charge)  {
546                        charge = iCharge;
547                        iClock = iEvent;
548                    }
549            }   // End of maximum searching procedure
550
551            integrator    = rawStream->GetIntegratorFlag(iChannel,iClock);
552            BBFlag        = rawStream->GetBBFlag(iChannel, iClock);
553            BGFlag        = rawStream->GetBGFlag(iChannel,iClock );
554
555            GetRawsData((integrator == 0 ? kChargeEoIInt0 : kChargeEoIInt1))->Fill(offlineCh,charge);
556            if(BBFlag) GetRawsData((integrator == 0 ? kChargeEoIBBInt0 : kChargeEoIBBInt1))->Fill(offlineCh,charge);
557            if(BGFlag) GetRawsData((integrator == 0 ? kChargeEoIBGInt0 : kChargeEoIBGInt1))->Fill(offlineCh,charge);
558
559            hProj = ((TH2I*)GetRawsData((integrator == 0 ? kPedestalInt0 : kPedestalInt1)))->ProjectionY("",offlineCh+1,offlineCh+1);
560            Double_t ped   = hProj->GetMean();
561            Double_t sigma = hProj->GetRMS();
562            delete hProj;
563
564            Double_t chargeEoI = charge - ped;
565                    
566            // Calculation of the number of MIP
567            Double_t mipEoI = chargeEoI * fCalibData->GetMIPperADC(offlineCh);
568
569                    
570            if(charge<1023 && chargeEoI > 5.*sigma){ 
571                    ((TH2I*)GetRawsData((integrator == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1)))->Fill(offlineCh,chargeEoI);
572                    ((TH2D*)GetRawsData(kRawMIPChannel))->Fill(offlineCh,mipEoI);
573                    if(offlineCh<32) {
574                                    mulV0C++;
575                                    chargeV0C += chargeEoI;
576                                    mipV0C += mipEoI;
577                    } else {
578                                    mulV0A++;
579                                    chargeV0A += chargeEoI;
580                                    mipV0A += mipEoI;
581                    }
582            }
583
584            // Fill Charge Minimum Bias Histograms
585                    
586            int idx;
587            for(Int_t iBunch=0; iBunch<10; iBunch++){
588                            integrator = rawStream->GetIntMBFlag(iChannel, iBunch);
589                            BBFlag     = rawStream->GetBBMBFlag(iChannel, iBunch);
590                            BGFlag     = rawStream->GetBGMBFlag(iChannel, iBunch);
591                            MBCharge   = rawStream->GetChargeMB(iChannel, iBunch);
592
593                            if(integrator==0){
594                                    if(BBFlag==0){
595                                            if(BGFlag==0) idx = kChargeMBBB0BG0Int0;
596                                            else idx = kChargeMBBB0BG1Int0;
597                                    } else {
598                                            if(BGFlag==0) idx = kChargeMBBB1BG0Int0;
599                                            else idx = kChargeMBBB1BG1Int0;
600                                    }
601                            } else {
602                                    if(BBFlag==0){
603                                            if(BGFlag==0) idx = kChargeMBBB0BG0Int1;
604                                            else idx = kChargeMBBB0BG1Int1;
605                                    } else {
606                                            if(BGFlag==0) idx = kChargeMBBB1BG0Int1;
607                                            else idx = kChargeMBBB1BG1Int1;
608                                    }
609                            }
610                            GetRawsData(idx)->Fill(offlineCh,MBCharge);
611           }   
612
613           // Fill HPTDC Time Histograms
614
615            BBFlag   = rawStream->GetBBFlag(iChannel, 10);
616            BGFlag   = rawStream->GetBGFlag(iChannel, 10);
617            time     = rawStream->GetTime(iChannel);
618            width    = rawStream->GetWidth(iChannel);
619
620            if(time>0.){
621                       if (offlineCh<32) {
622                                    itimeV0C++;
623                                    timeV0C += time;
624                       }else{
625                                    itimeV0A++;
626                                    timeV0A += time;
627                       }
628            }
629            GetRawsData(kHPTDCTime)->Fill(offlineCh,time);
630            GetRawsData(kWidth)->Fill(offlineCh,width);
631            if(BBFlag) {
632                   GetRawsData(kHPTDCTimeBB)->Fill(offlineCh,time);
633                   GetRawsData(kWidthBB)->Fill(offlineCh,width);
634            }
635            if(BGFlag) {
636                   GetRawsData(kHPTDCTimeBG)->Fill(offlineCh,time);
637                   GetRawsData(kWidthBG)->Fill(offlineCh,width);
638            }
639
640            // Fill Flag and Charge Versus LHC-Clock histograms
641            
642            for(Int_t iEvent=0; iEvent<21; iEvent++){
643                charge = rawStream->GetPedestal(iChannel,iEvent);
644                integrator = rawStream->GetIntegratorFlag(iChannel,iEvent);
645                BBFlag     = rawStream->GetBBFlag(iChannel, iEvent);
646                BGFlag     = rawStream->GetBGFlag(iChannel,iEvent );
647
648                ((TH2*) GetRawsData((integrator == 0 ? kChargeVsClockInt0 : kChargeVsClockInt1 )))->Fill(offlineCh,(float)iEvent-10,(float)charge);
649                ((TH2*) GetRawsData(kBBFlagVsClock))->Fill(offlineCh,(float)iEvent-10,(float)BBFlag);
650                ((TH2*) GetRawsData(kBGFlagVsClock))->Fill(offlineCh,(float)iEvent-10,(float)BGFlag);
651            }
652
653        }// END of Loop over channels
654
655             if(itimeV0A>0) timeV0A /= (itimeV0A * 10); // itimeV0A Channels and divide by 10 to have the result in ns because 1 TDC Channel = 100 ps
656             else timeV0A = -1.;
657             if(itimeV0C>0) timeV0C /= (itimeV0C * 10);
658             else timeV0C = -1.;
659             if(timeV0A<0. || timeV0C<0.) diffTime = -10000.;
660             else diffTime = timeV0A - timeV0C;
661                 
662             GetRawsData(kV0ATime)->Fill(timeV0A);
663             GetRawsData(kV0CTime)->Fill(timeV0C);
664             GetRawsData(kDiffTime)->Fill(diffTime);
665                 
666             GetRawsData(kMultiV0A)->Fill(mulV0A);
667             GetRawsData(kMultiV0C)->Fill(mulV0C);
668
669             GetRawsData(kChargeV0A)->Fill(chargeV0A);
670             GetRawsData(kChargeV0C)->Fill(chargeV0C);
671             GetRawsData(kChargeV0)->Fill(chargeV0A + chargeV0C);
672                 
673             GetRawsData(kRawMIPV0A)->Fill(mipV0A);
674             GetRawsData(kRawMIPV0C)->Fill(mipV0C);
675             GetRawsData(kRawMIPV0)->Fill(mipV0A + mipV0C);
676             break;
677             
678         } // END of SWITCH : EVENT TYPE 
679         
680         fEvent++; 
681         TParameter<double> * p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kMultiV0A)->GetName()))) ; 
682         p->SetVal((double)mulV0A) ; 
683
684         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kMultiV0C)->GetName()))) ; 
685         p->SetVal((double)mulV0C) ;                     
686
687         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kChargeV0A)->GetName()))) ; 
688         p->SetVal((double)chargeV0A) ; 
689
690         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kChargeV0C)->GetName()))) ; 
691         p->SetVal((double)chargeV0C) ;                     
692
693         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kChargeV0)->GetName()))) ; 
694         p->SetVal((double)(chargeV0A + chargeV0C)) ;                     
695         
696         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kRawMIPV0A)->GetName()))) ; 
697         p->SetVal((double)mipV0A) ; 
698         
699         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kRawMIPV0C)->GetName()))) ; 
700         p->SetVal((double)mipV0C) ;                     
701         
702         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kRawMIPV0)->GetName()))) ; 
703         p->SetVal((double)(mipV0A + mipV0C)) ;                     
704         
705         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kV0ATime)->GetName()))) ; 
706         p->SetVal((double)timeV0A) ; 
707         
708         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kV0CTime)->GetName()))) ; 
709         p->SetVal((double)timeV0C) ;                     
710         
711         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kDiffTime)->GetName()))) ; 
712         p->SetVal((double)diffTime) ;                     
713         
714         delete rawStream; rawStream = 0x0;      
715
716
717  }
718
719 //____________________________________________________________________________ 
720 void AliVZEROQADataMakerRec::StartOfDetectorCycle()
721 {
722   // Detector specific actions at start of cycle
723   
724   // Reset of the histogram used - to have the trend versus time -
725   
726   TH1* h;
727   h = GetRawsData(kPedestalCycleInt0);
728   if(h) h->Reset();
729   h = GetRawsData(kPedestalCycleInt1); 
730   if(h) h->Reset();
731   h = GetRawsData(kChargeEoICycleInt0);
732   if(h) h->Reset();
733   h = GetRawsData(kChargeEoICycleInt1);
734   if(h) h->Reset();
735
736 }