Reconstruction classes updated (all cabled channels included in reco object)
authorcoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 22 Jan 2008 14:28:31 +0000 (14:28 +0000)
committercoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 22 Jan 2008 14:28:31 +0000 (14:28 +0000)
ZDC/AliZDC.cxx
ZDC/AliZDCDigitizer.cxx
ZDC/AliZDCPreprocessor.cxx
ZDC/AliZDCReco.cxx
ZDC/AliZDCReco.h
ZDC/AliZDCReconstructor.cxx
ZDC/AliZDCReconstructor.h
ZDC/ZDCPEDESTALda.cxx

index a51537f..6ffe650 100644 (file)
@@ -534,8 +534,8 @@ void AliZDC::Digits2Raw()
     }
     // *** ADC2 (Reference PTMs) or ADC4 (Reference PTMs o.o.t.)
     else if(digit.GetSector(1)==5){
-      index = 20 + (digit.GetSector(0)-1)*1/3; 
-      lADCDataChannel = 5 + (digit.GetSector(0)-1)*8/3;
+      index = 20 + (digit.GetSector(0)-1)/3; 
+      lADCDataChannel = 5 + 8*(digit.GetSector(0)-1)/3;
       //
       /*printf("\t AliZDC::Digits2Raw -> idig%d det %d quad %d index %d, ADCch %d ADCVal[%d, %d]\n",
                iDigit,digit.GetSector(0),digit.GetSector(1),index,lADCDataChannel,
@@ -708,22 +708,20 @@ Int_t AliZDC::Pedestal(Int_t Det, Int_t Quad, Int_t Res) const
     return -1;
   }
   //
-  Float_t pedValue;
-  Float_t meanPed, pedWidth;
-    Int_t index=0;
-    if(Quad!=5){
-      if(Det==1)       index = Quad+24*Res;       // ZN1
-      else if(Det==2)  index = (Quad+5)+24*Res;           // ZP1
-      else if(Det==3)  index = (Quad+9)+24*Res; // ZEM
-      else if(Det==4)  index = (Quad+12)+24*Res; // ZN2
-      else if(Det==5)  index = (Quad+17)+24*Res; // ZP2
-    }
-    else index = (Det-1)/3+22+24*Res; // Reference PMs
+  Int_t index=0, kNch=24;
+  if(Quad!=5){
+    if(Det==1)        index = Quad+kNch*Res;    // ZN1
+    else if(Det==2)   index = Quad+5+kNch*Res;          // ZP1
+    else if(Det==3)   index = Quad+9+kNch*Res; // ZEM
+    else if(Det==4)   index = Quad+12+kNch*Res; // ZN2
+    else if(Det==5)   index = Quad+17+kNch*Res; // ZP2
+  }
+  else index = (Det-1)/3+22+kNch*Res; // Reference PMs
   //
   //
-  meanPed = calibPed->GetMeanPed(index);
-  pedWidth = calibPed->GetMeanPedWidth(index);
-  pedValue = gRandom->Gaus(meanPed,pedWidth);
+  Float_t meanPed = calibPed->GetMeanPed(index);
+  Float_t pedWidth = calibPed->GetMeanPedWidth(index);
+  Float_t pedValue = gRandom->Gaus(meanPed,pedWidth);
   //
   //printf("\t AliZDC::Pedestal - det(%d, %d) - Ped[%d] = %d\n",Det, Quad, index,(Int_t) pedValue); // Chiara debugging!
   
index 9e25c8a..6c651dd 100644 (file)
@@ -468,22 +468,20 @@ Int_t AliZDCDigitizer::Pedestal(Int_t Det, Int_t Quad, Int_t Res) const
   // Returns a pedestal for detector det, PM quad, channel with res.
   //
   Float_t pedValue;
-  
   // Normal run
   if(fIsCalibration == 0){
-    Float_t meanPed, pedWidth;
-    Int_t index=0;
+    Int_t index=0, kNch=24;
     if(Quad!=5){
-      if(Det==1)       index = Quad+24*Res;      // ZN1
-      else if(Det==2)  index = (Quad+5)+24*Res;  // ZP1
-      else if(Det==3)  index = (Quad+9)+24*Res;  // ZEM
-      else if(Det==4)  index = (Quad+12)+24*Res; // ZN2
-      else if(Det==5)  index = (Quad+17)+24*Res; // ZP2
+      if(Det==1)       index = Quad+kNch*Res;    // ZNC
+      else if(Det==2)  index = (Quad+5)+kNch*Res;  // ZPC
+      else if(Det==3)  index = (Quad+9)+kNch*Res;  // ZEM
+      else if(Det==4)  index = (Quad+12)+kNch*Res; // ZNA
+      else if(Det==5)  index = (Quad+17)+kNch*Res; // ZPA
     }
-    else index = (Det-1)/3+22+24*Res; // Reference PMs
+    else index = (Det-1)/3+22+kNch*Res; // Reference PMs
     //
-    meanPed = fPedData->GetMeanPed(index);
-    pedWidth = fPedData->GetMeanPedWidth(index);
+    Float_t meanPed = fPedData->GetMeanPed(index);
+    Float_t pedWidth = fPedData->GetMeanPedWidth(index);
     pedValue = gRandom->Gaus(meanPed,pedWidth);
     //
     /*printf("\t  AliZDCDigitizer::Pedestal -> det %d quad %d res %d - Ped[%d] = %d\n",
index 2da4757..527b8cd 100644 (file)
@@ -148,22 +148,22 @@ if(runType == "PEDESTAL_RUN"){
           return 1;
          }
          Log(Form("File %s connected to process pedestal data", pedFileName));
-         Float_t pedVal[(3*knZDCch)][2];
+         Float_t pedVal[(3*knZDCch)][3];
          for(Int_t i=0; i<(3*knZDCch); i++){
-            for(Int_t j=0; j<2; j++){
+            for(Int_t j=0; j<3; j++){
                fscanf(file,"%f",&pedVal[i][j]);
               //if(j==1) printf("pedVal[%d] -> %f, %f \n",i,pedVal[i][0],pedVal[i][1]);
             }
             if(i<knZDCch){
-              pedCalib->SetMeanPed(i,pedVal[i][0]);
-              pedCalib->SetMeanPedWidth(i,pedVal[i][1]);
+              pedCalib->SetMeanPed(i,pedVal[i][1]);
+              pedCalib->SetMeanPedWidth(i,pedVal[i][2]);
             }
             else if(i>=knZDCch && i<(2*knZDCch)){
-              pedCalib->SetOOTPed(i-knZDCch,pedVal[i][0]);
-              pedCalib->SetOOTPedWidth(i-knZDCch,pedVal[i][1]);
+              pedCalib->SetOOTPed(i-knZDCch,pedVal[i][1]);
+              pedCalib->SetOOTPedWidth(i-knZDCch,pedVal[i][2]);
             }
             else if(i>=(2*knZDCch) && i<(3*knZDCch)){
-              pedCalib->SetPedCorrCoeff(i-(2*knZDCch),pedVal[i][0],pedVal[i][1]);
+              pedCalib->SetPedCorrCoeff(i-(2*knZDCch),pedVal[i][1],pedVal[i][2]);
             }
          }
        }
index 62a86bf..480ecef 100644 (file)
@@ -32,13 +32,6 @@ ClassImp(AliZDCReco)
 AliZDCReco::AliZDCReco() :
        
   TObject(),
-  fZN1Energy(0),
-  fZP1Energy(0),
-  fZN2Energy(0),
-  fZP2Energy(0),
-  //
-  fZEM1signal(0),
-  fZEM2signal(0),
   //
   fNDetSpecNLeft(0),
   fNDetSpecPLeft(0),
@@ -58,43 +51,30 @@ AliZDCReco::AliZDCReco() :
   //
   // Default constructor
   //
-  for(Int_t i=0; i<5; i++){
-     fZN1EnTow[i] = 0;
-     fZP1EnTow[i] = 0;
-     fZN2EnTow[i] = 0;
-     fZP2EnTow[i] = 0;
-     fZN1SigLowRes[i] = 0;
-     fZP1SigLowRes[i] = 0;
-     fZN2SigLowRes[i] = 0;
-     fZP2SigLowRes[i] = 0;
-     
+  for(Int_t i=0; i<10; i++){
+     fZN1EnTow[i] = fZP1EnTow[i] = fZN2EnTow[i] = fZP2EnTow[i] = 0.;
+     if(i<2){
+       fZN1Energy[i] = fZP1Energy[i] = fZN2Energy[i] = fZP2Energy[i] =  0.;
+       fZEM1signal[i] = fZEM2signal[i] = 0.;
+       fPMRef1[i] = fPMRef2[i] = 0.;
+     }
   }
 }
   
 
 //_____________________________________________________________________________
-AliZDCReco::AliZDCReco(Float_t ezn1, Float_t ezp1, Float_t ezn2, Float_t ezp2,  
-            //
+AliZDCReco::AliZDCReco(Float_t* ezn1, Float_t* ezp1, Float_t* ezn2, Float_t* ezp2,  
             Float_t* ezn1tow, Float_t* ezp1tow,
             Float_t* ezn2tow, Float_t* ezp2tow, 
-            Float_t* ezn1siglr, Float_t* ezp1siglr,
-            Float_t* ezn2siglr, Float_t* ezp2siglr,
-            Float_t ezem1, Float_t ezem2,
+            Float_t* ezem1, Float_t* ezem2, 
+            Float_t* ref1, Float_t* ref2, 
             //    
-            Int_t detspnLeft,  Int_t detsppLeft, Int_t detspnRight,
-            Int_t detsppRight,  Int_t trspnLeft, Int_t trsppLeft, 
-            Int_t trspLeft, Int_t partLeft, Int_t trspnRight, 
-            Int_t trsppRight, Int_t trspRight, Int_t partRight,  
-            Float_t b) :
+            Int_t detspnLeft,  Int_t detsppLeft, Int_t detspnRight, Int_t detsppRight,  
+            Int_t trspnLeft, Int_t trsppLeft, Int_t trspLeft, 
+            Int_t trspnRight, Int_t trsppRight, Int_t trspRight,
+            Int_t partLeft, Int_t partRight, Float_t b) :
        
   TObject(),
-  fZN1Energy(ezn1),
-  fZP1Energy(ezp1),
-  fZN2Energy(ezn2),
-  fZP2Energy(ezp2),
-  //
-  fZEM1signal(ezem1),
-  fZEM2signal(ezem2),
   //
   fNDetSpecNLeft(detspnLeft),
   fNDetSpecPLeft(detsppLeft),
@@ -114,15 +94,21 @@ AliZDCReco::AliZDCReco(Float_t ezn1, Float_t ezp1, Float_t ezn2, Float_t ezp2,
   //
   // Constructor
   //
-  for(Int_t j=0; j<5; j++){
+  for(Int_t j=0; j<10; j++){
      fZN1EnTow[j] =  ezn1tow[j];
      fZP1EnTow[j] =  ezp1tow[j];
      fZN2EnTow[j] =  ezn2tow[j];
      fZP2EnTow[j] =  ezp2tow[j];
-     fZN1SigLowRes[j] = ezn1siglr[j];
-     fZP1SigLowRes[j] = ezp1siglr[j];
-     fZN2SigLowRes[j] = ezn2siglr[j];
-     fZP2SigLowRes[j] = ezp2siglr[j];
+     if(j<2){
+       fZN1Energy[j] = ezn1[j];
+       fZP1Energy[j] = ezp1[j];
+       fZN2Energy[j] = ezn2[j];
+       fZP2Energy[j] = ezp2[j];
+       fZEM1signal[j] = ezem1[j];
+       fZEM2signal[j] = ezem2[j];
+       fPMRef1[j] = ref1[j];
+       fPMRef2[j] = ref2[j];
+     }
   }
   
 }
@@ -134,24 +120,34 @@ AliZDCReco::AliZDCReco(const AliZDCReco &oldreco) :
 {
   // Copy constructor
 
-  fZN1Energy  = oldreco.GetZN1Energy();
-  fZP1Energy  = oldreco.GetZP1Energy();            
-  fZN2Energy  = oldreco.GetZN2Energy();           
-  fZP2Energy  = oldreco.GetZP2Energy();           
+  fZN1Energy[0]  = oldreco.GetZN1HREnergy();
+  fZP1Energy[0]  = oldreco.GetZP1HREnergy();           
+  fZN2Energy[0]  = oldreco.GetZN2HREnergy();        
+  fZP2Energy[0]  = oldreco.GetZP2HREnergy();    
+  //    
+  fZN1Energy[1]  = oldreco.GetZN1LREnergy();
+  fZP1Energy[1]  = oldreco.GetZP1LREnergy();          
+  fZN2Energy[1]  = oldreco.GetZN2LREnergy();       
+  fZP2Energy[1]  = oldreco.GetZP2LREnergy();       
   //
   for(Int_t i=0; i<5; i++){      
-     fZN1EnTow[i]  = oldreco.GetZN1EnTow(i);
-     fZP1EnTow[i]  = oldreco.GetZP1EnTow(i);
-     fZN2EnTow[i]  = oldreco.GetZN2EnTow(i);
-     fZP2EnTow[i]  = oldreco.GetZP2EnTow(i);
-     fZN1SigLowRes[i] = oldreco.GetZN1SigLowRes(i);
-     fZP1SigLowRes[i] = oldreco.GetZP1SigLowRes(i);
-     fZN2SigLowRes[i] = oldreco.GetZN2SigLowRes(i);
-     fZP2SigLowRes[i] = oldreco.GetZP2SigLowRes(i);
+     fZN1EnTow[i]  = oldreco.GetZN1HREnTow(i);
+     fZP1EnTow[i]  = oldreco.GetZP1HREnTow(i);
+     fZN2EnTow[i]  = oldreco.GetZN2HREnTow(i);
+     fZP2EnTow[i]  = oldreco.GetZP2HREnTow(i);
+     fZN1EnTow[i+5]  = oldreco.GetZN1LREnTow(i);
+     fZP1EnTow[i+5]  = oldreco.GetZP1LREnTow(i);
+     fZN2EnTow[i+5]  = oldreco.GetZN2LREnTow(i);
+     fZP2EnTow[i+5]  = oldreco.GetZP2LREnTow(i);
   }
-  //
-  fZEM1signal = oldreco.GetZEM1signal();       
-  fZEM2signal = oldreco.GetZEM2signal();       
+  fZEM1signal[0] = oldreco.GetZEM1HRsignal();
+  fZEM1signal[1] = oldreco.GetZEM1LRsignal();
+  fZEM2signal[0] = oldreco.GetZEM2HRsignal();
+  fZEM2signal[1] = oldreco.GetZEM2LRsignal();
+  fPMRef1[0] = oldreco.GetPMRef1HRsignal();
+  fPMRef1[1] = oldreco.GetPMRef1LRsignal();
+  fPMRef2[0] = oldreco.GetPMRef2HRsignal();
+  fPMRef2[1] = oldreco.GetPMRef2LRsignal();
   //   
   fNDetSpecNLeft = oldreco.GetNDetSpecNLeft(); 
   fNDetSpecPLeft = oldreco.GetNDetSpecPLeft(); 
@@ -180,7 +176,8 @@ void AliZDCReco::Print(Option_t *) const {
         " \t NDetSpecNRight = %d, NDetSpecPRight = %d, NspecnRight = %d,"
         " NspecpRight = %d, NpartRight = %d"
         " \t b = %f fm\n ", 
-        fZN1Energy,fZP1Energy,fZEM1signal,fZEM2signal, fZN2Energy, fZP2Energy,
+        fZN1Energy[0],fZP1Energy[0],fZEM1signal[0],fZEM2signal[0], 
+        fZN2Energy[0], fZP2Energy[0],
         fNDetSpecNLeft,fNDetSpecPLeft,fNTrueSpecNLeft,fNTrueSpecPLeft,fNPartLeft,
         fNDetSpecNRight,fNDetSpecPRight,fNTrueSpecNRight,fNTrueSpecPRight,fNPartRight,
         fImpPar);
index b836cae..0951f74 100644 (file)
@@ -13,40 +13,48 @@ class AliZDCReco : public TObject {
 
 public:
   AliZDCReco();
-  AliZDCReco(Float_t ezn1, Float_t ezp1, Float_t ezn2, Float_t ezp2,  
-            Float_t* ezn1tow, Float_t* ezp1tow,
-            Float_t* ezn2tow, Float_t* ezp2tow, 
-            Float_t* ezn1siglr, Float_t* ezp1siglr,
-            Float_t* ezn2siglr, Float_t* ezp2siglr,
-            Float_t ezem1, Float_t ezem2, 
+  AliZDCReco(Float_t* ezn1, Float_t* ezp1, Float_t* ezn2, Float_t* ezp2,  
+            Float_t* ezn1tow, Float_t* ezp1tow, Float_t* ezn2tow, Float_t* ezp2tow, 
+            Float_t* ezem1, Float_t* ezem2, Float_t* ref1, Float_t* ref2, 
             //    
             Int_t detspnLeft,  Int_t detsppLeft, Int_t detspnRight, Int_t detsppRight,  
             Int_t trspnLeft, Int_t trsppLeft, Int_t trspLeft, 
             Int_t trspnRight, Int_t trsppRight, Int_t trspRight,
-            Int_t partLeft, Int_t partRight,  
-            Float_t b);
+            Int_t partLeft, Int_t partRight, Float_t b);
 
   AliZDCReco(const AliZDCReco &oldreco);
   virtual ~AliZDCReco() {}
 
   // Getters 
-  virtual Float_t GetZN1Energy()   const  {return fZN1Energy;}
-  virtual Float_t GetZP1Energy()   const  {return fZP1Energy;}
-  virtual Float_t GetZN2Energy()   const  {return fZN2Energy;}
-  virtual Float_t GetZP2Energy()   const  {return fZP2Energy;}
+  virtual Float_t GetZN1HREnergy()   const  {return fZN1Energy[0];}
+  virtual Float_t GetZP1HREnergy()   const  {return fZP1Energy[0];}
+  virtual Float_t GetZN2HREnergy()   const  {return fZN2Energy[0];}
+  virtual Float_t GetZP2HREnergy()   const  {return fZP2Energy[0];}
   //
-  virtual Float_t GetZN1EnTow(Int_t tow)  const {return fZN1EnTow[tow];}
-  virtual Float_t GetZP1EnTow(Int_t tow)  const {return fZP1EnTow[tow];}
-  virtual Float_t GetZN2EnTow(Int_t tow)  const {return fZN2EnTow[tow];}
-  virtual Float_t GetZP2EnTow(Int_t tow)  const {return fZP2EnTow[tow];}
+  virtual Float_t GetZN1LREnergy()   const  {return fZN1Energy[1];}
+  virtual Float_t GetZP1LREnergy()   const  {return fZP1Energy[1];}
+  virtual Float_t GetZN2LREnergy()   const  {return fZN2Energy[1];}
+  virtual Float_t GetZP2LREnergy()   const  {return fZP2Energy[1];}
   //
-  virtual Float_t GetZN1SigLowRes(Int_t tow)  const {return fZN1SigLowRes[tow];}
-  virtual Float_t GetZP1SigLowRes(Int_t tow)  const {return fZP1SigLowRes[tow];}
-  virtual Float_t GetZN2SigLowRes(Int_t tow)  const {return fZN2SigLowRes[tow];}
-  virtual Float_t GetZP2SigLowRes(Int_t tow)  const {return fZP2SigLowRes[tow];}
+  virtual Float_t GetZN1HREnTow(Int_t tow)  const {return fZN1EnTow[tow];}
+  virtual Float_t GetZP1HREnTow(Int_t tow)  const {return fZP1EnTow[tow];}
+  virtual Float_t GetZN2HREnTow(Int_t tow)  const {return fZN2EnTow[tow];}
+  virtual Float_t GetZP2HREnTow(Int_t tow)  const {return fZP2EnTow[tow];}
   //
-  virtual Float_t GetZEM1signal()   const  {return fZEM1signal;}
-  virtual Float_t GetZEM2signal()   const  {return fZEM2signal;}
+  virtual Float_t GetZN1LREnTow(Int_t tow)  const {return fZN1EnTow[tow+5];}
+  virtual Float_t GetZP1LREnTow(Int_t tow)  const {return fZP1EnTow[tow+5];}
+  virtual Float_t GetZN2LREnTow(Int_t tow)  const {return fZN2EnTow[tow+5];}
+  virtual Float_t GetZP2LREnTow(Int_t tow)  const {return fZP2EnTow[tow+5];}
+  //
+  virtual Float_t GetZEM1HRsignal()   const  {return fZEM1signal[0];}
+  virtual Float_t GetZEM1LRsignal()   const  {return fZEM1signal[1];}
+  virtual Float_t GetZEM2HRsignal()   const  {return fZEM2signal[0];}
+  virtual Float_t GetZEM2LRsignal()   const  {return fZEM2signal[1];}
+  //
+  virtual Float_t GetPMRef1HRsignal()   const  {return fZEM1signal[0];}
+  virtual Float_t GetPMRef1LRsignal()   const  {return fZEM1signal[1];}
+  virtual Float_t GetPMRef2HRsignal()   const  {return fZEM2signal[0];}
+  virtual Float_t GetPMRef2LRsignal()   const  {return fZEM2signal[1];}
   //
   virtual Int_t   GetNDetSpecNLeft()   const {return fNDetSpecNLeft;}
   virtual Int_t   GetNDetSpecPLeft()   const {return fNDetSpecPLeft;}
@@ -67,23 +75,21 @@ public:
 
 private:
   // Data members
-  Float_t fZN1Energy;  // Energy detected in ZN1 (sum of 5 tower signals)
-  Float_t fZP1Energy;  // Energy detected in ZP1 (sum of 5 tower signals)
-  Float_t fZN2Energy;  // Energy detected in ZN2 (sum of 5 tower signals)
-  Float_t fZP2Energy;  // Energy detected in ZP2 (sum of 5 tower signals)
+  Float_t fZN1Energy[2];        // Energy detected in ZN1 (sum of 5 tower signals)
+  Float_t fZP1Energy[2];        // Energy detected in ZP1 (sum of 5 tower signals)
+  Float_t fZN2Energy[2];        // Energy detected in ZN2 (sum of 5 tower signals)
+  Float_t fZP2Energy[2];        // Energy detected in ZP2 (sum of 5 tower signals)
   //
-  Float_t fZN1EnTow[5];        // Energy in ZN1 towers
-  Float_t fZP1EnTow[5]; // Energy in ZP1 towers
-  Float_t fZN2EnTow[5];        // Energy in ZN2 towers
-  Float_t fZP2EnTow[5]; // Energy in ZP2 towers
+  Float_t fZN1EnTow[10]; // Energy in ZN1 towers
+  Float_t fZP1EnTow[10]; // Energy in ZP1 towers
+  Float_t fZN2EnTow[10]; // Energy in ZN2 towers
+  Float_t fZP2EnTow[10]; // Energy in ZP2 towers
   //
-  Float_t fZN1SigLowRes[5]; // Energy in ZN1 towers - low res ch.
-  Float_t fZP1SigLowRes[5]; // Energy in ZP1 towers - low res ch.
-  Float_t fZN2SigLowRes[5]; // Energy in ZN2 towers - low res ch.
-  Float_t fZP2SigLowRes[5]; // Energy in ZP2 towers - low res ch.
+  Float_t fZEM1signal[2];// Signal in EM1 ZDC
+  Float_t fZEM2signal[2];// Signal in EM2 ZDC
   //
-  Float_t fZEM1signal; // Signal in EM1 ZDC
-  Float_t fZEM2signal; // Signal in EM2 ZDC
+  Float_t fPMRef1[2];   // Reference PM side C
+  Float_t fPMRef2[2];   // Reference PM side A
   //
   Int_t          fNDetSpecNLeft;  // Number of spectator neutrons detected
   Int_t          fNDetSpecPLeft;  // Number of spectator protons detected
@@ -100,7 +106,7 @@ private:
   Float_t fImpPar;     // Estimate of the impact parameter
 
 
-  ClassDef(AliZDCReco,4)  // RecPoints for the Zero Degree Calorimeters
+  ClassDef(AliZDCReco,5)  // RecPoints for the Zero Degree Calorimeters
 };
  
 #endif
index a68a840..f77bca1 100644 (file)
@@ -108,94 +108,102 @@ void AliZDCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) co
   AliZDCDigit digit;
   AliZDCDigit* pdigit = &digit;
   digitsTree->SetBranchAddress("ZDC", &pdigit);
+  //printf("\n\t # of digits in tree: %d\n",(Int_t) digitsTree->GetEntries());
 
   // loop over digits
-  Float_t tZN1CorrHG[]={0.,0.,0.,0.,0.}, tZP1CorrHG[]={0.,0.,0.,0.,0.}; 
-  Float_t dZEM1CorrHG=0., dZEM2CorrHG=0.; 
-  Float_t tZN2CorrHG[]={0.,0.,0.,0.,0.}, tZP2CorrHG[]={0.,0.,0.,0.,0.};
-  Float_t tZN1CorrLG[]={0.,0.,0.,0.,0.}, tZP1CorrLG[]={0.,0.,0.,0.,0.};
-  Float_t dZEM1CorrLG=0., dZEM2CorrLG=0.; 
-  Float_t tZN2CorrLG[]={0.,0.,0.,0.,0.}, tZP2CorrLG[]={0.,0.,0.,0.,0.};
-  
-  //printf("\n\t # of digits in tree: %d\n",(Int_t) digitsTree->GetEntries());
+  Float_t tZN1Corr[10], tZP1Corr[10], tZN2Corr[10], tZP2Corr[10]; 
+  Float_t dZEM1Corr[2], dZEM2Corr[2], PMRef1[2], PMRef2[2]; 
+  for(Int_t i=0; i<10; i++){
+     tZN1Corr[i] = tZP1Corr[i] = tZN2Corr[i] = tZP2Corr[i] = 0.;
+     if(i<2) dZEM1Corr[i] = dZEM2Corr[i] = PMRef1[i] = PMRef2[i] = 0.;
+  }  
+  //
   for (Int_t iDigit = 0; iDigit < (digitsTree->GetEntries()/2); iDigit++) {
    digitsTree->GetEntry(iDigit);
    if (!pdigit) continue;
-   //pdigit->Print("");
    //  
    Int_t det = digit.GetSector(0);
    Int_t quad = digit.GetSector(1);
-   Int_t pedindex = -1;
+   Int_t pedindex = -1, kNch = 24;
    //printf("\n\t Digit #%d det %d quad %d", iDigit, det, quad);
    //
    if(quad != 5){ // ZDC (not reference PTMs!)
-    if(det == 1){ // *** ZN1
+    if(det == 1){ // *** ZNC
        pedindex = quad;
-       tZN1CorrHG[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
-       if(tZN1CorrHG[quad]<0.) tZN1CorrHG[quad] = 0.;
-       tZN1CorrLG[quad] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+24]);
-       if(tZN1CorrLG[quad]<0.) tZN1CorrLG[quad] = 0.;
-       //printf("\t pedindex %d tZN1CorrHG[%d] = %1.0f tZN1CorrLG[%d] = %1.0f", 
-       //      pedindex, quad, tZN1CorrHG[quad], quad, tZN1CorrLG[quad]);
+       tZN1Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+       if(tZN1Corr[quad]<0.) tZN1Corr[quad] = 0.;
+       tZN1Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+       if(tZN1Corr[quad+5]<0.) tZN1Corr[quad] = 0.;
+       //printf("\t pedindex %d tZN1Corr[%d] = %1.0f tZN1Corr[%d] = %1.0f", 
+       //      pedindex, quad, tZN1Corr[quad], quad+5, tZN1Corr[quad+5]);
     }
     else if(det == 2){ // *** ZP1
        pedindex = quad+5;
-       tZP1CorrHG[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
-       if(tZP1CorrLG[quad]<0.) tZP1CorrLG[quad] = 0.;
-       tZP1CorrLG[quad] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+24]);
-       if(tZP1CorrHG[quad]<0.) tZP1CorrHG[quad] = 0.;
-       //printf("\t pedindex %d tZP1CorrHG[%d] = %1.0f tZP1CorrLG[%d] = %1.0f", 
-       //      pedindex, quad, tZP1CorrHG[quad], quad, tZP1CorrLG[quad]);
+       tZP1Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+       if(tZP1Corr[quad]<0.) tZP1Corr[quad] = 0.;
+       tZP1Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+       if(tZP1Corr[quad+5]<0.) tZP1Corr[quad] = 0.;
+       //printf("\t pedindex %d tZP1Corr[%d] = %1.0f tZP1Corr[%d] = %1.0f", 
+       //      pedindex, quad, tZP1Corr[quad], quad+5, tZP1Corr[quad+5]);
     }
     else if(det == 3){
+       pedindex = quad+9;
        if(quad == 1){      // *** ZEM1  
-        pedindex = quad+9;
-         dZEM1CorrHG += (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]); 
-         if(dZEM1CorrHG<0.) dZEM1CorrHG = 0.;
-         dZEM1CorrLG += (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+24]); 
-         if(dZEM1CorrLG<0.) dZEM1CorrLG = 0.;
-         //printf("\t pedindex %d ADC(0) = %d ped = %1.0f ADCCorr = %1.0f\n", 
-        //     pedindex, digit.GetADCValue(0), meanPed[pedindex], dZEM1CorrHG);
-         //printf("\t pedindex %d ADC(1) = %d ped = %1.0f ADCCorr = %1.0f\n", 
-        //     pedindex+24, digit.GetADCValue(1), meanPed[pedindex+24], dZEM1CorrLG);
+         dZEM1Corr[0] += (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]); 
+         if(dZEM1Corr[0]<0.) dZEM1Corr[0] = 0.;
+         dZEM1Corr[1] += (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]); 
+         if(dZEM1Corr[1]<0.) dZEM1Corr[1] = 0.;
+         //printf("\t pedindex %d tZEM1Corr[%d] = %1.0f tZEM1Corr[%d] = %1.0f", 
+         //    pedindex, quad, tZEM1Corr[quad], quad+1, tZEM1Corr[quad+1]);
        }
        else if(quad == 2){  // *** ZEM2
-        pedindex = quad+9;
-         dZEM2CorrHG += (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]); 
-         if(dZEM2CorrHG<0.) dZEM2CorrHG = 0.;
-         dZEM2CorrLG += (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+24]); 
-         if(dZEM2CorrLG<0.) dZEM2CorrLG = 0.;
-         //printf("\t pedindex %d ADC(0) = %d ped = %1.0f ADCCorr = %1.0f\n", 
-        //     pedindex, digit.GetADCValue(0), meanPed[pedindex], dZEM2CorrHG);
-         //printf("\t pedindex %d ADC(1) = %d ped = %1.0f ADCCorr = %1.0f\n", 
-        //     pedindex+2, digit.GetADCValue(1),meanPed[pedindex+2], dZEM2CorrLG);
+         dZEM2Corr[0] += (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]); 
+         if(dZEM2Corr[0]<0.) dZEM2Corr[0] = 0.;
+         dZEM2Corr[1] += (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]); 
+         if(dZEM2Corr[1]<0.) dZEM2Corr[1] = 0.;
+         //printf("\t pedindex %d tZEM2Corr[%d] = %1.0f tZEM2Corr[%d] = %1.0f", 
+         //    pedindex, quad, tZEM2Corr[quad], quad+1, tZEM2Corr[quad+1]);
        }
     }
     else if(det == 4){  // *** ZN2
        pedindex = quad+12;
-       tZN2CorrHG[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
-       if(tZN2CorrHG[quad]<0.) tZN2CorrHG[quad] = 0.;
-       tZN2CorrLG[quad] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+24]);
-       if(tZN2CorrLG[quad]<0.) tZN2CorrLG[quad] = 0.;
-       //printf("\t pedindex %d tZN2CorrHG[%d] = %1.0f tZN2CorrLG[%d] = %1.0f\n", 
-       //      pedindex, quad, tZN2CorrHG[quad], quad, tZN2CorrLG[quad]);
+       tZN2Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+       if(tZN2Corr[quad]<0.) tZN2Corr[quad] = 0.;
+       tZN2Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+       if(tZN2Corr[quad+5]<0.) tZN2Corr[quad+5] = 0.;
+       //printf("\t pedindex %d tZN2Corr[%d] = %1.0f tZN2Corr[%d] = %1.0f\n", 
+       //      pedindex, quad, tZN2Corr[quad], quad+5, tZN2Corr[quad+5]);
     }
     else if(det == 5){  // *** ZP2 
        pedindex = quad+17;
-       tZP2CorrHG[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
-       if(tZP2CorrHG[quad]<0.) tZP2CorrHG[quad] = 0.;
-       tZP2CorrLG[quad] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+24]);
-       if(tZP2CorrLG[quad]<0.) tZP2CorrLG[quad] = 0.;
-       //printf("\t pedindex %d tZP2CorrHG[%d] = %1.0f tZP2CorrLG[%d] = %1.0f\n", 
-       //      pedindex, quad, tZP2CorrHG[quad], quad, tZP2CorrLG[quad]);
+       tZP2Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+       if(tZP2Corr[quad]<0.) tZP2Corr[quad] = 0.;
+       tZP2Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+       if(tZP2Corr[quad+5]<0.) tZP2Corr[quad+5] = 0.;
+       //printf("\t pedindex %d tZP2Corr[%d] = %1.0f tZP2Corr[%d] = %1.0f\n", 
+       //      pedindex, quad, tZP2Corr[quad], quad+5, tZP2Corr[quad+5]);
     }
    }
+   else{ // Reference PMs
+     pedindex = (det-1)/3+22;
+     if(det == 1){
+       PMRef1[0] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+       if(PMRef1[0]<0.) PMRef1[0] = 0.;
+       PMRef1[1] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+       if(PMRef2[1]<0.) PMRef1[1] = 0.;
+     }
+     else if(det == 4){
+       PMRef2[0] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+       if(PMRef2[0]<0.) PMRef2[0] = 0.;
+       PMRef2[1] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+       if(PMRef2[1]<0.) PMRef2[1] = 0.;
+     }
+   }
   }
 
   // reconstruct the event
-    ReconstructEvent(clustersTree, tZN1CorrHG, tZP1CorrHG, tZN2CorrHG, 
-       tZP2CorrHG, tZN1CorrLG, tZP1CorrLG, tZN2CorrLG, 
-       tZP2CorrLG, dZEM1CorrHG, dZEM2CorrHG);
+    ReconstructEvent(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr, 
+       dZEM1Corr, dZEM2Corr, PMRef1, PMRef2);
 
 }
 
@@ -211,15 +219,16 @@ void AliZDCReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTr
 
   rawReader->Reset();
 
-  // loop over raw data rawDatas
-  Float_t tZN1CorrHG[]={0.,0.,0.,0.,0.}, tZP1CorrHG[]={0.,0.,0.,0.,0.};
-  Float_t dZEM1CorrHG=0., dZEM2CorrHG=0.;
-  Float_t tZN2CorrHG[]={0.,0.,0.,0.,0.}, tZP2CorrHG[]={0.,0.,0.,0.,0.};
-  Float_t tZN1CorrLG[]={0.,0.,0.,0.,0.}, tZP1CorrLG[]={0.,0.,0.,0.,0.};
-  Float_t dZEM1CorrLG=0., dZEM2CorrLG=0.; 
-  Float_t tZN2CorrLG[]={0.,0.,0.,0.,0.}, tZP2CorrLG[]={0.,0.,0.,0.,0.};
+  // loop over raw data
+  Float_t tZN1Corr[10], tZP1Corr[10], tZN2Corr[10], tZP2Corr[10]; 
+  Float_t dZEM1Corr[2], dZEM2Corr[2], PMRef1[2], PMRef2[2]; 
+  for(Int_t i=0; i<10; i++){
+     tZN1Corr[i] = tZP1Corr[i] = tZN2Corr[i] = tZP2Corr[i] = 0.;
+     if(i<2) dZEM1Corr[i] = dZEM2Corr[i] = PMRef1[i] = PMRef2[i] = 0.;
+  }  
   //
   AliZDCRawStream rawData(rawReader);
+  Int_t kNch = 24;
   while (rawData.Next()) {
     if(rawData.IsADCDataWord()){
      Int_t det = rawData.GetSector(0);
@@ -230,98 +239,65 @@ void AliZDCReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTr
      if(quad !=5){ // ZDCs (not reference PTMs)
       if(det == 1){    
         pedindex = quad;
-        if(gain == 0) tZN1CorrHG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
-        else tZN1CorrLG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+24]); 
+        if(gain == 0) tZN1Corr[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+        else tZN1Corr[quad+5]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]); 
       }
       else if(det == 2){ 
         pedindex = quad+5;
-        if(gain == 0) tZP1CorrHG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
-        else tZP1CorrLG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+24]); 
+        if(gain == 0) tZP1Corr[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+        else tZP1Corr[quad+5]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]); 
       }
       else if(det == 3){ 
+        pedindex = quad+9;
         if(quad==1){    
-          pedindex = quad+9;
-          if(gain == 0) dZEM1CorrHG += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
-          else dZEM1CorrLG += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+24]); 
+          if(gain == 0) dZEM1Corr[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+          else dZEM1Corr[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]); 
         }
         else if(quad==2){ 
-          pedindex = quad+9;
-          if(gain == 0) dZEM2CorrHG += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
-          else dZEM2CorrLG += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+24]); 
+          if(gain == 0) dZEM2Corr[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+          else dZEM2Corr[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]); 
         }
       }
       else if(det == 4){       
         pedindex = quad+12;
-        if(gain == 0) tZN2CorrHG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
-        else tZN2CorrLG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+24]); 
+        if(gain == 0) tZN2Corr[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+        else tZN2Corr[quad+5]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]); 
       }
       else if(det == 5){
         pedindex = quad+17;
-        if(gain == 0) tZP2CorrHG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
-        else tZP2CorrLG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+24]); 
+        if(gain == 0) tZP2Corr[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+        else tZP2Corr[quad+5]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]); 
       }
-      printf("\t AliZDCReconstructor - det %d quad %d res %d -> Ped[%d] = %1.0f\n", 
-        det,quad,gain, pedindex, meanPed[pedindex]);
+      //printf("\t AliZDCReconstructor - det %d quad %d res %d -> Ped[%d] = %1.0f\n", 
+      //  det,quad,gain, pedindex, meanPed[pedindex]);
+     }
+     else{ // reference PM
+       pedindex = (det-1)/3 + 22;
+       if(det == 1){
+         if(gain==0) PMRef1[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
+        else PMRef1[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
+       }
+       else if(det ==4){
+         if(gain==0) PMRef2[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
+        else PMRef2[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
+       }
      }
     }//IsADCDataWord
   }
     
   // reconstruct the event
-    ReconstructEvent(clustersTree, tZN1CorrHG, tZP1CorrHG, tZN2CorrHG, 
-       tZP2CorrHG, tZN1CorrLG, tZP1CorrLG, tZN2CorrLG, 
-       tZP2CorrLG, dZEM1CorrHG, dZEM2CorrHG);
+    ReconstructEvent(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr, 
+       dZEM1Corr, dZEM2Corr, PMRef1, PMRef2);
 
 }
 
 //_____________________________________________________________________________
-void AliZDCReconstructor::ReconstructEvent(TTree *clustersTree, 
-               Float_t* ZN1ADCCorrHG, Float_t* ZP1ADCCorrHG, 
-               Float_t* ZN2ADCCorrHG, Float_t* ZP2ADCCorrHG, 
-               Float_t* ZN1ADCCorrLG, Float_t* ZP1ADCCorrLG, 
-               Float_t* ZN2ADCCorrLG, Float_t* ZP2ADCCorrLG, 
-               Float_t corrADCZEM1HG, Float_t corrADCZEM2HG) const
+void AliZDCReconstructor::ReconstructEvent(TTree *clustersTree, Float_t* ZN1ADCCorr, 
+       Float_t* ZP1ADCCorr, Float_t* ZN2ADCCorr, Float_t* ZP2ADCCorr,
+       Float_t* ZEM1ADCCorr, Float_t* ZEM2ADCCorr, Float_t* PMRef1, Float_t* PMRef2) const
 {
   // ***** Reconstruct one event
   
-  // *** RECONSTRUCTION FROM SIMULATED DATA
-  // It passes trhough the no. of phe which is known from simulations
-  //  ---      ADCchannel -> photoelectrons
-  // NB-> PM gain = 10^(5), ADC resolution = 6.4*10^(-7)
-  // Move to V965 (E.S.,15/09/04) NB-> PM gain = 10^(5), ADC resolution = 8*10^(-7)
-  //Float_t zn1phe, zp1phe, zemphe, zn2phe, zp2phe, convFactor = 0.08;
-  //zn1phe  = ZN1Corr/convFactor;
-  //zp1phe  = ZP1Corr/convFactor;
-  //zemphe = ZEMCorr/convFactor;
-  //zn2phe  = ZN2Corr/convFactor;
-  //zp2phe  = ZP2Corr/convFactor;
-  ////if AliDebug(1,Form("\n    znphe = %f, zpphe = %f, zemphe = %f\n",znphe, zpphe, zemphe);
-  //
-  ////  ---      Energy calibration
-  //// Conversion factors for hadronic ZDCs goes from phe yield to TRUE 
-  //// incident energy (conversion from GeV to TeV is included); while for EM 
-  //// calos conversion is from light yield to detected energy calculated by
-  //// GEANT NB -> ZN and ZP conversion factors are constant since incident
-  //// spectators have all the same energy, ZEM energy is obtained through a
-  //// fit over the whole range of incident particle energies 
-  //// (obtained with full HIJING simulations) 
-  //Float_t zn1energy, zp1energy, zemenergy, zdc1energy, zn2energy, zp2energy, zdc2energy;
-  //Float_t zn1phexTeV=329., zp1phexTeV=369., zn2phexTeV=329., zp2phexTeV=369.;
-  //zn1energy  = zn1phe/zn1phexTeV;
-  //zp1energy  = zp1phe/zp1phexTeV;
-  //zdc1energy = zn1energy+zp1energy;
-  //zn2energy  = zn2phe/zn2phexTeV;
-  //zp2energy  = zp2phe/zp2phexTeV;
-  //zdc2energy = zn2energy+zp2energy;
-  //zemenergy = -4.81+0.3238*zemphe;
-  //if(zemenergy<0) zemenergy=0;
-  ////  if AliDebug(1,Form("    znenergy = %f TeV, zpenergy = %f TeV, zdcenergy = %f GeV, "
-  ////                    "\n          zemenergy = %f TeV\n", znenergy, zpenergy, 
-  ////                    zdcenergy, zemenergy);
-  ////  if(zdcenergy==0)
-  ////    if AliDebug(1,Form("\n\n     ###     ATTENZIONE!!! -> ev# %d: znenergy = %f TeV, zpenergy = %f TeV, zdcenergy = %f GeV, "
-  ////                      " zemenergy = %f TeV\n\n", fMerger->EvNum(), znenergy, zpenergy, zdcenergy, zemenergy); 
-  
-  //
   // *** RECONSTRUCTION FROM "REAL" DATA
   //
   // Retrieving calibration data
@@ -347,63 +323,56 @@ void AliZDCReconstructor::ReconstructEvent(TTree *clustersTree,
   Float_t supValueZEM = cutValueZEM+(endPointZEM*dZEMSup);
   Float_t infValueZEM = cutValueZEM-(endPointZEM*dZEMInf);
   //
-  Float_t maxValEZN1 = fRecParam->GetEZN1MaxValue();
-  Float_t maxValEZP1 = fRecParam->GetEZP1MaxValue();
+  Float_t maxValEZN1  = fRecParam->GetEZN1MaxValue();
+  Float_t maxValEZP1  = fRecParam->GetEZP1MaxValue();
   Float_t maxValEZDC1 = fRecParam->GetEZDC1MaxValue();
-  Float_t maxValEZN2 = fRecParam->GetEZN2MaxValue();
-  Float_t maxValEZP2 = fRecParam->GetEZP2MaxValue();
+  Float_t maxValEZN2  = fRecParam->GetEZN2MaxValue();
+  Float_t maxValEZP2  = fRecParam->GetEZP2MaxValue();
   Float_t maxValEZDC2 = fRecParam->GetEZDC2MaxValue();
   //
   //printf("\n\t AliZDCReconstructor -> ZEMEndPoint %1.0f, ZEMCutValue %1.0f,"
   //   " ZEMSupValue %1.0f, ZEMInfValue %1.0f\n",endPointZEM,cutValueZEM,supValueZEM,infValueZEM);
   
   // Equalization of detector responses
-  Float_t equalTowZN1HG[5], equalTowZN2HG[5], equalTowZP1HG[5], equalTowZP2HG[5];
-  Float_t equalTowZN1LG[5], equalTowZN2LG[5], equalTowZP1LG[5], equalTowZP2LG[5];
-  for(Int_t gi=0; gi<5; gi++){
-     equalTowZN1HG[gi] = ZN1ADCCorrHG[gi]*equalCoeffZN1[gi];
-     equalTowZP1HG[gi] = ZP1ADCCorrHG[gi]*equalCoeffZP1[gi];
-     equalTowZN2HG[gi] = ZN2ADCCorrHG[gi]*equalCoeffZN2[gi];
-     equalTowZP2HG[gi] = ZP2ADCCorrHG[gi]*equalCoeffZP2[gi];
-     //
-     equalTowZN1LG[gi] = ZN1ADCCorrLG[gi]*equalCoeffZN1[gi];
-     equalTowZP1LG[gi] = ZP1ADCCorrLG[gi]*equalCoeffZP1[gi];
-     equalTowZN2LG[gi] = ZN2ADCCorrLG[gi]*equalCoeffZN2[gi];
-     equalTowZP2LG[gi] = ZP2ADCCorrLG[gi]*equalCoeffZP2[gi];
+  Float_t equalTowZN1[10], equalTowZN2[10], equalTowZP1[10], equalTowZP2[10];
+  for(Int_t gi=0; gi<10; gi++){
+     equalTowZN1[gi] = ZN1ADCCorr[gi]*equalCoeffZN1[gi];
+     equalTowZP1[gi] = ZP1ADCCorr[gi]*equalCoeffZP1[gi];
+     equalTowZN2[gi] = ZN2ADCCorr[gi]*equalCoeffZN2[gi];
+     equalTowZP2[gi] = ZP2ADCCorr[gi]*equalCoeffZP2[gi];
   }
   
   // Energy calibration of detector responses
-  Float_t calibTowZN1HG[5], calibTowZN2HG[5], calibTowZP1HG[5], calibTowZP2HG[5];
-  Float_t calibSumZN1HG=0., calibSumZN2HG=0., calibSumZP1HG=0., calibSumZP2HG=0.;
-  Float_t calibTowZN1LG[5], calibTowZN2LG[5], calibTowZP1LG[5], calibTowZP2LG[5];
-  Float_t calibSumZN1LG=0., calibSumZN2LG=0., calibSumZ12LG=0., calibSumZP2LG=0.;
-  for(Int_t gi=0; gi<5; gi++){
-     calibTowZN1HG[gi] = equalTowZN1HG[gi]*calibEne[0];
-     calibTowZP1HG[gi] = equalTowZP1HG[gi]*calibEne[1];
-     calibTowZN2HG[gi] = equalTowZN2HG[gi]*calibEne[2];
-     calibTowZP2HG[gi] = equalTowZP2HG[gi]*calibEne[3];
-     calibSumZN1HG += calibTowZN1HG[gi];
-     calibSumZP1HG += calibTowZP1HG[gi];
-     calibSumZN2HG += calibTowZN2HG[gi];
-     calibSumZP2HG += calibTowZP2HG[gi];
+  Float_t calibTowZN1[10], calibTowZN2[10], calibTowZP1[10], calibTowZP2[10];
+  Float_t calibSumZN1[2], calibSumZN2[2], calibSumZP1[2], calibSumZP2[2];
+  for(Int_t gi=0; gi<10; gi++){
+     calibTowZN1[gi] = equalTowZN1[gi]*calibEne[0];
+     calibTowZP1[gi] = equalTowZP1[gi]*calibEne[1];
+     calibTowZN2[gi] = equalTowZN2[gi]*calibEne[2];
+     calibTowZP2[gi] = equalTowZP2[gi]*calibEne[3];
      //
-     calibTowZN1LG[gi] = equalTowZN1LG[gi]*calibEne[0];
-     calibTowZP1LG[gi] = equalTowZP1LG[gi]*calibEne[1];
-     calibTowZN2LG[gi] = equalTowZN2LG[gi]*calibEne[2];
-     calibTowZP2LG[gi] = equalTowZP2LG[gi]*calibEne[3];
-     calibSumZN1LG += calibTowZN1LG[gi];
-     calibSumZ12LG += calibTowZP1LG[gi];
-     calibSumZN2LG += calibTowZN2LG[gi];
-     calibSumZP2LG += calibTowZP2LG[gi];
+     if(gi<5){
+       calibSumZN1[0] += calibTowZN1[gi];
+       calibSumZP1[0] += calibTowZP1[gi];
+       calibSumZN2[0] += calibTowZN2[gi];
+       calibSumZP2[0] += calibTowZP2[gi];
+     }
+     //
+     else{
+       calibSumZN1[1] += calibTowZN1[gi];
+       calibSumZP1[1] += calibTowZP1[gi];
+       calibSumZN2[1] += calibTowZN2[gi];
+       calibSumZP2[1] += calibTowZP2[gi];
+     }
   }
   
   //  ---      Number of detected spectator nucleons
   //  *** N.B. -> It works only in Pb-Pb
   Int_t nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight;
-  nDetSpecNLeft = (Int_t) (calibSumZN1HG/2.760);
-  nDetSpecPLeft = (Int_t) (calibSumZP1HG/2.760);
-  nDetSpecNRight = (Int_t) (calibSumZN2HG/2.760);
-  nDetSpecPRight = (Int_t) (calibSumZP2HG/2.760);
+  nDetSpecNLeft = (Int_t) (calibSumZN1[0]/2.760);
+  nDetSpecPLeft = (Int_t) (calibSumZP1[0]/2.760);
+  nDetSpecNRight = (Int_t) (calibSumZN2[0]/2.760);
+  nDetSpecPRight = (Int_t) (calibSumZP2[0]/2.760);
   /*printf("\n\t AliZDCReconstructor -> nDetSpecNLeft %d, nDetSpecPLeft %d,"
     " nDetSpecNRight %d, nDetSpecPRight %d\n",nDetSpecNLeft, nDetSpecPLeft, 
     nDetSpecNRight, nDetSpecPRight);*/
@@ -413,59 +382,23 @@ void AliZDCReconstructor::ReconstructEvent(TTree *clustersTree,
   Int_t nGenSpecNRight=0, nGenSpecPRight=0, nGenSpecRight=0;
   Double_t impPar=0.;
   //
-  // *** RECONSTRUCTION FROM SIMULATED DATA
-  // Cut value for Ezem (GeV)
-  // ### Results from production  -> 0<b<18 fm (Apr 2002)
-  /*Float_t eZEMCut = 420.;
-  Float_t deltaEZEMSup = 690.; 
-  Float_t deltaEZEMInf = 270.; 
-  if(zemenergy > (eZEMCut+deltaEZEMSup)){
-    nGenSpecNLeft  = (Int_t) (fZNCen->Eval(ZN1CalibSum));
-    nGenSpecPLeft  = (Int_t) (fZPCen->Eval(ZP1CalibSum));
-    nGenSpecLeft   = (Int_t) (fZDCCen->Eval(ZN1CalibSum+ZP1CalibSum));
-    nGenSpecNRight = (Int_t) (fZNCen->Eval(ZN2CalibSum));
-    nGenSpecPRight = (Int_t) (fZNCen->Eval(ZP2CalibSum));
-    nGenSpecRight  = (Int_t) (fZNCen->Eval(ZN2CalibSum+ZP2CalibSum));
-    impPar  = fbCen->Eval(ZN1CalibSum+ZP1CalibSum);
-  }
-  else if(zemenergy < (eZEMCut-deltaEZEMInf)){
-    nGenSpecNLeft = (Int_t) (fZNPer->Eval(ZN1CalibSum)); 
-    nGenSpecPLeft = (Int_t) (fZPPer->Eval(ZP1CalibSum));
-    nGenSpecLeft  = (Int_t) (fZDCPer->Eval(ZN1CalibSum+ZP1CalibSum));
-    impPar   = fbPer->Eval(ZN1CalibSum+ZP1CalibSum);
-  }
-  else if(zemenergy >= (eZEMCut-deltaEZEMInf) && zemenergy <= (eZEMCut+deltaEZEMSup)){
-    nGenSpecNLeft = (Int_t) (fZEMn->Eval(zemenergy));
-    nGenSpecPLeft = (Int_t) (fZEMp->Eval(zemenergy));
-    nGenSpecLeft  = (Int_t)(fZEMsp->Eval(zemenergy));
-    impPar   =  fZEMb->Eval(zemenergy);
-  }
-  // ### Results from production  -> 0<b<18 fm (Apr 2002)
-  if(ZN1CalibSum>162.)  nGenSpecNLeft = (Int_t) (fZEMn->Eval(zemenergy));
-  if(ZP1CalibSum>59.75)  nGenSpecPLeft = (Int_t) (fZEMp->Eval(zemenergy));
-  if(ZN1CalibSum+ZP1CalibSum>221.5) nGenSpecLeft  = (Int_t)(fZEMsp->Eval(zemenergy));
-  if(ZN1CalibSum+ZP1CalibSum>220.)  impPar    =  fZEMb->Eval(zemenergy);
-  */
   //
-  //
-  // *** RECONSTRUCTION FROM REAL DATA
-  //
-  Float_t corrADCZEMHG = corrADCZEM1HG + corrADCZEM2HG;
+  Float_t corrADCZEMHG = ZEM1ADCCorr[0] + ZEM2ADCCorr[0];
   //
   if(corrADCZEMHG > supValueZEM){
-    nGenSpecNLeft  = (Int_t) (fZNCen->Eval(calibSumZN1HG));
-    nGenSpecPLeft  = (Int_t) (fZPCen->Eval(calibSumZP1HG));
-    nGenSpecLeft   = (Int_t) (fZDCCen->Eval(calibSumZN1HG+calibSumZP1HG));
-    nGenSpecNRight = (Int_t) (fZNCen->Eval(calibSumZN2HG));
-    nGenSpecPRight = (Int_t) (fZNCen->Eval(calibSumZP2HG));
-    nGenSpecRight  = (Int_t) (fZNCen->Eval(calibSumZN2HG+calibSumZP2HG));
-    impPar  = fbCen->Eval(calibSumZN1HG+calibSumZP1HG);
+    nGenSpecNLeft  = (Int_t) (fZNCen->Eval(calibSumZN1[0]));
+    nGenSpecPLeft  = (Int_t) (fZPCen->Eval(calibSumZP1[0]));
+    nGenSpecLeft   = (Int_t) (fZDCCen->Eval(calibSumZN1[0]+calibSumZP1[0]));
+    nGenSpecNRight = (Int_t) (fZNCen->Eval(calibSumZN2[0]));
+    nGenSpecPRight = (Int_t) (fZNCen->Eval(calibSumZP2[0]));
+    nGenSpecRight  = (Int_t) (fZNCen->Eval(calibSumZN2[0]+calibSumZP2[0]));
+    impPar  = fbCen->Eval(calibSumZN1[0]+calibSumZP1[0]);
   }
   else if(corrADCZEMHG < infValueZEM){
-    nGenSpecNLeft = (Int_t) (fZNPer->Eval(calibSumZN1HG)); 
-    nGenSpecPLeft = (Int_t) (fZPPer->Eval(calibSumZP1HG));
-    nGenSpecLeft  = (Int_t) (fZDCPer->Eval(calibSumZN1HG+calibSumZP1HG));
-    impPar   = fbPer->Eval(calibSumZN1HG+calibSumZP1HG);
+    nGenSpecNLeft = (Int_t) (fZNPer->Eval(calibSumZN1[0])); 
+    nGenSpecPLeft = (Int_t) (fZPPer->Eval(calibSumZP1[0]));
+    nGenSpecLeft  = (Int_t) (fZDCPer->Eval(calibSumZN1[0]+calibSumZP1[0]));
+    impPar   = fbPer->Eval(calibSumZN1[0]+calibSumZP1[0]);
   }
   else if(corrADCZEMHG >= infValueZEM && corrADCZEMHG <= supValueZEM){
     nGenSpecNLeft = (Int_t) (fZEMn->Eval(corrADCZEMHG));
@@ -474,15 +407,15 @@ void AliZDCReconstructor::ReconstructEvent(TTree *clustersTree,
     impPar   =  fZEMb->Eval(corrADCZEMHG);
   }
   // 
-  if(calibSumZN1HG/maxValEZN1>1.)  nGenSpecNLeft = (Int_t) (fZEMn->Eval(corrADCZEMHG));
-  if(calibSumZP1HG/maxValEZP1>1.)  nGenSpecPLeft = (Int_t) (fZEMp->Eval(corrADCZEMHG));
-  if((calibSumZN1HG+calibSumZP1HG/maxValEZDC1)>1.){
+  if(calibSumZN1[0]/maxValEZN1>1.)  nGenSpecNLeft = (Int_t) (fZEMn->Eval(corrADCZEMHG));
+  if(calibSumZP1[0]/maxValEZP1>1.)  nGenSpecPLeft = (Int_t) (fZEMp->Eval(corrADCZEMHG));
+  if((calibSumZN1[0]+calibSumZP1[0]/maxValEZDC1)>1.){
      nGenSpecLeft = (Int_t)(fZEMsp->Eval(corrADCZEMHG));
      impPar = fZEMb->Eval(corrADCZEMHG);
   }
-  if(calibSumZN2HG/maxValEZN2>1.)  nGenSpecNRight = (Int_t) (fZEMn->Eval(corrADCZEMHG));
-  if(calibSumZP2HG/maxValEZP2>1.)  nGenSpecPRight = (Int_t) (fZEMp->Eval(corrADCZEMHG));
-  if((calibSumZN2HG+calibSumZP2HG/maxValEZDC2)>1.) nGenSpecRight = (Int_t)(fZEMsp->Eval(corrADCZEMHG));
+  if(calibSumZN2[0]/maxValEZN2>1.)  nGenSpecNRight = (Int_t) (fZEMn->Eval(corrADCZEMHG));
+  if(calibSumZP2[0]/maxValEZP2>1.)  nGenSpecPRight = (Int_t) (fZEMp->Eval(corrADCZEMHG));
+  if((calibSumZN2[0]+calibSumZP2[0]/maxValEZDC2)>1.) nGenSpecRight = (Int_t)(fZEMsp->Eval(corrADCZEMHG));
   //
   if(nGenSpecNLeft>125)    nGenSpecNLeft=125;
   else if(nGenSpecNLeft<0) nGenSpecNLeft=0;
@@ -501,24 +434,23 @@ void AliZDCReconstructor::ReconstructEvent(TTree *clustersTree,
   if(nPartTotRight<0) nPartTotRight=0;
   //
   // *** DEBUG ***
-  printf("\n\t AliZDCReconstructor -> calibSumZN1HG %1.0f, calibSumZP1HG %1.0f,"
-      "  calibSumZN2HG %1.0f, calibSumZP2HG %1.0f, corrADCZEMHG %1.0f\n", 
-      calibSumZN1HG,calibSumZP1HG,calibSumZN2HG,calibSumZP2HG,corrADCZEMHG);
+  /*printf("\n\t AliZDCReconstructor -> calibSumZN1[0] %1.0f, calibSumZP1[0] %1.0f,"
+      "  calibSumZN2[0] %1.0f, calibSumZP2[0] %1.0f, corrADCZEMHG %1.0f\n", 
+      calibSumZN1[0],calibSumZP1[0],calibSumZN2[0],calibSumZP2[0],corrADCZEMHG);
   printf("\t AliZDCReconstructor -> nGenSpecNLeft %d, nGenSpecPLeft %d, nGenSpecLeft %d\n"
       "\t\t nGenSpecNRight %d, nGenSpecPRight %d, nGenSpecRight %d\n", 
       nGenSpecNLeft, nGenSpecPLeft, nGenSpecLeft, 
       nGenSpecNRight, nGenSpecPRight, nGenSpecRight);
   printf("\t AliZDCReconstructor ->  NpartL %d,  NpartR %d,  b %1.2f fm\n\n",nPartTotLeft, nPartTotRight, impPar);
-
+  */
+  
   // create the output tree
-  AliZDCReco reco(calibSumZN1HG, calibSumZP1HG, calibSumZN2HG, calibSumZP2HG, 
-                 calibTowZN1LG, calibTowZN2LG, calibTowZP1LG, calibTowZP2LG, 
-                 calibTowZN1LG, calibTowZP1LG, calibTowZN2LG, calibTowZP2LG,
-                 corrADCZEM1HG, corrADCZEM2HG,
+  AliZDCReco reco(calibSumZN1, calibSumZP1, calibSumZN2, calibSumZP2, 
+                 calibTowZN1, calibTowZN2, calibTowZP1, calibTowZP2, 
+                 ZEM1ADCCorr, ZEM2ADCCorr, PMRef1, PMRef2,
                  nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight, 
                  nGenSpecNLeft, nGenSpecPLeft, nGenSpecLeft, nGenSpecNRight, 
-                 nGenSpecPRight, nGenSpecRight,
-                 nPartTotLeft, nPartTotRight, impPar);
+                 nGenSpecPRight, nGenSpecRight, nPartTotLeft, nPartTotRight, impPar);
                  
   AliZDCReco* preco = &reco;
   const Int_t kBufferSize = 4000;
@@ -543,14 +475,15 @@ void AliZDCReconstructor::FillZDCintoESD(TTree *clustersTree, AliESDEvent* esd)
   Float_t tZN1Ene[5], tZN2Ene[5], tZP1Ene[5], tZP2Ene[5];
   Float_t tZN1EneLR[5], tZN2EneLR[5], tZP1EneLR[5], tZP2EneLR[5];
   for(Int_t i=0; i<5; i++){
-     tZN1Ene[i] = reco.GetZN1EnTow(i);
-     tZN2Ene[i] = reco.GetZN2EnTow(i);
-     tZP1Ene[i] = reco.GetZP1EnTow(i);
-     tZP2Ene[i] = reco.GetZP2EnTow(i);
-     tZN1EneLR[i] = reco.GetZN1SigLowRes(i);
-     tZN2EneLR[i] = reco.GetZP1SigLowRes(i);
-     tZP1EneLR[i] = reco.GetZN2SigLowRes(i);
-     tZP2EneLR[i] = reco.GetZP2SigLowRes(i);
+     tZN1Ene[i] = reco.GetZN1HREnTow(i);
+     tZN2Ene[i] = reco.GetZN2HREnTow(i);
+     tZP1Ene[i] = reco.GetZP1HREnTow(i);
+     tZP2Ene[i] = reco.GetZP2HREnTow(i);
+     //
+     tZN1EneLR[i] = reco.GetZN1LREnTow(i);
+     tZN2EneLR[i] = reco.GetZN2LREnTow(i);
+     tZP1EneLR[i] = reco.GetZP1LREnTow(i);
+     tZP2EneLR[i] = reco.GetZP2LREnTow(i);
   }
   esdzdc->SetZN1TowerEnergy(tZN1Ene);
   esdzdc->SetZN2TowerEnergy(tZN2Ene);
@@ -561,8 +494,8 @@ void AliZDCReconstructor::FillZDCintoESD(TTree *clustersTree, AliESDEvent* esd)
   esdzdc->SetZP1TowerEnergyLR(tZP1EneLR);
   esdzdc->SetZP2TowerEnergyLR(tZP2EneLR);
   // 
-  esd->SetZDC(reco.GetZN1Energy(), reco.GetZP1Energy(), reco.GetZEM1signal(), 
-             reco.GetZEM2signal(), reco.GetZN2Energy(), reco.GetZP2Energy(), 
+  esd->SetZDC(reco.GetZN1HREnergy(), reco.GetZP1HREnergy(), reco.GetZEM1HRsignal(), 
+             reco.GetZEM2HRsignal(), reco.GetZN2HREnergy(), reco.GetZP2HREnergy(), 
              reco.GetNPartLeft());
   //
   
index 0d66b8c..56aa0ca 100644 (file)
@@ -46,12 +46,9 @@ private:
   AliZDCReconstructor(const AliZDCReconstructor&);
   AliZDCReconstructor& operator =(const AliZDCReconstructor&);
 
-  void   ReconstructEvent(TTree *clustersTree, Float_t* ZN1ADCCorrHG, 
-               Float_t* ZP1ADCCorrHG, Float_t* ZN2ADCCorrHG, 
-               Float_t* ZP2ADCCorrHG, Float_t* ZN1ADCCorrLG, 
-               Float_t* ZP1ADCCorrLG, Float_t* ZN2ADCCorrLG, 
-               Float_t* ZP2ADCCorrLG, 
-               Float_t ZEM1ADCCorrHG, Float_t ZEM2ADCCorrHG) const;
+  void   ReconstructEvent(TTree *clustersTree, 
+           Float_t* ZN1ADCCorr, Float_t* ZP1ADCCorr, Float_t* ZN2ADCCorr, Float_t* ZP2ADCCorr,
+           Float_t* ZEM1ADCCorr, Float_t* ZEM2ADCCorr, Float_t* PMRef1, Float_t* PMRef2) const;
   void   FillZDCintoESD(TTree *clustersTree, AliESDEvent*esd) const;
 
   TF1*   fZNCen;     //! Nspectator n true vs. EZN
index cae1b4c..dc109fe 100644 (file)
@@ -237,11 +237,11 @@ int main(int argc, char **argv) {
          Int_t index=-1;
          if(rawStreamZDC->IsADCDataWord()){
          if(rawStreamZDC->GetSector(1)!=5){ // Physics signals
-           if(rawStreamZDC->GetSector(0)==1) index = rawStreamZDC->GetSector(1); // *** ZN1
-           else if(rawStreamZDC->GetSector(0)==2) index = rawStreamZDC->GetSector(1)+5; // *** ZP1
+           if(rawStreamZDC->GetSector(0)==1) index = rawStreamZDC->GetSector(1); // *** ZNC
+           else if(rawStreamZDC->GetSector(0)==2) index = rawStreamZDC->GetSector(1)+5; // *** ZPC
            else if(rawStreamZDC->GetSector(0)==3) index = rawStreamZDC->GetSector(1)+9; // *** ZEM
-           else if(rawStreamZDC->GetSector(0)==4) index = rawStreamZDC->GetSector(1)+12; // *** ZN2
-           else if(rawStreamZDC->GetSector(0)==5) index = rawStreamZDC->GetSector(1)+17; // *** ZP2
+           else if(rawStreamZDC->GetSector(0)==4) index = rawStreamZDC->GetSector(1)+12; // *** ZNA
+           else if(rawStreamZDC->GetSector(0)==5) index = rawStreamZDC->GetSector(1)+17; // *** ZPA
          }
          else{ // Reference PMs
            index = (rawStreamZDC->GetSector(0)-1)/3+22;
@@ -313,7 +313,7 @@ int main(int argc, char **argv) {
      ADCfunchg[i] = hPedhg[i]->GetFunction("gaus");
      MeanPed[i] = ADCfunchg[i]->GetParameter(1);
      MeanPedWidth[i] = ADCfunchg[i]->GetParameter(2);
-     fprintf(fileShuttle,"\t%f\t%f\n",MeanPed[i],MeanPedWidth[i]);
+     fprintf(fileShuttle,"\t%d\t%f\t%f\n",i,MeanPed[i],MeanPedWidth[i]);
      //printf("\t MeanPed[%d] = %f\n",i, MeanPed[i]);
   }
   TF1 *ADCfunclg[kNChannels];
@@ -322,7 +322,7 @@ int main(int argc, char **argv) {
      ADCfunclg[i] = hPedlg[i]->GetFunction("gaus");
      MeanPed[i+kNChannels] = ADCfunclg[i]->GetParameter(1);
      MeanPedWidth[i+kNChannels] = ADCfunclg[i]->GetParameter(2);
-     fprintf(fileShuttle,"\t%f\t%f\n",MeanPed[i+kNChannels],MeanPedWidth[i+kNChannels]);
+     fprintf(fileShuttle,"\t%d\t%f\t%f\n",i+kNChannels,MeanPed[i+kNChannels],MeanPedWidth[i+kNChannels]);
      //printf("\t MeanPed[%d] = %f\n",i+kNChannels, MeanPed[i+kNChannels]);
   }
   // --- Out-of-time pedestals
@@ -332,7 +332,7 @@ int main(int argc, char **argv) {
      ADCootfunchg[i] = hPedOutOfTimehg[i]->GetFunction("gaus");
      MeanPedOOT[i] = ADCootfunchg[i]->GetParameter(1);
      MeanPedWidthOOT[i] = ADCootfunchg[i]->GetParameter(2);
-     fprintf(fileShuttle,"\t%f\t%f\n",MeanPedOOT[i],MeanPedWidthOOT[i]);
+     fprintf(fileShuttle,"\t%d\t%f\t%f\n",i,MeanPedOOT[i],MeanPedWidthOOT[i]);
      //printf("\t MeanPedOOT[%d] = %f\n",i, MeanPedOOT[i]);
   }
   TF1 *ADCootfunclg[kNChannels];
@@ -341,7 +341,7 @@ int main(int argc, char **argv) {
      ADCootfunclg[i] = hPedOutOfTimelg[i]->GetFunction("gaus");
      MeanPedOOT[i+kNChannels] = ADCootfunclg[i]->GetParameter(1);
      MeanPedWidthOOT[i+kNChannels] = ADCootfunclg[i]->GetParameter(2);
-     fprintf(fileShuttle,"\t%f\t%f\n",MeanPedOOT[i+kNChannels],MeanPedWidthOOT[i+kNChannels]);
+     fprintf(fileShuttle,"\t%d\t%f\t%f\n",i+kNChannels,MeanPedOOT[i+kNChannels],MeanPedWidthOOT[i+kNChannels]);
      //printf("\t MeanPedOOT[%d] = %f\n",i+kNChannels, MeanPedOOT[i+kNChannels]);
   }
   //
@@ -357,7 +357,7 @@ int main(int argc, char **argv) {
      ffunchg[i] = hPedCorrProfhg[i]->GetFunction("pol1");
      CorrCoeff0[i] = ffunchg[i]->GetParameter(0);
      CorrCoeff1[i] = ffunchg[i]->GetParameter(1);
-     fprintf(fileShuttle,"\t%f\t%f\n",CorrCoeff0[i],CorrCoeff1[i]);
+     fprintf(fileShuttle,"\t%d\t%f\t%f\n",i,CorrCoeff0[i],CorrCoeff1[i]);
      //printf("\t CorrCoeff0[%d] = %f, CorrCoeff1[%d] = %f\n",i, CorrCoeff0[i], i, CorrCoeff1[i]);
   }    
   for(int i=0;i<kNChannels;i++) {
@@ -368,7 +368,7 @@ int main(int argc, char **argv) {
      ffunclg[i] = hPedCorrProflg[i]->GetFunction("pol1");
      CorrCoeff0[i+kNChannels] = ffunclg[i]->GetParameter(0);
      CorrCoeff1[i+kNChannels] = ffunclg[i]->GetParameter(1);
-     fprintf(fileShuttle,"\t%f\t%f\n",CorrCoeff0[i+kNChannels],CorrCoeff1[i+kNChannels]);
+     fprintf(fileShuttle,"\t%d\t%f\t%f\n",i+kNChannels,CorrCoeff0[i+kNChannels],CorrCoeff1[i+kNChannels]);
      //printf("\t CorrCoeff0[%d] = %f, CorrCoeff1[%d] = %f\n",
      //                i+kNChannels, CorrCoeff0[i+kNChannels], i+kNChannels, CorrCoeff1[i+kNChannels]);
   }