New reconstruction algorithm
authorcoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 13 Sep 2007 12:41:17 +0000 (12:41 +0000)
committercoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 13 Sep 2007 12:41:17 +0000 (12:41 +0000)
ZDC/AliZDCCalibData.cxx
ZDC/AliZDCCalibData.h
ZDC/AliZDCReco.cxx
ZDC/AliZDCReco.h
ZDC/AliZDCReconstructor.cxx
ZDC/AliZDCReconstructor.h

index 86521b6b0f84517facc8ac1bd99341f9cfd0d727..29ffb0b3b8208702f8e8f08afdf1a11c97af4cd5 100644 (file)
@@ -28,7 +28,6 @@ ClassImp(AliZDCCalibData)
 //________________________________________________________________
 AliZDCCalibData::AliZDCCalibData()
 {
-//  fHistMeanPed=0;
   Reset();
 }
 
@@ -40,7 +39,6 @@ AliZDCCalibData::AliZDCCalibData(const char* name)
   namst += name;
   SetName(namst.Data());
   SetTitle(namst.Data());
-//  fHistMeanPed=0;
   Reset();
 }
 
@@ -64,8 +62,10 @@ AliZDCCalibData::AliZDCCalibData(const AliZDCCalibData& calibda) :
   }
   for(int t=0; t<6; t++)  fEnCalibration[t] = calibda.GetEnCalib(t);
   //
-  fEZEMEndValue    = calibda.GetEZEMEndValue();   
-  fEZEMCutFraction = calibda.GetEZEMCutFraction();
+  fZEMEndValue    = calibda.GetZEMEndValue();   
+  fZEMCutFraction = calibda.GetZEMCutFraction();
+  fDZEMSup       = calibda.GetDZEMSup();
+  fDZEMInf       = calibda.GetDZEMInf();
 }
 
 //________________________________________________________________
@@ -86,8 +86,8 @@ AliZDCCalibData &AliZDCCalibData::operator =(const AliZDCCalibData& calibda)
      fPedCorrCoeff[1][t] = calibda.GetPedCorrCoeff1(t);
   }
   for(int t=0; t<6; t++) fEnCalibration[t] = calibda.GetEnCalib(t);
-  fEZEMEndValue    = calibda.GetEZEMEndValue();
-  fEZEMCutFraction = calibda.GetEZEMCutFraction();
+  fZEMEndValue    = calibda.GetZEMEndValue();
+  fZEMCutFraction = calibda.GetZEMCutFraction();
 
   return *this;
 }
@@ -95,7 +95,6 @@ AliZDCCalibData &AliZDCCalibData::operator =(const AliZDCCalibData& calibda)
 //________________________________________________________________
 AliZDCCalibData::~AliZDCCalibData()
 {
-//  CleanHistos();
 }
 
 //________________________________________________________________
@@ -109,24 +108,6 @@ void AliZDCCalibData::Reset()
   memset(fEnCalibration,0,6*sizeof(Float_t));
 }                                                                                       
 
-/*
-//________________________________________________________________
-void AliZDCCalibData::CleanHistos()
-{
-  if (fHistMeanPed) delete fHistMeanPed; fHistMeanPed = 0;
-}
-
-//________________________________________________________________
-void AliZDCCalibData::PrepHistos()
-{
-//  CleanHistos(); // this gives a segm.viol!
-  Int_t   kNChannels = 47;
-  Float_t kMaxPedVal = 47.;
-  TString hname = GetName();  hname += "_Pedestals";
-  fHistMeanPed = new TH1F(hname.Data(),hname.Data(),kNChannels,0.,kMaxPedVal);
-  for(int i=0; i<47; i++)  fHistMeanPed->SetBinContent(i+1,GetMeanPed(i));
-}
-*/
 
 //________________________________________________________________
 void  AliZDCCalibData::Print(Option_t *) const
@@ -145,7 +126,7 @@ void  AliZDCCalibData::Print(Option_t *) const
      printf("ADC%d (%.1f, %.1f)  ",t,fMeanPedestal[t],fMeanPedWidth[t]);
    }
    //
-   printf("\n\n\n #######      Out-of-time pedestal values (mean value, sigma) ####### \n");
+   printf("\n\n #######        Out-of-time pedestal values (mean value, sigma) ####### \n");
    for(int t=0; t<44; t++){
      if(t==0 || t==24) printf("\n-------- ZN1 HighRes -------- \n");
      else if(t==5 || t==29) printf("\n-------- ZN1 LowRes -------- \n");
@@ -158,7 +139,7 @@ void  AliZDCCalibData::Print(Option_t *) const
      printf("ADC%d (%.1f, %.1f)  ",t,fOOTPedestal[t],fOOTPedWidth[t]);
    }
  
-   printf("\n\n\n #######      Energy calibration coefficients ####### \n");
+   printf("\n\n #######        Energy calibration coefficients ####### \n");
    printf("  ZN1 = %.4f (E[TeV]/ADCch.) \n",fEnCalibration[0]);
    printf("  ZP1 = %.4f (E[TeV]/ADCch.) \n",fEnCalibration[1]);
    printf("  ZN2 = %.4f (E[TeV]/ADCch.) \n",fEnCalibration[2]);
@@ -176,9 +157,17 @@ void  AliZDCCalibData::Print(Option_t *) const
    printf("  ZP2 -> %1.2f %1.2f %1.2f %1.2f %1.2f  \n",
     fZP2EqualCoeff[0],fZP2EqualCoeff[1],fZP2EqualCoeff[2],fZP2EqualCoeff[3],fZP2EqualCoeff[4]);
  
-   printf("\n\n #######        Parameters for centrality selection from ZEM #######    \n");
-   printf("  ZEM spectrum end point -> %1.0f (a.u.)\n",fEZEMEndValue);
-   printf("  ZEM cut value -> %1.2f \n\n\n",fEZEMCutFraction);
+   printf("\n\n #######        Parameters from EZDC vs. ZEM correlation #######        \n");
+   printf("  ZEMEndPoint = %1.2f, ZEMCutFraction = %1.2f \n"
+     " DZEMInf = %1.2f, DZEMSup = %1.2f\n",
+     fZEMEndValue, fZEMCutFraction, fDZEMInf, fDZEMSup);
+   printf("\n\n #######        Parameters from EZDC vs. Nspec correlation #######      \n");
+   printf("  EZN1MaxValue = %1.2f, EZP1MaxValue = %1.2f, EZDC1MaxValue = %1.2f \n"
+     "  EZN2MaxValue = %1.2f, EZP2MaxValue = %1.2f, EZDC2MaxValue = %1.2f \n\n",
+     fEZN1MaxValue, fEZP1MaxValue, fEZDC1MaxValue,
+     fEZN2MaxValue, fEZP2MaxValue, fEZDC2MaxValue);
+
 } 
 
 //________________________________________________________________
