]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/AliZDCQADataMakerRec.cxx
fix TRD digits display
[u/mrichter/AliRoot.git] / ZDC / AliZDCQADataMakerRec.cxx
index b44dd2f9d4f2fcffa57fe3081d2978db2ce45544..39ed625cf4d260c13edbb3dcc74ca2c7b47c4ded 100644 (file)
@@ -26,6 +26,7 @@
 #include <TFile.h> 
 #include <TH1F.h> 
 #include <TH2F.h>
+#include <TLine.h>
 #include <TProfile.h>
 #include <Riostream.h>
 // --- Standard library ---
 // --- AliRoot header files ---
 #include "AliLog.h"
 #include "AliQAChecker.h"
+#include "AliZDCReco.h"
 #include "AliRawReader.h"
 #include "AliZDCQADataMakerRec.h"
+#include "AliZDCPedestals.h"
 #include "AliZDCRawStream.h"
 #include "AliZDCDigit.h"
 #include "AliESDZDC.h"
@@ -44,14 +47,17 @@ ClassImp(AliZDCQADataMakerRec)
            
 //____________________________________________________________________________ 
   AliZDCQADataMakerRec::AliZDCQADataMakerRec() : 
-  AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kZDC), "ZDC Quality Assurance Data Maker")
+  AliQADataMakerRec(AliQAv1::GetDetName(AliQAv1::kZDC), "ZDC Quality Assurance Data Maker"), 
+  fPedCalibData(0x0)
 {
   // ctor
 }
 
 //____________________________________________________________________________ 
 AliZDCQADataMakerRec::AliZDCQADataMakerRec(const AliZDCQADataMakerRec& qadm) :
