]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - VZERO/AliVZEROQADataMakerRec.cxx
Time data monitoring (Raphael)
[u/mrichter/AliRoot.git] / VZERO / AliVZEROQADataMakerRec.cxx
index e90f5edc838a94e9301eec0ba078bfcb735b6b09..5d944f6d351bc0e3e7881e88e45bb63aab8e07d3 100644 (file)
@@ -28,6 +28,7 @@
 #include <TH2D.h> 
 #include <TGraph.h> 
 #include <TParameter.h>
+#include <TTimeStamp.h>
 
 // --- Standard library ---
 
@@ -41,7 +42,9 @@
 #include "AliQAChecker.h"
 #include "AliRawReader.h"
 #include "AliVZERORawStream.h"
+#include "AliVZEROdigit.h"
 #include "AliVZEROReconstructor.h"
+#include "AliVZEROTrending.h"
 #include "event.h"
 
 
@@ -49,15 +52,18 @@ ClassImp(AliVZEROQADataMakerRec)
            
 //____________________________________________________________________________ 
   AliVZEROQADataMakerRec::AliVZEROQADataMakerRec() : 
-       AliQADataMakerRec(AliQA::GetDetName(AliQA::kVZERO), "VZERO Quality Assurance Data Maker"),
+       AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kVZERO), "VZERO Quality Assurance Data Maker"),
        fCalibData(0x0),
