Adding TDC channel delays to the calib object.
[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  = 2048;
267   const Int_t kTdcTimeMin    =    0;
268   const Int_t kTdcTimeMax    = 4096;
269   const Int_t kNTdcWidthBins =  128;
270   const Int_t kTdcWidthMin   =    0;
271   const Int_t kTdcWidthMax   =  128;
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  for(Int_t iInt=0;iInt<kNintegrator;iInt++){
321     // Creation of Pedestal histograms 
322     sprintf(name,"H2I_Pedestal_Int%d",iInt);
323     sprintf(title,"Pedestal (Int%d);Pedestal [ADC counts];Counts",iInt);
324     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNPedestalBins,kPedestalMin ,kPedestalMax );
325     Add2RawsList(h2i,(iInt == 0 ? kPedestalInt0 : kPedestalInt1), expert, !image, !saveCorr); iHisto++;
326         
327     // Creation of temporary Pedestal histo used for the mean versus time histogram. This histogram will be reset at the end of each cycle
328     sprintf(name,"H2I_Pedestal_CycleInt%d",iInt);
329     sprintf(title,"One Cycle Pedestal (Int%d);Pedestal [ADC counts];Counts",iInt);
330     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNPedestalBins,kPedestalMin ,kPedestalMax );
331     Add2RawsList(h2i,(iInt == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1), expert, !image, !saveCorr); iHisto++;
332                 
333     // Creation of Pedestal versus time graph.
334     sprintf(name,"H2D_Pedestal_Time_Int%d",iInt);
335     sprintf(title,"Pedestal Versus Time (Int%d);Time [ns];Pedestal [ADC counts]",iInt);
336     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,kTimeMax,kTimeMin ,kTimeMax );
337     Add2RawsList(h2d,(iInt == 0 ? kPedestalTimeInt0 : kPedestalTimeInt1), expert, !image, !saveCorr); iHisto++;
338
339    // Creation of Charge EoI histograms 
340     sprintf(name,"H2I_ChargeEoI_Int%d",iInt);
341     sprintf(title,"Charge EoI (Int%d);Charge [ADC counts];Counts",iInt);
342     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
343     Add2RawsList(h2i,(iInt == 0 ? kChargeEoIInt0 : kChargeEoIInt1), expert, image, !saveCorr); iHisto++;
344
345    // Creation of temporary Charge EoI histograms used for the mean versus time histogram. This histogram will be reset at the end of each cycle
346     sprintf(name,"H2I_ChargeEoI_CycleInt%d",iInt);
347     sprintf(title,"One Cycle Charge EoI (Int%d);Charge [ADC counts];Counts",iInt);
348     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
349     Add2RawsList(h2i,(iInt == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1), expert, !image, !saveCorr); iHisto++;
350                 
351     // Creation of Charge EoI versus time graphs
352     sprintf(name,"H2D_ChargeEoI_Time_Int%d",iInt);
353     sprintf(title,"Charge EoI Versus Time (Int%d);Time [ns];Charge [ADC counts]",iInt);
354     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,kTimeMax,kTimeMin ,kTimeMax );
355     Add2RawsList(h2d,(iInt == 0 ? kChargeEoITimeInt0 : kChargeEoITimeInt1), expert, !image, !saveCorr); iHisto++;
356     
357     sprintf(name,"H2I_ChargeEoI_BB_Int%d",iInt);
358     sprintf(title,"Charge EoI w/ BB Flag (Int%d);??;Charge [ADC counts]",iInt);
359     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
360     Add2RawsList(h2i,(iInt == 0 ? kChargeEoIBBInt0 : kChargeEoIBBInt1), expert, !image, !saveCorr); iHisto++;
361     
362     sprintf(name,"H2I_ChargeEoI_BG_Int%d",iInt);
363     sprintf(title,"Charge EoI w/ BG Flag (Int%d);??;Charge [ADC counts]",iInt);
364     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
365     Add2RawsList(h2i,(iInt == 0 ?  kChargeEoIBGInt0: kChargeEoIBGInt1), expert, !image, !saveCorr); iHisto++;
366
367     // Creation of Charge versus LHC Clock histograms 
368     sprintf(name,"H2D_ChargeVsClock_Int%d",iInt);
369     sprintf(title,"Charge Versus LHC-Clock (Int%d);Tine [ns];Charge [ADC counts]",iInt);
370     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
371     Add2RawsList(h2d,(iInt == 0 ? kChargeVsClockInt0 : kChargeVsClockInt1 ), expert, !image, !saveCorr); iHisto++;
372         
373     // Creation of Minimum Bias Charge histograms 
374     for(Int_t iBB=0;iBB<2;iBB++){
375                 for(Int_t iBG=0;iBG<2;iBG++){
376                         sprintf(name,"H2I_ChargeMB_BB%d_BG%d_Int%d",iBB,iBG,iInt);
377                         sprintf(title,"MB Charge (BB=%d, BG=%d, Int=%d);Charge [ADC counts];Counts",iBB,iBG,iInt);
378                         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNChargeBins, kChargeMin, kChargeMax);
379                         int idx;
380                         if(iInt==0){
381                                 if(iBB==0){
382                                         if(iBG==0) idx = kChargeMBBB0BG0Int0;
383                                         else idx = kChargeMBBB0BG1Int0;
384                                 } else {
385                                         if(iBG==0) idx = kChargeMBBB1BG0Int0;
386                                         else idx = kChargeMBBB1BG1Int0;
387                                 }
388                         } else {
389                                 if(iBB==0){
390                                         if(iBG==0) idx = kChargeMBBB0BG0Int1;
391                                         else idx = kChargeMBBB0BG1Int1;
392                                 } else {
393                                         if(iBG==0) idx = kChargeMBBB1BG0Int1;
394                                         else idx = kChargeMBBB1BG1Int1;
395                                 }
396                         }
397                         Add2RawsList(h2i,idx, expert, !image, !saveCorr); iHisto++;
398                 }
399     }
400         
401  }
402  
403      // Creation of Time histograms 
404         sprintf(name,"H2I_Width");
405         sprintf(title,"HPTDC Width;Width [ns];Counts");
406         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
407         Add2RawsList(h2i,kWidth, expert, !image, !saveCorr); iHisto++;
408
409         sprintf(name,"H2I_Width_BB");
410         sprintf(title,"HPTDC Width w/ BB Flag condition;??;Width [ns]");
411         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
412         Add2RawsList(h2i,kWidthBB, expert, !image, !saveCorr); iHisto++;
413
414         sprintf(name,"H2I_Width_BG");
415         sprintf(title,"HPTDC Width w/ BG Flag condition??;Width [ns]");
416         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
417         Add2RawsList(h2i,kWidthBG, expert, !image, !saveCorr); iHisto++;
418
419         sprintf(name,"H2I_HPTDCTime");
420         sprintf(title,"HPTDC Time;??;Width [ns]");
421         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
422         Add2RawsList(h2i,kHPTDCTime, expert, image, !saveCorr); iHisto++;
423
424         sprintf(name,"H2I_HPTDCTime_BB");
425         sprintf(title,"HPTDC Time w/ BB Flag condition;??;Width [ns]");
426         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
427         Add2RawsList(h2i,kHPTDCTimeBB, expert, !image, !saveCorr); iHisto++;
428
429         sprintf(name,"H2I_HPTDCTime_BG");
430         sprintf(title,"HPTDC Time w/ BG Flag condition;??;Width [ns]");
431         h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
432         Add2RawsList(h2i,kHPTDCTimeBG, expert, !image, !saveCorr); iHisto++;
433         
434         sprintf(name,"H1D_V0A_Time");
435         sprintf(title,"V0A Time;Time [ns];Counts");
436         h1d = new TH1D(name, title,kNTdcTimeBins, kTdcTimeMin/10, kTdcTimeMax/10);
437         Add2RawsList(h1d,kV0ATime, expert, !image, saveCorr); iHisto++;
438         
439         sprintf(name,"H1D_V0C_Time");
440         sprintf(title,"V0C Time;Time [ns];Counts");
441         h1d = new TH1D(name, title,kNTdcTimeBins, kTdcTimeMin/10, kTdcTimeMax/10);
442         Add2RawsList(h1d,kV0CTime, expert, !image, saveCorr); iHisto++;
443         
444         sprintf(name,"H1D_Diff_Time");
445         sprintf(title,"Diff V0A-V0C Time;Time [ns];Counts");
446         h1d = new TH1D(name, title,2*kNTdcTimeBins, -kTdcTimeMax/10, kTdcTimeMax/10);
447         Add2RawsList(h1d,kDiffTime, expert, !image, saveCorr); iHisto++;
448         
449         // Creation of Flag versus LHC Clock histograms 
450         sprintf(name,"H2D_BBFlagVsClock");
451         sprintf(title,"BB-Flags Versus LHC-Clock;Time [ns];??");
452         h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
453         Add2RawsList(h2d,kBBFlagVsClock, expert, !image, !saveCorr); iHisto++;
454         
455         sprintf(name,"H2D_BGFlagVsClock");
456         sprintf(title,"BG-Flags Versus LHC-Clock;Time [ns];??");
457         h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
458         Add2RawsList(h2d,kBGFlagVsClock, expert, !image, !saveCorr); iHisto++;
459          
460         sprintf(name,"TREND_MeanChargePerRing");
461         sprintf(title,"Mean Charge per Event and per Ring versus time ");
462         trend = new AliVZEROTrending(name, title);
463         Add2RawsList(trend,kRawMeanChargePerRing, expert, !image, !saveCorr); iHisto++;
464          
465         sprintf(name,"TREND_MeanFlagPerRing");
466         sprintf(title,"Mean Flag per Event and per Ring versus time ");
467         trend = new AliVZEROTrending(name, title);
468         Add2RawsList(trend,kRawMeanFlagPerRing, expert, !image, !saveCorr); iHisto++;
469          
470         sprintf(name,"H1D_DQMFlag");
471         sprintf(title,"Current Flag per Event / Mean Flag per Event ");
472         h1d = new TH1D(name, title, kNChannelBins, kChannelMin, kChannelMax);
473         h1d->SetFillColor(29);
474         h1d->SetLineWidth(2);
475         h1d->GetXaxis()->SetLabelSize(0.06);
476     h1d->GetXaxis()->SetNdivisions(808,kFALSE);
477         h1d->GetXaxis()->SetBinLabel(4, "V0C");h1d->GetXaxis()->SetBinLabel(5, "R0");
478         h1d->GetXaxis()->SetBinLabel(12, "V0C");h1d->GetXaxis()->SetBinLabel(13, "R1");
479         h1d->GetXaxis()->SetBinLabel(20, "V0C");h1d->GetXaxis()->SetBinLabel(21, "R2");
480         h1d->GetXaxis()->SetBinLabel(28, "V0C");h1d->GetXaxis()->SetBinLabel(29, "R3");
481         h1d->GetXaxis()->SetBinLabel(36, "V0A");h1d->GetXaxis()->SetBinLabel(37, "R0");
482         h1d->GetXaxis()->SetBinLabel(44, "V0A");h1d->GetXaxis()->SetBinLabel(45, "R1");
483         h1d->GetXaxis()->SetBinLabel(52, "V0A");h1d->GetXaxis()->SetBinLabel(53, "R2");
484         h1d->GetXaxis()->SetBinLabel(60, "V0A");h1d->GetXaxis()->SetBinLabel(61, "R3");
485         h1d->GetXaxis()->CenterTitle();
486     h1d->GetXaxis()->SetTitleOffset(0.8);
487     h1d->GetXaxis()->SetNdivisions(808,kFALSE);
488         Add2RawsList(h1d,kRawDQMFlag, !expert, image, !saveCorr); iHisto++;
489          
490         sprintf(name,"H1D_DQMCharge");
491         sprintf(title,"Current Charge per Event / Mean Charge per Event ");
492         h1d = new TH1D(name, title, kNChannelBins, kChannelMin, kChannelMax);
493         h1d->SetFillColor(29);
494         h1d->SetLineWidth(2);
495         h1d->GetXaxis()->SetLabelSize(0.06);
496     h1d->GetXaxis()->SetNdivisions(808,kFALSE);
497         h1d->GetXaxis()->SetBinLabel(4, "V0C");h1d->GetXaxis()->SetBinLabel(5, "R0");
498         h1d->GetXaxis()->SetBinLabel(12, "V0C");h1d->GetXaxis()->SetBinLabel(13, "R1");
499         h1d->GetXaxis()->SetBinLabel(20, "V0C");h1d->GetXaxis()->SetBinLabel(21, "R2");
500         h1d->GetXaxis()->SetBinLabel(28, "V0C");h1d->GetXaxis()->SetBinLabel(29, "R3");
501         h1d->GetXaxis()->SetBinLabel(36, "V0A");h1d->GetXaxis()->SetBinLabel(37, "R0");
502         h1d->GetXaxis()->SetBinLabel(44, "V0A");h1d->GetXaxis()->SetBinLabel(45, "R1");
503         h1d->GetXaxis()->SetBinLabel(52, "V0A");h1d->GetXaxis()->SetBinLabel(53, "R2");
504         h1d->GetXaxis()->SetBinLabel(60, "V0A");h1d->GetXaxis()->SetBinLabel(61, "R3");
505         h1d->GetXaxis()->CenterTitle();
506     h1d->GetXaxis()->SetTitleOffset(0.8);
507     h1d->GetXaxis()->SetNdivisions(808,kFALSE);
508         Add2RawsList(h1d,kRawDQMCharge, !expert, image, !saveCorr); iHisto++;
509          
510         AliDebug(AliQAv1::GetQADebugLevel(), Form("%d Histograms has been added to the Raws List",iHisto));
511  }
512
513 //____________________________________________________________________________ 
514 void AliVZEROQADataMakerRec::InitDigits()
515 {
516   // create Digits histograms in Digits subdir
517   const Bool_t expert   = kTRUE ; 
518   const Bool_t image    = kTRUE ; 
519   
520   char TDCname[100];
521   char ADCname[100];
522   TH1I *fhDigTDC[64]; 
523   TH1I *fhDigADC[64]; 
524   char texte[100];
525   
526   // create Digits histograms in Digits subdir
527   TH1I * h0 = new TH1I("hDigitMultiplicity", "Digits multiplicity distribution in VZERO;# of Digits;Entries", 100, 0, 99) ; 
528   h0->Sumw2() ;
529   Add2DigitsList(h0, 0, !expert, image) ;
530   
531   for (Int_t i=0; i<64; i++)
532     {
533     sprintf(TDCname, "hDigitTDC%d", i);
534     sprintf(texte,"Digit TDC in cell %d; TDC value;Entries",i);    
535     fhDigTDC[i] = new TH1I(TDCname,texte,300,0.,149.);
536     
537     sprintf(ADCname,"hDigitADC%d",i);
538     sprintf(texte,"Digit ADC in cell %d;ADC value;Entries",i);
539     fhDigADC[i]= new TH1I(ADCname,texte,1024,0.,1023.);
540     
541     Add2DigitsList(fhDigTDC[i],i+1, !expert, image);
542     Add2DigitsList(fhDigADC[i],i+1+64, !expert, image);  
543     }  
544 }
545
546 //____________________________________________________________________________
547 void AliVZEROQADataMakerRec::MakeDigits()
548 {
549   // makes data from Digits
550
551   GetDigitsData(0)->Fill(fDigitsArray->GetEntriesFast()) ; 
552   TIter next(fDigitsArray) ; 
553   AliVZEROdigit *VZERODigit ; 
554   while ( (VZERODigit = dynamic_cast<AliVZEROdigit *>(next())) ) {
555     Int_t   PMNumber  = VZERODigit->PMNumber();         
556     GetDigitsData(PMNumber +1)->Fill( VZERODigit->Time()) ;    // in 100 of picoseconds
557     GetDigitsData(PMNumber +1+64)->Fill( VZERODigit->ADC()) ;
558   }  
559 }
560
561
562 //____________________________________________________________________________
563 void AliVZEROQADataMakerRec::MakeDigits(TTree *digitTree)
564 {
565   // makes data from Digit Tree
566         
567   if ( fDigitsArray ) 
568     fDigitsArray->Clear() ; 
569   else 
570     fDigitsArray = new TClonesArray("AliVZEROdigit", 1000) ; 
571   
572   TBranch * branch = digitTree->GetBranch("VZERODigit") ;
573   if ( ! branch ) {
574     AliWarning("VZERO branch in Digit Tree not found") ; 
575   } else {
576     branch->SetAddress(&fDigitsArray) ;
577     branch->GetEntry(0) ; 
578     MakeDigits() ; 
579   }  
580 }
581
582
583 //____________________________________________________________________________
584 void AliVZEROQADataMakerRec::MakeESDs(AliESDEvent * esd)
585 {
586   // Creates QA data from ESDs
587   
588   UInt_t eventType = esd->GetEventType();
589
590   switch (eventType){
591         case PHYSICS_EVENT:
592         AliESDVZERO *esdVZERO=esd->GetVZEROData();
593    
594         if (!esdVZERO) break;
595                   
596         GetESDsData(kCellMultiV0A)->Fill(esdVZERO->GetNbPMV0A());
597         GetESDsData(kCellMultiV0C)->Fill(esdVZERO->GetNbPMV0C());  
598         GetESDsData(kMIPMultiV0A)->Fill(esdVZERO->GetMTotV0A());
599         GetESDsData(kMIPMultiV0C)->Fill(esdVZERO->GetMTotV0C());  
600         
601         Float_t  timeV0A = 0., timeV0C = 0., diffTime;
602         Int_t   iTimeV0A = 0, iTimeV0C = 0;
603                 
604         for(Int_t i=0;i<64;i++) {
605                         GetESDsData(kMIPMultiChannel)->Fill((Float_t) i,(Float_t) esdVZERO->GetMultiplicity(i));
606                         GetESDsData(kChargeChannel)->Fill((Float_t) i,(Float_t) esdVZERO->GetAdc(i));
607                         if(esdVZERO->GetBBFlag(i)) GetESDsData(kBBFlag)->Fill((Float_t) i);
608                         if(esdVZERO->GetBGFlag(i)) GetESDsData(kBGFlag)->Fill((Float_t) i);
609
610                         Float_t time = (Float_t) esdVZERO->GetTime(i)/10.; //Convert in ns:  1 TDC channel = 100ps 
611                         GetESDsData(kTimeChannel)->Fill((Float_t) i,time);
612
613                         if(time>0.){
614                                 if (i<32) {
615                                         iTimeV0C++;
616                                         timeV0C += time;
617                                 }else{
618                                         iTimeV0A++;
619                                         timeV0A += time;
620                                 }
621                         }
622         }
623         if(iTimeV0A>0) timeV0A /= iTimeV0A; 
624         else timeV0A = -1.;
625         if(iTimeV0C>0) timeV0C /= iTimeV0C;
626         else timeV0C = -1.;
627         if(timeV0A<0. || timeV0C<0.) diffTime = -10000.;
628         else diffTime = timeV0A - timeV0C;
629                                 
630         GetESDsData(kESDV0ATime)->Fill(timeV0A);
631         GetESDsData(kESDV0CTime)->Fill(timeV0C);
632         GetESDsData(kESDDiffTime)->Fill(diffTime);
633                 
634         break;
635         }  
636   
637 }
638
639 //____________________________________________________________________________
640  void AliVZEROQADataMakerRec::MakeRaws(AliRawReader* rawReader)
641  {
642   // Fills histograms with Raws, computes average ADC values dynamically (pedestal subtracted)
643                   
644    // Check id histograms already created for this Event Specie
645    if ( ! GetRawsData(kPedestalInt0) )
646      InitRaws() ;
647
648    rawReader->Reset() ; 
649   AliVZERORawStream* rawStream  = new AliVZERORawStream(rawReader); 
650  if(!(rawStream->Next())) return;  
651  
652   eventTypeType eventType = rawReader->GetType();
653
654   Int_t    mulV0A = 0 ; 
655   Int_t    mulV0C = 0 ; 
656   Double_t timeV0A =0., timeV0C = 0.;
657   UInt_t   itimeV0A=0, itimeV0C=0;
658   Double_t chargeV0A=0., chargeV0C=0.;
659   Double_t mipV0A=0., mipV0C=0.;
660
661   Double_t diffTime=-100000.;
662
663   
664   switch (eventType){
665        case PHYSICS_EVENT:
666   
667                 fNTotEvents++;
668
669                 if(fNSubEvents++>=fTrendingUpdateEvent && fTrendingUpdateEvent>0) {
670                         fNSubEvents=0;
671                         AddTrendingEntry();
672                 }
673        Int_t  iFlag=0;
674        Int_t  pedestal;
675        Int_t  integrator;
676        Bool_t BBFlag;    
677        Bool_t BGFlag;    
678        Float_t time, width;
679        Int_t  MBCharge;
680            Float_t charge;
681        Int_t  offlineCh;
682        TH1D * hProj;
683
684        for(Int_t iChannel=0; iChannel<64; iChannel++) { // BEGIN : Loop over channels
685                    
686            offlineCh = rawStream->GetOfflineChannel(iChannel);
687                    
688            // Fill Pedestal histograms
689            
690            for(Int_t j=15; j<21; j++) {
691                        if((rawStream->GetBGFlag(iChannel,j) || rawStream->GetBBFlag(iChannel,j))) iFlag++;
692            }
693
694            if(iFlag == 0){ //No Flag found
695                        for(Int_t j=15; j<21; j++){
696                                pedestal= (Int_t) rawStream->GetPedestal(iChannel, j);
697                                integrator = rawStream->GetIntegratorFlag(iChannel, j);
698
699                                GetRawsData((integrator == 0 ? kPedestalInt0 : kPedestalInt1))->Fill(offlineCh,pedestal);
700                                GetRawsData((integrator == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1))->Fill(offlineCh,pedestal);
701                        }
702             }
703
704            // Fill Charge EoI histograms
705            
706            // Look for the maximum in the LHC clock train
707            charge = 0;
708            Int_t iClock  = 0;
709            Float_t iCharge = 0;
710            for(Int_t iEvent=0; iEvent<21; iEvent++){
711                iCharge = rawStream->GetPedestal(iChannel,iEvent);
712                if(iCharge>charge)  {
713                        charge = iCharge;
714                        iClock = iEvent;
715                    }
716            }   // End of maximum searching procedure
717
718            integrator    = rawStream->GetIntegratorFlag(iChannel,iClock);
719            BBFlag        = rawStream->GetBBFlag(iChannel, iClock);
720            BGFlag        = rawStream->GetBGFlag(iChannel,iClock );
721
722            GetRawsData((integrator == 0 ? kChargeEoIInt0 : kChargeEoIInt1))->Fill(offlineCh,charge);
723            if(BBFlag) GetRawsData((integrator == 0 ? kChargeEoIBBInt0 : kChargeEoIBBInt1))->Fill(offlineCh,charge);
724            if(BGFlag) GetRawsData((integrator == 0 ? kChargeEoIBGInt0 : kChargeEoIBGInt1))->Fill(offlineCh,charge);
725
726            hProj = ((TH2I*)GetRawsData((integrator == 0 ? kPedestalInt0 : kPedestalInt1)))->ProjectionY("",offlineCh+1,offlineCh+1);
727            Double_t ped   = hProj->GetMean();
728            Double_t sigma = hProj->GetRMS();
729            delete hProj;
730
731            Double_t chargeEoI = charge - ped;
732                    
733            // Calculation of the number of MIP
734            Double_t mipEoI = chargeEoI * fCalibData->GetMIPperADC(offlineCh);
735
736            int side = offlineCh/32;
737            int ring = (offlineCh - 32*side) / 8;
738            if(BBFlag) {
739                         fFlagPerRing[side*4 + ring] += 1;
740                         fFlagPerChannel[offlineCh] += 1;
741            }    
742
743            if(charge<1023 && chargeEoI > 5.*sigma){ 
744                    fChargePerRing[side*4 + ring] += chargeEoI;  
745                    fChargePerChannel[offlineCh] += chargeEoI;
746                    ((TH2I*)GetRawsData((integrator == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1)))->Fill(offlineCh,chargeEoI);
747                    ((TH2D*)GetRawsData(kRawMIPChannel))->Fill(offlineCh,mipEoI);
748                    if(offlineCh<32) {
749                                    mulV0C++;
750                                    chargeV0C += chargeEoI;
751                                    mipV0C += mipEoI;
752                    } else {
753                                    mulV0A++;
754                                    chargeV0A += chargeEoI;
755                                    mipV0A += mipEoI;
756                    }
757            }
758
759            // Fill Charge Minimum Bias Histograms
760                    
761            int idx;
762            for(Int_t iBunch=0; iBunch<10; iBunch++){
763                            integrator = rawStream->GetIntMBFlag(iChannel, iBunch);
764                            BBFlag     = rawStream->GetBBMBFlag(iChannel, iBunch);
765                            BGFlag     = rawStream->GetBGMBFlag(iChannel, iBunch);
766                            MBCharge   = rawStream->GetChargeMB(iChannel, iBunch);
767
768                            if(integrator==0){
769                                    if(BBFlag==0){
770                                            if(BGFlag==0) idx = kChargeMBBB0BG0Int0;
771                                            else idx = kChargeMBBB0BG1Int0;
772                                    } else {
773                                            if(BGFlag==0) idx = kChargeMBBB1BG0Int0;
774                                            else idx = kChargeMBBB1BG1Int0;
775                                    }
776                            } else {
777                                    if(BBFlag==0){
778                                            if(BGFlag==0) idx = kChargeMBBB0BG0Int1;
779                                            else idx = kChargeMBBB0BG1Int1;
780                                    } else {
781                                            if(BGFlag==0) idx = kChargeMBBB1BG0Int1;
782                                            else idx = kChargeMBBB1BG1Int1;
783                                    }
784                            }
785                            GetRawsData(idx)->Fill(offlineCh,MBCharge);
786           }   
787
788           // Fill HPTDC Time Histograms
789
790            BBFlag   = rawStream->GetBBFlag(iChannel, 10);
791            BGFlag   = rawStream->GetBGFlag(iChannel, 10);
792            time     = rawStream->GetTime(iChannel);
793            width    = rawStream->GetWidth(iChannel);
794
795            if(time>0.){
796                       if (offlineCh<32) {
797                                    itimeV0C++;
798                                    timeV0C += time;
799                       }else{
800                                    itimeV0A++;
801                                    timeV0A += time;
802                       }
803            }
804            GetRawsData(kHPTDCTime)->Fill(offlineCh,time);
805            GetRawsData(kWidth)->Fill(offlineCh,width);
806            if(BBFlag) {
807                   GetRawsData(kHPTDCTimeBB)->Fill(offlineCh,time);
808                   GetRawsData(kWidthBB)->Fill(offlineCh,width);
809            }
810            if(BGFlag) {
811                   GetRawsData(kHPTDCTimeBG)->Fill(offlineCh,time);
812                   GetRawsData(kWidthBG)->Fill(offlineCh,width);
813            }
814
815            // Fill Flag and Charge Versus LHC-Clock histograms
816            
817            for(Int_t iEvent=0; iEvent<21; iEvent++){
818                charge = rawStream->GetPedestal(iChannel,iEvent);
819                integrator = rawStream->GetIntegratorFlag(iChannel,iEvent);
820                BBFlag     = rawStream->GetBBFlag(iChannel, iEvent);
821                BGFlag     = rawStream->GetBGFlag(iChannel,iEvent );
822
823                ((TH2*) GetRawsData((integrator == 0 ? kChargeVsClockInt0 : kChargeVsClockInt1 )))->Fill(offlineCh,(float)iEvent-10,(float)charge);
824                ((TH2*) GetRawsData(kBBFlagVsClock))->Fill(offlineCh,(float)iEvent-10,(float)BBFlag);
825                ((TH2*) GetRawsData(kBGFlagVsClock))->Fill(offlineCh,(float)iEvent-10,(float)BGFlag);
826            }
827
828        }// END of Loop over channels
829
830             if(itimeV0A>0) timeV0A /= (itimeV0A * 10); // itimeV0A Channels and divide by 10 to have the result in ns because 1 TDC Channel = 100 ps
831             else timeV0A = -1.;
832             if(itimeV0C>0) timeV0C /= (itimeV0C * 10);
833             else timeV0C = -1.;
834             if(timeV0A<0. || timeV0C<0.) diffTime = -10000.;
835             else diffTime = timeV0A - timeV0C;
836                 
837             GetRawsData(kV0ATime)->Fill(timeV0A);
838             GetRawsData(kV0CTime)->Fill(timeV0C);
839             GetRawsData(kDiffTime)->Fill(diffTime);
840                 
841             GetRawsData(kMultiV0A)->Fill(mulV0A);
842             GetRawsData(kMultiV0C)->Fill(mulV0C);
843
844             GetRawsData(kChargeV0A)->Fill(chargeV0A);
845             GetRawsData(kChargeV0C)->Fill(chargeV0C);
846             GetRawsData(kChargeV0)->Fill(chargeV0A + chargeV0C);
847                 
848             GetRawsData(kRawMIPV0A)->Fill(mipV0A);
849             GetRawsData(kRawMIPV0C)->Fill(mipV0C);
850             GetRawsData(kRawMIPV0)->Fill(mipV0A + mipV0C);
851             break;
852             
853         } // END of SWITCH : EVENT TYPE 
854         
855         fEvent++; 
856         TParameter<double> * p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kMultiV0A)->GetName()))) ; 
857         if (p) p->SetVal((double)mulV0A) ; 
858
859         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kMultiV0C)->GetName()))) ; 
860         if (p) p->SetVal((double)mulV0C) ;                     
861
862         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeV0A)->GetName()))) ; 
863         if (p) p->SetVal((double)chargeV0A) ; 
864
865         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeV0C)->GetName()))) ; 
866         if (p) p->SetVal((double)chargeV0C) ;                     
867
868         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeV0)->GetName()))) ; 
869         if (p) p->SetVal((double)(chargeV0A + chargeV0C)) ;                     
870         
871         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kRawMIPV0A)->GetName()))) ; 
872         if (p) p->SetVal((double)mipV0A) ; 
873         
874         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kRawMIPV0C)->GetName()))) ; 
875         if (p) p->SetVal((double)mipV0C) ;                     
876         
877         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kRawMIPV0)->GetName()))) ; 
878         if (p) p->SetVal((double)(mipV0A + mipV0C)) ;                     
879         
880         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kV0ATime)->GetName()))) ; 
881         if (p) p->SetVal((double)timeV0A) ; 
882         
883         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kV0CTime)->GetName()))) ; 
884         if (p) p->SetVal((double)timeV0C) ;                     
885         
886         p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kDiffTime)->GetName()))) ; 
887         if (p) p->SetVal((double)diffTime) ;                     
888         
889         delete rawStream; rawStream = 0x0;      
890
891
892  }
893
894 //____________________________________________________________________________ 
895 void AliVZEROQADataMakerRec::StartOfDetectorCycle()
896 {
897   // Detector specific actions at start of cycle
898   
899   // Reset of the histogram used - to have the trend versus time -
900  
901   fCalibData = GetCalibData();
902   
903   TH1* h;
904   h = GetRawsData(kPedestalCycleInt0);
905   if(h) h->Reset();
906   h = GetRawsData(kPedestalCycleInt1); 
907   if(h) h->Reset();
908   h = GetRawsData(kChargeEoICycleInt0);
909   if(h) h->Reset();
910   h = GetRawsData(kChargeEoICycleInt1);
911   if(h) h->Reset();
912         
913   TTimeStamp currentTime;
914   fCycleStartTime = currentTime.GetSec();
915  
916   fNTotEvents = 0;
917 }
918
919 //-------------------------------------------------------------------------------------------------
920 void AliVZEROQADataMakerRec::AddTrendingEntry(){   
921      //printf("AddTrendingEntry\n");
922         fNTrendingUpdates++;
923         
924         // Normalize to the number of events
925         for(int i=0; i<8;i++){
926 //              fChargePerRing[i] *= TMath::Power(10.,i)/fTrendingUpdateEvent;
927 //              fFlagPerRing[i] *= TMath::Power(10.,i)/fTrendingUpdateEvent;
928                 fChargePerRing[i] /= fTrendingUpdateEvent;
929                 fFlagPerRing[i] /= fTrendingUpdateEvent;
930         }
931         
932         GetRawsData(kRawDQMCharge)->Reset();
933         GetRawsData(kRawDQMFlag)->Reset();
934
935         for(int i=0; i<64;i++){
936                 fChargePerChannel[i] /= fTrendingUpdateEvent;
937                 fFlagPerChannel[i] /= fTrendingUpdateEvent;
938                 
939                 if(fMeanChargePerChannel[i]) GetRawsData(kRawDQMCharge)->Fill(i,fChargePerChannel[i]/fMeanChargePerChannel[i]);
940                 else GetRawsData(kRawDQMCharge)->Fill(i,0.);
941                 
942                 if(fMeanFlagPerChannel[i]) GetRawsData(kRawDQMFlag)->Fill(i,fFlagPerChannel[i]/fMeanFlagPerChannel[i]);
943                 else GetRawsData(kRawDQMFlag)->Fill(i,0.);
944                 
945                 fMeanChargePerChannel[i] = (fMeanChargePerChannel[i] * (fNTrendingUpdates-1) + fChargePerChannel[i]) / fNTrendingUpdates;
946                 fMeanFlagPerChannel[i] = (fMeanFlagPerChannel[i] * (fNTrendingUpdates-1) + fFlagPerChannel[i]) / fNTrendingUpdates;
947                 
948         }
949         
950         TTimeStamp currentTime;
951         ((AliVZEROTrending*)GetRawsData(kRawMeanChargePerRing))->AddEntry(fChargePerRing,  currentTime.GetSec());
952         ((AliVZEROTrending*)GetRawsData(kRawMeanFlagPerRing))->AddEntry(fFlagPerRing,  currentTime.GetSec());
953         //moMeanFlagPerRing->AddEntry(fFlagPerRing,  currentTime.GetSec());
954         
955         // Put back counters to zero
956         for(int i=0; i<8;i++){
957                 fChargePerRing[i] = 0.;
958                 fFlagPerRing[i] = 0.;
959         }
960         for(int i=0; i<64;i++){
961                 fChargePerChannel[i] = 0.;
962                 fFlagPerChannel[i] = 0.;
963         }
964         
965 }
966