Make it find libraries independently of location
[u/mrichter/AliRoot.git] / ZDC / AliZDCQADataMakerRec.cxx
index 8f2ee59..e49a4ca 100644 (file)
@@ -174,32 +174,32 @@ void AliZDCQADataMakerRec::InitRaws()
   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.);
+  TH1F * hZEM1Spectrum = new TH1F("hZEM1Spectrum","ZEM1 spectrum;Amplitude [ADC counts];Counts",100,8., 1208.);
+  TH1F * hZEM2Spectrum = new TH1F("hZEM2Spectrum","ZEM2 spectrum;Amplitude [ADC counts];Counts",100,8., 1208.);
   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);
+  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.,1407.,50,7., 1407.);
-  TH2F * hZPCpmCvsPMq = new TH2F("hZPCpmCvsPMq", "ZPC;PMC [ADC counts];Sum(PMQ) [ADC counts]",50,7.,1407.,50,7., 1407.);
-  TH2F * hZNApmCvsPMq = new TH2F("hZNApmCvsPMq", "ZNA;PMC [ADC counts];Sum(PMQ) [ADC counts]",50,7.,1407.,50,7., 1407.);
-  TH2F * hZPApmCvsPMq = new TH2F("hZPApmCvsPMq", "ZPA;PMC [ADC counts];Sum(PMQ) [ADC counts]",50,7.,1407.,50,7., 1407.);
-  Add2RawsList(hZNCpmCvsPMq, 6, !expert, image);
-  Add2RawsList(hZPCpmCvsPMq, 7, !expert, image);
-  Add2RawsList(hZNApmCvsPMq, 8, !expert, image);
-  Add2RawsList(hZPApmCvsPMq, 9, !expert, image);
+  TH2F * hZNCpmCvsPMq = new TH2F("hZNCpmCvsPMq", "ZNC;PMC [ADC counts];Sum(PMQ) [ADC counts]",50,8.,1208.,50,8., 1208.);
+  TH2F * hZPCpmCvsPMq = new TH2F("hZPCpmCvsPMq", "ZPC;PMC [ADC counts];Sum(PMQ) [ADC counts]",50,8.,1208.,50,8., 1208.);
+  TH2F * hZNApmCvsPMq = new TH2F("hZNApmCvsPMq", "ZNA;PMC [ADC counts];Sum(PMQ) [ADC counts]",50,8.,1208.,50,8., 1208.);
+  TH2F * hZPApmCvsPMq = new TH2F("hZPApmCvsPMq", "ZPA;PMC [ADC counts];Sum(PMQ) [ADC counts]",50,8.,1208.,50,8., 1208.);
+  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 * hRawPMCZNC = new TH1F("hRawPMCZNC", "Raw ZNC PMC;Amplitude [ADC counts];Counts",100, 8., 1208.);
+  TH1F * hRawPMCZNA = new TH1F("hRawPMCZNA", "Raw ZNA PMC;Amplitude [ADC counts];Counts",100, 8., 1208.);
+  TH1F * hRawPMCZPC = new TH1F("hRawPMCZPC", "Raw ZPC PMC;Amplitude [ADC counts];Counts",100, 8., 1208.);
+  TH1F * hRawPMCZPA = new TH1F("hRawPMCZPA", "Raw ZPA PMC;Amplitude [ADC counts];Counts",100, 8., 1208.);
+  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.);
@@ -208,7 +208,28 @@ void AliZDCQADataMakerRec::InitRaws()
   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]",160, -350., -310.);