-    fEvent(0)
+    fEvent(0), fNTotEvents(0), fNSubEvents(0), fTrendingUpdateEvent(0), fTrendingUpdateTime(0), fCycleStartTime(0), fCycleStopTime(0), fMonitorRate(0.)
     
 {
    // Constructor
    
-   AliInfo("Construct VZERO QA Object");
-  
+      AliDebug(AliQAv1::GetQADebugLevel(), "Construct VZERO QA Object");
+  for(Int_t i=0;i<8;i++){
+       fChargePerRing[i] = 0.;
+       fFlagPerRing[i] = 0.;
+  }
    for(Int_t i=0; i<64; i++){  
        fEven[i] = 0;   
        fOdd[i]  = 0;  }
@@ -70,7 +76,7 @@ ClassImp(AliVZEROQADataMakerRec)
   AliVZEROQADataMakerRec::AliVZEROQADataMakerRec(const AliVZEROQADataMakerRec& qadm) :
   AliQADataMakerRec(),
        fCalibData(0x0),
-    fEvent(0)
+    fEvent(0), fNTotEvents(0), fNSubEvents(0), fTrendingUpdateEvent(0), fTrendingUpdateTime(0), fCycleStartTime(0), fCycleStopTime(0), fMonitorRate(0.)
   
 {
   // Copy constructor 
@@ -93,61 +99,84 @@ AliVZEROQADataMakerRec& AliVZEROQADataMakerRec::operator = (const AliVZEROQAData
 AliVZEROCalibData* AliVZEROQADataMakerRec::GetCalibData() const
 
 {
+   AliCDBManager *man = AliCDBManager::Instance();
 
-  // Gets calibration data - not used here anymore -
-  
-  AliCDBManager *man = AliCDBManager::Instance();
-  
-  //man->SetDefaultStorage("local://$ALICE_ROOT");
-
-  AliCDBEntry *entry=0;
-  
-  entry = man->Get("VZERO/Calib/Data",fRun);
+   AliCDBEntry *entry=0;
 
-  // Retrieval of data in directory VZERO/Calib/Data:
+   entry = man->Get("VZERO/Calib/Data",fRun);
+   if(!entry){
+       AliWarning("Load of calibration data from default storage failed!");
+       AliWarning("Calibration data will be loaded from local storage ($ALICE_ROOT)");
+       
+       man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+       entry = man->Get("VZERO/Calib/Data",fRun);
+   }
+   // Retrieval of data in directory VZERO/Calib/Data:
 
-  AliVZEROCalibData *calibdata = 0;
+   AliVZEROCalibData *calibdata = 0;
 
-  if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
-  if (!calibdata)  AliFatal("No calibration data from calibration database !");
+   if (entry) calibdata = (AliVZEROCalibData*) entry->GetObject();
+   if (!calibdata)  AliFatal("No calibration data from calibration database !");
 
-  return calibdata;
+   return calibdata;
 }
+
+
  
 //____________________________________________________________________________ 
-void AliVZEROQADataMakerRec::EndOfDetectorCycle(AliQA::TASKINDEX_t task, TObjArray * list)
+void AliVZEROQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray ** list)
 {
   // Detector specific actions at end of cycle
   // Does the QA checking
   
-  AliQAChecker::Instance()->Run(AliQA::kVZERO, task, list) ;
+  AliQAChecker::Instance()->Run(AliQAv1::kVZERO, task, list) ;
   
-  if(task == AliQA::kRAWS){
+  if(task == AliQAv1::kRAWS){
+       TTimeStamp currentTime;
+       fCycleStopTime = currentTime.GetSec();
+       if(fCycleStopTime-fCycleStartTime>0.) fMonitorRate = fNTotEvents/(fCycleStopTime-fCycleStartTime);
+       //printf("%d event have been monitored -> Monitoring Rate = %f Hz\n",fNTotEvents,fMonitorRate); 
+       Bool_t update = kFALSE;
+       if(!fTrendingUpdateEvent) {
+               update = kTRUE;
+       } else if ((TMath::Abs(fTrendingUpdateTime * fMonitorRate - fTrendingUpdateEvent) / fTrendingUpdateEvent) > 0.1){
+               update = kTRUE;
+       }
+       if(update) fTrendingUpdateEvent = fTrendingUpdateTime * fMonitorRate;
+       //printf("Update trending information every %d events\n",fTrendingUpdateEvent); 
+
+  }
+
+  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+    if (! IsValidEventSpecie(specie, list)) 
+      continue ;
+    SetEventSpecie(AliRecoParam::ConvertIndex(specie)) ; 
+    if(task == AliQAv1::kRAWS){
          int nMaxBin = GetRawsData(kPedestalTimeInt0)->GetNbinsY();
-         if(fCurrentCycle%nMaxBin==0) {
-               GetRawsData(kPedestalTimeInt0)->Reset();
-               GetRawsData(kPedestalTimeInt1)->Reset();
-               GetRawsData(kChargeEoITimeInt0)->Reset();
-               GetRawsData(kChargeEoITimeInt1)->Reset();
-         }
-         TH1D* hProj;
-         char name[50];
-         for(Int_t iChannel=0; iChannel<64; iChannel++) {
-               for(Int_t integrator=0;integrator<2;integrator++){
-                       sprintf(name,"Ped_%d_%d",iChannel,integrator);
-                       hProj = ((TH2I*)GetRawsData((integrator == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1)))->ProjectionY(name,iChannel+1,iChannel+1);
-                       ((TH2D*)GetRawsData((integrator == 0 ? kPedestalTimeInt0 : kPedestalTimeInt1)))->Fill((double)iChannel,(double)(fCurrentCycle%nMaxBin),(double)hProj->GetMean());
-                       delete hProj;
-
-                       sprintf(name,"Charge_%d_%d",iChannel,integrator);
-                       hProj = ((TH2I*)GetRawsData((integrator == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1)))->ProjectionY(name,iChannel+1,iChannel+1);
-                       ((TH2D*)GetRawsData((integrator == 0 ? kChargeEoITimeInt0 : kChargeEoITimeInt1)))->Fill((double)iChannel,(double)(fCurrentCycle%nMaxBin),hProj->GetMean());
-                       delete hProj;
-               }
-         }
-  } else if (task == AliQA::kESDS) {
+      if(fCurrentCycle%nMaxBin==0) {
+        GetRawsData(kPedestalTimeInt0)->Reset();
+        GetRawsData(kPedestalTimeInt1)->Reset();
+        GetRawsData(kChargeEoITimeInt0)->Reset();
+        GetRawsData(kChargeEoITimeInt1)->Reset();
+      }
+      TH1D* hProj;
+      char name[50];
+      for(Int_t iChannel=0; iChannel<64; iChannel++) {
+        for(Int_t integrator=0;integrator<2;integrator++){
+          sprintf(name,"Ped_%d_%d",iChannel,integrator);
+          hProj = ((TH2I*)GetRawsData((integrator == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1)))->ProjectionY(name,iChannel+1,iChannel+1);
+          ((TH2D*)GetRawsData((integrator == 0 ? kPedestalTimeInt0 : kPedestalTimeInt1)))->Fill((double)iChannel,(double)(fCurrentCycle%nMaxBin),(double)hProj->GetMean());
+          delete hProj;
+
+          sprintf(name,"Charge_%d_%d",iChannel,integrator);
+          hProj = ((TH2I*)GetRawsData((integrator == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1)))->ProjectionY(name,iChannel+1,iChannel+1);
+          ((TH2D*)GetRawsData((integrator == 0 ? kChargeEoITimeInt0 : kChargeEoITimeInt1)))->Fill((double)iChannel,(double)(fCurrentCycle%nMaxBin),hProj->GetMean());
+          delete hProj;
+        }
+      }
+    } else if (task == AliQAv1::kESDS) {
+    }
   }
-  
 }
 
 //____________________________________________________________________________ 
@@ -155,62 +184,48 @@ void AliVZEROQADataMakerRec::InitESDs()
 {
   // Creates histograms to control ESDs
   
-  Bool_t expert   = kTRUE ; 
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t image    = kTRUE ; 
        
   TH2D * h2d;
   TH1I * h1i;
   TH1D * h1d;
                
-  h1i = new TH1I("H1I_Cell_Multiplicity_V0A", "Cell Multiplicity in V0A", 35, 0, 35) ;  
-  Add2ESDsList(h1i, kCellMultiV0A, !expert)  ;  
-  h1i->GetXaxis()->SetTitle("Multiplicity (Nb of Cell)");
+  h1i = new TH1I("H1I_Cell_Multiplicity_V0A", "Cell Multiplicity in V0A;Multiplicity (Nb of Cell);Counts", 35, 0, 35) ;  
+  Add2ESDsList(h1i, kCellMultiV0A, !expert, image)  ;  
                                                                                                         
-  h1i = new TH1I("H1I_Cell_Multiplicity_V0C", "Cell Multiplicity in V0C", 35, 0, 35) ;  
-  Add2ESDsList(h1i, kCellMultiV0C, !expert)  ;  
-  h1i->GetXaxis()->SetTitle("Multiplicity (Nb of Cell)");
+  h1i = new TH1I("H1I_Cell_Multiplicity_V0C", "Cell Multiplicity in V0;Multiplicity (Nb of Cell);Counts", 35, 0, 35) ;  
+  Add2ESDsList(h1i, kCellMultiV0C, !expert, image)  ;  
    
-  h1d = new TH1D("H1D_MIP_Multiplicity_V0A", "MIP Multiplicity in V0A", 1000, 0, 1000) ;  
-  Add2ESDsList(h1d, kMIPMultiV0A, !expert)  ;  
-  h1d->GetXaxis()->SetTitle("Multiplicity (Nb of MIP)");
+  h1d = new TH1D("H1D_MIP_Multiplicity_V0A", "MIP Multiplicity in V0A;Multiplicity (Nb of MIP);Counts", 1000, 0, 1000) ;  
+  Add2ESDsList(h1d, kMIPMultiV0A, !expert, image)  ;  
   
-  h1d = new TH1D("H1D_MIP_Multiplicity_V0C", "MIP Multiplicity in V0C", 1000, 0, 1000) ;  
-  Add2ESDsList(h1d, kMIPMultiV0C, !expert)  ;  
-  h1d->GetXaxis()->SetTitle("Multiplicity (Nb of MIP)");
-
-  h2d = new TH2D("H2D_MIP_Multiplicity_Channel", "MIP Multiplicity per Channel",64, 0, 64, 100, 0, 100) ;  
-  h2d->GetXaxis()->SetTitle("Channel");
-  h2d->GetYaxis()->SetTitle("Multiplicity (Nb of MIP)");
-  Add2ESDsList(h2d, kMIPMultiChannel, !expert)  ;  
+  h1d = new TH1D("H1D_MIP_Multiplicity_V0C", "MIP Multiplicity in V0C;Multiplicity (Nb of MIP);Counts", 1000, 0, 1000) ;  
+  Add2ESDsList(h1d, kMIPMultiV0C, !expert, image)  ;  
+
+  h2d = new TH2D("H2D_MIP_Multiplicity_Channel", "MIP Multiplicity per Channel;Channel;Multiplicity (Nb of MIP)",64, 0, 64, 100, 0, 100) ;  
+  Add2ESDsList(h2d, kMIPMultiChannel, !expert, image)  ;  
   
-  h1d = new TH1D("H1D_BBFlag_Counters", "BB Flag Counters",64, 0, 64) ;  
-  h1d->GetXaxis()->SetTitle("Channel");
-  Add2ESDsList(h1d, kBBFlag, !expert)  ;  
+  h1d = new TH1D("H1D_BBFlag_Counters", "BB Flag Counters;Channel;Counts",64, 0, 64) ;  
+  Add2ESDsList(h1d, kBBFlag, !expert, image)  ;  
   
-  h1d = new TH1D("H1D_BGFlag_Counters", "BG Flag Counters",64, 0, 64) ;  
-  h1d->GetXaxis()->SetTitle("Channel");
-  Add2ESDsList(h1d, kBGFlag, !expert)  ;  
+  h1d = new TH1D("H1D_BGFlag_Counters", "BG Flag Counters;Channel;Counts",64, 0, 64) ;  
+  Add2ESDsList(h1d, kBGFlag, !expert, image)  ;  
   
-  h2d = new TH2D("H2D_Charge_Channel", "ADC Charge per channel",64, 0, 64, 1024, 0, 1024) ;  
-  h2d->GetXaxis()->SetTitle("Channel");
-  h2d->GetYaxis()->SetTitle("Charge (ADC counts)");
-  Add2ESDsList(h2d, kChargeChannel, !expert)  ;  
+  h2d = new TH2D("H2D_Charge_Channel", "ADC Charge per channel;Channel;Charge (ADC counts)",64, 0, 64, 1024, 0, 1024) ;  
+  Add2ESDsList(h2d, kChargeChannel, !expert, image)  ;  
   
-  h2d = new TH2D("H2D_Time_Channel", "Time per channel",64, 0, 64, 820, 0, 410) ;  
-  h2d->GetXaxis()->SetTitle("Channel");
-  h2d->GetYaxis()->SetTitle("Time (ns)");
-  Add2ESDsList(h2d, kTimeChannel, !expert)  ;  
+  h2d = new TH2D("H2D_Time_Channel", "Time per channel;Channel;Time (ns)",64, 0, 64, 820, 0, 410) ;  
+  Add2ESDsList(h2d, kTimeChannel, !expert, image)  ;  
   
-  h1d = new TH1D("H1D_V0A_Time", "Mean V0A Time",2048, 0., 409.6);
-  h1d->GetXaxis()->SetTitle("Time (ns)");
-  Add2ESDsList(h1d,kESDV0ATime, !expert); 
+  h1d = new TH1D("H1D_V0A_Time", "Mean V0A Time;Time (ns);Counts",2048, 0., 409.6);
+  Add2ESDsList(h1d,kESDV0ATime, !expert, image); 
   
-  h1d = new TH1D("H1D_V0C_Time", "Mean V0C Time",2048, 0., 409.6);
-  h1d->GetXaxis()->SetTitle("Time (ns)");
-  Add2ESDsList(h1d,kESDV0CTime, !expert); 
+  h1d = new TH1D("H1D_V0C_Time", "Mean V0C Time;Time (ns);Counts",2048, 0., 409.6);
+  Add2ESDsList(h1d,kESDV0CTime, !expert, image); 
   
-  h1d = new TH1D("H1D_Diff_Time", "Diff Time V0A - V0C",2*2048, -409.6, 409.6);
-  h1d->GetXaxis()->SetTitle("Diff Time V0A - V0C (ns)");
-  Add2ESDsList(h1d,kESDDiffTime, !expert); 
+  h1d = new TH1D("H1D_Diff_Time", "Diff Time V0A - V0C;Diff Time V0A - V0C (ns);Counts",2*2048, -409.6, 409.6);
+  Add2ESDsList(h1d,kESDDiffTime, !expert, image); 
        
 }
 
@@ -219,10 +234,9 @@ void AliVZEROQADataMakerRec::InitESDs()
  {
    // Creates RAW histograms in Raws subdir
    
-  fCalibData = GetCalibData();
-
-  Bool_t expert   = kTRUE ; 
-  Bool_t saveCorr = kTRUE ; 
+   const Bool_t expert   = kTRUE ; 
+   const Bool_t saveCorr = kTRUE ; 
+   const Bool_t image    = kTRUE ; 
 
   char name[50] , title[100];
   const Int_t kNintegrator  =    2;
@@ -252,92 +266,93 @@ void AliVZEROQADataMakerRec::InitESDs()
   TH2D * h2d;
   TH1I * h1i;
   TH1D * h1d;
+  AliVZEROTrending * trend;
 
   int iHisto =0;
  
    // Creation of Cell Multiplicity Histograms
-  h1i = new TH1I("H1I_Multiplicity_V0A", "Cell Multiplicity in V0A", 35, 0, 35) ;  
-  Add2RawsList(h1i,kMultiV0A, !expert, saveCorr);   iHisto++;
-  h1i = new TH1I("H1I_Multiplicity_V0C", "Cell Multiplicity in V0C", 35, 0, 35) ;  
-  Add2RawsList(h1i,kMultiV0C, !expert, saveCorr);   iHisto++;
+  h1i = new TH1I("H1I_Multiplicity_V0A", "Cell Multiplicity in V0A;# of Cells;Entries", 35, 0, 35) ;  
+  Add2RawsList(h1i,kMultiV0A, !expert, image, saveCorr);   iHisto++;
+  h1i = new TH1I("H1I_Multiplicity_V0C", "Cell Multiplicity in V0C;# of Cells;Entries", 35, 0, 35) ;  
+  Add2RawsList(h1i,kMultiV0C, !expert, image, saveCorr);   iHisto++;
  
   // Creation of Total Charge Histograms
-  h1d = new TH1D("H1D_Charge_V0A", "Total Charge in V0A", 2048, 0, 32768) ;  
-  Add2RawsList(h1d,kChargeV0A, !expert, saveCorr);   iHisto++;
-  h1d = new TH1D("H1D_Charge_V0C", "Total Charge in V0C", 2048, 0, 32768) ;  
-  Add2RawsList(h1d,kChargeV0C, !expert, saveCorr);   iHisto++;
-  h1d = new TH1D("H1D_Charge_V0", "Total Charge in V0", 2048, 0, 65536) ;  
-  Add2RawsList(h1d,kChargeV0, !expert, saveCorr);   iHisto++;
+  h1d = new TH1D("H1D_Charge_V0A", "Total Charge in V0A;Charge [ADC counts];Counts", 2048, 0, 32768) ;  
+  Add2RawsList(h1d,kChargeV0A, !expert, image, saveCorr);   iHisto++;
+  h1d = new TH1D("H1D_Charge_V0C", "Total Charge in V0C;Charge [ADC counts];Counts", 2048, 0, 32768) ;  
+  Add2RawsList(h1d,kChargeV0C, !expert, image, saveCorr);   iHisto++;
+  h1d = new TH1D("H1D_Charge_V0", "Total Charge in V0;Charge [ADC counts];Counts", 2048, 0, 65536) ;  
+  Add2RawsList(h1d,kChargeV0, !expert, image, saveCorr);   iHisto++;
   
   // Creation of MIP Histograms
-  h1d = new TH1D("H1D_MIP_V0A", "Total MIP in V0A", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
-  Add2RawsList(h1d,kRawMIPV0A, !expert, saveCorr);   iHisto++;
-  h1d = new TH1D("H1D_MIP_V0C", "Total MIP in V0C", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
-  Add2RawsList(h1d,kRawMIPV0C, !expert, saveCorr);   iHisto++;
-  h1d = new TH1D("H1D_MIP_V0", "Total MIP in V0", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
-  Add2RawsList(h1d,kRawMIPV0, !expert, saveCorr);   iHisto++;
-  h2d = new TH2D("H2D_MIP_Channel", "Nb of MIP per channel", kNChannelBins, kChannelMin, kChannelMax,kNMIPBins,kMIPMin ,kMIPMax) ;  
-  Add2RawsList(h2d,kRawMIPChannel, expert, !saveCorr);   iHisto++;
+  h1d = new TH1D("H1D_MIP_V0A", "Total MIP in V0A;Charge [MIP];Counts", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
+  Add2RawsList(h1d,kRawMIPV0A, !expert, image, saveCorr);   iHisto++;
+  h1d = new TH1D("H1D_MIP_V0C", "Total MIP in V0C;Charge [MIP];Counts", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
+  Add2RawsList(h1d,kRawMIPV0C, !expert, image, saveCorr);   iHisto++;
+  h1d = new TH1D("H1D_MIP_V0", "Total MIP in V0;Charge [MIP];Counts", 2*kNMIPBins,kMIPMin ,32*kMIPMax) ;  
+  Add2RawsList(h1d,kRawMIPV0, !expert, image, saveCorr);   iHisto++;
+  h2d = new TH2D("H2D_MIP_Channel", "Nb of MIP per channel;Channel;# of Mips", kNChannelBins, kChannelMin, kChannelMax,kNMIPBins,kMIPMin ,kMIPMax) ;  
+  Add2RawsList(h2d,kRawMIPChannel, expert, !image, !saveCorr);   iHisto++;
   
  
  for(Int_t iInt=0;iInt<kNintegrator;iInt++){
     // Creation of Pedestal histograms 
     sprintf(name,"H2I_Pedestal_Int%d",iInt);
-    sprintf(title,"Pedestal (Int%d)",iInt);
+    sprintf(title,"Pedestal (Int%d);Pedestal [ADC counts];Counts",iInt);
     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNPedestalBins,kPedestalMin ,kPedestalMax );
-    Add2RawsList(h2i,(iInt == 0 ? kPedestalInt0 : kPedestalInt1), expert, !saveCorr); iHisto++;
+    Add2RawsList(h2i,(iInt == 0 ? kPedestalInt0 : kPedestalInt1), expert, !image, !saveCorr); iHisto++;
        
     // Creation of temporary Pedestal histo used for the mean versus time histogram. This histogram will be reset at the end of each cycle
     sprintf(name,"H2I_Pedestal_CycleInt%d",iInt);
-    sprintf(title,"One Cycle Pedestal (Int%d)",iInt);
+    sprintf(title,"One Cycle Pedestal (Int%d);Pedestal [ADC counts];Counts",iInt);
     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNPedestalBins,kPedestalMin ,kPedestalMax );
-    Add2RawsList(h2i,(iInt == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1), expert, !saveCorr); iHisto++;
+    Add2RawsList(h2i,(iInt == 0 ? kPedestalCycleInt0 : kPedestalCycleInt1), expert, !image, !saveCorr); iHisto++;
                
     // Creation of Pedestal versus time graph.
     sprintf(name,"H2D_Pedestal_Time_Int%d",iInt);
-    sprintf(title,"Pedestal Versus Time (Int%d)",iInt);
+    sprintf(title,"Pedestal Versus Time (Int%d);Time [ns];Pedestal [ADC counts]",iInt);
     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,kTimeMax,kTimeMin ,kTimeMax );
-    Add2RawsList(h2d,(iInt == 0 ? kPedestalTimeInt0 : kPedestalTimeInt1), expert, !saveCorr); iHisto++;
+    Add2RawsList(h2d,(iInt == 0 ? kPedestalTimeInt0 : kPedestalTimeInt1), expert, !image, !saveCorr); iHisto++;
 
    // Creation of Charge EoI histograms 
     sprintf(name,"H2I_ChargeEoI_Int%d",iInt);
-    sprintf(title,"Charge EoI (Int%d)",iInt);
+    sprintf(title,"Charge EoI (Int%d);Charge [ADC counts];Counts",iInt);
     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
-    Add2RawsList(h2i,(iInt == 0 ? kChargeEoIInt0 : kChargeEoIInt1), !expert, !saveCorr); iHisto++;
+    Add2RawsList(h2i,(iInt == 0 ? kChargeEoIInt0 : kChargeEoIInt1), !expert, image, !saveCorr); iHisto++;
 
    // Creation of temporary Charge EoI histograms used for the mean versus time histogram. This histogram will be reset at the end of each cycle
     sprintf(name,"H2I_ChargeEoI_CycleInt%d",iInt);
-    sprintf(title,"One Cycle Charge EoI (Int%d)",iInt);
+    sprintf(title,"One Cycle Charge EoI (Int%d);Charge [ADC counts];Counts",iInt);
     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
-    Add2RawsList(h2i,(iInt == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1), expert, !saveCorr); iHisto++;
+    Add2RawsList(h2i,(iInt == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1), expert, !image, !saveCorr); iHisto++;
                
     // Creation of Charge EoI versus time graphs
     sprintf(name,"H2D_ChargeEoI_Time_Int%d",iInt);
-    sprintf(title,"Charge EoI Versus Time (Int%d)",iInt);
+    sprintf(title,"Charge EoI Versus Time (Int%d);Time [ns];Charge [ADC counts]",iInt);
     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,kTimeMax,kTimeMin ,kTimeMax );
-    Add2RawsList(h2d,(iInt == 0 ? kChargeEoITimeInt0 : kChargeEoITimeInt1), expert, !saveCorr); iHisto++;
+    Add2RawsList(h2d,(iInt == 0 ? kChargeEoITimeInt0 : kChargeEoITimeInt1), expert, !image, !saveCorr); iHisto++;
     
     sprintf(name,"H2I_ChargeEoI_BB_Int%d",iInt);
-    sprintf(title,"Charge EoI w/ BB Flag (Int%d)",iInt);
+    sprintf(title,"Charge EoI w/ BB Flag (Int%d);??;Charge [ADC counts]",iInt);
     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
-    Add2RawsList(h2i,(iInt == 0 ? kChargeEoIBBInt0 : kChargeEoIBBInt1), expert, !saveCorr); iHisto++;
+    Add2RawsList(h2i,(iInt == 0 ? kChargeEoIBBInt0 : kChargeEoIBBInt1), expert, !image, !saveCorr); iHisto++;
     
     sprintf(name,"H2I_ChargeEoI_BG_Int%d",iInt);
-    sprintf(title,"Charge EoI w/ BG Flag (Int%d)",iInt);
+    sprintf(title,"Charge EoI w/ BG Flag (Int%d);??;Charge [ADC counts]",iInt);
     h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNChargeBins, kChargeMin, kChargeMax);
-    Add2RawsList(h2i,(iInt == 0 ?  kChargeEoIBGInt0: kChargeEoIBGInt1), expert, !saveCorr); iHisto++;
+    Add2RawsList(h2i,(iInt == 0 ?  kChargeEoIBGInt0: kChargeEoIBGInt1), expert, !image, !saveCorr); iHisto++;
 
     // Creation of Charge versus LHC Clock histograms 
     sprintf(name,"H2D_ChargeVsClock_Int%d",iInt);
-    sprintf(title,"Charge Versus LHC-Clock (Int%d)",iInt);
+    sprintf(title,"Charge Versus LHC-Clock (Int%d);Tine [ns];Charge [ADC counts]",iInt);
     h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
-    Add2RawsList(h2d,(iInt == 0 ? kChargeVsClockInt0 : kChargeVsClockInt1 ), expert, !saveCorr); iHisto++;
+    Add2RawsList(h2d,(iInt == 0 ? kChargeVsClockInt0 : kChargeVsClockInt1 ), expert, !image, !saveCorr); iHisto++;
        
     // Creation of Minimum Bias Charge histograms 
     for(Int_t iBB=0;iBB<2;iBB++){
                for(Int_t iBG=0;iBG<2;iBG++){
                        sprintf(name,"H2I_ChargeMB_BB%d_BG%d_Int%d",iBB,iBG,iInt);
-                       sprintf(title,"MB Charge (BB=%d, BG=%d, Int=%d)",iBB,iBG,iInt);
+                       sprintf(title,"MB Charge (BB=%d, BG=%d, Int=%d);Charge [ADC counts];Counts",iBB,iBG,iInt);
                        h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax,kNChargeBins, kChargeMin, kChargeMax);
                        int idx;
                        if(iInt==0){
@@ -357,7 +372,7 @@ void AliVZEROQADataMakerRec::InitESDs()
                                        else idx = kChargeMBBB1BG1Int1;
                                }
                        }
-                       Add2RawsList(h2i,idx, expert, !saveCorr); iHisto++;
+                       Add2RawsList(h2i,idx, expert, !image, !saveCorr); iHisto++;
                }
     }
        
@@ -365,64 +380,144 @@ void AliVZEROQADataMakerRec::InitESDs()
  
      // Creation of Time histograms 
        sprintf(name,"H2I_Width");
-       sprintf(title,"HPTDC Width");
+       sprintf(title,"HPTDC Width;Width [ns];Counts");
        h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
-       Add2RawsList(h2i,kWidth, expert, !saveCorr); iHisto++;
+       Add2RawsList(h2i,kWidth, expert, !image, !saveCorr); iHisto++;
 
        sprintf(name,"H2I_Width_BB");
-       sprintf(title,"HPTDC Width w/ BB Flag condition");
+       sprintf(title,"HPTDC Width w/ BB Flag condition;??;Width [ns]");
        h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
-       Add2RawsList(h2i,kWidthBB, expert, !saveCorr); iHisto++;
+       Add2RawsList(h2i,kWidthBB, expert, !image, !saveCorr); iHisto++;
 
        sprintf(name,"H2I_Width_BG");
-       sprintf(title,"HPTDC Width w/ BG Flag condition");
+       sprintf(title,"HPTDC Width w/ BG Flag condition??;Width [ns]");
        h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcWidthBins, kTdcWidthMin, kTdcWidthMax);
-       Add2RawsList(h2i,kWidthBG, expert, !saveCorr); iHisto++;
+       Add2RawsList(h2i,kWidthBG, expert, !image, !saveCorr); iHisto++;
 
        sprintf(name,"H2I_HPTDCTime");
-       sprintf(title,"HPTDC Time");
+       sprintf(title,"HPTDC Time;??;Width [ns]");
        h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
-       Add2RawsList(h2i,kHPTDCTime, !expert, !saveCorr); iHisto++;
+       Add2RawsList(h2i,kHPTDCTime, !expert, image, !saveCorr); iHisto++;
 
        sprintf(name,"H2I_HPTDCTime_BB");
-       sprintf(title,"HPTDC Time w/ BB Flag condition");
+       sprintf(title,"HPTDC Time w/ BB Flag condition;??;Width [ns]");
        h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
-       Add2RawsList(h2i,kHPTDCTimeBB, expert, !saveCorr); iHisto++;
+       Add2RawsList(h2i,kHPTDCTimeBB, expert, !image, !saveCorr); iHisto++;
 
        sprintf(name,"H2I_HPTDCTime_BG");
-       sprintf(title,"HPTDC Time w/ BG Flag condition");
+       sprintf(title,"HPTDC Time w/ BG Flag condition;??;Width [ns]");
        h2i = new TH2I(name, title,kNChannelBins, kChannelMin, kChannelMax, kNTdcTimeBins, kTdcTimeMin, kTdcTimeMax);
-       Add2RawsList(h2i,kHPTDCTimeBG, expert, !saveCorr); iHisto++;
+       Add2RawsList(h2i,kHPTDCTimeBG, expert, !image, !saveCorr); iHisto++;
        
        sprintf(name,"H1D_V0A_Time");
-       sprintf(title,"V0A Time");
+       sprintf(title,"V0A Time;Time [ns];Counts");
        h1d = new TH1D(name, title,kNTdcTimeBins, kTdcTimeMin/10, kTdcTimeMax/10);
-       Add2RawsList(h1d,kV0ATime, !expert, saveCorr); iHisto++;
+       Add2RawsList(h1d,kV0ATime, !expert, !image, saveCorr); iHisto++;
        
        sprintf(name,"H1D_V0C_Time");
-       sprintf(title,"V0C Time");
+       sprintf(title,"V0C Time;Time [ns];Counts");
        h1d = new TH1D(name, title,kNTdcTimeBins, kTdcTimeMin/10, kTdcTimeMax/10);
-       Add2RawsList(h1d,kV0CTime, !expert, saveCorr); iHisto++;
+       Add2RawsList(h1d,kV0CTime, !expert, !image, saveCorr); iHisto++;
        
        sprintf(name,"H1D_Diff_Time");
-       sprintf(title,"Diff V0A-V0C Time");
+       sprintf(title,"Diff V0A-V0C Time;Time [ns];Counts");
        h1d = new TH1D(name, title,2*kNTdcTimeBins, -kTdcTimeMax/10, kTdcTimeMax/10);
-       Add2RawsList(h1d,kDiffTime, !expert, saveCorr); iHisto++;
+       Add2RawsList(h1d,kDiffTime, !expert, !image, saveCorr); iHisto++;
        
        // Creation of Flag versus LHC Clock histograms 
        sprintf(name,"H2D_BBFlagVsClock");
-       sprintf(title,"BB-Flags Versus LHC-Clock");
+       sprintf(title,"BB-Flags Versus LHC-Clock;Time [ns];??");
        h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
-       Add2RawsList(h2d,kBBFlagVsClock, expert, !saveCorr); iHisto++;
+       Add2RawsList(h2d,kBBFlagVsClock, expert, !image, !saveCorr); iHisto++;
        
        sprintf(name,"H2D_BGFlagVsClock");
-       sprintf(title,"BG-Flags Versus LHC-Clock");
+       sprintf(title,"BG-Flags Versus LHC-Clock;Time [ns];??");
        h2d = new TH2D(name, title,kNChannelBins, kChannelMin, kChannelMax,21, -10.5, 10.5 );
-       Add2RawsList(h2d,kBGFlagVsClock, expert, !saveCorr); iHisto++;
+       Add2RawsList(h2d,kBGFlagVsClock, expert, !image, !saveCorr); iHisto++;
+        
+       sprintf(name,"TREND_MeanChargePerRing");
+       sprintf(title,"Mean Charge per Event and per Ring versus time ");
+       trend = new AliVZEROTrending(name, title);
+       Add2RawsList(trend,kRawMeanChargePerRing, !expert, !image, !saveCorr); iHisto++;
+        
+       sprintf(name,"TREND_MeanFlagPerRing");
+       sprintf(title,"Mean Flag per Event and per Ring versus time ");
+       trend = new AliVZEROTrending(name, title);
+       Add2RawsList(trend,kRawMeanFlagPerRing, !expert, !image, !saveCorr); iHisto++;
         
-       AliInfo(Form("%d Histograms has been added to the Raws List",iHisto));
+       AliDebug(AliQAv1::GetQADebugLevel(), Form("%d Histograms has been added to the Raws List",iHisto));
  }
 