index 6e4c4f2e7146eb8d73c8e21038e6c2f2d604dd95..6eb8f12955b6d417f96088ebeb8961b7adf89a93 100644 (file)
@@ -81,11 +81,27 @@ class AliZDCCalibData: public TNamed {
   void         SetZP2EqualCoeff(Int_t channel, Float_t val) {fZP2EqualCoeff[channel]=val;}
   void         SetZP2EqualCoeff(Float_t* EqualCoeff);
   //  
-  void    SetEZEMEndValue(Float_t EZEMEndValue) {fEZEMEndValue = EZEMEndValue;}
-  void    SetEZEMCutFraction(Float_t EZEMCutFraction) {fEZEMCutFraction = EZEMCutFraction;}
-  virtual Float_t GetEZEMEndValue()     const {return fEZEMEndValue;}
-  virtual Float_t GetEZEMCutFraction()  const {return fEZEMCutFraction;}
-  
+  void    SetZEMEndValue(Float_t ZEMEndValue) {fZEMEndValue = ZEMEndValue;}
+  void    SetZEMCutFraction(Float_t ZEMCutFraction) {fZEMCutFraction = ZEMCutFraction;}
+  void    SetDZEMSup(Float_t DZEMSup) {fDZEMSup = DZEMSup;}
+  void    SetDZEMInf(Float_t DZEMInf) {fDZEMInf = DZEMInf;}
+  virtual Float_t GetZEMEndValue()     const {return fZEMEndValue;}
+  virtual Float_t GetZEMCutFraction()  const {return fZEMCutFraction;}
+  virtual Float_t GetDZEMSup()        const {return fDZEMSup;}
+  virtual Float_t GetDZEMInf()        const {return fDZEMInf;}
+  //
+  void   SetEZN1MaxValue(Float_t value)  {fEZN1MaxValue = value;}
+  void   SetEZP1MaxValue(Float_t value)  {fEZP1MaxValue = value;}
+  void   SetEZDC1MaxValue(Float_t value) {fEZDC1MaxValue = value;}
+  void   SetEZN2MaxValue(Float_t value)  {fEZN2MaxValue = value;}
+  void   SetEZP2MaxValue(Float_t value)  {fEZP2MaxValue = value;}
+  void   SetEZDC2MaxValue(Float_t value) {fEZDC2MaxValue = value;}
+  virtual Float_t GetEZN1MaxValue()  const {return fEZN1MaxValue;}
+  virtual Float_t GetEZP1MaxValue()  const {return fEZP1MaxValue;}
+  virtual Float_t GetEZDC1MaxValue() const {return fEZDC1MaxValue;}
+  virtual Float_t GetEZN2MaxValue()  const {return fEZN2MaxValue;}
+  virtual Float_t GetEZP2MaxValue()  const {return fEZP2MaxValue;}
+  virtual Float_t GetEZDC2MaxValue() const {return fEZDC2MaxValue;}
   
  protected:
   // --- Pedestals
@@ -104,10 +120,19 @@ class AliZDCCalibData: public TNamed {
   Float_t  fZN2EqualCoeff[5];   // Equalization coefficients for ZN1 PTMs
   Float_t  fZP2EqualCoeff[5];   // Equalization coefficients for ZN1 PTMs
   // --- Coefficients for centrality selection from ZEM signal
-  Float_t fEZEMEndValue;        //End point value of ZEM energy spectrum
-  Float_t fEZEMCutFraction;     //Fraction of ZEM energy spectrum used to cut
+  Float_t  fZEMEndValue;        // End point value of ZEM energy spectrum
+  Float_t  fZEMCutFraction;     // Fraction of ZEM energy spectrum used to cut
+  Float_t  fDZEMSup;// Upper value of EZDCvs.ZEM correlation where ZEM signal is used
+  Float_t  fDZEMInf;// Lower value of EZDCvs.ZEM correlation where ZEM signal is used
+  // --- Parameters from EZDC vs. Nspec correlation
+  Float_t  fEZN1MaxValue;       // Max value of ZN1 vs. Nspec n correlation
+  Float_t  fEZP1MaxValue;       // Max value of ZP1 vs. Nspec p correlation
+  Float_t  fEZDC1MaxValue;      // Max value of ZDC1 vs. Nspec n+p correlation
+  Float_t  fEZN2MaxValue;       // Max value of ZN2 vs. Nspec n correlation
+  Float_t  fEZP2MaxValue;       // Max value of ZP2 vs. Nspec p correlation
+  Float_t  fEZDC2MaxValue;      // Max value of ZDC2 vs. Nspec n+p correlation
   //
-  ClassDef(AliZDCCalibData,7)    // ZDC  Calibration data
+  ClassDef(AliZDCCalibData,8)    // ZDC  Calibration data
 };
 
 #endif
index 7cb8c278e5378e94b0c1442be7a0915be75c5395..f922c4f74a2e8a3aaf9fdb2a3dbf0f10c9e08bf2 100644 (file)
@@ -32,21 +32,30 @@ ClassImp(AliZDCReco)
 AliZDCReco::AliZDCReco() :
        
   TObject(),
-  fZN1energy(0),
-  fZP1energy(0),
-  fZDC1energy(0),
-  fZN2energy(0),
-  fZP2energy(0),
-  fZDC2energy(0),
-  fZEMenergy(0),
+  fZN1Energy(0),
+  fZP1Energy(0),
+  fZN2Energy(0),
+  fZP2Energy(0),
+  //
+//  fZN1EnTow(0x0),
+//  fZP1EnTow(0x0),
+//  fZN2EnTow(0x0),
+//  fZP2EnTow(0x0),
+  //
+  fZEMsignal(0),
+  //
   fNDetSpecNLeft(0),
   fNDetSpecPLeft(0),
   fNDetSpecNRight(0),
   fNDetSpecPRight(0),
-  fNTrueSpecN(0),
-  fNTrueSpecP(0),
-  fNTrueSpec(0),
-  fNPart(0),
+  fNTrueSpecNLeft(0),
+  fNTrueSpecPLeft(0),
+  fNTrueSpecLeft(0),
+  fNTrueSpecNRight(0),
+  fNTrueSpecPRight(0),
+  fNTrueSpecRight(0),
+  fNPartLeft(0),
+  fNPartRight(0),
   fImpPar(0)
 
 { 
@@ -57,34 +66,50 @@ AliZDCReco::AliZDCReco() :
   
 
 //_____________________________________________________________________________
-AliZDCReco::AliZDCReco(Float_t ezn1, Float_t ezp1, Float_t ezdc1, Float_t ezem,
-       Float_t ezn2, Float_t ezp2, Float_t ezdc2,
-       Int_t detspnLeft, Int_t detsppLeft, Int_t detspnRight, Int_t detsppRight,
-       Int_t trspn, Int_t trspp, Int_t trsp, Int_t part,
-       Float_t b) :
+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 ezem, 
+            //    
+            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) :
        
   TObject(),
-  fZN1energy(ezn1),
-  fZP1energy(ezp1),
-  fZDC1energy(ezdc1),
-  fZN2energy(ezn2),
-  fZP2energy(ezp2),
-  fZDC2energy(ezdc2),
-  fZEMenergy(ezem),
+  fZN1Energy(ezn1),
+  fZP1Energy(ezp1),
+  fZN2Energy(ezn2),
+  fZP2Energy(ezp2),
+  //
+  fZEMsignal(ezem),
+  //
   fNDetSpecNLeft(detspnLeft),
   fNDetSpecPLeft(detsppLeft),
   fNDetSpecNRight(detspnRight),
   fNDetSpecPRight(detsppRight),
-  fNTrueSpecN(trspn),
-  fNTrueSpecP(trspp),
-  fNTrueSpec(trsp),
-  fNPart(part),
+  fNTrueSpecNLeft(trspnLeft),
+  fNTrueSpecPLeft(trsppLeft),
+  fNTrueSpecLeft(trspLeft),
+  fNTrueSpecNRight(trspnRight),
+  fNTrueSpecPRight(trsppRight),
+  fNTrueSpecRight(trspRight),
+  fNPartLeft(partLeft),
+  fNPartRight(partRight),
   fImpPar(b)
 
 { 
   //
   // Constructor
   //
+  for(Int_t j=0; j<5; j++){
+     fZN1EnTow[j] =  ezn1tow[j];
+     fZP1EnTow[j] =  ezp1tow[j];
+     fZN2EnTow[j] =  ezn2tow[j];
+     fZP2EnTow[j] =  ezp2tow[j];
+  }
   
 }
 
@@ -95,21 +120,32 @@ AliZDCReco::AliZDCReco(const AliZDCReco &oldreco) :
 {
   // Copy constructor
 
-  fZN1energy = oldreco.GetZN1energy();
-  fZP1energy = oldreco.GetZP1energy();            
-  fZDC1energy = oldreco.GetZDC1energy();         
-  fZN2energy = oldreco.GetZN2energy();    
-  fZP2energy = oldreco.GetZP2energy();            
-  fZDC2energy = oldreco.GetZDC2energy();         
-  fZEMenergy = oldreco.GetZEMenergy();    
+  fZN1Energy  = oldreco.GetZN1Energy();
+  fZP1Energy  = oldreco.GetZP1Energy();            
+  fZN2Energy  = oldreco.GetZN2Energy();           
+  fZP2Energy  = oldreco.GetZP2Energy();           
+  //
+  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);
+  }
+  //
+  fZEMsignal = oldreco.GetZEMsignal(); 
+  //   
   fNDetSpecNLeft = oldreco.GetNDetSpecNLeft(); 
   fNDetSpecPLeft = oldreco.GetNDetSpecPLeft(); 
   fNDetSpecNRight = oldreco.GetNDetSpecNRight();       
   fNDetSpecPRight = oldreco.GetNDetSpecPRight();       