-  AliQADataMakerRec() 
+  AliQADataMakerRec(),      
+  fPedCalibData(qadm.fPedCalibData)
+
 {
   //copy ctor 
   SetName((const char*)qadm.GetName()); 
@@ -67,67 +73,28 @@ AliZDCQADataMakerRec& AliZDCQADataMakerRec::operator = (const AliZDCQADataMakerR
   return *this;
 }
 
-//____________________________________________________________________________
+//____________________________________________________________________________ 
+AliZDCQADataMakerRec::~AliZDCQADataMakerRec()
+{
+  if(fPedCalibData && !(AliCDBManager::Instance()->GetCacheFlag())){
+    delete fPedCalibData;
+    fPedCalibData=0;
+  } 
+}
 
-void AliZDCQADataMakerRec::InitRaws()
+//____________________________________________________________________________ 
+AliZDCPedestals* AliZDCQADataMakerRec::GetPedCalibData() const
 {
-  // create Digits histograms in Digits subdir
-  //
-  // ------------------- HIGH GAIN CHAIN ---------------------------
-  TH1F * hRawZNCTot = new TH1F("hRawZNCTot", "Raw signal in ZNC;Amplitude [ADC counts];Counts", 100, 0., 6000.);
-  TH1F * hRawZNATot = new TH1F("hRawZNATot", "Raw signal in ZNA;Amplitude [ADC counts];Counts", 100, 0., 6000.);
-  TH1F * hRawZPCTot = new TH1F("hRawZPCTot", "Raw signal in ZPC;Amplitude [ADC counts];Counts", 100, 0., 10000.);
-  TH1F * hRawZPATot = new TH1F("hRawZPATot", "Raw signal in ZPA;Amplitude [ADC counts];Counts", 100, 0., 10000.);
-  Add2RawsList(hRawZNCTot, 0);
-  Add2RawsList(hRawZNATot, 1);
-  Add2RawsList(hRawZPCTot, 2);
-  Add2RawsList(hRawZPATot, 3);
-  //
-  TH1F * hRawSumQZNC = new TH1F("hRawSumQZNC", "Raw summed 4 ZNC quadrants;Amplitude [ADC counts];Counts",100, 0., 4000.);
-  TH1F * hRawSumQZNA = new TH1F("hRawSumQZNA", "Raw summed 4 ZNA quadrants;Amplitude [ADC counts];Counts",100, 0., 4000.);
-  TH1F * hRawSumQZPC = new TH1F("hRawSumQZPC", "Raw summed 4 ZPC quadrants;Amplitude [ADC counts];Counts",100, 0., 4000.);
-  TH1F * hRawSumQZPA = new TH1F("hRawSumQZPA", "Raw summed 4 ZPA quadrants;Amplitude [ADC counts];Counts",100, 0., 4000.);
-  Add2RawsList(hRawSumQZNC, 4, kTRUE);
-  Add2RawsList(hRawSumQZNA, 5, kTRUE);
-  Add2RawsList(hRawSumQZPC, 6, kTRUE);
-  Add2RawsList(hRawSumQZPA, 7, kTRUE);
-  //
-  TH1F * hRawPMCZNC = new TH1F("hRawPMCZNC", "Raw common ZNC PMT;Amplitude [ADC counts];Counts",100, 0., 4000.);
-  TH1F * hRawPMCZNA = new TH1F("hRawPMCZNA", "Raw common ZNA PMT;Amplitude [ADC counts];Counts",100, 0., 4000.);
-  TH1F * hRawPMCZPC = new TH1F("hRawPMCZPC", "Raw common ZPC PMT;Amplitude [ADC counts];Counts",100, 0., 4000.);
-  TH1F * hRawPMCZPA = new TH1F("hRawPMCZPA", "Raw common ZPA PMT;Amplitude [ADC counts];Counts",100, 0., 4000.);
-  Add2RawsList(hRawPMCZNC, 8 , kTRUE);
-  Add2RawsList(hRawPMCZNA, 9 , kTRUE);
-  Add2RawsList(hRawPMCZPC, 10, kTRUE);
-  Add2RawsList(hRawPMCZPA, 11, kTRUE);
-  // 
-/*  // ------------------- LOW GAIN CHAIN ---------------------------
-  TH1F * hRawZNCTotlg = new TH1F("hRawZNCTotlg", "Rawit lg signal in ZNC", 100, 0., 6000.);
-  TH1F * hRawZNATotlg = new TH1F("hRawZNATotlg", "Rawit lg signal in ZNA", 100, 0., 6000.);
-  TH1F * hRawZPCTotlg = new TH1F("hRawZPCTotlg", "Rawit lg signal in ZPC", 100, 0., 10000.);
-  TH1F * hRawZPATotlg = new TH1F("hRawZPATotlg", "Rawit lg signal in ZPA", 100, 0., 10000.);
-  Add2RawsList(hRawZNCTotlg, 12);
-  Add2RawsList(hRawZNATotlg, 13);
-  Add2RawsList(hRawZPCTotlg, 14);
-  Add2RawsList(hRawZPATotlg, 15);
-  //
-  TH1F * hRawSumQZNClg = new TH1F("hRawSumQZNClg", "Raw summed 4 lg ZNC quadrants",100, 0., 4000.);
-  TH1F * hRawSumQZNAlg = new TH1F("hRawSumQZNAlg", "Raw summed 4 lg ZNA quadrants",100, 0., 4000.);
-  TH1F * hRawSumQZPClg = new TH1F("hRawSumQZPClg", "Raw summed 4 lg ZPC quadrants",100, 0., 4000.);
-  TH1F * hRawSumQZPAlg = new TH1F("hRawSumQZPAlg", "Raw summed 4 lg ZPA quadrants",100, 0., 4000.);
-  Add2RawsList(hRawSumQZNClg, 16, kTRUE);
-  Add2RawsList(hRawSumQZNAlg, 17, kTRUE);
-  Add2RawsList(hRawSumQZPClg, 18, kTRUE);
-  Add2RawsList(hRawSumQZPAlg, 19, kTRUE);
-  //
-  TH1F * hRawPMCZNClg = new TH1F("hRawPMCZNClg", "Raw common lg ZNC PMT",100, 0., 4000.);
-  TH1F * hRawPMCZNAlg = new TH1F("hRawPMCZNAlg", "Raw common lg ZNA PMT",100, 0., 4000.);
-  TH1F * hRawPMCZPClg = new TH1F("hRawPMCZPClg", "Raw common lg ZPC PMT",100, 0., 4000.);
-  TH1F * hRawPMCZPAlg = new TH1F("hRawPMCZPAlg", "Raw common lg ZPA PMT",100, 0., 4000.);
-  Add2RawsList(hRawPMCZNClg, 20, kTRUE);
-  Add2RawsList(hRawPMCZNAlg, 21, kTRUE);
-  Add2RawsList(hRawPMCZPClg, 22, kTRUE);
-  Add2RawsList(hRawPMCZPAlg, 23, kTRUE);*/
+
+  // Retrieving pedestal calibration object from OCDB
+  AliCDBEntry  *entry = AliCDBManager::Instance()->Get("ZDC/Calib/Pedestals");
+  if(!entry) AliWarning("No calibration data loaded!");  
+
+  AliZDCPedestals *calibdata = (AliZDCPedestals*)  (entry->GetObject());
+  if(!calibdata) AliFatal("Wrong calibration object in calibration  file!");
+
+  return calibdata;
+
 }
 
 //____________________________________________________________________________ 
@@ -167,14 +134,14 @@ void AliZDCQADataMakerRec::InitDigits()
   Add2DigitsList(hDigPMCZPA, 11, expert, !image);
   // 
   // ------------------- LOW GAIN CHAIN ---------------------------
-  /*  TH1F * hDigZNCTotlg = new TH1F("hDigZNCTotlg", "Digit lg signal in ZNC", 100, 0., 6000.);
+  TH1F * hDigZNCTotlg = new TH1F("hDigZNCTotlg", "Digit lg signal in ZNC", 100, 0., 6000.);
   TH1F * hDigZNATotlg = new TH1F("hDigZNATotlg", "Digit lg signal in ZNA", 100, 0., 6000.);
   TH1F * hDigZPCTotlg = new TH1F("hDigZPCTotlg", "Digit lg signal in ZPC", 100, 0., 6000.);
   TH1F * hDigZPATotlg = new TH1F("hDigZPATotlg", "Digit lg signal in ZPA", 100, 0., 6000.);
-  Add2DigitsList(hDigZNCTotlg, 12, !expert, image);
-  Add2DigitsList(hDigZNATotlg, 13, !expert, image);
-  Add2DigitsList(hDigZPCTotlg, 14, !expert, image);
-  Add2DigitsList(hDigZPATotlg, 15, !expert, image);
+  Add2DigitsList(hDigZNCTotlg, 12, expert, !image);
+  Add2DigitsList(hDigZNATotlg, 13, expert, !image);
+  Add2DigitsList(hDigZPCTotlg, 14, expert, !image);
+  Add2DigitsList(hDigZPATotlg, 15, expert, !image);
   //
   TH1F * hDigSumQZNClg = new TH1F("hDigSumQZNClg", "Signal in 4 ZNC PMQlg",100, 0., 4000.);
   TH1F * hDigSumQZNAlg = new TH1F("hDigSumQZNAlg", "Signal in 4 ZNA PMQlg",100, 0., 4000.);
@@ -193,7 +160,96 @@ void AliZDCQADataMakerRec::InitDigits()
   Add2DigitsList(hDigPMCZNAlg, 21, expert, !image);
   Add2DigitsList(hDigPMCZPClg, 22, expert, !image);
   Add2DigitsList(hDigPMCZPAlg, 23, expert, !image);
-  */
+
+}
+
+//____________________________________________________________________________
+void AliZDCQADataMakerRec::InitRaws()
+{
+  // create Digits histograms in Digits subdir
+  const Bool_t expert   = kTRUE ; 
+  const Bool_t image    = kTRUE ; 
+
+  TH1F * hZNCSpectrum = new TH1F("hZNCSpectrum","ZNC spectrum;Amplitude [ADC counts];Counts",100,0.,1200.);
+  TH1F * hZPCSpectrum = new TH1F("hZPCSpectrum","ZPC spectrum;Amplitude [ADC counts];Counts",100,0.,1200.);
+  TH1F * hZNASpectrum = new TH1F("hZNASpectrum","ZNA spectrum;Amplitude [ADC counts];Counts",100,0.,1200.);
+  TH1F * hZPASpectrum = new TH1F("hZPASpectrum","ZPA spectrum;Amplitude [ADC counts];Counts",100,0.,1200.);
+  TH1F * hZEM1Spectrum = new TH1F("hZEM1Spectrum","ZEM1 spectrum;Amplitude [ADC counts];Counts",100,0.,1200.);
+  TH1F * hZEM2Spectrum = new TH1F("hZEM2Spectrum","ZEM2 spectrum;Amplitude [ADC counts];Counts",100,0.,1200.);
+  Add2RawsList(hZNCSpectrum, 0, expert, !image);
+  Add2RawsList(hZNASpectrum, 1, expert, !image);
+  Add2RawsList(hZPCSpectrum, 2, expert, !image);
+  Add2RawsList(hZPASpectrum, 3, expert, !image);
+  Add2RawsList(hZEM1Spectrum, 4, !expert, image);
+  Add2RawsList(hZEM2Spectrum, 5, !expert, image);
+  //
+  TH2F * hZNCpmCvsPMq = new TH2F("hZNCpmCvsPMq", "ZNC;PMC [ADC counts];Sum(PMQ) [ADC counts]",50,7.,1207.,50,7., 1207.);
+  TH2F * hZPCpmCvsPMq = new TH2F("hZPCpmCvsPMq", "ZPC;PMC [ADC counts];Sum(PMQ) [ADC counts]",50,7.,1207.,50,7., 1207.);
+  TH2F * hZNApmCvsPMq = new TH2F("hZNApmCvsPMq", "ZNA;PMC [ADC counts];Sum(PMQ) [ADC counts]",50,7.,1207.,50,7., 1207.);
+  TH2F * hZPApmCvsPMq = new TH2F("hZPApmCvsPMq", "ZPA;PMC [ADC counts];Sum(PMQ) [ADC counts]",50,7.,1207.,50,7., 1207.);
+  Add2RawsList(hZNCpmCvsPMq, 6, !expert, image);
+  Add2RawsList(hZNApmCvsPMq, 7, !expert, image);
+  Add2RawsList(hZPCpmCvsPMq, 8, !expert, image);
+  Add2RawsList(hZPApmCvsPMq, 9, !expert, image);
+    
+  TH1F * hRawPMCZNC = new TH1F("hRawPMCZNC", "Raw ZNC PMC;Amplitude [ADC counts];Counts",100, 0., 1200.);
+  TH1F * hRawPMCZNA = new TH1F("hRawPMCZNA", "Raw ZNA PMC;Amplitude [ADC counts];Counts",100, 0., 1200.);
+  TH1F * hRawPMCZPC = new TH1F("hRawPMCZPC", "Raw ZPC PMC;Amplitude [ADC counts];Counts",100, 0., 1200.);
+  TH1F * hRawPMCZPA = new TH1F("hRawPMCZPA", "Raw ZPA PMC;Amplitude [ADC counts];Counts",100, 0., 1200.);
+  Add2RawsList(hRawPMCZNC, 10, !expert, image);
+  Add2RawsList(hRawPMCZNA, 11, !expert, image);
+  Add2RawsList(hRawPMCZPC, 12, !expert, image);
+  Add2RawsList(hRawPMCZPA, 13, !expert, image);
+  TH1F * hRawSumQZNC = new TH1F("hRawSumQZNC", "Raw sumQ ZNC;Amplitude [ADC counts];Counts",100, 0., 1200.);
+  TH1F * hRawSumQZNA = new TH1F("hRawSumQZNA", "Raw sumQ ZNA;Amplitude [ADC counts];Counts",100, 0., 1200.);
+  TH1F * hRawSumQZPC = new TH1F("hRawSumQZPC", "Raw sumQ ZPC;Amplitude [ADC counts];Counts",100, 0., 1200.);
+  TH1F * hRawSumQZPA = new TH1F("hRawSumQZPA", "Raw sumQ ZPA;Amplitude [ADC counts];Counts",100, 0., 1200.);
+  Add2RawsList(hRawSumQZNC, 14, expert, !image);
+  Add2RawsList(hRawSumQZNA, 15, expert, !image);
+  Add2RawsList(hRawSumQZPC, 16, expert, !image);
+  Add2RawsList(hRawSumQZPA, 17, expert, !image);
+  
+  TH1F * hRawTDCZEM1 = new TH1F("hRawTDCZEM1", "Raw TDC ZEM1;TDC [ns]",200, -100., -50.);
+  Add2RawsList(hRawTDCZEM1, 18, !expert, image);
+  TH1F * hRawTDCZPC = new TH1F("hRawTDCZPC", "Raw TDC ZPC;TDC [ns]",200, -100., -50.);
+  Add2RawsList(hRawTDCZPC, 19, !expert, image);
+
+}
+
+//____________________________________________________________________________
+void AliZDCQADataMakerRec::InitRecPoints()
+{
+  // create Digits histograms in Digits subdir
+  const Bool_t expert = kTRUE ; 
+  const Bool_t image  = kTRUE ; 
+  //
+  // ------------------- HIGH GAIN CHAIN ---------------------------
+  TH1F * hRecZNCTot = new TH1F("hRecZNCTot", "Rec signal in ZNC;Amplitude [ADC counts];Counts", 100, 0., 2000.);
+  TH1F * hRecZNATot = new TH1F("hRecZNATot", "Rec signal in ZNA;Amplitude [ADC counts];Counts", 100, 0., 2000.);
+  TH1F * hRecZPCTot = new TH1F("hRecZPCTot", "Rec signal in ZPC;Amplitude [ADC counts];Counts", 100, 0., 8000.);
+  TH1F * hRecZPATot = new TH1F("hRecZPATot", "Rec signal in ZPA;Amplitude [ADC counts];Counts", 100, 0., 8000.);
+  Add2RecPointsList(hRecZNCTot, 0, !expert, image);
+  Add2RecPointsList(hRecZNATot, 1, !expert, image);
+  Add2RecPointsList(hRecZPCTot, 2, !expert, image);
+  Add2RecPointsList(hRecZPATot, 3, !expert, image);
+  //
+  TH1F * hRecSumQZNC = new TH1F("hRecSumQZNC", "Rec summed 4 ZNC quadrants;Amplitude [ADC counts];Counts",100, 0., 2000.);
+  TH1F * hRecSumQZNA = new TH1F("hRecSumQZNA", "Rec summed 4 ZNA quadrants;Amplitude [ADC counts];Counts",100, 0., 2000.);
+  TH1F * hRecSumQZPC = new TH1F("hRecSumQZPC", "Rec summed 4 ZPC quadrants;Amplitude [ADC counts];Counts",100, 0., 2000.);
+  TH1F * hRecSumQZPA = new TH1F("hRecSumQZPA", "Rec summed 4 ZPA quadrants;Amplitude [ADC counts];Counts",100, 0., 2000.);
+  Add2RecPointsList(hRecSumQZNC, 4, expert, !image);
+  Add2RecPointsList(hRecSumQZNA, 5, expert, !image);
+  Add2RecPointsList(hRecSumQZPC, 6, expert, !image);
+  Add2RecPointsList(hRecSumQZPA, 7, expert, !image);
+  //
+  TH1F * hRecPMCZNC = new TH1F("hRecPMCZNC", "Rec common ZNC PMT;Amplitude [ADC counts];Counts",100, 0., 2000.);
+  TH1F * hRecPMCZNA = new TH1F("hRecPMCZNA", "Rec common ZNA PMT;Amplitude [ADC counts];Counts",100, 0., 2000.);
+  TH1F * hRecPMCZPC = new TH1F("hRecPMCZPC", "Rec common ZPC PMT;Amplitude [ADC counts];Counts",100, 0., 2000.);
+  TH1F * hRecPMCZPA = new TH1F("hRecPMCZPA", "Rec common ZPA PMT;Amplitude [ADC counts];Counts",100, 0., 2000.);
+  Add2RecPointsList(hRecPMCZNC, 8 , expert, !image);
+  Add2RecPointsList(hRecPMCZNA, 9 , expert, !image);
+  Add2RecPointsList(hRecPMCZPC, 10, expert, !image);
+  Add2RecPointsList(hRecPMCZPA, 11, expert, !image); 
 }
 
 //____________________________________________________________________________