+//____________________________________________________________________________ 
+void AliVZEROQADataMakerRec::InitDigits()
+{
+  // create Digits histograms in Digits subdir
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t image    = kTRUE ; 
+  
+  char TDCname[100];
+  char ADCname[100];
+  TH1I *fhDigTDC[64]; 
+  TH1I *fhDigADC[64]; 
+  char texte[100];
+  
+  // create Digits histograms in Digits subdir
+  TH1I * h0 = new TH1I("hDigitMultiplicity", "Digits multiplicity distribution in VZERO;# of Digits;Entries", 100, 0, 99) ; 
+  h0->Sumw2() ;
+  Add2DigitsList(h0, 0, !expert, image) ;
+  
+  for (Int_t i=0; i<64; i++)
+    {
+    sprintf(TDCname, "hDigitTDC%d", i);
+    sprintf(texte,"Digit TDC in cell %d; TDC value;Entries",i);    
+    fhDigTDC[i] = new TH1I(TDCname,texte,300,0.,149.);
+    
+    sprintf(ADCname,"hDigitADC%d",i);
+    sprintf(texte,"Digit ADC in cell %d;ADC value;Entries",i);
+    fhDigADC[i]= new TH1I(ADCname,texte,1024,0.,1023.);
+    
+    Add2DigitsList(fhDigTDC[i],i+1, !expert, image);
+    Add2DigitsList(fhDigADC[i],i+1+64, !expert, image);  
+    }  
+}
+
+//____________________________________________________________________________
+void AliVZEROQADataMakerRec::MakeDigits()
+{
+  // makes data from Digits
+
+  GetDigitsData(0)->Fill(fDigitsArray->GetEntriesFast()) ; 
+  TIter next(fDigitsArray) ; 
+  AliVZEROdigit *VZERODigit ; 
+  while ( (VZERODigit = dynamic_cast<AliVZEROdigit *>(next())) ) {
+    Int_t   PMNumber  = VZERODigit->PMNumber();         
+    GetDigitsData(PMNumber +1)->Fill( VZERODigit->Time()) ;    // in 100 of picoseconds
+    GetDigitsData(PMNumber +1+64)->Fill( VZERODigit->ADC()) ;
+  }  
+}
+
+
+//____________________________________________________________________________
+void AliVZEROQADataMakerRec::MakeDigits(TTree *digitTree)
+{
+  // makes data from Digit Tree
+       
+  if ( fDigitsArray ) 
+    fDigitsArray->Clear() ; 
+  else 
+    fDigitsArray = new TClonesArray("AliVZEROdigit", 1000) ; 
+  
+  TBranch * branch = digitTree->GetBranch("VZERODigit") ;
+  if ( ! branch ) {
+    AliWarning("VZERO branch in Digit Tree not found") ; 
+  } else {
+    branch->SetAddress(&fDigitsArray) ;
+    branch->GetEntry(0) ; 
+    MakeDigits() ; 
+  }  
+}
+
+
 //____________________________________________________________________________
 void AliVZEROQADataMakerRec::MakeESDs(AliESDEvent * esd)
 {
@@ -484,10 +579,14 @@ void AliVZEROQADataMakerRec::MakeESDs(AliESDEvent * esd)
  {
   // Fills histograms with Raws, computes average ADC values dynamically (pedestal subtracted)
                   
-  rawReader->Reset() ; 
+   // Check id histograms already created for this Event Specie
+   if ( ! GetRawsData(kPedestalInt0) )
+     InitRaws() ;
+
+   rawReader->Reset() ; 
   AliVZERORawStream* rawStream  = new AliVZERORawStream(rawReader); 
-  rawStream->Next();
-  
+ if(!(rawStream->Next())) return;  
   eventTypeType eventType = rawReader->GetType();
 
   Int_t    mulV0A = 0 ; 
@@ -502,13 +601,21 @@ void AliVZEROQADataMakerRec::MakeESDs(AliESDEvent * esd)
   
   switch (eventType){
        case PHYSICS_EVENT:
+  
+               fNTotEvents++;
+
+               if(fNSubEvents++>=fTrendingUpdateEvent && fTrendingUpdateEvent>0) {
+                       fNSubEvents=0;
+                       AddTrendingEntry();
+               }
        Int_t  iFlag=0;
        Int_t  pedestal;
        Int_t  integrator;
        Bool_t BBFlag;   
        Bool_t BGFlag;   
        UInt_t time, width;
-       Int_t  MBCharge, charge;
+       Int_t  MBCharge;
+          Float_t charge;
        Int_t  offlineCh;
        TH1D * hProj;
 
@@ -537,7 +644,7 @@ void AliVZEROQADataMakerRec::MakeESDs(AliESDEvent * esd)
           // Look for the maximum in the LHC clock train
            charge = 0;
            Int_t iClock  = 0;
-           Int_t iCharge = 0;
+           Float_t iCharge = 0;
            for(Int_t iEvent=0; iEvent<21; iEvent++){
                iCharge = rawStream->GetPedestal(iChannel,iEvent);
                if(iCharge>charge)  {
@@ -564,8 +671,12 @@ void AliVZEROQADataMakerRec::MakeESDs(AliESDEvent * esd)
           // Calculation of the number of MIP
           Double_t mipEoI = chargeEoI * fCalibData->GetMIPperADC(offlineCh);
 
-                  
+          int side = offlineCh/32;
+          int ring = (offlineCh - 32*side) / 8;
+          if(BBFlag) fFlagPerRing[side*4 + ring] += 1;
+
           if(charge<1023 && chargeEoI > 5.*sigma){ 
+                  fChargePerRing[side*4 + ring] += chargeEoI;  
                   ((TH2I*)GetRawsData((integrator == 0 ? kChargeEoICycleInt0 : kChargeEoICycleInt1)))->Fill(offlineCh,chargeEoI);
                   ((TH2D*)GetRawsData(kRawMIPChannel))->Fill(offlineCh,mipEoI);
                   if(offlineCh<32) {
@@ -676,38 +787,38 @@ void AliVZEROQADataMakerRec::MakeESDs(AliESDEvent * esd)
        } // END of SWITCH : EVENT TYPE 
        
        fEvent++; 
-       TParameter<double> * p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kMultiV0A)->GetName()))) ; 
-       p->SetVal((double)mulV0A) ; 
+       TParameter<double> * p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kMultiV0A)->GetName()))) ; 
+       if (p) p->SetVal((double)mulV0A) ; 
 