-  fNTrueSpecN = oldreco.GetNTrueSpecN();         
-  fNTrueSpecP = oldreco.GetNTrueSpecP();         
-  fNTrueSpec = oldreco.GetNTrueSpec();   
-  fNPart = oldreco.GetNPart();                  
+  fNTrueSpecNLeft = oldreco.GetNTrueSpecNLeft();         
+  fNTrueSpecPLeft = oldreco.GetNTrueSpecPLeft();         
+  fNTrueSpecLeft = oldreco.GetNTrueSpecLeft();   
+  fNTrueSpecNRight = oldreco.GetNTrueSpecNRight();       
+  fNTrueSpecPRight = oldreco.GetNTrueSpecPRight();       
+  fNTrueSpecRight = oldreco.GetNTrueSpecRight();         
+  fNPartLeft = oldreco.GetNPartLeft();                  
+  fNPartRight = oldreco.GetNPartRight();                        
   fImpPar = oldreco.GetImpPar();                        
 }
 
@@ -118,9 +154,14 @@ void AliZDCReco::Print(Option_t *) const {
   //
   // Printing Reconstruction Parameters
   //
-  printf("     ---   Reconstruction -> EZN = %f TeV, EZP = %f TeV, EZDC = %f TeV,"
-        " EZEM = %f GeV \n             NDetSpecN = %d, NDetSpecP = %d, Nspecn = %d,"
-        " Nspecp = %d, Npart = %d, b = %f fm.\n ", 
-        fZN1energy,fZP1energy,fZDC1energy,fZEMenergy,fNDetSpecNLeft,
-        fNDetSpecPLeft,fNTrueSpecN,fNTrueSpecP,fNPart,fImpPar);
+  printf(" \t ---   Reconstruction -> EZN = %f TeV, EZP = %f TeV,  EZEM = %f GeV \n "          
+        " \t NDetSpecNLeft = %d, NDetSpecPLeft = %d, NspecnLeft = %d,"
+        " NspecpLeft = %d, NpartLeft = %d"
+        " \t NDetSpecNRight = %d, NDetSpecPRight = %d, NspecnRight = %d,"
+        " NspecpRight = %d, NpartRight = %d"
+        " \t b = %f fm\n ", 
+        fZN1Energy,fZP1Energy,fZEMsignal,
+        fNDetSpecNLeft,fNDetSpecPLeft,fNTrueSpecNLeft,fNTrueSpecPLeft,fNPartLeft,
+        fNDetSpecNRight,fNDetSpecPRight,fNTrueSpecNRight,fNTrueSpecPRight,fNPartRight,
+        fImpPar);
 }
index a258aff52e999bfe6584fdac980a948ec6481b03..a8fd8b250d5550df74a76b943395a9d33e22e5b0 100644 (file)
@@ -13,55 +13,80 @@ class AliZDCReco : public TObject {
 
 public:
   AliZDCReco();
-  AliZDCReco(Float_t ezn1, Float_t ezp1, Float_t ezdc1, Float_t ezem, 
-            Float_t ezn2, Float_t ezp2, Float_t ezdc2, Int_t detspnLeft, 
-             Int_t detsppLeft, Int_t detspnRight, Int_t detsppRight, 
-            Int_t trspn, Int_t trspp, Int_t trsp, Int_t part, Float_t b);
+  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 ezem, 
+            //    
+            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);
+
   AliZDCReco(const AliZDCReco &oldreco);
   virtual ~AliZDCReco() {}
 
   // Getters 