+  Add2RawsList(hRawTDCZEM1, 18, expert, !image);
+  TH1F * hRawTDCZPC = new TH1F("hRawTDCZPC", "Raw TDC ZPC;TDC [ns]",160, -350., -310.);
+  Add2RawsList(hRawTDCZPC, 19, expert, !image);
+  
+  TProfile * hRawADCProfs = new TProfile("hRawADCProfs", "ADC profiles;ADC id;Mean ADC values",22,-0.5,21.5,10.,1210.,"");
+  Add2RawsList(hRawADCProfs, 20, expert, !image);
+  TProfile * hRawTDCProfs = new TProfile("hRawTDCProfs", "TDC profiles;TDC id;Mean TDC values",6,0.5,6.5,-350.,-310.,"S");
+  Add2RawsList(hRawTDCProfs, 21, expert, !image);
+  
+  TH1F * hRawADCs = new TH1F("hRawADCs", "ADCs;ADC id;Mean ADC values",22,-0.5,21.5);
+  Add2RawsList(hRawADCs, 22, !expert, image);
+  TH1F * hRawTDCs = new TH1F("hRawTDCs", "TDCs;TDC id;Mean TDC values",6,0.5,6.5);
+  hRawTDCs->SetMaximum(-310);
+  Add2RawsList(hRawTDCs, 23, !expert, image);
+  
+  TH2F *hZNCrawCentr  = new TH2F("hZNCrawCentr", "Centroid in ZNC;X (cm);Y(cm)", 100, -5.,5.,100,-5.,5.);
+  Add2RawsList(hZNCrawCentr, 24, expert, !image);
+  TH2F *hZNArawCentr  = new TH2F("hZNArawCentr", "Centroid in ZNA;X (cm);Y(cm)", 100, -5.,5.,100,-5.,5.);
+  Add2RawsList(hZNArawCentr, 25, expert, !image);
 }
 
 //____________________________________________________________________________
@@ -255,8 +276,8 @@ void AliZDCQADataMakerRec::InitESDs()
   const Bool_t expert = kTRUE ; 
   const Bool_t image  = kTRUE ; 
   
-  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.);
+  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);
   //