-       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kMultiV0C)->GetName()))) ; 
-       p->SetVal((double)mulV0C) ;                     
+       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kMultiV0C)->GetName()))) ; 
+       if (p) p->SetVal((double)mulV0C) ;                     
 
-       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kChargeV0A)->GetName()))) ; 
-       p->SetVal((double)chargeV0A) ; 
+       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeV0A)->GetName()))) ; 
+       if (p) p->SetVal((double)chargeV0A) ; 
 
-       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kChargeV0C)->GetName()))) ; 
-       p->SetVal((double)chargeV0C) ;                     
+       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeV0C)->GetName()))) ; 
+       if (p) p->SetVal((double)chargeV0C) ;                     
 
-       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kChargeV0)->GetName()))) ; 
-       p->SetVal((double)(chargeV0A + chargeV0C)) ;                     
+       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kChargeV0)->GetName()))) ; 
+       if (p) p->SetVal((double)(chargeV0A + chargeV0C)) ;                     
        
-       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kRawMIPV0A)->GetName()))) ; 
-       p->SetVal((double)mipV0A) ; 
+       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kRawMIPV0A)->GetName()))) ; 
+       if (p) p->SetVal((double)mipV0A) ; 
        
-       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kRawMIPV0C)->GetName()))) ; 
-       p->SetVal((double)mipV0C) ;                     
+       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kRawMIPV0C)->GetName()))) ; 
+       if (p) p->SetVal((double)mipV0C) ;                     
        