-  virtual Float_t GetZN1energy()   const  {return fZN1energy;}
-  virtual Float_t GetZP1energy()   const  {return fZP1energy;}
-  virtual Float_t GetZDC1energy()  const  {return fZDC1energy;}
-  virtual Float_t GetZN2energy()   const  {return fZN2energy;}
-  virtual Float_t GetZP2energy()   const  {return fZP2energy;}
-  virtual Float_t GetZDC2energy()  const  {return fZDC2energy;}
-  virtual Float_t GetZEMenergy()   const  {return fZEMenergy;}
-  virtual Int_t   GetNDetSpecNLeft()  const  {return fNDetSpecNLeft;}
-  virtual Int_t   GetNDetSpecPLeft()  const  {return fNDetSpecPLeft;}
-  virtual Int_t   GetNDetSpecNRight() const  {return fNDetSpecNRight;}
-  virtual Int_t   GetNDetSpecPRight() const  {return fNDetSpecPRight;}
-  virtual Int_t   GetNTrueSpecN()  const  {return fNTrueSpecN;}
-  virtual Int_t   GetNTrueSpecP()  const  {return fNTrueSpecP;}
-  virtual Int_t   GetNTrueSpec()   const  {return fNTrueSpec;}
-  virtual Int_t   GetNPart()       const  {return fNPart;}
-  virtual Float_t GetImpPar()      const  {return fImpPar;}
+  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 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 GetZEMsignal()   const  {return fZEMsignal;}
+  //
+  virtual Int_t   GetNDetSpecNLeft()   const {return fNDetSpecNLeft;}
+  virtual Int_t   GetNDetSpecPLeft()   const {return fNDetSpecPLeft;}
+  virtual Int_t   GetNDetSpecNRight()  const {return fNDetSpecNRight;}
+  virtual Int_t   GetNDetSpecPRight()  const {return fNDetSpecPRight;}
+  virtual Int_t   GetNTrueSpecNLeft()  const {return fNTrueSpecNLeft;}
+  virtual Int_t   GetNTrueSpecPLeft()  const {return fNTrueSpecPLeft;}
+  virtual Int_t   GetNTrueSpecLeft()   const {return fNTrueSpecLeft;}
+  virtual Int_t   GetNTrueSpecNRight() const {return fNTrueSpecNRight;}
+  virtual Int_t   GetNTrueSpecPRight() const {return fNTrueSpecPRight;}
+  virtual Int_t   GetNTrueSpecRight()  const {return fNTrueSpecRight;}
+  virtual Int_t   GetNPartLeft()       const {return fNPartLeft;}
+  virtual Int_t   GetNPartRight()      const {return fNPartRight;}
+  virtual Float_t GetImpPar()          const {return fImpPar;}
 
   // Print method
   virtual void Print(Option_t *) const;
 
 private:
   // Data members
-  Float_t fZN1energy;  // Energy detected in neutron ZDC
-  Float_t fZP1energy;  // Energy detected in proton ZDC
-  Float_t fZDC1energy; // Total hadronic energy detcted in ZDCs
-  Float_t fZN2energy;  // Energy detected in neutron ZDC
-  Float_t fZP2energy;  // Energy detected in proton ZDC
-  Float_t fZDC2energy; // Total hadronic energy detcted in ZDCs
-  Float_t fZEMenergy;  // Energy detected in EM ZDC
+  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 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 fZEMsignal;  // Signal in EM ZDC
+  //
   Int_t          fNDetSpecNLeft;  // Number of spectator neutrons detected
   Int_t          fNDetSpecPLeft;  // Number of spectator protons detected
   Int_t          fNDetSpecNRight; // Number of spectator neutrons detected
   Int_t          fNDetSpecPRight; // Number of spectator protons detected
-  Int_t          fNTrueSpecN;  // Estimate of the number of spectator neutrons generated
-  Int_t          fNTrueSpecP;  // Estimate of the number of spectator protons generated
-  Int_t          fNTrueSpec ;  // Estimate of the total number of spectators
-  Int_t          fNPart;       // Estimate of the number of participants for 1 nucleus
+  Int_t          fNTrueSpecNLeft; // Estimate of the number of spectator neutrons generated
+  Int_t          fNTrueSpecPLeft; // Estimate of the number of spectator protons generated
+  Int_t          fNTrueSpecLeft;  // Estimate of the total number of spectators
+  Int_t          fNTrueSpecNRight;// Estimate of the number of spectator neutrons generated
+  Int_t          fNTrueSpecPRight;// Estimate of the number of spectator protons generated
+  Int_t          fNTrueSpecRight; // Estimate of the total number of spectators
+  Int_t          fNPartLeft;   // Estimate of the number of participants for 1 nucleus
+  Int_t          fNPartRight;  // Estimate of the number of participants for 1 nucleus
   Float_t fImpPar;     // Estimate of the impact parameter
 
 
-  ClassDef(AliZDCReco,1)  // RecPoints for the Zero Degree Calorimeters
+  ClassDef(AliZDCReco,2)  // RecPoints for the Zero Degree Calorimeters
 };
  
 #endif
index 996cda72adc6d064b994835043f0ec604a03e44c..3037576b43228eee09488485ec53aa63116f5104 100644 (file)
@@ -40,25 +40,26 @@ ClassImp(AliZDCReconstructor)
 //_____________________________________________________________________________
 AliZDCReconstructor:: AliZDCReconstructor() :
 