@@ -427,127 +448,282 @@ void AliZDCQADataMakerRec::MakeRaws(AliRawReader *rawReader)
 {
   // Filling Raws QA histos
   //
-  // Check if histograms already created for this Event Specie
-  if(!GetRawsData(0)) InitRaws();
+  // Checking the event type 
+//  if (rawReader->GetType()!=7){
   
-  // 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);
-  
-  AliZDCRawStream stream(rawReader);
-  while(stream.Next()){
+    // 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 zncTDC[10], zpcTDC[10], zem1TDC[10], zem2TDC[10], znaTDC[10], zpaTDC[10];
+    for(Int_t i=0; i<10; i++){
+       zncTDC[i]=zpcTDC[i]=zem1TDC[i]=zem2TDC[i]=znaTDC[i]=zpaTDC[i]=-999.;
+    }
+    Float_t tdcGate=-999.;
+    Int_t iMultZNCTDC=0, iMultZPCTDC=0, iMultZEM1TDC=0, iMultZEM2TDC=0, iMultZNATDC=0, iMultZPATDC=0;
     
-    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;
+    const Float_t x[4] = {-1.75, 1.75, -1.75, 1.75};
+    const Float_t y[4] = {-1.75, -1.75, 1.75, 1.75};
+    const Float_t alpha=0.5;
+    Float_t numXZNC=0., numYZNC=0., denZNC=0., wZNC=0.; 
+    Float_t numXZNA=0., numYZNA=0., denZNA=0., wZNA=0.; 
+    
+    rawReader->Reset();
+    AliZDCRawStream stream(rawReader);
+    while(stream.Next()){
+
+      if(stream.IsADCDataWord() && 
+        (stream.GetADCModule()==0 || stream.GetADCModule()==1)){
        
-       // 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);
-           }
-         }
-        }
-        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);
-           }
-         }
-        }
-        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);
-           }
-         }
-        }
-        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);
-           }
-         }
-        }
-       }
-       //
-      if(isZNCFired){
-        GetRawsData(0)->Fill(zncSignal);
-        GetRawsData(6)->Fill(zncSumQ, zncpmC);
-        GetRawsData(14)->Fill(zncSumQ); 
+        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)
+         Float_t pedSubVal=-99.;
+         if(det == 1){    
+           pedindex = quad;
+           if(gain == 0){
+             pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+             zncSignal  += pedSubVal; 
+             isZNCFired = kTRUE;
+             if(quad!=0){
+               zncSumQ += pedSubVal;
+               if(pedSubVal>0.&& zncpmC>50.){
+                 wZNC = TMath::Power(pedSubVal, alpha);
+                 numXZNC += x[quad-1]*wZNC;
+                 numYZNC += y[quad-1]*wZNC;
+                 denZNC += wZNC;
+               }
+             }
+             else{
+               zncpmC = pedSubVal;
+               GetRawsData(10)->Fill(zncpmC);
+             }
+             indZNC++;
+             
+             GetRawsData(20)->Fill(pedindex, pedSubVal);
+           }
+         }
+         else if(det == 2){ 
+           pedindex = quad+5;
+           if(gain == 0){
+             pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+             zpcSignal += pedSubVal; 
+             isZPCFired = kTRUE;
+             if(quad!=0) zpcSumQ += pedSubVal;
+             else{
+               zpcpmC = pedSubVal;
+               GetRawsData(12)->Fill(zpcpmC);
+             }
+             indZPC++;
+             
+             GetRawsData(20)->Fill(pedindex, pedSubVal);
+           }
+         }
+         else if(det == 3){ 
+           pedindex = quad+9;
+           if(quad==1){     
+             if(gain == 0){
+               pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+               GetRawsData(4)->Fill(pedSubVal);
+             
+               GetRawsData(20)->Fill(pedindex, pedSubVal);
+             }
+           }
+           else if(quad==2){ 
+             if(gain == 0){
+               pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+               GetRawsData(5)->Fill(pedSubVal); 
+             
+               GetRawsData(20)->Fill(pedindex, pedSubVal);
+             }
+           }
+         }
+         else if(det == 4){       
+           pedindex = quad+12;
+           if(gain == 0){
+             pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+             znaSignal  += pedSubVal; 
+             isZNAFired = kTRUE;
+             if(quad!=0){
+               znaSumQ += pedSubVal;
+               if(pedSubVal>0.&& znapmC>50.) {
+                 wZNA = TMath::Power(pedSubVal, alpha);
+                 numXZNA += x[quad-1]*wZNA;
+                 numYZNA += y[quad-1]*wZNA;
+                 denZNA += wZNA;
+               }
+             }
+             else{
+               znapmC = pedSubVal;
+               GetRawsData(11)->Fill(znapmC);
+             }
+             indZNA++;
+             
+             GetRawsData(20)->Fill(pedindex, pedSubVal);
+             //GetRawsData(22)->SetBinContent(pedindex+1, GetRawsData(20)->GetBinContent(pedindex+1));
+             //GetRawsData(22)->SetBinError(pedindex+1, GetRawsData(20)->GetBinError(pedindex+1));
+           }
+         }
+         else if(det == 5){
+           pedindex = quad+17;
+           if(gain == 0){
+             pedSubVal = (Float_t) (stream.GetADCValue()-meanPed[pedindex]); 
+             zpaSignal  += pedSubVal; 
+             isZPAFired = kTRUE;
+             if(quad!=0) zpaSumQ += pedSubVal;
+             else{
+               zpapmC = pedSubVal;
+               GetRawsData(13)->Fill(zpapmC);
+             }
+             indZPA++;
+             
+             GetRawsData(20)->Fill(pedindex, pedSubVal);
+             //GetRawsData(22)->SetBinContent(pedindex+1, GetRawsData(20)->GetBinContent(pedindex+1));
+             //GetRawsData(22)->SetBinError(pedindex+1, GetRawsData(20)->GetBinError(pedindex+1));
+           }
+         }
+                        
+        }
+
+        if(isZNCFired && indZNC==5){
+          GetRawsData(0)->Fill(zncSignal);
+          GetRawsData(6)->Fill(zncpmC, zncSumQ);
+          GetRawsData(14)->Fill(zncSumQ); 
+           //
+          Float_t xZNC, yZNC;           
+          if(denZNC!=0){
+            xZNC = numXZNC/denZNC;
+            yZNC = numYZNC/denZNC;
+          } 
+          else xZNC = yZNC = 999.;
+          GetRawsData(24)->Fill(xZNC, yZNC);
+        }
+        if(isZPCFired && indZPC==5){
+          GetRawsData(2)->Fill(zpcSignal);
+           GetRawsData(8)->Fill(zpcpmC, zpcSumQ);
+           GetRawsData(16)->Fill(zpcSumQ); 
+         }
+         if(isZNAFired && indZNA==5){ 
+           GetRawsData(1)->Fill(znaSignal);
+           GetRawsData(7)->Fill(znapmC, znaSumQ);
+           GetRawsData(15)->Fill(znaSumQ); 
+          //
+          Float_t xZNA, yZNA;
+          if(denZNA!=0){
+            xZNA = numXZNA/denZNA;
+            yZNA = numYZNA/denZNA;
+          } 
+          else xZNA = yZNA = 999.;
+          GetRawsData(25)->Fill(xZNA, yZNA);
+         }
+         if(isZPAFired && indZPA==5){ 
+           GetRawsData(3)->Fill(zpaSignal);
+           GetRawsData(9)->Fill(zpapmC, zpaSumQ);
+           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()==1){
+           zncTDC[iMultZNCTDC] = (0.025*(stream.GetZDCTDCDatum()));
+           iMultZNCTDC++;
+        }
+        else if(stream.GetChannel()==3){
+           zpcTDC[iMultZPCTDC] = (0.025*(stream.GetZDCTDCDatum()));
+           iMultZPCTDC++;
+        }
+        else if(stream.GetChannel()==5){
+           znaTDC[iMultZNATDC] = (0.025*(stream.GetZDCTDCDatum()));
+           iMultZNATDC++;
+        }
+        else if(stream.GetChannel()==7){
+           zpaTDC[iMultZPATDC] = (0.025*(stream.GetZDCTDCDatum()));
+           iMultZPATDC++;
+        }
+        else if(stream.GetChannel()==8){
+           zem1TDC[iMultZEM1TDC] = (0.025*(stream.GetZDCTDCDatum()));
+           iMultZEM1TDC++;
+        }
+        else if(stream.GetChannel()==9){
+           zem2TDC[iMultZEM2TDC] = (0.025*(stream.GetZDCTDCDatum()));
+           iMultZEM2TDC++;
+        }
+        else if(stream.GetChannel()==15) tdcGate = (0.025*(stream.GetZDCTDCDatum()));
+        
+        if(stream.GetChannel()==16 && tdcGate!=-999.){
+          for(Int_t iHit=0; iHit<10; iHit++){
+             if(zncTDC[iHit]!=-999.){
+               GetRawsData(21)->Fill(1, zncTDC[iHit]-tdcGate);
+               //GetRawsData(23)->SetBinContent(1, GetRawsData(21)->GetBinContent(1));
+             }
+             if(zpcTDC[iHit]!=-999.){
+               Float_t diffZPC = zpcTDC[iHit]-tdcGate;
+               GetRawsData(19)->Fill(diffZPC);
+               GetRawsData(21)->Fill(2, diffZPC);
+               //GetRawsData(23)->SetBinContent(2,  GetRawsData(21)->GetBinContent(3));
+             }
+             if(znaTDC[iHit]!=-999.){
+               GetRawsData(21)->Fill(3, znaTDC[iHit]-tdcGate);
+               //GetRawsData(23)->SetBinContent(3,  GetRawsData(21)->GetBinContent(5));
+             }
+             if(zpaTDC[iHit]!=-999.){
+               GetRawsData(21)->Fill(4, zpaTDC[iHit]-tdcGate);
+               //GetRawsData(23)->SetBinContent(4,  GetRawsData(21)->GetBinContent(7));
+             }
+             if(zem1TDC[iHit]!=-999.){
+               Float_t diffZEM1 = zem1TDC[iHit]-tdcGate;
+               GetRawsData(18)->Fill(diffZEM1);
+               GetRawsData(21)->Fill(5, diffZEM1);
+               //GetRawsData(23)->SetBinContent(5,  GetRawsData(21)->GetBinContent(8));
+             }
+             if(zem2TDC[iHit]!=-999.){
+               GetRawsData(21)->Fill(6, zem2TDC[iHit]-tdcGate);
+               //GetRawsData(23)->SetBinContent(6,  GetRawsData(21)->GetBinContent(9));
+              }
+          }
+          //
+          tdcGate = -999.;
+           for(Int_t i=0; i<10; i++){
+              zpcTDC[i] = zem1TDC[i] = -999.;
+           } 
+        }
       }