@@ -201,241 +257,148 @@ void AliZDCQADataMakerRec::InitESDs()
 {
   //Booking ESDs histograms
   //
-  const Bool_t expert   = kTRUE ; 
-  const Bool_t image    = kTRUE ; 
+  const Bool_t expert = kTRUE ; 
+  const Bool_t image  = kTRUE ; 
   
-  TH2F * hZNC  = new TH2F("hZNC", "Centroid in ZNC", 100, -5.,5.,100,-5.,5.);
-  TH2F * hZNA  = new TH2F("hZNA", "Centroid in ZNA", 100, -5.,5.,100,-5.,5.);
-  Add2ESDsList(hZNC, 0, !expert, image);
-  Add2ESDsList(hZNA, 1, !expert, image);
+  TH2F * hZNCcentr  = new TH2F("hZNCcentr", "Centroid in ZNC;X [cm];Y[cm]", 100, -5.,5.,100,-5.,5.);
+  TH2F * hZNAcentr  = new TH2F("hZNAcentr", "Centroid in ZNA;X [cm];Y[cm]", 100, -5.,5.,100,-5.,5.);
+  Add2ESDsList(hZNCcentr, 0, !expert, image);
+  Add2ESDsList(hZNAcentr, 1, !expert, image);
   //
   // ------------------- HIGH GAIN CHAIN ---------------------------
-  TH1F * hESDZNCTot = new TH1F("hESDZNCTot", "Energy in ZNC", 100, 0., 6000.);
-  TH1F * hESDZNATot = new TH1F("hESDZNATot", "Energy in ZNA", 100, 0., 6000.);
-  TH1F * hESDZPCTot = new TH1F("hESDZPCTot", "Energy in ZPC", 100, 0., 10000.);
-  TH1F * hESDZPATot = new TH1F("hESDZPATot", "Energy in ZPA", 100, 0., 10000.);
+  TH1F * hESDZNCTot = new TH1F("hESDZNCTot", "Energy in ZNC", 100, 0., 4000.);
+  TH1F * hESDZNATot = new TH1F("hESDZNATot", "Energy in ZNA", 100, 0., 4000.);
+  TH1F * hESDZPCTot = new TH1F("hESDZPCTot", "Energy in ZPC", 100, 0., 4000.);
+  TH1F * hESDZPATot = new TH1F("hESDZPATot", "Energy in ZPA", 100, 0., 4000.);
   Add2ESDsList(hESDZNCTot, 2, !expert, image);
   Add2ESDsList(hESDZNATot, 3, !expert, image);
   Add2ESDsList(hESDZPCTot, 4, !expert, image);
   Add2ESDsList(hESDZPATot, 5, !expert, image);
   //
-  TH1F * hESDSumQZNC = new TH1F("hESDSumQZNC", "Sum of 4 ZNC energy",100, 0., 4000.);
-  TH1F * hESDSumQZNA = new TH1F("hESDSumQZNA", "Sum of 4 ZNA energy",100, 0., 4000.);
-  TH1F * hESDSumQZPC = new TH1F("hESDSumQZPC", "Sum of 4 ZPC energy",100, 0., 4000.);
-  TH1F * hESDSumQZPA = new TH1F("hESDSumQZPA", "Sum of 4 ZPA energy",100, 0., 4000.);
-  Add2ESDsList(hESDSumQZNC, 6, expert, !image);
-  Add2ESDsList(hESDSumQZNA, 7, expert, !image);
-  Add2ESDsList(hESDSumQZPC, 8, expert, !image);
-  Add2ESDsList(hESDSumQZPA, 9, expert, !image);
-  //
-  TH1F * hESDPMCZNC = new TH1F("hESDPMCZNC", "Energy in common ZNC PMT",100, 0., 4000.);
-  TH1F * hESDPMCZNA = new TH1F("hESDPMCZNA", "Energy in common ZNA PMT",100, 0., 4000.);
-  TH1F * hESDPMCZPC = new TH1F("hESDPMCZPC", "Energy in common ZPC PMT",100, 0., 4000.);
-  TH1F * hESDPMCZPA = new TH1F("hESDPMCZPA", "Energy in common ZPA PMT",100, 0., 4000.);
-  Add2ESDsList(hESDPMCZNC, 10, expert, !image);
-  Add2ESDsList(hESDPMCZNA, 11, expert, !image);
-  Add2ESDsList(hESDPMCZPC, 12, expert, !image);
-  Add2ESDsList(hESDPMCZPA, 13, expert, !image);
+  TH1F * hESDZEM1 = new TH1F("hESDZEM1", "Energy in ZEM1", 100, 0., 2000.);
+  TH1F * hESDZEM2 = new TH1F("hESDZEM2", "Energy in ZEM2", 100, 0., 2000.);
+  Add2ESDsList(hESDZEM1,6, !expert, image);
+  Add2ESDsList(hESDZEM2,7, !expert, image);
+  //
+  TH1F * hESDSumQZNC = new TH1F("hESDSumQZNC", "Sum of 4 ZNC energy",100, 0., 2000.);
+  TH1F * hESDSumQZNA = new TH1F("hESDSumQZNA", "Sum of 4 ZNA energy",100, 0., 2000.);
+  TH1F * hESDSumQZPC = new TH1F("hESDSumQZPC", "Sum of 4 ZPC energy",100, 0., 2000.);
+  TH1F * hESDSumQZPA = new TH1F("hESDSumQZPA", "Sum of 4 ZPA energy",100, 0., 2000.);
+  Add2ESDsList(hESDSumQZNC, 8, expert, !image);
+  Add2ESDsList(hESDSumQZNA, 9, expert, !image);
+  Add2ESDsList(hESDSumQZPC, 10, expert, !image);
+  Add2ESDsList(hESDSumQZPA, 11, expert, !image);
+  //
+  TH1F * hESDPMCZNC = new TH1F("hESDPMCZNC", "Energy in ZNC PMC",100, 0., 2000.);
+  TH1F * hESDPMCZNA = new TH1F("hESDPMCZNA", "Energy in ZNA PMC",100, 0., 2000.);
+  TH1F * hESDPMCZPC = new TH1F("hESDPMCZPC", "Energy in ZPC PMC",100, 0., 2000.);
+  TH1F * hESDPMCZPA = new TH1F("hESDPMCZPA", "Energy in ZPA PMC",100, 0., 2000.);
+  Add2ESDsList(hESDPMCZNC, 12, expert, !image);
+  Add2ESDsList(hESDPMCZNA, 13, expert, !image);
+  Add2ESDsList(hESDPMCZPC, 14, expert, !image);
+  Add2ESDsList(hESDPMCZPA, 15, expert, !image);
   // 
-/*  // ------------------- LOW GAIN CHAIN ---------------------------
-  TH1F * hESDZNCTotlg = new TH1F("hESDZNCTotlg", "ESD lg signal in ZNC", 100, 0., 6000.);
-  TH1F * hESDZNATotlg = new TH1F("hESDZNATotlg", "ESD lg signal in ZNA", 100, 0., 6000.);
-  TH1F * hESDZPCTotlg = new TH1F("hESDZPCTotlg", "ESD lg signal in ZPC", 100, 0., 10000.);
-  TH1F * hESDZPATotlg = new TH1F("hESDZPATotlg", "ESD lg signal in ZPA", 100, 0., 10000.);
-  Add2ESDsList(hESDZNCTotlg, !expert, image);
-  Add2ESDsList(hESDZNATotlg, !expert, image);
-  Add2ESDsList(hESDZPCTotlg, !expert, image);
-  Add2ESDsList(hESDZPATotlg, !expert, image);
-  //
+  // ------------------- LOW GAIN CHAIN ---------------------------
   TH1F * hESDSumQZNClg = new TH1F("hESDSumQZNClg", "Sum of 4 lg ZNC sectors",100, 0., 4000.);
   TH1F * hESDSumQZNAlg = new TH1F("hESDSumQZNAlg", "Sum of 4 lg ZNA sectors",100, 0., 4000.);
   TH1F * hESDSumQZPClg = new TH1F("hESDSumQZPClg", "Sum of 4 lg ZPC sectors",100, 0., 4000.);
   TH1F * hESDSumQZPAlg = new TH1F("hESDSumQZPAlg", "Sum of 4 lg ZPA sectors",100, 0., 4000.);
-  Add2ESDsList(hESDSumQZNClg, 18, expert, !image);
-  Add2ESDsList(hESDSumQZNAlg, 19, expert, !image);
-  Add2ESDsList(hESDSumQZPClg, 20, expert, !image);
-  Add2ESDsList(hESDSumQZPAlg, 21, expert, !image);
+  Add2ESDsList(hESDSumQZNClg, 16, expert, !image);
+  Add2ESDsList(hESDSumQZNAlg, 17, expert, !image);
+  Add2ESDsList(hESDSumQZPClg, 18, expert, !image);
+  Add2ESDsList(hESDSumQZPAlg, 19, expert, !image);
   //
   TH1F * hESDPMCZNClg = new TH1F("hESDPMCZNClg", "Signal in common ZNC lg PMT",100, 0., 4000.);
   TH1F * hESDPMCZNAlg = new TH1F("hESDPMCZNAlg", "Signal in common ZNA lg PMT",100, 0., 4000.);
   TH1F * hESDPMCZPClg = new TH1F("hESDPMCZPClg", "Signal in common ZPC lg PMT",100, 0., 4000.);
   TH1F * hESDPMCZPAlg = new TH1F("hESDPMCZPAlg", "Signal in common ZPA lg PMT",100, 0., 4000.);
-  Add2ESDsList(hESDPMCZNClg, 22, expert, !image);
-  Add2ESDsList(hESDPMCZNAlg, 23, expert, !image);
-  Add2ESDsList(hESDPMCZPClg, 24, expert, !image);
-  Add2ESDsList(hESDPMCZPAlg, 25, expert, !image);*/
-}
-  
-//____________________________________________________________________________
-
-void AliZDCQADataMakerRec::MakeRaws(AliRawReader *rawReader)
-{
-  // Filling Raws QA histos
-  //
-       rawReader->Reset() ; 
-  Float_t sum_ZNC=0., sum_ZNA=0., sum_ZPC=0., sum_ZPA=0.;
-  Float_t sumQ_ZNC=0., sumQ_ZNA=0., sumQ_ZPC=0., sumQ_ZPA=0.;
-  //Float_t sum_ZNC_lg=0., sum_ZNA_lg=0., sum_ZPC_lg=0., sum_ZPA_lg=0.;
-  //Float_t sumQ_ZNC_lg=0., sumQ_ZNA_lg=0., sumQ_ZPC_lg=0., sumQ_ZPA_lg=0.;
-  //
-  AliZDCRawStream stream(rawReader);
-  while(stream.Next()){
-    if(stream.IsADCDataWord() && 
-     (stream.GetADCModule()==0 || stream.GetADCModule()==1)){
-       if(stream.GetSector(0)==1){
-         if(stream.GetADCGain()==0){
-          sum_ZNC += stream.GetADCValue();
-          if(stream.GetSector(1)!=0) sumQ_ZNC += stream.GetADCValue();
-          else GetRawsData(8)->Fill(stream.GetADCValue());
-        }
-        /*else{
-          sum_ZNC_lg += stream.GetADCValue();
-          if(stream.GetSector(1)!=0) sumQ_ZNC_lg += stream.GetADCValue();
-          else GetRawsData(20)->Fill(stream.GetADCValue());
-        }*/
-       }
-       else if(stream.GetSector(0)==2){
-         if(stream.GetADCGain()==0){
-          sum_ZPC += stream.GetADCValue();
-          if(stream.GetSector(1)!=0) sumQ_ZPC += stream.GetADCValue();
-          else GetRawsData(10)->Fill(stream.GetADCValue());
-        }
-        /*else{
-          sum_ZPC_lg += stream.GetADCValue();
-          if(stream.GetSector(1)!=0) sumQ_ZPC_lg += stream.GetADCValue();
-          else GetRawsData(22)->Fill(stream.GetADCValue());
-        }*/
-       }
-       else if(stream.GetSector(0)==4){
-         if(stream.GetADCGain()==0){
-          sum_ZNA += stream.GetADCValue();
-          if(stream.GetSector(1)!=0) sumQ_ZNA += stream.GetADCValue();
-          else GetRawsData(9)->Fill(stream.GetADCValue());
-        }
-        /*else{
-          sum_ZNA_lg += stream.GetADCValue();
-          if(stream.GetSector(1)!=0) sumQ_ZNA_lg += stream.GetADCValue();
-          else GetRawsData(21)->Fill(stream.GetADCValue());
-        }*/
-       }
-       else if(stream.GetSector(0)==5){
-         if(stream.GetADCGain()==0){
-          sum_ZPA += stream.GetADCValue();
-          if(stream.GetSector(1)!=0) sumQ_ZPA += stream.GetADCValue();
-          else GetRawsData(11)->Fill(stream.GetADCValue());
-        }
-        /*else{
-          sum_ZPA_lg += stream.GetADCValue();
-          if(stream.GetSector(1)!=0) sumQ_ZPA_lg += stream.GetADCValue();
-          else GetRawsData(23)->Fill(stream.GetADCValue());
-        }*/
-       }
-    }
-  }
-  //
-  GetRawsData(0)->Fill(sum_ZNC);
-  GetRawsData(1)->Fill(sum_ZNA);
-  GetRawsData(2)->Fill(sum_ZPC);
-  GetRawsData(3)->Fill(sum_ZPA);
-  //
-  GetRawsData(4)->Fill(sumQ_ZNC);
-  GetRawsData(5)->Fill(sumQ_ZNA);
-  GetRawsData(6)->Fill(sumQ_ZPC);
-  GetRawsData(7)->Fill(sumQ_ZPA);
-  //
-  /*GetRawsData(12)->Fill(sum_ZNC_lg);
-  GetRawsData(13)->Fill(sum_ZNA_lg);
-  GetRawsData(14)->Fill(sum_ZPC_lg);
-  GetRawsData(15)->Fill(sum_ZPA_lg);
-  //
-  GetRawsData(16)->Fill(sumQ_ZNC_lg);
-  GetRawsData(17)->Fill(sumQ_ZNA_lg);
-  GetRawsData(18)->Fill(sumQ_ZPC_lg);
-  GetRawsData(19)->Fill(sumQ_ZPA_lg);*/
-  //
-  stream.Delete();
+  Add2ESDsList(hESDPMCZNClg, 20, expert, !image);
+  Add2ESDsList(hESDPMCZNAlg, 21, expert, !image);
+  Add2ESDsList(hESDPMCZPClg, 22, expert, !image);
+  Add2ESDsList(hESDPMCZPAlg, 23, expert, !image);
 }
 
 //___________________________________________________________________________