-  fZNCen (new TF1("fZNCen", 
+  fZNCen(new TF1("fZNCen", 
        "(-2.287920+sqrt(2.287920*2.287920-4*(-0.007629)*(11.921710-x)))/(2*(-0.007629))",0.,164.)),
-  fZNPer (new TF1("fZNPer",
+  fZNPer(new TF1("fZNPer",
       "(-37.812280-sqrt(37.812280*37.812280-4*(-0.190932)*(-1709.249672-x)))/(2*(-0.190932))",0.,164.)),
-  fZPCen (new TF1("fZPCen",
+  fZPCen(new TF1("fZPCen",
        "(-1.321353+sqrt(1.321353*1.321353-4*(-0.007283)*(3.550697-x)))/(2*(-0.007283))",0.,60.)),
-  fZPPer (new TF1("fZPPer",
+  fZPPer(new TF1("fZPPer",
       "(-42.643308-sqrt(42.643308*42.643308-4*(-0.310786)*(-1402.945615-x)))/(2*(-0.310786))",0.,60.)),
-  fZDCCen (new TF1("fZDCCen",
+  fZDCCen(new TF1("fZDCCen",
       "(-1.934991+sqrt(1.934991*1.934991-4*(-0.004080)*(15.111124-x)))/(2*(-0.004080))",0.,225.)),
-  fZDCPer (new TF1("fZDCPer",
+  fZDCPer(new TF1("fZDCPer",
       "(-34.380639-sqrt(34.380639*34.380639-4*(-0.104251)*(-2612.189017-x)))/(2*(-0.104251))",0.,225.)),
-  fbCen (new TF1("fbCen","-0.056923+0.079703*x-0.0004301*x*x+0.000001366*x*x*x",0.,220.)),
-  fbPer (new TF1("fbPer","17.943998-0.046846*x+0.000074*x*x",0.,220.)),
-  fZEMn (new TF1("fZEMn","126.2-0.05399*x+0.000005679*x*x",0.,4000.)),
-  fZEMp (new TF1("fZEMp","82.49-0.03611*x+0.00000385*x*x",0.,4000.)),
-  fZEMsp (new TF1("fZEMsp","208.7-0.09006*x+0.000009526*x*x",0.,4000.)),
-  fZEMb (new TF1("fZEMb",
+  fbCen(new TF1("fbCen","-0.056923+0.079703*x-0.0004301*x*x+0.000001366*x*x*x",0.,220.)),
+  fbPer(new TF1("fbPer","17.943998-0.046846*x+0.000074*x*x",0.,220.)),
+  fZEMn(new TF1("fZEMn","126.2-0.05399*x+0.000005679*x*x",0.,4000.)),
+  fZEMp(new TF1("fZEMp","82.49-0.03611*x+0.00000385*x*x",0.,4000.)),
+  fZEMsp(new TF1("fZEMsp","208.7-0.09006*x+0.000009526*x*x",0.,4000.)),
+  fZEMb(new TF1("fZEMb",
        "16.06-0.01633*x+1.44e-5*x*x-6.778e-9*x*x*x+1.438e-12*x*x*x*x-1.112e-16*x*x*x*x*x",0.,4000.)),
+  //
   fCalibData(GetCalibData())
 
 {
@@ -84,6 +85,7 @@ AliZDCReconstructor::~AliZDCReconstructor()
   delete fZEMp;
   delete fZEMsp;
   delete fZEMb;
+
 }
 
 
@@ -93,6 +95,7 @@ void AliZDCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) co
   // *** Local ZDC reconstruction for digits
   // Works on the current event
     
+  // Retrieving calibration data  
   Float_t meanPed[47];
   for(Int_t jj=0; jj<47; jj++) meanPed[jj] = fCalibData->GetMeanPed(jj);
 
@@ -102,35 +105,57 @@ void AliZDCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) co
   digitsTree->SetBranchAddress("ZDC", &pdigit);
 
   // loop over digits
-  Float_t zn1corr=0, zp1corr=0, zn2corr=0, zp2corr=0, zemcorr=0;
+    Float_t ZN1TowCorrHG[5], ZP1TowCorrHG[5], ZEMCorrHG=0., 
+           ZN2TowCorrHG[5], ZP2TowCorrHG[5];
+    Float_t ZN1TowCorrLG[5], ZP1TowCorrLG[5], ZEMCorrLG=0., 
+            ZN2TowCorrLG[5], ZP2TowCorrLG[5];
+    
   for (Int_t iDigit = 0; iDigit < digitsTree->GetEntries(); iDigit++) {
     digitsTree->GetEntry(iDigit);
     if (!pdigit) continue;
-
-    if(digit.GetSector(0) == 1)
-      zn1corr  += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)]);     // high gain ZN1 ADCs
-    else if(digit.GetSector(0) == 2)
-      zp1corr  += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)+10]);  // high gain ZP1 ADCs
-    else if(digit.GetSector(0) == 3){
-      if(digit.GetSector(1)==1)      
-       zemcorr += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)+20]); // high gain ZEM1 ADCs
-      else if(digit.GetSector(1)==2) 
-       zemcorr += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)+22]); // high gain ZEM2 ADCs
+      
+    Int_t det = digit.GetSector(0);
+    Int_t quad = digit.GetSector(1);
+    Int_t pedindex;
+    //
+    if(det == 1){ // *** ZN1
+       pedindex = quad;
+       ZN1TowCorrHG[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+       ZN1TowCorrLG[quad] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+5]);
+    }
+    else if(det == 2){ // *** ZP1
+       pedindex = quad+10;
+       ZP1TowCorrHG[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+       ZP1TowCorrLG[quad] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+5]);
+    }
+    else if(det == 3){
+       if(quad == 1){      // *** ZEM1  
+        pedindex = quad+20;
+         ZEMCorrHG += (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]); 
+         ZEMCorrLG += (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+2]); 
+       }
+       else if(quad == 2){  // *** ZEM1
+        pedindex = quad+21;
+         ZEMCorrHG += (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]); 
+         ZEMCorrLG += (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+2]); 
+       }
+    }
+    else if(det == 4){  // *** ZN2
+       pedindex = quad+24;
+       ZN2TowCorrHG[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+       ZN2TowCorrLG[quad] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+5]);
+    }
+    else if(det == 5){  // *** ZP2 
+       pedindex = quad+34;
+       ZP2TowCorrHG[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+       ZP2TowCorrLG[quad] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+5]);
     }
-    else if(digit.GetSector(0) == 4)
-      zn2corr  += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)+24]);  // high gain ZN2 ADCs
-    else if(digit.GetSector(0) == 5)
-      zp2corr  += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)+34]);  // high gain ZP2 ADCs
   }
-  if(zn1corr<0)  zn1corr=0;
-  if(zp1corr<0)  zp1corr=0;
-  if(zn2corr<0)  zn2corr=0;
-  if(zp2corr<0)  zp2corr=0;
-  if(zemcorr<0)  zemcorr=0;
 
   // reconstruct the event
-  //printf("\n \t ZDCReco from digits-> ZN = %.0f, ZP = %.0f, ZEM = %.0f\n",zncorr,zpcorr,zemcorr);
-  ReconstructEvent(clustersTree, zn1corr, zp1corr, zemcorr, zn2corr, zp2corr);
+    ReconstructEvent(clustersTree, ZN1TowCorrHG, ZP1TowCorrHG, ZN2TowCorrHG, 
+       ZP2TowCorrHG, ZN1TowCorrLG, ZP1TowCorrLG, ZN2TowCorrLG, 
+       ZP2TowCorrLG, ZEMCorrHG);
 
 }
 
@@ -140,148 +165,291 @@ void AliZDCReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTr
   // *** ZDC raw data reconstruction
   // Works on the current event
   
+  // Retrieving calibration data  
   Float_t meanPed[47];
   for(Int_t jj=0; jj<47; jj++) meanPed[jj] = fCalibData->GetMeanPed(jj);
 
   rawReader->Reset();
 