-      if(isZPCFired){
-        GetRawsData(2)->Fill(zpcSignal);
-        GetRawsData(8)->Fill(zpcSumQ, zpcpmC);
-        GetRawsData(15)->Fill(zpcSumQ); 
-      }
-      if(isZNAFired){ 
-        GetRawsData(1)->Fill(znaSignal);
-        GetRawsData(7)->Fill(znaSumQ, znapmC);
-        GetRawsData(16)->Fill(znaSumQ); 
-      }
-      if(isZPAFired){ 
-        GetRawsData(3)->Fill(zpaSignal);
-        GetRawsData(9)->Fill(znaSumQ, zpapmC);
-        GetRawsData(17)->Fill(znaSumQ); 
-      }
-       
-    } //IsADCDataWord && signal ADCs
     
-  } //stream.Next()
-
-//   stream.Delete();
+    } //stream.Next()
+//  } // check on event type
+//  else{
+//    AliDebug(1,Form("Skipping non-physics event for QA -> event type %d \n", rawReader->GetType())); 
+//  }
 }
 
 //____________________________________________________________________________
@@ -623,7 +799,7 @@ void AliZDCQADataMakerRec::MakeESDs(AliESDEvent * esd)
     Float_t beamEne = esd->GetBeamEnergy();
     zdcESD->GetZNCentroidInPbPb(beamEne, centr_ZNC, centr_ZNA);
   }