-void AliZDCQADataMakerRec::MakeDigits(TTree *digitTree )
+void AliZDCQADataMakerRec::MakeDigits(TTree *digitTree)
 {
   // makes data from Digit Tree
+  if(!GetDigitsData(0)) InitDigits();
+
+  if(!digitTree){
+    AliError("Can't get ZDC digit tree!!");
+    return; 
+  }    
+   
   TBranch * branch = digitTree->GetBranch("ZDC");
   if(!branch){
-    AliError("ZDC branch in Digit Tree not found"); 
+    AliError("ZDC branch in digit tree not found"); 
     return;
   } 
-  AliZDCDigit* fDigit = NULL ; 
-  char** add = (char**) (branch->GetAddress());
-  if(add){
-    fDigit = (AliZDCDigit*)(*add);
-  } 
-  else{
-    if(!fDigit) fDigit = new AliZDCDigit();
-    branch->SetAddress(&fDigit);
-  }
-  
-  Int_t ndig = digitTree->GetEntries();
-  
+    
+  AliZDCDigit *digit = 0x0;
+  branch->SetAddress(&digit);
+     
   Float_t adcSum_ZNC=0., adcSum_ZNA=0., adcSum_ZPC=0., adcSum_ZPA=0.;
   Float_t adcSumQ_ZNC=0., adcSumQ_ZNA=0., adcSumQ_ZPC=0., adcSumQ_ZPA=0.;
-  //Float_t adcSum_ZNC_lg=0., adcSum_ZNA_lg=0., adcSum_ZPC_lg=0., adcSum_ZPA_lg=0.;
-  //Float_t adcSumQ_ZNC_lg=0., adcSumQ_ZNA_lg=0., adcSumQ_ZPC_lg=0., adcSumQ_ZPA_lg=0.;
-  //
-  for(Int_t i = 0; i < ndig; i++){
-    digitTree->GetEntry(i);
-    if(fDigit->GetSector(0)==1){
-      adcSum_ZNC += fDigit->GetADCValue(0);
-      //adcSum_ZNC_lg += fDigit->GetADCValue(1);
-      //
-      if(fDigit->GetSector(1)!=0){
-             adcSumQ_ZNC += fDigit->GetADCValue(0);
-             //adcSumQ_ZNC_lg+= fDigit->GetADCValue(1);
-      }
-      else{
-             GetDigitsData(8)->Fill(fDigit->GetADCValue(0));
-             //GetDigitsData(20)->Fill(fDigit->GetADCValue(1));
-      }
-    }
-    else if(fDigit->GetSector(0)==2){
-      adcSum_ZPC += fDigit->GetADCValue(0);
-      //adcSum_ZPC_lg += fDigit->GetADCValue(1);
-      //
-      if(fDigit->GetSector(1)!=0){
-             adcSumQ_ZPC += fDigit->GetADCValue(0);
-             //adcSumQ_ZPC_lg+= fDigit->GetADCValue(1);
-      }
-      else{
-             GetDigitsData(10)->Fill(fDigit->GetADCValue(0));
-             //GetDigitsData(22)->Fill(fDigit->GetADCValue(1));
-      }
-    }
-    else if(fDigit->GetSector(0)==4){
-      adcSum_ZNA += fDigit->GetADCValue(0);
-      //adcSum_ZNA_lg += fDigit->GetADCValue(1);
-      //
-      if(fDigit->GetSector(1)!=0){
-             adcSumQ_ZNA += fDigit->GetADCValue(0);
-             //adcSumQ_ZNA_lg+= fDigit->GetADCValue(1);
+  Float_t adcSum_ZNC_lg=0., adcSum_ZNA_lg=0., adcSum_ZPC_lg=0., adcSum_ZPA_lg=0.;
+  Float_t adcSumQ_ZNC_lg=0., adcSumQ_ZNA_lg=0., adcSumQ_ZPC_lg=0., adcSumQ_ZPA_lg=0.;
+  
+  Int_t ndig = digitTree->GetEntries();
+  for(Int_t i=0; i<ndig; i++){
+      branch->GetEntry(i);
+      
+      if(digit->GetSector(0)==1 && digit->GetSector(1)!=5){
+         adcSum_ZNC += digit->GetADCValue(0);
+         adcSum_ZNC_lg += digit->GetADCValue(1);
+         //
+         if(digit->GetSector(1)!=0){
+             adcSumQ_ZNC += digit->GetADCValue(0);
+             adcSumQ_ZNC_lg+= digit->GetADCValue(1);
+         }
+         else{
+             GetDigitsData(8)->Fill(digit->GetADCValue(0));
+             GetDigitsData(20)->Fill(digit->GetADCValue(1));
+         }
       }
-      else{
-             GetDigitsData(9)->Fill(fDigit->GetADCValue(0));
-             //GetDigitsData(21)->Fill(fDigit->GetADCValue(1));
+      else if(digit->GetSector(0)==2){
+         adcSum_ZPC += digit->GetADCValue(0);
+         adcSum_ZPC_lg += digit->GetADCValue(1);
+         //
+         if(digit->GetSector(1)!=0){
+             adcSumQ_ZPC += digit->GetADCValue(0);
+             adcSumQ_ZPC_lg+= digit->GetADCValue(1);
+         }
+         else{
+             GetDigitsData(10)->Fill(digit->GetADCValue(0));
+             GetDigitsData(22)->Fill(digit->GetADCValue(1));
+         }
       }
-    }
-    else if(fDigit->GetSector(0)==5){
-      adcSum_ZPA += fDigit->GetADCValue(0);
-      //adcSum_ZPA_lg += fDigit->GetADCValue(1);
-      //
-      if(fDigit->GetSector(1)!=0){
-             adcSumQ_ZPA += fDigit->GetADCValue(0);
-             //adcSumQ_ZPA_lg+= fDigit->GetADCValue(1);
+      else if(digit->GetSector(0)==4 && digit->GetSector(1)!=5){
+         adcSum_ZNA += digit->GetADCValue(0);
+         adcSum_ZNA_lg += digit->GetADCValue(1);
+         //
+         if(digit->GetSector(1)!=0){
+             adcSumQ_ZNA += digit->GetADCValue(0);
+             adcSumQ_ZNA_lg+= digit->GetADCValue(1);
+         }
+         else{
+             GetDigitsData(9)->Fill(digit->GetADCValue(0));
+             GetDigitsData(21)->Fill(digit->GetADCValue(1));
+         }
       }
-      else{
-             GetDigitsData(11)->Fill(fDigit->GetADCValue(0));
-             //GetDigitsData(23)->Fill(fDigit->GetADCValue(1));
+      else if(digit->GetSector(0)==5){
+         adcSum_ZPA += digit->GetADCValue(0);
+         adcSum_ZPA_lg += digit->GetADCValue(1);
+         //
+         if(digit->GetSector(1)!=0){
+             adcSumQ_ZPA += digit->GetADCValue(0);
+             adcSumQ_ZPA_lg+= digit->GetADCValue(1);
+         }
+         else{
+             GetDigitsData(11)->Fill(digit->GetADCValue(0));
+             GetDigitsData(23)->Fill(digit->GetADCValue(1));
+         }
       }
-    }
   }
   //
   GetDigitsData(0)->Fill(adcSum_ZNC);
@@ -448,7 +411,7 @@ void AliZDCQADataMakerRec::MakeDigits(TTree *digitTree )
   GetDigitsData(6)->Fill(adcSumQ_ZPC);
   GetDigitsData(7)->Fill(adcSumQ_ZPA);
   //
-  /*GetDigitsData(12)->Fill(adcSum_ZNC_lg);
+  GetDigitsData(12)->Fill(adcSum_ZNC_lg);
   GetDigitsData(13)->Fill(adcSum_ZNA_lg);
   GetDigitsData(14)->Fill(adcSum_ZPC_lg);
   GetDigitsData(15)->Fill(adcSum_ZPA_lg);
@@ -456,20 +419,280 @@ void AliZDCQADataMakerRec::MakeDigits(TTree *digitTree )
   GetDigitsData(16)->Fill(adcSumQ_ZNC_lg);
   GetDigitsData(17)->Fill(adcSumQ_ZNA_lg);
   GetDigitsData(18)->Fill(adcSumQ_ZPC_lg);
-  GetDigitsData(19)->Fill(adcSumQ_ZPA_lg);*/
+  GetDigitsData(19)->Fill(adcSumQ_ZPA_lg);
+  
+  delete digit;
+  digit=0;
+
 }
 
+
+//____________________________________________________________________________
+void AliZDCQADataMakerRec::MakeRaws(AliRawReader *rawReader)
+{
+  // Filling Raws QA histos
+  //
+  // Checking the event type 
+//  if (rawReader->GetType()!=7){
+  
+    // Check if histograms already created for this Event Specie
+    if(!GetRawsData(0)) InitRaws();
+  
+    // Parameters for mean value pedestal subtraction
+    int const kNch = 24;
+    Float_t meanPed[2*kNch];    
+    for(Int_t jj=0; jj<2*kNch; jj++) meanPed[jj] = fPedCalibData->GetMeanPed(jj);
+    
+    Float_t zncSignal=0., znaSignal=0., zpcSignal=0., zpaSignal=0.;
+    Float_t zncSumQ=0., znaSumQ=0., zpcSumQ=0., zpaSumQ=0.;
+    Float_t zncpmC=0., znapmC=0., zpcpmC=0., zpapmC=0.;
+    Bool_t isZNCFired=kFALSE, isZPCFired=kFALSE, isZNAFired=kFALSE, isZPAFired=kFALSE;
+    Int_t  indZNC=0, indZNA=0, indZPC=0, indZPA=0;
+    Float_t zpcTDC[10], zem1TDC[10];
+    for(Int_t i=0; i<10; i++){
+       zpcTDC[i] = zem1TDC[i] = -999.;
+    }
+    Float_t tdcL0=-999.;
+    Int_t iMultZPCTDC=0, iMultZEMTDC=0;
+    
+    rawReader->Reset();
+    AliZDCRawStream stream(rawReader);
+    while(stream.Next()){
+
+      if(stream.IsADCDataWord() && 
+        (stream.GetADCModule()==0 || stream.GetADCModule()==1)){
+       
+        Int_t det = stream.GetSector(0);
+        Int_t quad = stream.GetSector(1);
+        Int_t gain = stream.GetADCGain();
+        Int_t pedindex=0;
+        
+        // Stuff for pedestal subtraction
+        if(quad != 5){ // ZDCs (not reference PTMs)
+         if(det == 1){    
+           pedindex = quad;
+           if(gain == 0){
+             Float_t pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+             zncSignal  += pedSubVal; 
+             isZNCFired = kTRUE;
+             if(quad!=0) zncSumQ += pedSubVal;
+             else{
+               zncpmC = pedSubVal;
+               GetRawsData(10)->Fill(zncpmC);
+             }
+             indZNC++;
+           }
+         }
+         else if(det == 2){ 
+           pedindex = quad+5;
+           if(gain == 0){
+             Float_t pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+             zpcSignal += pedSubVal; 
+             isZPCFired = kTRUE;
+             if(quad!=0) zpcSumQ += pedSubVal;
+             else{
+               zpcpmC = pedSubVal;
+               GetRawsData(12)->Fill(zpcpmC);
+             }
+             indZPC++;
+           }
+         }
+         else if(det == 3){ 
+           pedindex = quad+9;
+           if(quad==1){     
+             if(gain == 0){
+               Float_t pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+               GetRawsData(4)->Fill(pedSubVal);
+             }
+           }
+           else if(quad==2){ 
+             if(gain == 0){
+               Float_t pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+               GetRawsData(5)->Fill(pedSubVal); 
+             }
+           }
+         }
+         else if(det == 4){       
+           pedindex = quad+12;
+           if(gain == 0){
+             Float_t pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+             znaSignal  += pedSubVal; 
+             isZNAFired = kTRUE;
+             if(quad!=0) znaSumQ += pedSubVal;
+             else{
+               znapmC = pedSubVal;
+               GetRawsData(11)->Fill(znapmC);
+             }
+             indZNA++;
+           }
+         }
+         else if(det == 5){
+           pedindex = quad+17;
+           if(gain == 0){
+             Float_t pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+             zpaSignal  += pedSubVal; 
+             isZPAFired = kTRUE;
+             if(quad!=0) zpaSumQ += pedSubVal;
+             else{
+               zpapmC = pedSubVal;
+               GetRawsData(13)->Fill(zpapmC);
+             }
+             indZPA++;
+           }
+         }
+        }
+        //
+        if(isZNCFired && indZNC==5){
+          GetRawsData(0)->Fill(zncSignal);
+          GetRawsData(6)->Fill(zncSumQ, zncpmC);
+          GetRawsData(14)->Fill(zncSumQ); 
+        }
+        if(isZPCFired && indZPC==5){
+          GetRawsData(2)->Fill(zpcSignal);
+           GetRawsData(8)->Fill(zpcSumQ, zpcpmC);
+           GetRawsData(16)->Fill(zpcSumQ); 
+         }
+         if(isZNAFired && indZNA==5){ 
+          GetRawsData(1)->Fill(znaSignal);
+          GetRawsData(7)->Fill(znaSumQ, znapmC);
+          GetRawsData(15)->Fill(znaSumQ); 
+         }
+         if(isZPAFired && indZPA==5){ 
+          GetRawsData(3)->Fill(zpaSignal);
+          GetRawsData(9)->Fill(zpaSumQ, zpapmC);
+          GetRawsData(17)->Fill(zpaSumQ); 
+         }
+        
+        if(indZNC==5){
+          zncSignal = zncSumQ = zncpmC = 0;
+          isZNCFired=kFALSE; indZNC=0;
+        }
+        if(indZPC==5){
+          zpcSignal = zpcSumQ = zpcpmC = 0;
+          isZPCFired=kFALSE; indZPC=0;
+        }
+        if(indZNA==5){
+          znaSignal = znaSumQ = znapmC = 0;
+          isZNAFired=kFALSE; indZNA=0;
+        }
+        if(indZPA==5){
+          zpaSignal = zpaSumQ = zpapmC = 0;
+          isZPAFired=kFALSE; indZPA=0;
+        }
+       
+      } //IsADCDataWord && signal ADCs
+      else if(stream.IsZDCTDCDatum()){
+        if(stream.GetChannel()==3){
+           zpcTDC[iMultZPCTDC] = (0.025*(stream.GetZDCTDCDatum()));
+           iMultZPCTDC++;
+        }
+        else if(stream.GetChannel()==8){
+           zem1TDC[iMultZEMTDC] = (0.025*(stream.GetZDCTDCDatum()));
+           iMultZEMTDC++;
+        }
+        else if(stream.GetChannel()==16) tdcL0 = (0.025*(stream.GetZDCTDCDatum()));
+        
+        if(stream.GetChannel()==16 && tdcL0!=-999.){
+          for(Int_t iHit=0; iHit<10; iHit++){
+             if(zpcTDC[iHit]!=-999.){
+               Float_t diffZPC = zpcTDC[iHit]-tdcL0;
+               GetRawsData(19)->Fill(diffZPC);
+             }
+             if(zem1TDC[iHit]!=-999.){
+               Float_t diffZEM1 = zem1TDC[iHit]-tdcL0;
+               GetRawsData(18)->Fill(diffZEM1);
+             }
+          }
+          //
+          tdcL0 = -999.;
+           for(Int_t i=0; i<10; i++){
+              zpcTDC[i] = zem1TDC[i] = -999.;
+           } 
+        }
+      }
+    
+    } //stream.Next()
+//  } // check on event type
+//  else{
+//    AliDebug(1,Form("Skipping non-physics event for QA -> event type %d \n", rawReader->GetType())); 
+//  }
+}
+
+//____________________________________________________________________________
+void AliZDCQADataMakerRec::MakeRecPoints(TTree * clustersTree)
+{
+  // Filling QA histos from RecPoints
+
+  TBranch *branch = clustersTree->GetBranch("ZDC");
+  if(!branch){ 
+    AliError("Can't get the ZDC branch for rec points!");
+    return;
+  }
+  
+  if(!GetRecPointsData(0)) InitRecPoints() ;
+
+  Float_t sum_ZNC=0., sum_ZNA=0., sum_ZPC=0., sum_ZPA=0.;
+  Float_t sumQ_ZNC=0., sumQ_ZNA=0., sumQ_ZPC=0., sumQ_ZPA=0.;
+
+  AliZDCReco reco;
+  AliZDCReco* preco = &reco;
+  clustersTree->SetBranchAddress("ZDC", &preco);
+
+  clustersTree->GetEntry(0);
+  for(Int_t i=0; i<5; i++){
+    sum_ZNC += reco.GetZN1HREnTow(i);
+    sum_ZPC += reco.GetZN2HREnTow(i);
+    sum_ZNA += reco.GetZP1HREnTow(i);
+    sum_ZPA += reco.GetZP2HREnTow(i);
+    if(i==0){
+      GetRecPointsData(8)->Fill(reco.GetZN1HREnTow(i));
+      GetRecPointsData(9)->Fill(reco.GetZN2HREnTow(i));
+      GetRecPointsData(10)->Fill(reco.GetZP1HREnTow(i));
+      GetRecPointsData(11)->Fill(reco.GetZP2HREnTow(i));
+    }
+    else{
+      sumQ_ZNC += reco.GetZN1HREnTow(i);
+      sumQ_ZPC += reco.GetZN2HREnTow(i);
+      sumQ_ZNA += reco.GetZP1HREnTow(i);
+      sumQ_ZPA += reco.GetZP2HREnTow(i);
+    }
+  }
+  
+  GetRecPointsData(0)->Fill(sum_ZNC);
+  GetRecPointsData(1)->Fill(sum_ZNA);
+  GetRecPointsData(2)->Fill(sum_ZPC);
+  GetRecPointsData(3)->Fill(sum_ZPA);
+  //
+  GetRecPointsData(4)->Fill(sumQ_ZNC);
+  GetRecPointsData(5)->Fill(sumQ_ZNA);
+  GetRecPointsData(6)->Fill(sumQ_ZPC);
+  GetRecPointsData(7)->Fill(sumQ_ZPA);
+  
+}  
+
 //____________________________________________________________________________
 void AliZDCQADataMakerRec::MakeESDs(AliESDEvent * esd)
 {
   // make QA data from ESDs
   //
+  
+  // Check id histograms already created for this Event Specie
+  if(!GetESDsData(0)) InitESDs() ;
+
   AliESDZDC * zdcESD =  esd->GetESDZDC();
   //
-  Double32_t * centr_ZNC = zdcESD->GetZNCCentroid();
+  TString beamType = esd->GetBeamType();
+  Double_t centr_ZNC[2]={999.,999}, centr_ZNA[2]={999.,999};
+  if(((beamType.CompareTo("pp"))==0) || ((beamType.CompareTo("p-p"))==0)
+     ||((beamType.CompareTo("PP"))==0) || ((beamType.CompareTo("P-P"))==0)){
+    zdcESD->GetZNCentroidInpp(centr_ZNC, centr_ZNA);
+  }
+  else if((beamType.CompareTo("A-A")) == 0 || (beamType.CompareTo("Pb-Pb")) == 0){
+    Float_t beamEne = esd->GetBeamEnergy();
+    zdcESD->GetZNCentroidInPbPb(beamEne, centr_ZNC, centr_ZNA);
+  }
+  else printf("\n WARNING!!! AliZDCQADataMakerRec::MakeESDs: can't calculate centroids for beam type: %s\n\n",beamType.Data());
   GetESDsData(0)->Fill(centr_ZNC[0], centr_ZNC[1]);
-
-  Double32_t * centr_ZNA = zdcESD->GetZNACentroid();
   GetESDsData(1)->Fill(centr_ZNA[0], centr_ZNA[1]);
 
   //
@@ -477,34 +700,36 @@ void AliZDCQADataMakerRec::MakeESDs(AliESDEvent * esd)
   GetESDsData(3)->Fill(esd->GetZDCN2Energy());
   GetESDsData(4)->Fill(esd->GetZDCP1Energy());
   GetESDsData(5)->Fill(esd->GetZDCP2Energy());
+  GetESDsData(6)->Fill(esd->GetZDCEMEnergy(0));
+  GetESDsData(7)->Fill(esd->GetZDCEMEnergy(1));
   //
   Double_t sumQZNC=0., sumQZPC=0., sumQZNA=0., sumQZPA=0.;
-  //Double_t sumQZNC_lg=0., sumQZPC_lg=0., sumQZNA_lg=0., sumQZPA_lg=0.;
+  Double_t sumQZNC_lg=0., sumQZPC_lg=0., sumQZNA_lg=0., sumQZPA_lg=0.;
   //
   const Double_t *towZNC, *towZPC, *towZNA, *towZPA;
-  //const Double_t *towZNC_lg, *towZPC_lg, *towZNA_lg, *towZPA_lg;
+  const Double_t *towZNC_lg, *towZPC_lg, *towZNA_lg, *towZPA_lg;
   //
   towZNC = zdcESD->GetZN1TowerEnergy();
   towZPC = zdcESD->GetZP1TowerEnergy();
   towZNA = zdcESD->GetZN2TowerEnergy();
   towZPA = zdcESD->GetZP2TowerEnergy();
   //
-  /*towZNC_lg = zdcESD->GetZN1TowerEnergyLR();
+  towZNC_lg = zdcESD->GetZN1TowerEnergyLR();
   towZPC_lg = zdcESD->GetZP1TowerEnergyLR();
   towZNA_lg = zdcESD->GetZN2TowerEnergyLR();
-  towZPA_lg = zdcESD->GetZP2TowerEnergyLR();*/
+  towZPA_lg = zdcESD->GetZP2TowerEnergyLR();
   //
   for(Int_t i=0; i<5; i++){
      if(i==0){
-       GetESDsData(10)->Fill(towZNC[i]);
-       GetESDsData(11)->Fill(towZNA[i]);
-       GetESDsData(12)->Fill(towZPC[i]);
-       GetESDsData(13)->Fill(towZPA[i]);
+       GetESDsData(12)->Fill(towZNC[i]);
+       GetESDsData(13)->Fill(towZNA[i]);
+       GetESDsData(14)->Fill(towZPC[i]);
+       GetESDsData(15)->Fill(towZPA[i]);
        //
-       /*GetESDsData(22)->Fill(towZNC_lg[i]);
-       GetESDsData(23)->Fill(towZNA_lg[i]);
-       GetESDsData(24)->Fill(towZPC_lg[i]);
-       GetESDsData(25)->Fill(towZPA_lg[i]);*/
+       GetESDsData(20)->Fill(towZNC_lg[i]);
+       GetESDsData(21)->Fill(towZNA_lg[i]);
+       GetESDsData(22)->Fill(towZPC_lg[i]);
+       GetESDsData(23)->Fill(towZPA_lg[i]);
      }
      else{
        sumQZNC += towZNC[i];
@@ -512,27 +737,29 @@ void AliZDCQADataMakerRec::MakeESDs(AliESDEvent * esd)
        sumQZNA += towZNA[i];
        sumQZPA += towZPA[i];
        //
-       /*sumQZNC_lg += towZNC_lg[i];
+       sumQZNC_lg += towZNC_lg[i];
        sumQZPC_lg += towZPC_lg[i];
        sumQZNA_lg += towZNA_lg[i];
-       sumQZPA_lg += towZPA_lg[i];*/
+       sumQZPA_lg += towZPA_lg[i];
      }
   }
-  GetESDsData(6)->Fill(sumQZNC);
-  GetESDsData(7)->Fill(sumQZNA);
-  GetESDsData(8)->Fill(sumQZPC);
-  GetESDsData(9)->Fill(sumQZPA);
-  //
-  /*GetESDsData(18)->Fill(sumQZNC_lg);
-  GetESDsData(19)->Fill(sumQZNA_lg);
-  GetESDsData(20)->Fill(sumQZPC_lg);
-  GetESDsData(21)->Fill(sumQZPA_lg);*/
+  GetESDsData(8)->Fill(sumQZNC);
+  GetESDsData(9)->Fill(sumQZNA);
+  GetESDsData(10)->Fill(sumQZPC);
+  GetESDsData(11)->Fill(sumQZPA);
+  //
+  GetESDsData(16)->Fill(sumQZNC_lg);
+  GetESDsData(17)->Fill(sumQZNA_lg);
+  GetESDsData(18)->Fill(sumQZPC_lg);
+  GetESDsData(19)->Fill(sumQZPA_lg);
 }
 
 //____________________________________________________________________________
 void AliZDCQADataMakerRec::StartOfDetectorCycle()
 {
   //Detector specific actions at start of cycle
+
+  fPedCalibData = GetPedCalibData();
   
 }
 
@@ -541,6 +768,34 @@ void AliZDCQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArr
 {
   //Detector specific actions at end of cycle
   // do the QA checking
+  if( task == AliQAv1::kRAWS){
+     if (!GetRawsData(4) || !GetRawsData(5) || !GetRawsData(6) || !GetRawsData(7) || 
+        !GetRawsData(8) || !GetRawsData(9) || !GetRawsData(10) || !GetRawsData(11) || 
+       !GetRawsData(12) || !GetRawsData(13)) {
+        printf("  WARNING!!! AliZDCQADataMaker Rec -> No histogram for DQM found!\n"); 
+     }
+     else{
+      
+       GetRawsData(6)->SetOption("colz");
+       GetRawsData(7)->SetOption("colz");
+       GetRawsData(8)->SetOption("colz");
+       GetRawsData(9)->SetOption("colz");  
+     
+       GetRawsData(4)->SetLineColor(kAzure+1); GetRawsData(4)->SetLineWidth(2);
+       GetRawsData(5)->SetLineColor(kAzure+2); GetRawsData(5)->SetLineWidth(2);
+       GetRawsData(10)->SetLineColor(kBlue);   GetRawsData(10)->SetLineWidth(2);
+       GetRawsData(11)->SetLineColor(kBlue+1); GetRawsData(11)->SetLineWidth(2);
+       GetRawsData(12)->SetLineColor(kBlue+2); GetRawsData(12)->SetLineWidth(2);
+       GetRawsData(13)->SetLineColor(kBlue+3); GetRawsData(13)->SetLineWidth(2);
+     
+       if(((GetRawsData(4))->GetEntries())>0)  GetRawsData(4)->SetDrawOption("LOGY");
+       if(((GetRawsData(5))->GetEntries())>0)  GetRawsData(5)->SetDrawOption("LOGY");
+       if(((GetRawsData(10))->GetEntries())>0) GetRawsData(10)->SetDrawOption("LOGY");
+       if(((GetRawsData(11))->GetEntries())>0) GetRawsData(11)->SetDrawOption("LOGY");
+       if(((GetRawsData(12))->GetEntries())>0) GetRawsData(12)->SetDrawOption("LOGY");
+       if(((GetRawsData(13))->GetEntries())>0) GetRawsData(13)->SetDrawOption("LOGY");
+     }
+  }
+       
   AliQAChecker::Instance()->Run(AliQAv1::kZDC, task, list) ;  
 }
-