-       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kRawMIPV0)->GetName()))) ; 
-       p->SetVal((double)(mipV0A + mipV0C)) ;                     
+       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kRawMIPV0)->GetName()))) ; 
+       if (p) p->SetVal((double)(mipV0A + mipV0C)) ;                     
        
-       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kV0ATime)->GetName()))) ; 
-       p->SetVal((double)timeV0A) ; 
+       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kV0ATime)->GetName()))) ; 
+       if (p) p->SetVal((double)timeV0A) ; 
        
-       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kV0CTime)->GetName()))) ; 
-       p->SetVal((double)timeV0C) ;                     
+       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kV0CTime)->GetName()))) ; 
+       if (p) p->SetVal((double)timeV0C) ;                     
        
-       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQA::GetTaskName(AliQA::kRAWS).Data(), GetRawsData(kDiffTime)->GetName()))) ; 
-       p->SetVal((double)diffTime) ;                     
+       p = dynamic_cast<TParameter<double>*>(GetParameterList()->FindObject(Form("%s_%s_%s", GetName(), AliQAv1::GetTaskName(AliQAv1::kRAWS).Data(), GetRawsData(kDiffTime)->GetName()))) ; 
+       if (p) p->SetVal((double)diffTime) ;                     
        
        delete rawStream; rawStream = 0x0;      
 