-  // loop over raw data digits
-  Float_t zn1corr=0, zp1corr=0,  zn2corr=0, zp2corr=0,zemcorr=0;
-  AliZDCRawStream digit(rawReader);
-  while (digit.Next()) {
-    if(digit.IsADCDataWord()){
-      if(digit.GetADCGain() == 0){
-       if(digit.GetSector(0) == 1)        
-         zn1corr  += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)]); // high gain ZN1 ADCs;
-       else if(digit.GetSector(0) == 2) 
-         zp1corr  += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)+10]); // high gain ZP1 ADCs;
-       else if(digit.GetSector(0) == 3){
-         if(digit.GetSector(1)==1)      
-           zemcorr += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)+20]); // high gain ZEM1 ADCs
-         else if(digit.GetSector(1)==2) 
-           zemcorr += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)+22]); // high gain ZEM2 ADCs
-       }
-       else if(digit.GetSector(0) == 4)           
-         zn2corr  += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)+24]); // high gain ZN2 ADCs;
-       else if(digit.GetSector(0) == 5) 
-         zp2corr  += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)+34]); // high gain ZP2 ADCs;
+  // loop over raw data rawDatas
+  Float_t ZN1TowCorrHG[5], ZP1TowCorrHG[5], ZEMCorrHG=0., 
+         ZN2TowCorrHG[5], ZP2TowCorrHG[5];
+  Float_t ZN1TowCorrLG[5], ZP1TowCorrLG[5], ZEMCorrLG=0., 
+         ZN2TowCorrLG[5], ZP2TowCorrLG[5];
+  //
+  AliZDCRawStream rawData(rawReader);
+  while (rawData.Next()) {
+    if(rawData.IsADCDataWord()){
+      Int_t det = rawData.GetSector(0);
+      Int_t quad = rawData.GetSector(1);
+      Int_t gain = rawData.GetADCGain();
+      Int_t pedindex;
+      //
+      if(det == 1){    
+        pedindex = quad;
+        if(gain == 0) ZN1TowCorrHG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+        else ZN1TowCorrLG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+5]); 
+      }
+      else if(det == 2){ 
+        pedindex = quad+10;
+        if(gain == 0) ZP1TowCorrHG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+        else ZP1TowCorrLG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+5]); 
+      }
+      else if(det == 3){ 
+        if(quad==1){    
+          pedindex = quad+20;
+          if(gain == 0) ZEMCorrHG += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+          else ZEMCorrLG += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+2]); 
+        }
+        else if(quad==2){ 
+          pedindex = rawData.GetSector(1)+21;
+          if(gain == 0) ZEMCorrHG += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+          else ZEMCorrLG += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+2]); 
+        }
+      }
+      else if(det == 4){       
+        pedindex = rawData.GetSector(1)+24;
+        if(gain == 0) ZN2TowCorrHG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+        else ZN2TowCorrLG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+2]); 
+      }
+      else if(det == 5){
+        pedindex = rawData.GetSector(1)+34;
+        if(gain == 0) ZP2TowCorrHG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]); 
+        else ZP2TowCorrLG[quad]  += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+5]); 
       }
     }
   }
-  if(zn1corr<0) zn1corr=0;
-  if(zp1corr<0) zp1corr=0;
-  if(zn2corr<0) zn2corr=0;
-  if(zp2corr<0) zp2corr=0;
-  if(zemcorr<0) zemcorr=0;
     
   // reconstruct the event
-  //printf("\n\t ZDCReco from raw-> ZN = %.0f, ZP = %.0f, ZEM = %.0f\n",zncorr,zpcorr,zemcorr);
-  ReconstructEvent(clustersTree, zn1corr, zp1corr, zemcorr, zn2corr, zp2corr);
+    ReconstructEvent(clustersTree, ZN1TowCorrHG, ZP1TowCorrHG, ZN2TowCorrHG, 
+       ZP2TowCorrHG, ZN1TowCorrLG, ZP1TowCorrLG, ZN2TowCorrLG, 
+       ZP2TowCorrLG, ZEMCorrHG);
 
 }
 
 //_____________________________________________________________________________
-void AliZDCReconstructor::ReconstructEvent(TTree *clustersTree, Float_t zn1corr, 
-       Float_t zp1corr, Float_t zemcorr, Float_t zn2corr, Float_t zp2corr) const
+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 ZEMADCCorrHG) 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);
+  //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
+  Float_t ZN1EqualCoeff[5], ZP1EqualCoeff[5], ZN2EqualCoeff[5], ZP2EqualCoeff[5];
+  for(Int_t ji=0; ji<5; ji++){
+     ZN1EqualCoeff[ji] = fCalibData->GetZN1EqualCoeff(ji);
+     ZP1EqualCoeff[ji] = fCalibData->GetZP1EqualCoeff(ji); 
+     ZN2EqualCoeff[ji] = fCalibData->GetZN2EqualCoeff(ji); 
+     ZP2EqualCoeff[ji] = fCalibData->GetZP2EqualCoeff(ji); 
+  }
+  //
+  Float_t CalibEne[4];
+  for(Int_t ij=0; ij<4; ij++) CalibEne[ij] = fCalibData->GetEnCalib(ij);
+  //
+  Float_t ZEMEndPoint = fCalibData->GetZEMEndValue();
+  Float_t ZEMCutFraction = fCalibData->GetZEMCutFraction();
+  Float_t DZEMSup = fCalibData->GetDZEMSup();
+  Float_t DZEMInf = fCalibData->GetDZEMInf();
+  //
+  Float_t ZEMCutValue = ZEMEndPoint*ZEMCutFraction;
+  Float_t ZEMSupValue = ZEMCutValue+(ZEMEndPoint*DZEMSup);
+  Float_t ZEMInfValue = ZEMCutValue-(ZEMEndPoint*DZEMInf);
+  //
+  Float_t EZN1MaxVal = fCalibData->GetEZN1MaxValue();
+  Float_t EZP1MaxVal = fCalibData->GetEZP1MaxValue();
+  Float_t EZDC1MaxVal = fCalibData->GetEZDC1MaxValue();
+  Float_t EZN2MaxVal = fCalibData->GetEZN1MaxValue();
+  Float_t EZP2MaxVal = fCalibData->GetEZP1MaxValue();
+  Float_t EZDC2MaxVal = fCalibData->GetEZDC1MaxValue();
+  
+  // Equalization of detector responses
+  Float_t ZN1EqualTowHG[5], ZN2EqualTowHG[5], ZP1EqualTowHG[5], ZP2EqualTowHG[5];
+  Float_t ZN1EqualTowLG[5], ZN2EqualTowLG[5], ZP1EqualTowLG[5], ZP2EqualTowLG[5];
+  for(Int_t gi=0; gi<5; gi++){
+     ZN1EqualTowHG[gi] = ZN1ADCCorrHG[gi]*ZN1EqualCoeff[gi];
+     ZP1EqualTowHG[gi] = ZP1ADCCorrHG[gi]*ZP1EqualCoeff[gi];
+     ZN2EqualTowHG[gi] = ZN2ADCCorrHG[gi]*ZN2EqualCoeff[gi];
+     ZP2EqualTowHG[gi] = ZP2ADCCorrHG[gi]*ZP2EqualCoeff[gi];
+     //
+     ZN1EqualTowLG[gi] = ZN1ADCCorrLG[gi]*ZN1EqualCoeff[gi];
+     ZP1EqualTowLG[gi] = ZP1ADCCorrLG[gi]*ZP1EqualCoeff[gi];
+     ZN2EqualTowLG[gi] = ZN2ADCCorrLG[gi]*ZN2EqualCoeff[gi];
+     ZP2EqualTowLG[gi] = ZP2ADCCorrLG[gi]*ZP2EqualCoeff[gi];
+  }
+  
+  // Energy calibration of detector responses
+  Float_t ZN1CalibTowHG[5], ZN2CalibTowHG[5], ZP1CalibTowHG[5], ZP2CalibTowHG[5];
+  Float_t ZN1CalibSumHG=0., ZN2CalibSumHG=0., ZP1CalibSumHG=0., ZP2CalibSumHG=0.;
+  Float_t ZN1CalibTowLG[5], ZN2CalibTowLG[5], ZP1CalibTowLG[5], ZP2CalibTowLG[5];
+  Float_t ZN1CalibSumLG=0., ZN2CalibSumLG=0., ZP1CalibSumLG=0., ZP2CalibSumLG=0.;
+  for(Int_t gi=0; gi<5; gi++){
+     ZN1CalibTowHG[gi] = ZN1EqualTowHG[gi]*CalibEne[0];
+     ZP1CalibTowHG[gi] = ZP1EqualTowHG[gi]*CalibEne[1];
+     ZN2CalibTowHG[gi] = ZN2EqualTowHG[gi]*CalibEne[2];
+     ZP2CalibTowHG[gi] = ZP2EqualTowHG[gi]*CalibEne[3];
+     ZN1CalibSumHG += ZN1CalibTowHG[gi];
+     ZP1CalibSumHG += ZP1CalibTowHG[gi];
+     ZN2CalibSumHG += ZN2CalibTowHG[gi];
+     ZP2CalibSumHG += ZP2CalibTowHG[gi];
+     //
+     ZN1CalibTowLG[gi] = ZN1EqualTowLG[gi]*CalibEne[0];
+     ZP1CalibTowLG[gi] = ZP1EqualTowLG[gi]*CalibEne[1];
+     ZN2CalibTowLG[gi] = ZN2EqualTowLG[gi]*CalibEne[2];
+     ZP2CalibTowLG[gi] = ZP2EqualTowLG[gi]*CalibEne[3];
+     ZN1CalibSumLG += ZN1CalibTowLG[gi];
+     ZP1CalibSumLG += ZP1CalibTowLG[gi];
+     ZN2CalibSumLG += ZN2CalibTowLG[gi];
+     ZP2CalibSumLG += ZP2CalibTowLG[gi];
+  }
   