-  else printf(" AliZDCQADataMakerRec::MakeESDs: can't calculate centroids for beam type: %s\n\n",beamType.Data());
+  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]);
   GetESDsData(1)->Fill(centr_ZNA[0], centr_ZNA[1]);
 
@@ -700,46 +876,23 @@ void AliZDCQADataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArr
 {
   //Detector specific actions at end of cycle
   // do the QA checking
-  for(Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
-     if( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) continue; 
-     
-    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") ; 
-        continue;
+  if( task == AliQAv1::kRAWS){
+     if (!GetRawsData(20) || !GetRawsData(21) || !GetRawsData(24)  || !GetRawsData(25)) {
+        printf("  WARNING!!! AliZDCQADataMaker Rec -> Not all histogram for DQM found!\n"); 
+     }
+     else{
+       for(Int_t ibin=1; ibin<=GetRawsData(20)->GetNbinsX(); ibin++){
+          GetRawsData(22)->SetBinContent(ibin, GetRawsData(20)->GetBinContent(ibin)); 
+         GetRawsData(22)->SetBinError(ibin, GetRawsData(20)->GetBinError(ibin));
+          GetRawsData(22)->SetLineColor(kBlue); GetRawsData(22)->SetLineWidth(2);
+       }
+       for(Int_t ibin=1; ibin<=GetRawsData(21)->GetNbinsX(); ibin++){
+          GetRawsData(23)->SetBinContent(ibin, GetRawsData(21)->GetBinContent(ibin)); 
+         GetRawsData(23)->SetBinError(ibin, GetRawsData(21)->GetBinError(ibin));
+          GetRawsData(23)->SetLineColor(kAzure-3); GetRawsData(23)->SetLineWidth(2);
+       }
      }
-     
-     TLine* diag = new TLine(7., 7., 1407., 1407.);
-     diag->SetLineColor(kRed);
-     diag->SetLineWidth(2);
-     
-     ((TH2F*)GetRawsData(6))->GetListOfFunctions()->Add(diag);
-     ((TH2F*)GetRawsData(7))->GetListOfFunctions()->Add(diag);
-     ((TH2F*)GetRawsData(8))->GetListOfFunctions()->Add(diag);
-     ((TH2F*)GetRawsData(9))->GetListOfFunctions()->Add(diag);
-
-     GetRawsData(6)->SetOption("colz");
-     GetRawsData(7)->SetOption("colz");
-     GetRawsData(8)->SetOption("colz");
-     GetRawsData(9)->SetOption("colz");  
-     
-     GetRawsData(4)->SetLineColor(kBlue+1);  GetRawsData(4)->SetLineWidth(2);
-     GetRawsData(5)->SetLineColor(kBlue+2);  GetRawsData(5)->SetLineWidth(2);
-     GetRawsData(10)->SetLineColor(kBlue+3); GetRawsData(10)->SetLineWidth(2);
-     GetRawsData(11)->SetLineColor(kBlue+4); GetRawsData(11)->SetLineWidth(2);
-     GetRawsData(12)->SetLineColor(kBlue+5); GetRawsData(12)->SetLineWidth(2);
-     GetRawsData(13)->SetLineColor(kBlue+6); GetRawsData(13)->SetLineWidth(2);
-     
-     GetRawsData(4)->SetDrawOption("LOGY");
-     GetRawsData(5)->SetDrawOption("LOGY");
-     GetRawsData(10)->SetDrawOption("LOGY");
-     GetRawsData(11)->SetDrawOption("LOGY");
-     GetRawsData(12)->SetDrawOption("LOGY");
-     GetRawsData(13)->SetDrawOption("LOGY");
-
   }
-       
+       
   AliQAChecker::Instance()->Run(AliQAv1::kZDC, task, list) ;  
 }
-