]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZEROQADataMakerRec.cxx
undo previous changes
[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 #include <TTimeStamp.h>
32
33 // --- Standard library ---
34
35 // --- AliRoot header files ---
36 #include "AliESDEvent.h"
37 #include "AliLog.h"
38 #include "AliCDBManager.h"
39 #include "AliCDBStorage.h"
40 #include "AliCDBEntry.h"
41 #include "AliVZEROQADataMakerRec.h"
42 #include "AliQAChecker.h"
43 #include "AliRawReader.h"
44 #include "AliVZERORawStream.h"
45 #include "AliVZEROdigit.h"
46 #include "AliVZEROReconstructor.h"
47 #include "AliVZEROTrending.h"
48 #include "AliVZEROCalibData.h"
49 #include "event.h"
50
51
52 ClassImp(AliVZEROQADataMakerRec)
53            
54 //____________________________________________________________________________ 
55   AliVZEROQADataMakerRec::AliVZEROQADataMakerRec() : 
56         AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kVZERO), "VZERO Quality Assurance Data Maker"),
57         fCalibData(0x0),
58         fEvent(0), 
59         fNTotEvents(0), 
60         fNSubEvents(0), 
61         fTrendingUpdateEvent(0), 
62         fNTrendingUpdates(0), 
63         fTrendingUpdateTime(0), 
64         fCycleStartTime(0), 
65         fCycleStopTime(0), 
66         fMonitorRate(0.)
67     
68 {
69    // Constructor
70    
71       AliDebug(AliQAv1::GetQADebugLevel(), "Construct VZERO QA Object");
72   for(Int_t i=0;i<8;i++){
73         fChargePerRing[i] = 0.;
74         fFlagPerRing[i] = 0.;
75   }
76    for(Int_t i=0; i<64; i++){  
77        fEven[i] = 0;   
78        fOdd[i]  = 0;
79            fChargePerChannel[i] = 0.;  
80            fFlagPerChannel[i] = 0.;  
81            fMeanChargePerChannel[i] = 0.;  
82            fMeanFlagPerChannel[i] = 0.;  
83   }
84   
85    for(Int_t i=0; i<128; i++){  
86        fADCmean[i] = 0.0;   }   
87 }
88
89 //____________________________________________________________________________ 
90   AliVZEROQADataMakerRec::AliVZEROQADataMakerRec(const AliVZEROQADataMakerRec& qadm) :
91   AliQADataMakerRec(),
92         fCalibData(0x0),
93         fEvent(0), 
94         fNTotEvents(0), 
95         fNSubEvents(0), 
96         fTrendingUpdateEvent(0), 
97         fNTrendingUpdates(0), 
98         fTrendingUpdateTime(0), 
99         fCycleStartTime(0), 
100         fCycleStopTime(0), 
101         fMonitorRate(0.)
102   
103 {
104   // Copy constructor 
105   
106    SetName((const char*)qadm.GetName()) ; 
107    SetTitle((const char*)qadm.GetTitle()); 
108 }
109
110 //__________________________________________________________________
111 AliVZEROQADataMakerRec& AliVZEROQADataMakerRec::operator = (const AliVZEROQADataMakerRec& qadm )
112 {
113   // Equal operator
114   
115   this->~AliVZEROQADataMakerRec();
116   new(this) AliVZEROQADataMakerRec(qadm);
117   return *this;
118 }
119
120 //____________________________________________________________________________
121 AliVZEROCalibData* AliVZEROQADataMakerRec::GetCalibData() const
122
123 {
124    AliCDBManager *man = AliCDBManager::Instance();
125
126    AliCDBEntry *entry=0;
127
128    entry = man->Get("VZERO/Calib/Data",fRun);
129    if(!entry){
130         AliWarning("Load of calibration data from default storage failed!");
131         AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
132         
133         man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
134         entry = man->Get("VZERO/Calib/Data",fRun);
135    }
136    // Retrieval of data in directory VZERO/Calib/Data:
137
138    AliVZEROCalibData *calibdata = 0;
139
140    if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
141    if (!calibdata)  AliFatal("No calibration data from calibration database !");
142
143    return calibdata;
144 }
145
146
147  
148 //____________________________________________________________________________ 
149 void AliVZEROQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
150 {
151   // Detector specific actions at end of cycle
152   // Does the QA checking
153   
154   AliQAChecker::Instance()->Run(AliQAv1::kVZERO, task, list) ;
155   
156   if(task == AliQAv1::kRAWS){
157         TTimeStamp currentTime;
158         fCycleStopTime = currentTime.GetSec();
159         if(fCycleStopTime-fCycleStartTime>0.) fMonitorRate = fNTotEvents/(fCycleStopTime-fCycleStartTime);
160         //printf("%d event have been monitored -> Monitoring Rate = %f Hz\n",fNTotEvents,fMonitorRate); 
161         Bool_t update = kFALSE;
162         if(!fTrendingUpdateEvent) {
163                 update = kTRUE;
164         } else if ((TMath::Abs(fTrendingUpdateTime * fMonitorRate - fTrendingUpdateEvent) / fTrendingUpdateEvent) > 0.1){
165                 update = kTRUE;
166         }
167         if(update) fTrendingUpdateEvent = (size_t)(fTrendingUpdateTime * fMonitorRate);
168         //printf("Update trending information every %d events\n",fTrendingUpdateEvent); 
169
170   }
171
172   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
173     if (! IsValidEventSpecie(specie, list)) 
174       continue ;
175     SetEventSpecie(AliRecoParam::ConvertIndex(specie)) ; 
176     if(task == AliQAv1::kRAWS){
177           int nMaxBin = GetRawsData(kPedestalTimeInt0)->GetNbinsY();
178       if(fCurrentCycle%nMaxBin==0) {
179         GetRawsData(kPedestalTimeInt0)->Reset();
180         GetRawsData(kPedestalTimeInt1)->Reset();
181         GetRawsData(kChargeEoITimeInt0)->Reset();
182         GetRawsData(kChargeEoITimeInt1)->Reset();
183       }
184       TH1D* hProj;
185       char name[50];
186       for(Int_t iChannel=0; iChannel<64; iChannel++) {
187         for(Int_t integrator=0;integrator<2;integrator++){
188           sprintf(name,"Ped_%d_%d",iChannel,integrator);
189           hProj = ((TH2I*)GetRawsData((integrator == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1)))->ProjectionY(name,iChannel+1,iChannel+1);
190           ((TH2D*)GetRawsData((integrator == 0 ? kPedestalTimeInt0 : kPedestalTimeInt1)))->Fill((double)iChannel,(double)(fCurrentCycle%nMaxBin),(double)hProj->GetMean());
191           delete hProj;
192
193           sprintf(name,"Charge_%d_%d",iChannel,integrator);
194           hProj = ((TH2I*)GetRawsData((integrator == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1)))->ProjectionY(name,iChannel+1,iChannel+1);
195           ((TH2D*)GetRawsData((integrator == 0 ? kChargeEoITimeInt0 : kChargeEoITimeInt1)))->Fill((double)iChannel,(double)(fCurrentCycle%nMaxBin),hProj->GetMean());
196           delete hProj;
197         }
198       }
199     } else if (task == AliQAv1::kESDS) {
200     }
201   }
202 }
203
204 //____________________________________________________________________________ 
205 void AliVZEROQADataMakerRec::InitESDs()
206 {
207   // Creates histograms to control ESDs
208   
209   const Bool_t expert   = kTRUE ; 
210   const Bool_t image    = kTRUE ; 
211         
212   TH2D * h2d;
213   TH1I * h1i;
214   TH1D * h1d;
215                 
216   h1i = new TH1I("H1I_Cell_Multiplicity_V0A", "Cell Multiplicity in V0A;Multiplicity (Nb of Cell);Counts", 35, 0, 35) ;  
217   Add2ESDsList(h1i, kCellMultiV0A, !expert, image)  ;  
218                                                                                                         
219   h1i = new TH1I("H1I_Cell_Multiplicity_V0C", "Cell Multiplicity in V0;Multiplicity (Nb of Cell);Counts", 35, 0, 35) ;  
220   Add2ESDsList(h1i, kCellMultiV0C, !expert, image)  ;  
221    
222   h1d = new TH1D("H1D_MIP_Multiplicity_V0A", "MIP Multiplicity in V0A;Multiplicity (Nb of MIP);Counts", 1000, 0, 1000) ;  
223   Add2ESDsList(h1d, kMIPMultiV0A, !expert, image)  ;  
224   
225   h1d = new TH1D("H1D_MIP_Multiplicity_V0C", "MIP Multiplicity in V0C;Multiplicity (Nb of MIP);Counts", 1000, 0, 1000) ;  
226   Add2ESDsList(h1d, kMIPMultiV0C, !expert, image)  ;  
227
228   h2d = new TH2D("H2D_MIP_Multiplicity_Channel", "MIP Multiplicity per Channel;Channel;Multiplicity (Nb of MIP)",64, 0, 64, 100, 0, 100) ;  
229   Add2ESDsList(h2d, kMIPMultiChannel, !expert, image)  ;  
230   
231   h1d = new TH1D("H1D_BBFlag_Counters", "BB Flag Counters;Channel;Counts",64, 0, 64) ;  
232   Add2ESDsList(h1d, kBBFlag, !expert, image)  ;  
233   
234   h1d = new TH1D("H1D_BGFlag_Counters", "BG Flag Counters;Channel;Counts",64, 0, 64) ;  
235   Add2ESDsList(h1d, kBGFlag, !expert, image)  ;  
236   
237   h2d = new TH2D("H2D_Charge_Channel", "ADC Charge per channel;Channel;Charge (ADC counts)",64, 0, 64, 1024, 0, 1024) ;  
238   Add2ESDsList(h2d, kChargeChannel, !expert, image)  ;  
239   
240   h2d = new TH2D("H2D_Time_Channel", "Time per channel;Channel;Time (ns)",64, 0, 64, 820, 0, 410) ;  
241   Add2ESDsList(h2d, kTimeChannel, !expert, image)  ;  
242   
243   h1d = new TH1D("H1D_V0A_Time", "Mean V0A Time;Time (ns);Counts",2048, 0., 409.6);
244   Add2ESDsList(h1d,kESDV0ATime, !expert, image); 
245   
246   h1d = new TH1D("H1D_V0C_Time", "Mean V0C Time;Time (ns);Counts",2048, 0., 409.6);
247   Add2ESDsList(h1d,kESDV0CTime, !expert, image); 
248   
249   h1d = new TH1D("H1D_Diff_Time", "Diff Time V0A - V0C;Diff Time V0A - V0C (ns);Counts",2*2048, -409.6, 409.6);
250   Add2ESDsList(h1d,kESDDiffTime, !expert, image); 
251         
252 }
253
254 //____________________________________________________________________________ 
255  void AliVZEROQADataMakerRec::InitRaws()
256  {
257    // Creates RAW histograms in Raws subdir
258
259    const Bool_t expert   = kTRUE ; 
260    const Bool_t saveCorr = kTRUE ; 
261    const Bool_t image    = kTRUE ; 
262
263   char name[50] , title[100];
264   const Int_t kNintegrator  =    2;
265  
266   const Int_t kNTdcTimeBins  = 1280;
267   const Int_t kTdcTimeMin    =    0.;
268   const Int_t kTdcTimeMax    = 125.;
269   const Int_t kNTdcWidthBins =  128;
270   const Int_t kTdcWidthMin   =    0;
271   const Int_t kTdcWidthMax   =  50.;
272   const Int_t kNChargeBins   = 1024;
273   const Int_t kChargeMin     =    0;
274   const Int_t kChargeMax     = 1024;
275   const Int_t kNChannelBins  =   64;
276   const Int_t kChannelMin    =    0;
277   const Int_t kChannelMax    =   64;
278   const Int_t kNPedestalBins =  200;
279   const Int_t kPedestalMin   =    0;
280   const Int_t kPedestalMax   =  200;
281   const Int_t kTimeMin       =   0;
282   const Int_t kTimeMax       = 100;
283   const Int_t kNMIPBins      = 200;
284   const Int_t kMIPMin        =   0;
285   const Int_t kMIPMax        = 200;
286
287   TH2I * h2i;
288   TH2D * h2d;
289   TH1I * h1i;
290   TH1D * h1d;
291   AliVZEROTrending * trend;
292
293   int iHisto =0;
294  
295    // Creation of Cell Multiplicity Histograms
296   h1i = new TH1I("H1I_Multiplicity_V0A", "Cell Multiplicity in V0A;# of Cells;Entries", 35, 0, 35) ;  
297   Add2RawsList(h1i,kMultiV0A, expert, image, saveCorr);   iHisto++;
298   h1i = new TH1I("H1I_Multiplicity_V0C", "Cell Multiplicity in V0C;# of Cells;Entries", 35, 0, 35) ;  
299   Add2RawsList(h1i,kMultiV0C, expert, image, saveCorr);   iHisto++;
300  
301   // Creation of Total Charge Histograms
302   h1d = new TH1D("H1D_Charge_V0A", "Total Charge in V0A;Charge [ADC counts];Counts", 2048, 0, 32768) ;  
303   Add2RawsList(h1d,kChargeV0A, expert, image, saveCorr);   iHisto++;
304   h1d = new TH1D("H1D_Charge_V0C", "Total Charge in V0C;Charge [ADC counts];Counts", 2048, 0, 32768) ;  
305   Add2RawsList(h1d,kChargeV0C, expert, image, saveCorr);   iHisto++;
306   h1d = new TH1D("H1D_Charge_V0", "Total Charge in V0;Charge [ADC counts];Counts", 2048, 0, 65536) ;  
307   Add2RawsList(h1d,kChargeV0, expert, image, saveCorr);   iHisto++;
308   
309   // Creation of MIP Histograms
310   h1d = new TH1D("H1D_MIP_V0A", "Total MIP in V0A;Charge [MIP];Counts", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
311   Add2RawsList(h1d,kRawMIPV0A, expert, image, saveCorr);   iHisto++;
312   h1d = new TH1D("H1D_MIP_V0C", "Total MIP in V0C;Charge [MIP];Counts", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
313   Add2RawsList(h1d,kRawMIPV0C, expert, image, saveCorr);   iHisto++;
314   h1d = new TH1D("H1D_MIP_V0", "Total MIP in V0;Charge [MIP];Counts", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
315   Add2RawsList(h1d,kRawMIPV0, expert, image, saveCorr);   iHisto++;
316   h2d = new TH2D("H2D_MIP_Channel", "Nb of MIP per channel;Channel;# of Mips", kNChannelBins, kChannelMin, kChannelMax,kNMIPBins,kMIPMin ,kMIPMax) ;  
317   Add2RawsList(h2d,kRawMIPChannel, expert, !image, !saveCorr);   iHisto++;
318   
319  
320
321   // Creation of Charge EoI histogram 
322    sprintf(name,"H2D_ChargeEoI");
323    sprintf(title,"Charge Event of Interest;Channel;Charge [ADC counts]");
324    h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
325    Add2RawsList(h2d,kChargeEoI, !expert, image, !saveCorr); iHisto++;
326
327  for(Int_t iInt=0;iInt<kNintegrator;iInt++){
328     // Creation of Pedestal histograms 
329     sprintf(name,"H2I_Pedestal_Int%d",iInt);
330     sprintf(title,"Pedestal (Int%d);Channel;Pedestal [ADC counts]",iInt);
331     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNPedestalBins,kPedestalMin ,kPedestalMax );
332     Add2RawsList(h2i,(iInt == 0 ? kPedestalInt0 : kPedestalInt1), expert, !image, !saveCorr); iHisto++;
333         
334     // Creation of temporary Pedestal histo used for the mean versus time histogram. This histogram will be reset at the end of each cycle
335     sprintf(name,"H2I_Pedestal_CycleInt%d",iInt);
336     sprintf(title,"One Cycle Pedestal (Int%d);Pedestal [ADC counts];Counts",iInt);
337     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNPedestalBins,kPedestalMin ,kPedestalMax );
338     Add2RawsList(h2i,(iInt == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1), expert, !image, !saveCorr); iHisto++;
339                 
340     // Creation of Pedestal versus time graph.
341     sprintf(name,"H2D_Pedestal_Time_Int%d",iInt);
342     sprintf(title,"Pedestal Versus Time (Int%d);Time [ns];Pedestal [ADC counts]",iInt);
343     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,kTimeMax,kTimeMin ,kTimeMax );
344     Add2RawsList(h2d,(iInt == 0 ? kPedestalTimeInt0 : kPedestalTimeInt1), expert, !image, !saveCorr); iHisto++;
345
346    // Creation of Charge EoI histograms 
347     sprintf(name,"H2I_ChargeEoI_Int%d",iInt);
348     sprintf(title,"Charge EoI (Int%d);Channel;Charge [ADC counts]",iInt);
349     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
350     Add2RawsList(h2i,(iInt == 0 ? kChargeEoIInt0 : kChargeEoIInt1), expert, image, !saveCorr); iHisto++;
351
352    // Creation of temporary Charge EoI histograms used for the mean versus time histogram. This histogram will be reset at the end of each cycle
353     sprintf(name,"H2I_ChargeEoI_CycleInt%d",iInt);
354     sprintf(title,"One Cycle Charge EoI (Int%d);Charge [ADC counts];Counts",iInt);
355     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
356     Add2RawsList(h2i,(iInt == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1), expert, !image, !saveCorr); iHisto++;
357                 
358     // Creation of Charge EoI versus time graphs
359     sprintf(name,"H2D_ChargeEoI_Time_Int%d",iInt);
360     sprintf(title,"Charge EoI Versus Time (Int%d);Channel;Time",iInt);
361     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,kTimeMax,kTimeMin ,kTimeMax );
362     Add2RawsList(h2d,(iInt == 0 ? kChargeEoITimeInt0 : kChargeEoITimeInt1), expert, !image, !saveCorr); iHisto++;
363     
364     sprintf(name,"H2I_ChargeEoI_BB_Int%d",iInt);
365     sprintf(title,"Charge EoI w/ BB Flag (Int%d);Channel;Charge [ADC counts]",iInt);
366     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
367     Add2RawsList(h2i,(iInt == 0 ? kChargeEoIBBInt0 : kChargeEoIBBInt1), expert, !image, !saveCorr); iHisto++;
368     
369     sprintf(name,"H2I_ChargeEoI_BG_Int%d",iInt);
370     sprintf(title,"Charge EoI w/ BG Flag (Int%d);Channel;Charge [ADC counts]",iInt);
371     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
372     Add2RawsList(h2i,(iInt == 0 ?  kChargeEoIBGInt0: kChargeEoIBGInt1), expert, !image, !saveCorr); iHisto++;
373
374     // Creation of Charge versus LHC Clock histograms 
375     sprintf(name,"H2D_ChargeVsClock_Int%d",iInt);
376     sprintf(title,"Charge Versus LHC-Clock (Int%d);Channel;LHCClock;Charge [ADC counts]",iInt);
377     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
378     Add2RawsList(h2d,(iInt == 0 ? kChargeVsClockInt0 : kChargeVsClockInt1 ), expert, !image, !saveCorr); iHisto++;
379         
380     // Creation of Minimum Bias Charge histograms 
381     for(Int_t iBB=0;iBB<2;iBB++){
382                 for(Int_t iBG=0;iBG<2;iBG++){
383                         sprintf(name,"H2I_ChargeMB_BB%d_BG%d_Int%d",iBB,iBG,iInt);
384                         sprintf(title,"MB Charge (BB=%d, BG=%d, Int=%d);Channel;Charge [ADC counts]",iBB,iBG,iInt);
385                         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNChargeBins, kChargeMin, kChargeMax);
386                         int idx;
387                         if(iInt==0){
388                                 if(iBB==0){
389                                         if(iBG==0) idx = kChargeMBBB0BG0Int0;
390                                         else idx = kChargeMBBB0BG1Int0;
391                                 } else {
392                                         if(iBG==0) idx = kChargeMBBB1BG0Int0;
393                                         else idx = kChargeMBBB1BG1Int0;
394                                 }
395                         } else {
396                                 if(iBB==0){
397                                         if(iBG==0) idx = kChargeMBBB0BG0Int1;
398                                         else idx = kChargeMBBB0BG1Int1;
399                                 } else {
400                                         if(iBG==0) idx = kChargeMBBB1BG0Int1;
401                                         else idx = kChargeMBBB1BG1Int1;
402                                 }
403                         }
404                         Add2RawsList(h2i,idx, expert, !image, !saveCorr); iHisto++;
405                 }
406     }
407         
408  }
409  
410      // Creation of Time histograms 
411         sprintf(name,"H2I_Width");
412         sprintf(title,"HPTDC Width;Channel;Width [ns]");
413         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
414         Add2RawsList(h2i,kWidth, expert, !image, !saveCorr); iHisto++;
415
416         sprintf(name,"H2I_Width_BB");
417         sprintf(title,"HPTDC Width w/ BB Flag condition;Channel;Width [ns]");
418         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
419         Add2RawsList(h2i,kWidthBB, expert, !image, !saveCorr); iHisto++;
420
421         sprintf(name,"H2I_Width_BG");
422         sprintf(title,"HPTDC Width w/ BG Flag condition;Channel;Width [ns]");
423         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
424         Add2RawsList(h2i,kWidthBG, expert, !image, !saveCorr); iHisto++;
425
426         sprintf(name,"H2I_HPTDCTime");
427         sprintf(title,"HPTDC Time;Channel;Leading Time [ns]");
428         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
429         Add2RawsList(h2i,kHPTDCTime, expert, image, !saveCorr); iHisto++;
430
431         sprintf(name,"H2I_HPTDCTime_BB");
432         sprintf(title,"HPTDC Time w/ BB Flag condition;Channel;Leading Time [ns]");
433         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
434         Add2RawsList(h2i,kHPTDCTimeBB, !expert, image, !saveCorr); iHisto++;
435
436         sprintf(name,"H2I_HPTDCTime_BG");
437         sprintf(title,"HPTDC Time w/ BG Flag condition;Channel;Leading Time [ns]");
438         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
439         Add2RawsList(h2i,kHPTDCTimeBG, !expert, image, !saveCorr); iHisto++;
440         
441         sprintf(name,"H1D_V0A_Time");
442         sprintf(title,"V0A Time;Time [ns];Counts");
443         h1d = new TH1D(name, title,kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
444         Add2RawsList(h1d,kV0ATime, expert, !image, saveCorr); iHisto++;
445         
446         sprintf(name,"H1D_V0C_Time");
447         sprintf(title,"V0C Time;Time [ns];Counts");
448         h1d = new TH1D(name, title,kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
449         Add2RawsList(h1d,kV0CTime, expert, !image, saveCorr); iHisto++;
450         
451         sprintf(name,"H1D_Diff_Time");
452         sprintf(title,"Diff V0A-V0C Time;Time [ns];Counts");
453         h1d = new TH1D(name, title,2*kNTdcTimeBins, -kTdcTimeMax, kTdcTimeMax);
454         Add2RawsList(h1d,kDiffTime, expert, !image, saveCorr); iHisto++;
455         
456         // Creation of Flag versus LHC Clock histograms 
457
458         sprintf(name,"H1D_BBFlagPerChannel");
459         sprintf(title,"BB-Flags Versus Channel;Channel;BB Flags Count");
460         h1d = new TH1D(name, title,kNChannelBins, kChannelMin, kChannelMax );
461         Add2RawsList(h1d,kBBFlagsPerChannel, !expert, image, !saveCorr); iHisto++;
462
463         sprintf(name,"H2D_BBFlagVsClock");
464         sprintf(title,"BB-Flags Versus LHC-Clock;Channel;LHC Clocks");
465         h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
466         Add2RawsList(h2d,kBBFlagVsClock, expert, !image, !saveCorr); iHisto++;
467         
468         sprintf(name,"H2D_BGFlagVsClock");
469         sprintf(title,"BG-Flags Versus LHC-Clock;Channel;LHC Clocks");
470         h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
471         Add2RawsList(h2d,kBGFlagVsClock, expert, !image, !saveCorr); iHisto++;
472          
473         sprintf(name,"TREND_MeanChargePerRing");
474         sprintf(title,"Mean Charge per Event and per Ring versus time ");
475         trend = new AliVZEROTrending(name, title);
476         Add2RawsList(trend,kRawMeanChargePerRing, expert, !image, !saveCorr); iHisto++;
477          
478         sprintf(name,"TREND_MeanFlagPerRing");
479         sprintf(title,"Mean Flag per Event and per Ring versus time ");
480         trend = new AliVZEROTrending(name, title);
481         Add2RawsList(trend,kRawMeanFlagPerRing, expert, !image, !saveCorr); iHisto++;
482          
483         sprintf(name,"H1D_DQMFlag");
484         sprintf(title,"Current Flag per Event / Mean Flag per Event ");
485         h1d = new TH1D(name, title, kNChannelBins, kChannelMin, kChannelMax);
486         h1d->SetFillColor(29);
487         h1d->SetLineWidth(2);
488         h1d->GetXaxis()->SetLabelSize(0.06);
489     h1d->GetXaxis()->SetNdivisions(808,kFALSE);
490         h1d->GetXaxis()->SetBinLabel(4, "V0C");h1d->GetXaxis()->SetBinLabel(5, "R0");
491         h1d->GetXaxis()->SetBinLabel(12, "V0C");h1d->GetXaxis()->SetBinLabel(13, "R1");
492         h1d->GetXaxis()->SetBinLabel(20, "V0C");h1d->GetXaxis()->SetBinLabel(21, "R2");
493         h1d->GetXaxis()->SetBinLabel(28, "V0C");h1d->GetXaxis()->SetBinLabel(29, "R3");
494         h1d->GetXaxis()->SetBinLabel(36, "V0A");h1d->GetXaxis()->SetBinLabel(37, "R0");
495         h1d->GetXaxis()->SetBinLabel(44, "V0A");h1d->GetXaxis()->SetBinLabel(45, "R1");
496         h1d->GetXaxis()->SetBinLabel(52, "V0A");h1d->GetXaxis()->SetBinLabel(53, "R2");
497         h1d->GetXaxis()->SetBinLabel(60, "V0A");h1d->GetXaxis()->SetBinLabel(61, "R3");
498         h1d->GetXaxis()->CenterTitle();
499     h1d->GetXaxis()->SetTitleOffset(0.8);
500     h1d->GetXaxis()->SetNdivisions(808,kFALSE);
501         Add2RawsList(h1d,kRawDQMFlag, expert, image, !saveCorr); iHisto++;
502          
503         sprintf(name,"H1D_DQMCharge");
504         sprintf(title,"Current Charge per Event / Mean Charge per Event ");
505         h1d = new TH1D(name, title, kNChannelBins, kChannelMin, kChannelMax);
506         h1d->SetFillColor(29);
507         h1d->SetLineWidth(2);
508         h1d->GetXaxis()->SetLabelSize(0.06);
509     h1d->GetXaxis()->SetNdivisions(808,kFALSE);
510         h1d->GetXaxis()->SetBinLabel(4, "V0C");h1d->GetXaxis()->SetBinLabel(5, "R0");
511         h1d->GetXaxis()->SetBinLabel(12, "V0C");h1d->GetXaxis()->SetBinLabel(13, "R1");
512         h1d->GetXaxis()->SetBinLabel(20, "V0C");h1d->GetXaxis()->SetBinLabel(21, "R2");
513         h1d->GetXaxis()->SetBinLabel(28, "V0C");h1d->GetXaxis()->SetBinLabel(29, "R3");
514         h1d->GetXaxis()->SetBinLabel(36, "V0A");h1d->GetXaxis()->SetBinLabel(37, "R0");
515         h1d->GetXaxis()->SetBinLabel(44, "V0A");h1d->GetXaxis()->SetBinLabel(45, "R1");
516         h1d->GetXaxis()->SetBinLabel(52, "V0A");h1d->GetXaxis()->SetBinLabel(53, "R2");
517         h1d->GetXaxis()->SetBinLabel(60, "V0A");h1d->GetXaxis()->SetBinLabel(61, "R3");
518         h1d->GetXaxis()->CenterTitle();
519     h1d->GetXaxis()->SetTitleOffset(0.8);
520     h1d->GetXaxis()->SetNdivisions(808,kFALSE);
521         Add2RawsList(h1d,kRawDQMCharge, expert, image, !saveCorr); iHisto++;
522          
523         AliDebug(AliQAv1::GetQADebugLevel(), Form("%d Histograms has been added to the Raws List",iHisto));
524  }
525
526 //____________________________________________________________________________ 
527 void AliVZEROQADataMakerRec::InitDigits()
528 {
529   // create Digits histograms in Digits subdir
530   const Bool_t expert   = kTRUE ; 
531   const Bool_t image    = kTRUE ; 
532   
533   char tDCname[100];
534   char aDCname[100];
535   TH1I *fhDigTDC[64]; 
536   TH1I *fhDigADC[64]; 
537   char texte[100];
538   
539   // create Digits histograms in Digits subdir
540   TH1I * h0 = new TH1I("hDigitMultiplicity", "Digits multiplicity distribution in VZERO;# of Digits;Entries", 100, 0, 99) ; 
541   h0->Sumw2() ;
542   Add2DigitsList(h0, 0, !expert, image) ;
543   
544   for (Int_t i=0; i<64; i++)
545     {
546     sprintf(tDCname, "hDigitTDC%d", i);
547     sprintf(texte,"Digit TDC in cell %d; TDC value;Entries",i);    
548     fhDigTDC[i] = new TH1I(tDCname,texte,300,0.,149.);
549     
550     sprintf(aDCname,"hDigitADC%d",i);
551     sprintf(texte,"Digit ADC in cell %d;ADC value;Entries",i);
552     fhDigADC[i]= new TH1I(aDCname,texte,1024,0.,1023.);
553     
554     Add2DigitsList(fhDigTDC[i],i+1, !expert, image);
555     Add2DigitsList(fhDigADC[i],i+1+64, !expert, image);  
556     }  
557 }
558
559 //____________________________________________________________________________
560 void AliVZEROQADataMakerRec::MakeDigits()
561 {
562   // makes data from Digits
563
564   GetDigitsData(0)->Fill(fDigitsArray->GetEntriesFast()) ; 
565   TIter next(fDigitsArray) ; 
566   AliVZEROdigit *aVZERODigit ; 
567   while ( (aVZERODigit = dynamic_cast<AliVZEROdigit *>(next())) ) {
568     Int_t   aPMNumber  = aVZERODigit->PMNumber();         
569     GetDigitsData(aPMNumber +1)->Fill( aVZERODigit->Time()) ;    // in 100 of picoseconds
570     GetDigitsData(aPMNumber +1+64)->Fill( aVZERODigit->ADC()) ;
571   }  
572 }
573
574
575 //____________________________________________________________________________
576 void AliVZEROQADataMakerRec::MakeDigits(TTree *digitTree)
577 {
578   // makes data from Digit Tree
579         
580   if ( fDigitsArray ) 
581     fDigitsArray->Clear() ; 
582   else 
583     fDigitsArray = new TClonesArray("AliVZEROdigit", 1000) ; 
584   
585   TBranch * branch = digitTree->GetBranch("VZERODigit") ;
586   if ( ! branch ) {
587     AliWarning("VZERO branch in Digit Tree not found") ; 
588   } else {
589     branch->SetAddress(&fDigitsArray) ;
590     branch->GetEntry(0) ; 
591     MakeDigits() ; 
592   }  
593 }
594
595
596 //____________________________________________________________________________
597 void AliVZEROQADataMakerRec::MakeESDs(AliESDEvent * esd)
598 {
599   // Creates QA data from ESDs
600   
601   UInt_t eventType = esd->GetEventType();
602
603   switch (eventType){
604         case PHYSICS_EVENT:
605         AliESDVZERO *esdVZERO=esd->GetVZEROData();
606    
607         if (!esdVZERO) break;
608                   
609         GetESDsData(kCellMultiV0A)->Fill(esdVZERO->GetNbPMV0A());
610         GetESDsData(kCellMultiV0C)->Fill(esdVZERO->GetNbPMV0C());  
611         GetESDsData(kMIPMultiV0A)->Fill(esdVZERO->GetMTotV0A());
612         GetESDsData(kMIPMultiV0C)->Fill(esdVZERO->GetMTotV0C());  
613         
614         Float_t  timeV0A = 0., timeV0C = 0., diffTime;
615         Int_t   iTimeV0A = 0, iTimeV0C = 0;
616                 
617         for(Int_t i=0;i<64;i++) {
618                         GetESDsData(kMIPMultiChannel)->Fill((Float_t) i,(Float_t) esdVZERO->GetMultiplicity(i));
619                         GetESDsData(kChargeChannel)->Fill((Float_t) i,(Float_t) esdVZERO->GetAdc(i));
620                         if(esdVZERO->GetBBFlag(i)) GetESDsData(kBBFlag)->Fill((Float_t) i);
621                         if(esdVZERO->GetBGFlag(i)) GetESDsData(kBGFlag)->Fill((Float_t) i);
622
623                         Float_t time = (Float_t) esdVZERO->GetTime(i)/10.; //Convert in ns:  1 TDC channel = 100ps 
624                         GetESDsData(kTimeChannel)->Fill((Float_t) i,time);
625
626                         if(time>0.){
627                                 if (i<32) {
628                                         iTimeV0C++;
629                                         timeV0C += time;
630                                 }else{
631                                         iTimeV0A++;
632                                         timeV0A += time;
633                                 }
634                         }
635         }
636         if(iTimeV0A>0) timeV0A /= iTimeV0A; 
637         else timeV0A = -1.;
638         if(iTimeV0C>0) timeV0C /= iTimeV0C;
639         else timeV0C = -1.;
640         if(timeV0A<0. || timeV0C<0.) diffTime = -10000.;
641         else diffTime = timeV0A - timeV0C;
642                                 
643         GetESDsData(kESDV0ATime)->Fill(timeV0A);
644         GetESDsData(kESDV0CTime)->Fill(timeV0C);
645         GetESDsData(kESDDiffTime)->Fill(diffTime);
646                 
647         break;
648         }  
649   
650 }
651
652 //____________________________________________________________________________
653  void AliVZEROQADataMakerRec::MakeRaws(AliRawReader* rawReader)
654  {
655   // Fills histograms with Raws, computes average ADC values dynamically (pedestal subtracted)
656                   
657    // Check id histograms already created for this Event Specie
658    if ( ! GetRawsData(kPedestalInt0) )
659      InitRaws() ;
660
661    rawReader->Reset() ; 
662   AliVZERORawStream* rawStream  = new AliVZERORawStream(rawReader); 
663  if(!(rawStream->Next())) return;  
664  
665   eventTypeType eventType = rawReader->GetType();
666
667   Int_t    mulV0A = 0 ; 
668   Int_t    mulV0C = 0 ; 
669   Double_t timeV0A =0., timeV0C = 0.;
670   UInt_t   itimeV0A=0, itimeV0C=0;
671   Double_t chargeV0A=0., chargeV0C=0.;
672   Double_t mipV0A=0., mipV0C=0.;
673
674   Double_t diffTime=-100000.;
675
676   
677   switch (eventType){
678        case PHYSICS_EVENT:
679   
680                 fNTotEvents++;
681
682                 if(fNSubEvents++>=fTrendingUpdateEvent && fTrendingUpdateEvent>0) {
683                         fNSubEvents=0;
684                         AddTrendingEntry();
685                 }
686        Int_t  iFlag=0;
687        Int_t  pedestal;
688        Int_t  integrator;
689        Bool_t BBFlag;    
690        Bool_t BGFlag;    
691        Float_t time, width;
692        Int_t  MBCharge;
693            Float_t charge;
694        Int_t  offlineCh;
695        TH1D * hProj;
696        Float_t adc[64]; 
697
698        for(Int_t iChannel=0; iChannel<64; iChannel++) { // BEGIN : Loop over channels
699                    
700            offlineCh = rawStream->GetOfflineChannel(iChannel);
701                    
702            // Fill Pedestal histograms
703            
704            for(Int_t j=15; j<21; j++) {
705                        if((rawStream->GetBGFlag(iChannel,j) || rawStream->GetBBFlag(iChannel,j))) iFlag++;
706            }
707
708            if(iFlag == 0){ //No Flag found
709                        for(Int_t j=15; j<21; j++){
710                                pedestal= (Int_t) rawStream->GetPedestal(iChannel, j);
711                                integrator = rawStream->GetIntegratorFlag(iChannel, j);
712
713                                GetRawsData((integrator == 0 ? kPedestalInt0 : kPedestalInt1))->Fill(offlineCh,pedestal);
714                                GetRawsData((integrator == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1))->Fill(offlineCh,pedestal);
715                        }
716             }
717
718            // Fill Charge EoI histograms
719            
720                adc[offlineCh]    = 0.0;
721
722                // Search for the maximum charge in the train of 21 LHC clocks 
723                // regardless of the integrator which has been operated:
724                Float_t maxadc = 0;
725                Int_t imax = -1;
726                Float_t adcPedSub[21];
727                for(Int_t iClock=0; iClock<21; iClock++){
728                            Bool_t iIntegrator = rawStream->GetIntegratorFlag(iChannel,iClock);
729                            Int_t k = offlineCh+64*iIntegrator;
730
731                            //printf(Form("clock = %d adc = %f ped %f\n",iClock,rawStream->GetPedestal(iChannel,iClock),fPedestal[k]));
732
733                                 adcPedSub[iClock] = rawStream->GetPedestal(iChannel,iClock) - fCalibData->GetPedestal(k);
734 //                              if(adcPedSub[iClock] <= GetRecoParam()->GetNSigmaPed()*fCalibData->GetSigma(k)) {
735                                 if(adcPedSub[iClock] <= 2.*fCalibData->GetSigma(k)) {
736                                         adcPedSub[iClock] = 0;
737                                         continue;
738                                 }
739 //                              if(iClock < GetRecoParam()->GetStartClock() || iClock > GetRecoParam()->GetEndClock()) continue;
740                                 if(iClock < 8 || iClock > 12) continue;
741                                 if(adcPedSub[iClock] > maxadc) {
742                                         maxadc = adcPedSub[iClock];
743                                         imax   = iClock;
744                                 }
745                }
746                //printf(Form("Channel %d (online), %d (offline)\n",iChannel,j)); 
747                if (imax != -1) {
748 //                              Int_t start = imax - GetRecoParam()->GetNPreClocks();
749                                 Int_t start = imax - 2;
750                                 if (start < 0) start = 0;
751 //                              Int_t end = imax + GetRecoParam()->GetNPostClocks();
752                                 Int_t end = imax + 1;
753                                 if (end > 20) end = 20;
754                                 for(Int_t iClock = start; iClock <= end; iClock++) {
755                                         adc[offlineCh] += adcPedSub[iClock];
756                                 }
757                         }
758         
759                 
760            Int_t iClock  = imax;
761            charge = rawStream->GetPedestal(iChannel,iClock); // Charge at the maximum 
762
763            integrator    = rawStream->GetIntegratorFlag(iChannel,iClock);
764            BBFlag        = rawStream->GetBBFlag(iChannel, iClock);
765            BGFlag        = rawStream->GetBGFlag(iChannel,iClock );
766                Int_t board = AliVZEROCalibData::GetBoardNumber(offlineCh);
767                time = rawStream->GetTime(iChannel)*fCalibData->GetTimeResolution(board);
768                width = rawStream->GetWidth(iChannel)*fCalibData->GetWidthResolution(board);
769
770            GetRawsData(kChargeEoI)->Fill(offlineCh,adc[offlineCh]);
771
772            GetRawsData((integrator == 0 ? kChargeEoIInt0 : kChargeEoIInt1))->Fill(offlineCh,charge);
773            if(BBFlag) GetRawsData((integrator == 0 ? kChargeEoIBBInt0 : kChargeEoIBBInt1))->Fill(offlineCh,charge);
774            if(BGFlag) GetRawsData((integrator == 0 ? kChargeEoIBGInt0 : kChargeEoIBGInt1))->Fill(offlineCh,charge);
775
776            hProj = ((TH2I*)GetRawsData((integrator == 0 ? kPedestalInt0 : kPedestalInt1)))->ProjectionY("",offlineCh+1,offlineCh+1);
777            Double_t ped   = hProj->GetMean();
778            Double_t sigma = hProj->GetRMS();
779            delete hProj;
780
781            Double_t chargeEoI = charge - ped;
782                    
783            // Calculation of the number of MIP
784            Double_t mipEoI = chargeEoI * fCalibData->GetMIPperADC(offlineCh);
785
786            int side = offlineCh/32;
787            int ring = (offlineCh - 32*side) / 8;
788            if(BBFlag) {
789                         fFlagPerRing[side*4 + ring] += 1;
790                         fFlagPerChannel[offlineCh] += 1;
791            }    
792
793            if((chargeEoI > 2.*sigma) && !(time <1.e-6)){ 
794                    fChargePerRing[side*4 + ring] += chargeEoI;  
795                    fChargePerChannel[offlineCh] += chargeEoI;
796                    ((TH2I*)GetRawsData((integrator == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1)))->Fill(offlineCh,chargeEoI);
797                    ((TH2D*)GetRawsData(kRawMIPChannel))->Fill(offlineCh,mipEoI);
798                    if(offlineCh<32) {
799                                    mulV0C++;
800                                    chargeV0C += chargeEoI;
801                                    mipV0C += mipEoI;
802                    } else {
803                                    mulV0A++;
804                                    chargeV0A += chargeEoI;
805                                    mipV0A += mipEoI;
806                    }
807            }
808
809            // Fill Charge Minimum Bias Histograms
810                    
811            int idx;
812            for(Int_t iBunch=0; iBunch<10; iBunch++){
813                            integrator = rawStream->GetIntMBFlag(iChannel, iBunch);
814                            BBFlag     = rawStream->GetBBMBFlag(iChannel, iBunch);
815                            BGFlag     = rawStream->GetBGMBFlag(iChannel, iBunch);
816                            MBCharge   = rawStream->GetChargeMB(iChannel, iBunch);
817
818                            if(integrator==0){
819                                    if(BBFlag==0){
820                                            if(BGFlag==0) idx = kChargeMBBB0BG0Int0;
821                                            else idx = kChargeMBBB0BG1Int0;
822                                    } else {
823                                            if(BGFlag==0) idx = kChargeMBBB1BG0Int0;
824                                            else idx = kChargeMBBB1BG1Int0;
825                                    }
826                            } else {
827                                    if(BBFlag==0){
828                                            if(BGFlag==0) idx = kChargeMBBB0BG0Int1;
829                                            else idx = kChargeMBBB0BG1Int1;
830                                    } else {
831                                            if(BGFlag==0) idx = kChargeMBBB1BG0Int1;
832                                            else idx = kChargeMBBB1BG1Int1;
833                                    }
834                            }
835                            GetRawsData(idx)->Fill(offlineCh,MBCharge);
836        }   
837
838           // Fill HPTDC Time Histograms
839
840            BBFlag   = rawStream->GetBBFlag(iChannel, 10);
841            BGFlag   = rawStream->GetBGFlag(iChannel, 10);
842
843            if(!(time<1.e-6)){
844                       if (offlineCh<32) {
845                                    itimeV0C++;
846                                    timeV0C += time;
847                       }else{
848                                    itimeV0A++;
849                                    timeV0A += time;
850                       }
851            }
852            GetRawsData(kHPTDCTime)->Fill(offlineCh,time);
853            GetRawsData(kWidth)->Fill(offlineCh,width);
854            if(BBFlag) {
855                   GetRawsData(kHPTDCTimeBB)->Fill(offlineCh,time);
856                   GetRawsData(kWidthBB)->Fill(offlineCh,width);
857            }
858            if(BGFlag) {
859                   GetRawsData(kHPTDCTimeBG)->Fill(offlineCh,time);
860                   GetRawsData(kWidthBG)->Fill(offlineCh,width);
861            }
862
863            // Fill Flag and Charge Versus LHC-Clock histograms
864            
865            for(Int_t iEvent=0; iEvent<21; iEvent++){
866                charge = rawStream->GetPedestal(iChannel,iEvent);
867                integrator = rawStream->GetIntegratorFlag(iChannel,iEvent);
868                BBFlag     = rawStream->GetBBFlag(iChannel, iEvent);
869                BGFlag     = rawStream->GetBGFlag(iChannel,iEvent );
870
871                ((TH2*) GetRawsData((integrator == 0 ? kChargeVsClockInt0 : kChargeVsClockInt1 )))->Fill(offlineCh,(float)iEvent-10,(float)charge);
872                ((TH2*) GetRawsData(kBBFlagVsClock))->Fill(offlineCh,(float)iEvent-10,(float)BBFlag);
873                ((TH2*) GetRawsData(kBGFlagVsClock))->Fill(offlineCh,(float)iEvent-10,(float)BGFlag);
874                if(iEvent==10) ((TH1*) GetRawsData(kBBFlagsPerChannel))->Fill(offlineCh,(float)BBFlag);
875            }
876
877        }// END of Loop over channels
878
879             if(itimeV0A>0) timeV0A /= itimeV0A; 
880             else timeV0A = -1.;
881             if(itimeV0C>0) timeV0C /= itimeV0C;
882             else timeV0C = -1.;
883             if(timeV0A<0. || timeV0C<0.) diffTime = -10000.;
884             else diffTime = timeV0A - timeV0C;
885                 
886             GetRawsData(kV0ATime)->Fill(timeV0A);
887             GetRawsData(kV0CTime)->Fill(timeV0C);
888             GetRawsData(kDiffTime)->Fill(diffTime);
889                 
890             GetRawsData(kMultiV0A)->Fill(mulV0A);
891             GetRawsData(kMultiV0C)->Fill(mulV0C);
892
893             GetRawsData(kChargeV0A)->Fill(chargeV0A);
894             GetRawsData(kChargeV0C)->Fill(chargeV0C);
895             GetRawsData(kChargeV0)->Fill(chargeV0A + chargeV0C);
896                 
897             GetRawsData(kRawMIPV0A)->Fill(mipV0A);
898             GetRawsData(kRawMIPV0C)->Fill(mipV0C);
899             GetRawsData(kRawMIPV0)->Fill(mipV0A + mipV0C);
900             break;
901             
902         } // END of SWITCH : EVENT TYPE 
903         
904         fEvent++; 
905         TParameter<double> * p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kMultiV0A)->GetName()))) ; 
906         if (p) p->SetVal((double)mulV0A) ; 
907
908         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kMultiV0C)->GetName()))) ; 
909         if (p) p->SetVal((double)mulV0C) ;                     
910
911         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeV0A)->GetName()))) ; 
912         if (p) p->SetVal((double)chargeV0A) ; 
913
914         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeV0C)->GetName()))) ; 
915         if (p) p->SetVal((double)chargeV0C) ;                     
916
917         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeV0)->GetName()))) ; 
918         if (p) p->SetVal((double)(chargeV0A + chargeV0C)) ;                     
919         
920         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kRawMIPV0A)->GetName()))) ; 
921         if (p) p->SetVal((double)mipV0A) ; 
922         
923         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kRawMIPV0C)->GetName()))) ; 
924         if (p) p->SetVal((double)mipV0C) ;                     
925         
926         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kRawMIPV0)->GetName()))) ; 
927         if (p) p->SetVal((double)(mipV0A + mipV0C)) ;                     
928         
929         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kV0ATime)->GetName()))) ; 
930         if (p) p->SetVal((double)timeV0A) ; 
931         
932         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kV0CTime)->GetName()))) ; 
933         if (p) p->SetVal((double)timeV0C) ;                     
934         
935         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kDiffTime)->GetName()))) ; 
936         if (p) p->SetVal((double)diffTime) ;                     
937         
938         delete rawStream; rawStream = 0x0;      
939
940
941  }
942
943 //____________________________________________________________________________ 
944 void AliVZEROQADataMakerRec::StartOfDetectorCycle()
945 {
946   // Detector specific actions at start of cycle
947   
948   // Reset of the histogram used - to have the trend versus time -
949  
950   fCalibData = GetCalibData();
951   
952   TH1* h;
953   h = GetRawsData(kPedestalCycleInt0);
954   if(h) h->Reset();
955   h = GetRawsData(kPedestalCycleInt1); 
956   if(h) h->Reset();
957   h = GetRawsData(kChargeEoICycleInt0);
958   if(h) h->Reset();
959   h = GetRawsData(kChargeEoICycleInt1);
960   if(h) h->Reset();
961         
962   TTimeStamp currentTime;
963   fCycleStartTime = currentTime.GetSec();
964  
965   fNTotEvents = 0;
966 }
967
968 //-------------------------------------------------------------------------------------------------
969 void AliVZEROQADataMakerRec::AddTrendingEntry(){   
970      //printf("AddTrendingEntry\n");
971         fNTrendingUpdates++;
972         
973         // Normalize to the number of events
974         for(int i=0; i<8;i++){
975 //              fChargePerRing[i] *= TMath::Power(10.,i)/fTrendingUpdateEvent;
976 //              fFlagPerRing[i] *= TMath::Power(10.,i)/fTrendingUpdateEvent;
977                 fChargePerRing[i] /= fTrendingUpdateEvent;
978                 fFlagPerRing[i] /= fTrendingUpdateEvent;
979         }
980         
981         GetRawsData(kRawDQMCharge)->Reset();
982         GetRawsData(kRawDQMFlag)->Reset();
983
984         for(int i=0; i<64;i++){
985                 fChargePerChannel[i] /= fTrendingUpdateEvent;
986                 fFlagPerChannel[i] /= fTrendingUpdateEvent;
987                 
988                 if(fMeanChargePerChannel[i]) GetRawsData(kRawDQMCharge)->Fill(i,fChargePerChannel[i]/fMeanChargePerChannel[i]);
989                 else GetRawsData(kRawDQMCharge)->Fill(i,0.);
990                 
991                 if(fMeanFlagPerChannel[i]) GetRawsData(kRawDQMFlag)->Fill(i,fFlagPerChannel[i]/fMeanFlagPerChannel[i]);
992                 else GetRawsData(kRawDQMFlag)->Fill(i,0.);
993                 
994                 fMeanChargePerChannel[i] = (fMeanChargePerChannel[i] * (fNTrendingUpdates-1) + fChargePerChannel[i]) / fNTrendingUpdates;
995                 fMeanFlagPerChannel[i] = (fMeanFlagPerChannel[i] * (fNTrendingUpdates-1) + fFlagPerChannel[i]) / fNTrendingUpdates;
996                 
997         }
998         
999         TTimeStamp currentTime;
1000         ((AliVZEROTrending*)GetRawsData(kRawMeanChargePerRing))->AddEntry(fChargePerRing,  currentTime.GetSec());
1001         ((AliVZEROTrending*)GetRawsData(kRawMeanFlagPerRing))->AddEntry(fFlagPerRing,  currentTime.GetSec());
1002         //moMeanFlagPerRing->AddEntry(fFlagPerRing,  currentTime.GetSec());
1003         
1004         // Put back counters to zero
1005         for(int i=0; i<8;i++){
1006                 fChargePerRing[i] = 0.;
1007                 fFlagPerRing[i] = 0.;
1008         }
1009         for(int i=0; i<64;i++){
1010                 fChargePerChannel[i] = 0.;
1011                 fFlagPerChannel[i] = 0.;
1012         }
1013         
1014 }
1015