-  //  ---      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); 
-
   //  ---      Number of detected spectator nucleons
   //  *** N.B. -> It works only in Pb-Pb
   Int_t nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight;
-  nDetSpecNLeft = (Int_t) (zn1energy/2.760);
-  nDetSpecPLeft = (Int_t) (zp1energy/2.760);
-  nDetSpecNRight = (Int_t) (zn2energy/2.760);
-  nDetSpecPRight = (Int_t) (zp2energy/2.760);
+  nDetSpecNLeft = (Int_t) (ZN1CalibSumHG/2.760);
+  nDetSpecPLeft = (Int_t) (ZP1CalibSumHG/2.760);
+  nDetSpecNRight = (Int_t) (ZN2CalibSumHG/2.760);
+  nDetSpecPRight = (Int_t) (ZP2CalibSumHG/2.760);
 
   //  ---      Number of generated spectator nucleons (from HIJING parameterization)
-   //  *** N.B. -> Only one side!!!
- Int_t nGenSpecN=0, nGenSpecP=0, nGenSpec=0;
-  Double_t impPar=0;
+  Int_t nGenSpecNLeft=0, nGenSpecPLeft=0, nGenSpecLeft=0;
+  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 eZEMCut = 420.;
   Float_t deltaEZEMSup = 690.; 
   Float_t deltaEZEMInf = 270.; 
   if(zemenergy > (eZEMCut+deltaEZEMSup)){
-    nGenSpecN = (Int_t) (fZNCen->Eval(zn1energy));
-    nGenSpecP = (Int_t) (fZPCen->Eval(zp1energy));
-    nGenSpec  = (Int_t) (fZDCCen->Eval(zdc1energy));
-    impPar    = fbCen->Eval(zdc1energy);
+    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)){
-    nGenSpecN = (Int_t) (fZNPer->Eval(zn1energy)); 
-    nGenSpecP = (Int_t) (fZPPer->Eval(zp1energy));
-    nGenSpec  = (Int_t) (fZDCPer->Eval(zdc1energy));
-    impPar    = fbPer->Eval(zdc1energy);
+    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)){
-    nGenSpecN = (Int_t) (fZEMn->Eval(zemenergy));
-    nGenSpecP = (Int_t) (fZEMp->Eval(zemenergy));
-    nGenSpec  = (Int_t)(fZEMsp->Eval(zemenergy));
-    impPar    =  fZEMb->Eval(zemenergy);
+    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(zn1energy>162.)  nGenSpecN = (Int_t) (fZEMn->Eval(zemenergy));
-  if(zp1energy>59.75)  nGenSpecP = (Int_t) (fZEMp->Eval(zemenergy));
-  if(zdc1energy>221.5) nGenSpec  = (Int_t)(fZEMsp->Eval(zemenergy));
-  if(zdc1energy>220.)  impPar    =  fZEMb->Eval(zemenergy);
-  
-  if(nGenSpecN>125)    nGenSpecN=125;
-  else if(nGenSpecN<0) nGenSpecN=0;
-  if(nGenSpecP>82)     nGenSpecP=82;
-  else if(nGenSpecP<0) nGenSpecP=0;
-  if(nGenSpec>207)     nGenSpec=207;
-  else if(nGenSpec<0)  nGenSpec=0;
+  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
+  //
+  if(ZEMADCCorrHG > ZEMSupValue){
+    nGenSpecNLeft  = (Int_t) (fZNCen->Eval(ZN1CalibSumHG));
+    nGenSpecPLeft  = (Int_t) (fZPCen->Eval(ZP1CalibSumHG));
+    nGenSpecLeft   = (Int_t) (fZDCCen->Eval(ZN1CalibSumHG+ZP1CalibSumHG));
+    nGenSpecNRight = (Int_t) (fZNCen->Eval(ZN2CalibSumHG));
+    nGenSpecPRight = (Int_t) (fZNCen->Eval(ZP2CalibSumHG));
+    nGenSpecRight  = (Int_t) (fZNCen->Eval(ZN2CalibSumHG+ZP2CalibSumHG));
+    impPar  = fbCen->Eval(ZN1CalibSumHG+ZP1CalibSumHG);
+  }
+  else if(ZEMADCCorrHG < ZEMInfValue){
+    nGenSpecNLeft = (Int_t) (fZNPer->Eval(ZN1CalibSumHG)); 
+    nGenSpecPLeft = (Int_t) (fZPPer->Eval(ZP1CalibSumHG));
+    nGenSpecLeft  = (Int_t) (fZDCPer->Eval(ZN1CalibSumHG+ZP1CalibSumHG));
+    impPar   = fbPer->Eval(ZN1CalibSumHG+ZP1CalibSumHG);
+  }
+  else if(ZEMADCCorrHG >= ZEMInfValue && ZEMADCCorrHG <= ZEMSupValue){
+    nGenSpecNLeft = (Int_t) (fZEMn->Eval(ZEMADCCorrHG));
+    nGenSpecPLeft = (Int_t) (fZEMp->Eval(ZEMADCCorrHG));
+    nGenSpecLeft  = (Int_t)(fZEMsp->Eval(ZEMADCCorrHG));
+    impPar   =  fZEMb->Eval(ZEMADCCorrHG);
+  }
+  // 
+  if(ZN1CalibSumHG/EZN1MaxVal>1.)  nGenSpecNLeft = (Int_t) (fZEMn->Eval(ZEMADCCorrHG));
+  if(ZP1CalibSumHG/EZP1MaxVal>1.)  nGenSpecPLeft = (Int_t) (fZEMp->Eval(ZEMADCCorrHG));
+  if((ZN1CalibSumHG+ZP1CalibSumHG/EZDC1MaxVal)>1.){
+     nGenSpecLeft = (Int_t)(fZEMsp->Eval(ZEMADCCorrHG));
+     impPar = fZEMb->Eval(ZEMADCCorrHG);
+  }
+  if(ZN2CalibSumHG/EZN2MaxVal>1.)  nGenSpecNRight = (Int_t) (fZEMn->Eval(ZEMADCCorrHG));
+  if(ZP2CalibSumHG/EZP2MaxVal>1.)  nGenSpecPRight = (Int_t) (fZEMp->Eval(ZEMADCCorrHG));
+  if((ZN2CalibSumHG+ZP2CalibSumHG/EZDC2MaxVal)>1.) nGenSpecRight = (Int_t)(fZEMsp->Eval(ZEMADCCorrHG));
+  //
+  if(nGenSpecNLeft>125)    nGenSpecNLeft=125;
+  else if(nGenSpecNLeft<0) nGenSpecNLeft=0;
+  if(nGenSpecPLeft>82)     nGenSpecPLeft=82;
+  else if(nGenSpecPLeft<0) nGenSpecPLeft=0;
+  if(nGenSpecLeft>207)     nGenSpecLeft=207;
+  else if(nGenSpecLeft<0)  nGenSpecLeft=0;
   
   //  ---      Number of generated participants (from HIJING parameterization)
-  Int_t nPart, nPartTot;
-  nPart = 207-nGenSpecN-nGenSpecP;
-  nPartTot = 207-nGenSpec;
-  //printf("\t  ZDCeventReco-> ZNEn = %.0f GeV, ZPEn = %.0f GeV, ZEMEn = %.0f GeV\n",
-  //   znenergy, zpenergy, zemenergy);
-
-  // get the output tree and store the ZDC reco object there
-  AliZDCReco reco(zn1energy, zp1energy, zdc1energy, zemenergy,
-                 zn2energy, zp2energy, zdc2energy, 
-                  nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight,
-                 nGenSpecN, nGenSpecP, nGenSpec,nPartTot, impPar);
+  Int_t nPart, nPartTotLeft, nPartTotRight;
+  nPart = 207-nGenSpecNLeft-nGenSpecPLeft;
+  nPartTotLeft = 207-nGenSpecLeft;
+  nPartTotRight = 207-nGenSpecRight;
+
+  // create the output tree
+  AliZDCReco reco(ZN1CalibSumHG, ZP1CalibSumHG, ZN2CalibSumHG, ZP2CalibSumHG, 
+                 ZN1CalibTowLG, ZN2CalibTowLG, ZP1CalibTowLG, ZP2CalibTowLG, 
+                 ZEMADCCorrHG, 
+                 nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight, 
+                 nGenSpecNLeft, nGenSpecPLeft, nGenSpecLeft, nGenSpecNRight, 
+                 nGenSpecPRight, nGenSpecRight,
+                 nPartTotLeft, nPartTotRight, impPar);
+                 
   AliZDCReco* preco = &reco;
   const Int_t kBufferSize = 4000;
   clustersTree->Branch("ZDC", "AliZDCReco", &preco, kBufferSize);
@@ -300,8 +468,9 @@ void AliZDCReconstructor::FillZDCintoESD(TTree *clustersTree, AliESDEvent* esd)
   clustersTree->SetBranchAddress("ZDC", &preco);
 
   clustersTree->GetEntry(0);
-  esd->SetZDC(reco.GetZN1energy(), reco.GetZP1energy(), reco.GetZEMenergy(),
-             reco.GetZN2energy(), reco.GetZP2energy(), reco.GetNPart());
+  esd->SetZDC(reco.GetZN1Energy(), reco.GetZP1Energy(), reco.GetZEMsignal(),
+             reco.GetZN2Energy(), reco.GetZP2Energy(), 
+             reco.GetNPartLeft());
 }
 
 //_____________________________________________________________________________