@@ -720,6 +831,8 @@ void AliVZEROQADataMakerRec::StartOfDetectorCycle()
   // Detector specific actions at start of cycle
   
   // Reset of the histogram used - to have the trend versus time -
+  fCalibData = GetCalibData();
   
   TH1* h;
   h = GetRawsData(kPedestalCycleInt0);
@@ -730,5 +843,34 @@ void AliVZEROQADataMakerRec::StartOfDetectorCycle()
   if(h) h->Reset();
   h = GetRawsData(kChargeEoICycleInt1);
   if(h) h->Reset();
+       
+  TTimeStamp currentTime;
+  fCycleStartTime = currentTime.GetSec();
+  fNTotEvents = 0;
+}
 
+//-------------------------------------------------------------------------------------------------
+void AliVZEROQADataMakerRec::AddTrendingEntry(){   
+     printf("AddTrendingEntry\n");
+       
+       // Normalize to the number of events
+       for(int i=0; i<8;i++){
+//             fChargePerRing[i] *= TMath::Power(10.,i)/fTrendingUpdateEvent;
+//             fFlagPerRing[i] *= TMath::Power(10.,i)/fTrendingUpdateEvent;
+               fChargePerRing[i] /= fTrendingUpdateEvent;
+               fFlagPerRing[i] /= fTrendingUpdateEvent;
+       }
+       
+       TTimeStamp currentTime;
+       ((AliVZEROTrending*)GetRawsData(kRawMeanChargePerRing))->AddEntry(fChargePerRing,  currentTime.GetSec());
+       ((AliVZEROTrending*)GetRawsData(kRawMeanFlagPerRing))->AddEntry(fFlagPerRing,  currentTime.GetSec());
+       //moMeanFlagPerRing->AddEntry(fFlagPerRing,  currentTime.GetSec());
+       
+       // Put back counters to zero
+       for(int i=0; i<8;i++){
+               fChargePerRing[i] = 0.;
+               fFlagPerRing[i] = 0.;
+       }
+       
 }