index 67a89a2dd7483f3561f1995e607e6f024c47e35a..07dbf13f56f5f49967009ab958906b1df8a91f9f 100644 (file)
@@ -25,8 +25,8 @@ public:
   AliZDCReconstructor();
   virtual ~AliZDCReconstructor();
 
-  virtual Bool_t       HasDigitConversion() const {return kFALSE;};
-  virtual Bool_t       HasLocalReconstruction() const {return kTRUE;};
+  virtual Bool_t HasDigitConversion() const {return kFALSE;}
+  virtual Bool_t HasLocalReconstruction() const {return kTRUE;}
 
   virtual void Reconstruct(TTree* digitsTree, TTree* clustersTree) const; 
   virtual void Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const;
@@ -49,16 +49,19 @@ public:
   virtual void FillESD(AliRunLoader* /*runLoader*/, 
                       AliRawReader* /*rawReader*/, AliESDEvent* /*esd*/) const
     { AliError("Method should not be used anymore !"); }
-
+  
   AliCDBStorage   *SetStorage(const char* uri);
   AliZDCCalibData *GetCalibData() const; 
-
+  
 private:
   AliZDCReconstructor(const AliZDCReconstructor&);
   AliZDCReconstructor& operator =(const AliZDCReconstructor&);
 
-  void   ReconstructEvent(TTree *clustersTree, Float_t zn1corr, Float_t zp1corr, Float_t zemcorr,
-               Float_t zn2corr, Float_t zp2corr) const;
+  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 ZEMADCCorrHG) const;
   void   FillZDCintoESD(TTree *clustersTree, AliESDEvent*esd) const;
 
   TF1*   fZNCen;     //! Nspectator n true vs. EZN
@@ -76,7 +79,7 @@ private:
   
   AliZDCCalibData *fCalibData;         //! calibration data
 
-  ClassDef(AliZDCReconstructor, 1)   // class for the ZDC reconstruction
+  ClassDef(AliZDCReconstructor, 2)   // class for the ZDC reconstruction
 };
 
 #endif