]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Preliminary version of CDB
authorcoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 30 Dec 2005 12:28:26 +0000 (12:28 +0000)
committercoppedis <coppedis@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 30 Dec 2005 12:28:26 +0000 (12:28 +0000)
ZDC/AliZDCCalibData.cxx
ZDC/AliZDCCalibData.h
ZDC/AliZDCDigitizer.cxx
ZDC/AliZDCDigitizer.h
ZDC/AliZDCRawStream.cxx
ZDC/AliZDCReconstructor.cxx
ZDC/AliZDCReconstructor.h

index e1af544d08a0733f94e44971605e2b8c67ff2ddc..b12463d228b8763e37777cdae3ad8f11ae995f74 100644 (file)
@@ -106,7 +106,15 @@ void  AliZDCCalibData::Print(Option_t *) const
 {
    printf("\n  ----    Mean pedestal values    ----\n\n");
    for(int t=0; t<47; t++){
-      printf(" MeanPed Value[ADC%d] = %f\n",t,fMeanPedestal[t]);
+     if(t==0 || t==24) printf("\t ZN HighRes -------- ");
+     else if(t==5 || t==29) printf("\t ZN LowRes -------- ");
+     else if(t==10 || t==34) printf("\t ZP HighRes -------- ");
+     else if(t==15 || t==39) printf("\t ZP LowRes -------- ");
+     else if(t==20) printf("\t ZEM1 HighRes -------- ");
+     else if(t==21) printf("\t ZEM1 LowRes -------- ");
+     else if(t==22) printf("\t ZEM2 HighRes -------- ");
+     else if(t==23) printf("\t ZEM2 LowRes -------- ");
+     printf("\t MeanPed[ADC%d] = %.1f\n",t,fMeanPedestal[t]);
    }
  
    printf("\n  ----    Energy calibration coefficients         ----\n\n");
index 4456207fab3ae2e26255e0ba329854d8f2203ed7..89ca61421234f659e074c7b2c8491037cbb0e69a 100644 (file)
@@ -11,6 +11,7 @@
 #include "TNamed.h"
 #include "TH1.h"
 #include "AliZDC.h"
+#include "AliCDBEntry.h"
 
 class AliZDCCalibData: public TNamed {
 
index 68ab2159b0abe2fdce9208c45cb5ef3b68f9f836..11b00c2b784b351bd39618350f6b56ce96531dbe 100644 (file)
 #include "AliGenHijingEventHeader.h"
 #include "AliRunDigitizer.h"
 #include "AliRunLoader.h"
+#include "AliCDBStorage.h"
+#include "AliCDBEntry.h"
 #include "AliZDCSDigit.h"
 #include "AliZDCDigit.h"
 #include "AliZDCFragment.h"
 #include "AliZDCDigitizer.h"
+#include "AliZDCCalibData.h"
 
 ClassImp(AliZDCDigitizer)
 
@@ -55,8 +58,8 @@ AliZDCDigitizer::AliZDCDigitizer()
 AliZDCDigitizer::AliZDCDigitizer(AliRunDigitizer* manager):
   AliDigitizer(manager)
 {
-// Constructor    
-
+  // Constructor    
+  // if(!fStorage) fStorage =  AliCDBManager::Instance()->GetStorage("local://DBlocal");
 }
 
 //____________________________________________________________________________
@@ -70,15 +73,14 @@ AliZDCDigitizer::~AliZDCDigitizer()
 //____________________________________________________________________________
 Bool_t AliZDCDigitizer::Init()
 {
-// Initialize the digitizer
-
+  // Initialize the digitizer
+  // NB -> PM gain vs. HV & ADC resolutions will move to DCDB ***************
   for (Int_t i = 0; i < 3; i++) {
     for(Int_t j = 0; j < 5; j++) {
       fPMGain[i][j]   = 100000.;
     }
   }
-
-// ADC Caen V965
+  // ADC Caen V965
   fADCRes[0]   = 0.0000008; // ADC Resolution high gain: 200 fC/adcCh
   fADCRes[1]   = 0.0000064; // ADC Resolution low gain:  25  fC/adcCh
 
@@ -88,16 +90,16 @@ Bool_t AliZDCDigitizer::Init()
 //____________________________________________________________________________
 void AliZDCDigitizer::Exec(Option_t* /*option*/)
 {
-// Execute digitization
+  // Execute digitization
 
   Float_t pm[3][5];
+  // --- pm[0][...] = light in ZN  [C, Q1, Q2, Q3, Q4]
+  // --- pm[1][...] = light in ZP  [C, Q1, Q2, Q3, Q4]
+  // --- pm[2][...] = light in ZEM [x, 1, 2, x, x]
   for (Int_t iSector1 = 0; iSector1 < 3; iSector1++)
     for (Int_t iSector2 = 0; iSector2 < 5; iSector2++) {
       pm[iSector1][iSector2] = 0;
     }
-  // pm[0][...] = light in ZN [C, Q1, Q2, Q3, Q4]
-  // pm[1][...] = light in ZP [C, Q1, Q2, Q3, Q4]
-  // pm[2][...] = light in ZEM [x, 1, 2, x, x]
 
   // impact parameter and number of spectators
   Float_t impPar = -1;
@@ -131,10 +133,10 @@ void AliZDCDigitizer::Exec(Option_t* /*option*/)
                       sdigit.GetSector(0), sdigit.GetSector(1)));
        continue;
       }
-      pm[sdigit.GetSector(0)-1][sdigit.GetSector(1)] += sdigit.GetLightPM();
-      //printf("\n\t sector[0] = %d, sector[1] = %d, pm[%d][%d] = %f \n",
-      //         sdigit.GetSector(0), sdigit.GetSector(1),sdigit.GetSector(0)-1,
-      //         sdigit.GetSector(1), pm[sdigit.GetSector(0)-1][sdigit.GetSector(1)]); // Chiara debugging!
+      pm[(sdigit.GetSector(0))-1][sdigit.GetSector(1)] += sdigit.GetLightPM();
+      printf("\n\t Detector (%d, %d), pm[%d][%d] = %.0f \n",
+         sdigit.GetSector(0), sdigit.GetSector(1),sdigit.GetSector(0)-1,
+         sdigit.GetSector(1), pm[sdigit.GetSector(0)-1][sdigit.GetSector(1)]); // Chiara debugging!
     }
 
     // unload sdigits
@@ -153,13 +155,17 @@ void AliZDCDigitizer::Exec(Option_t* /*option*/)
     specP = ((AliGenHijingEventHeader*) genHeader)->ProjSpectatorsp();
     AliDebug(2, Form("\n b = %f fm, Nspecn = %d, Nspecp = %d\n",
                      impPar, specN, specP));
+   printf("\n\t **** b = %f fm, Nspecn = %d, Nspecp = %d\n",
+                     impPar, specN, specP);
   }
 
   // add spectators
   if (impPar >= 0) {
     Int_t freeSpecN, freeSpecP;
     Fragmentation(impPar, specN, specP, freeSpecN, freeSpecP);
+    printf("\n\t ---- Adding signal for %d free spectator n\n",freeSpecN);
     SpectatorSignal(1, freeSpecN, pm);
+    printf("\t ---- Adding signal for %d free spectator p\n\n",freeSpecP);
     SpectatorSignal(2, freeSpecP, pm);
   }
 
@@ -190,10 +196,10 @@ void AliZDCDigitizer::Exec(Option_t* /*option*/)
     for (sector[1] = 0; sector[1] < 5; sector[1]++)  {
         if ((sector[0] == 3) && ((sector[1] < 1) || (sector[1] > 2))) continue;
         for (Int_t res = 0; res < 2; res++){
-          digi[res] = Phe2ADCch(1, 0, pm[sector[0]-1][sector[1]], res) 
-                   + Pedestal();
-         //printf("\n\t sector[0] = %d, sector[1] = %d, digi[%d] = %d\n",
-         //    sector[0], sector[1], res, digi[res]); // Chiara debugging!
+          digi[res] = Phe2ADCch(sector[0], sector[1], pm[sector[0]-1][sector[1]], res) 
+                   + Pedestal(sector[0], sector[1], res);
+         printf("\t DIGIT added -> det = %d, quad = %d - digi[%d] = %d\n\n",
+             sector[0], sector[1], res, digi[res]); // Chiara debugging!
        }
         new(pdigit) AliZDCDigit(sector, digi);
         treeD->Fill();
@@ -255,9 +261,7 @@ void AliZDCDigitizer::SpectatorSignal(Int_t SpecType, Int_t numEvents,
   
   Float_t *entry, hitsSpec[7];
   Int_t pl, i, j, k, iev=0, rnd[125], volume[2];
-  for(pl=0;pl<125;pl++){
-     rnd[pl] = 0;
-  }
+  for(pl=0;pl<125;pl++) rnd[pl] = 0;
   if (numEvents > 125) {
     AliWarning(Form("numEvents (%d) is larger than 125", numEvents));
     numEvents = 125;
@@ -276,20 +280,24 @@ void AliZDCDigitizer::SpectatorSignal(Int_t SpecType, Int_t numEvents,
        if(entry[0] == rnd[iev]){
           for(k=0; k<2; k++) volume[k] = (Int_t) entry[k+1];
           for(j=0; j<7; j++) hitsSpec[j] = entry[j+3];
-
+         //
          Float_t lightQ = hitsSpec[4];
          Float_t lightC = hitsSpec[5];
-         AliDebug(3, Form("volume = (%d, %d), lightQ = %.3f, lightC = %.3f",
+         AliDebug(3, Form("Volume = (%d, %d), lightQ = %.0f, lightC = %.0f",
                            volume[0], volume[1], lightQ, lightC));
+         //printf("\n   Volume = (%d, %d), lightQ = %.0f, lightC = %.0f",
+          //                 volume[0], volume[1], lightQ, lightC);
          if (volume[0] < 3) {  // ZN or ZP
             pm[volume[0]-1][0] += lightC;
             pm[volume[0]-1][volume[1]] += lightQ;
-         } else {
-            if (volume[1] == 1) pm[2][1] += lightC;
-            else                pm[2][2] += lightQ;
-       }
-
-
+           //printf("\n   pm[%d][0] = %.0f, pm[%d][%d] = %.0f\n",(volume[0]-1),pm[volume[0]-1][0],
+           //  (volume[0]-1),volume[1],pm[volume[0]-1][volume[1]]);
+         } 
+         else { 
+            if (volume[1] == 1) pm[2][1] += lightC; // ZEM 1
+            else                pm[2][2] += lightQ; // ZEM 2
+           //printf("\n   pm[2][1] = %.0f, pm[2][2] = %.0f\n",pm[2][1],pm[2][2]);
+         }
        }
        else if(entry[0] > rnd[iev]){
          iev++;
@@ -307,19 +315,46 @@ void AliZDCDigitizer::SpectatorSignal(Int_t SpecType, Int_t numEvents,
 Int_t AliZDCDigitizer::Phe2ADCch(Int_t Det, Int_t Quad, Float_t Light, 
                                  Int_t Res) const
 {
-// Evaluation of the ADC channel corresponding to the light yield Light
+  // Evaluation of the ADC channel corresponding to the light yield Light
+  Int_t ADCch = (Int_t) (Light * fPMGain[Det-1][Quad] * fADCRes[Res]);
+  printf("\t Phe2ADCch -> det %d quad %d - phe %.0f  ADC %d\n", Det,Quad,Light,ADCch);
+  return ADCch;
+}
 
-  return (Int_t) (Light * fPMGain[Det-1][Quad] * fADCRes[Res]);
+//_____________________________________________________________________________
+Int_t AliZDCDigitizer::Pedestal(Int_t Det, Int_t Quad, Int_t Res) const
+{
+  // Get calibration data
+  int runNumber = 0;
+  AliZDCCalibData *calibda = GetCalibData(runNumber);  
+  //calibda->Print("");
+  
+  Float_t meanPed;
+  if(Det != 3) meanPed = calibda->GetMeanPed(10*(Det-1)+Quad+5*Res);
+  else         meanPed = calibda->GetMeanPed(10*(Det-1)+Quad+1*Res);
+  
+  printf("\t Pedestal -> det = %d, quad = %d, res = %d - Ped[%d] = %d\n",
+       Det, Quad, Res,10*(Det-1)+Quad+5*Res,(Int_t) meanPed); // Chiara debugging!
+  
+  return (Int_t) meanPed;
 }
 
 //_____________________________________________________________________________
-Int_t AliZDCDigitizer::Pedestal() const
+AliZDCCalibData* AliZDCDigitizer::GetCalibData(int runNumber) const
 {
-  // --- Pedestal value -> extracted from a gaussian distribution
-  // obtained from the beam test on the ZEM prototype (Aug. 2000)
 
-  Float_t pedMean  = 50.;
-  Float_t pedWidth = 5.;
+  printf("\t AliZDCReconstructor::GetCalibData for RUN #%d\n",runNumber);
+  //fStorage->PrintSelectionList();
+  //AliCDBEntry *entry = fStorage->Get("ZDC/Calib/Data",runNumber);
+  
+  AliCDBStorage *fStorage = AliCDBManager::Instance()->GetStorage("local://DBlocal");
+  AliCDBEntry  *entry = fStorage->Get("ZDC/Calib/Data",1);
+  
+  AliZDCCalibData *calibda = (AliZDCCalibData*) entry->GetObject();
+  //calibda->Print("");
+
+  AliCDBManager::Instance()->Destroy();
+
+  return calibda;
 
-  return (Int_t) gRandom->Gaus(pedMean, pedWidth);
 }
index 0536542969c02b69bb61334de9a657256181e57b..c2a2dc942fcf2017eab69ae31b0a1bab06b50bac 100644 (file)
@@ -10,6 +10,9 @@
 ////////////////////////////////////////////////
 
 #include "AliDigitizer.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#include "AliZDCCalibData.h"
 
 class AliRunDigitizer;
 
@@ -39,6 +42,9 @@ public:
   //  Two conversion factor are needed for ADC CAEN V965 
     {for (Int_t i=0;i<2;i++) fADCRes[i] = adcRes[i];}
   Float_t GetADCRes(Int_t i) const {return fADCRes[i];}
+  
+  void   GetStorage(const char* uri) {fStorage = AliCDBManager::Instance()->GetStorage(uri);}
+  AliZDCCalibData *GetCalibData(int runNumber) const; 
 
 private:
   void    Fragmentation(Float_t impPar, Int_t specN, Int_t specP,
@@ -48,12 +54,14 @@ private:
 
   Int_t   Phe2ADCch(Int_t Detector, Int_t Quadrant, Float_t Light, 
                     Int_t Res) const;
-  Int_t   Pedestal() const;
+  Int_t   Pedestal(Int_t Detector, Int_t Quadrant, Int_t Res) const;
 
   Float_t fPMGain[3][5];      // PM gain
   Float_t fADCRes[2];        // ADC conversion factors
+  
+  AliCDBStorage *fStorage; //! storage
 
        
-  ClassDef(AliZDCDigitizer, 2)     // digitizer for ZDC
+  ClassDef(AliZDCDigitizer, 3)     // digitizer for ZDC
 };    
 #endif
index 344a3f41c5c7b5f94367b5340ce1e502836f8c3f..ac12ddf15e796fca393cabec58bb51e81e520c4c 100644 (file)
@@ -83,20 +83,20 @@ Bool_t AliZDCRawStream::Next()
   
   //ADC Header
   if (fRawADC & 0x2000000) {
-    printf("This is the ADC Header\n");
-    printf("%d data words will follow \n",2*((fRawADC & 0x3f00) >> 8));
+    //printf("This is the ADC Header\n");
+    //printf("%d data words will follow \n",2*((fRawADC & 0x3f00) >> 8));
   } 
   //ADC EOB
   else if (fRawADC & 0x4000000) {
-    printf("This is the ADC End Of Block\n");
-    printf("This was event number %d\n",(fRawADC & 0xffffff));
-  } else 
+    //printf("This is the ADC End Of Block\n");
+    //printf("This was event number %d\n",(fRawADC & 0xffffff));
+  } 
+  else 
   //ADC Data Words
   {
-    printf("This is an ADC Data Word\n");
-    printf("Channel %d range %d\n", 
-           (fRawADC & 0x1e0000) >> 17, (fRawADC & 0x10000) >> 16);
-    if(fRawADC & 0x1000) printf("Data = overflow\n");
+    //printf("This is an ADC Data Word\n");
+    //printf("Channel %d range %d\n",(fRawADC & 0x1e0000) >> 17, (fRawADC & 0x10000) >> 16);
+    //if(fRawADC & 0x1000) printf("Data = overflow\n");
     fADCGain = (fRawADC & 0x10000) >> 16;
     fADCValue = (fRawADC & 0xfff);   
     fIsADCDataWord = kTRUE;
index 7d651141406cbdbc25eda769125cb79e13516950..b8822ff32f85acae0fe2170bb35066de6c3e4ea7 100644 (file)
@@ -31,6 +31,7 @@
 #include "AliZDCRawStream.h"
 #include "AliZDCReco.h"
 #include "AliZDCReconstructor.h"
+#include "AliZDCCalibData.h"
 
 
 ClassImp(AliZDCReconstructor)
@@ -39,27 +40,11 @@ ClassImp(AliZDCReconstructor)
 //_____________________________________________________________________________
 AliZDCReconstructor:: AliZDCReconstructor()
 {
-// default constructor
+  // **** Default constructor
+  // if(!fStorage) fStorage =  AliCDBManager::Instance()->GetStorage("local://DBlocal");
 
   //  ---      Number of generated spectator nucleons and impact parameter
   // --------------------------------------------------------------------------------------------------
-  // [1] ### Results in Chiara's PhD thesis -> 0<b<15 fm (Dec 2001)
-  /*// Fit results for neutrons (Nspectator n true vs. EZN)
-  fZNCen = new TF1("fZNCen",
-      "(-2.116909+sqrt(2.116909*2.116909-4*(-0.00651)*(14.556798-x)))/(2*(-0.00651))",0.,158.5);
-  fZNPer = new TF1("fZNPer",
-      "(-34.695134-sqrt(34.695134*34.695134-4*(-0.174780)*(-1562.283443-x)))/(2*(-0.174780))",0.,158.5);
-  // Fit results for protons (Nspectator p true vs. EZP)
-  fZPCen = new TF1("fZPCen",
-      "(-1.3217+sqrt(1.3217*1.3217-4*(-0.007934)*(4.742873-x)))/(2*(-0.007934))",0.,58.91);
-  fZPPer = new TF1("fZPPer",
-      "(-15.788267-sqrt(15.788267*15.788267-4*(-0.133359)*(-383.800673-x)))/(2*(-0.133359))",0.,58.91);
-  // Fit results for total number of spectators (Nspectators true vs. EZDC)
-  fZDCCen = new TF1("fZDCCen",
-      "(-1.867335+sqrt(1.867335*1.867335-4*(-0.004119)*(19.100289-x)))/(2*(-0.004119))",0.,220.4);
-  fZDCPer = new TF1("fZDCPer",
-      "(-22.429097-sqrt(22.429097*22.429097-4*(-0.072435)*(-1482.034526-x)))/(2*(-0.072435))",0.,220.4);*/
-  // --------------------------------------------------------------------------------------------------
   // [1] ### Results from a new production  -> 0<b<18 fm (Apr 2002)
   // Fit results for neutrons (Nspectator n true vs. EZN)
   fZNCen = new TF1("fZNCen",
@@ -77,24 +62,12 @@ AliZDCReconstructor:: AliZDCReconstructor()
   fZDCPer = new TF1("fZDCPer",
       "(-34.380639-sqrt(34.380639*34.380639-4*(-0.104251)*(-2612.189017-x)))/(2*(-0.104251))",0.,225.);
   // --------------------------------------------------------------------------------------------------
-  // [1] ### Results in Chiara's PhD thesis -> 0<b<15 fm (Dec 2001)
-  /*// Fit results for b (b vs. EZDC)
-  //fbCen = new TF1("fbCen","0.611543+0.052231*x-0.000112*x*x+0.000000374*x*x*x",0.,222.);
-  //fbPer = new TF1("fbPer","16.552010-0.023866*x-0.00001*x*x",0.,222.);
-  fbCen = new TF1("fbCen","0.612769+0.051929*x-0.0001074*x*x+0.0000003724*x*x*x",0.,225.);
-  fbPer = new TF1("fbPer","16.6131016-0.026053*x+0.000006893*x*x",0.,225.);*/
-  // --------------------------------------------------------------------------------------------------
+  // Fit results for b (b vs. EZDC)
   // [2] ### Results from a new production  -> 0<b<18 fm (Apr 2002)
   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.);
   // --------------------------------------------------------------------------------------------------
   // Evaluating Nspectators and b from ZEM energy
-  // [1] ### Results in Chiara's PhD thesis -> 0<b<15 fm (Dec 2001)
-  /*fZEMn  = new TF1("fZEMn","124.2-0.0566*x+0.000006014*x*x",0.,3500.);
-  fZEMp  = new TF1("fZEMp","81.3-0.03834*x+0.000004359*x*x",0.,3500.);
-  fZEMsp = new TF1("fZEMsp","205.6-0.09567*x+0.00001056*x*x",0.,3500.);
-  fZEMb  = new TF1("fZEMb","15.8-0.02084*x+2.802e-5*x*x-2.007e-8*x*x*x+6.586e-12*x*x*x*x-8.042e-16*x*x*x*x*x",0.,3500.);*/
-  // --------------------------------------------------------------------------------------------------
   // [2] ### Results from a new production  -> 0<b<18 fm (Apr 2002)
   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.);
@@ -145,7 +118,14 @@ AliZDCReconstructor::~AliZDCReconstructor()
 //_____________________________________________________________________________
 void AliZDCReconstructor::Reconstruct(AliRunLoader* runLoader) const
 {
-// local ZDC reconstruction
+  // *** Local ZDC reconstruction for digits
+  
+  // Get calibration data
+  int runNumber = 0;
+  AliZDCCalibData *calibda = GetCalibData(runNumber);  
+  
+  Float_t meanPed[47];
+  for(Int_t jj=0; jj<47; jj++) meanPed[jj] = calibda->GetMeanPed(jj);
 
   AliLoader* loader = runLoader->GetLoader("ZDCLoader");
   if (!loader) return;
@@ -165,18 +145,27 @@ void AliZDCReconstructor::Reconstruct(AliRunLoader* runLoader) const
     treeD->SetBranchAddress("ZDC", &pdigit);
 
     // loop over digits
-    Int_t znraw=0, zpraw=0, zemraw=0;
+    Float_t zncorr=0, zpcorr=0, zemcorr=0;
     for (Int_t iDigit = 0; iDigit < treeD->GetEntries(); iDigit++) {
       treeD->GetEntry(iDigit);
       if (!pdigit) continue;
 
-      if(digit.GetSector(0) == 1)      znraw  += digit.GetADCValue(0);
-      else if(digit.GetSector(0) == 2)         zpraw  += digit.GetADCValue(0);
-      else if(digit.GetSector(0) == 3)         zemraw += digit.GetADCValue(0);
+      if(digit.GetSector(0) == 1)
+                zncorr  += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)]);          // ped 4 high gain ZN ADCs
+      else if(digit.GetSector(0) == 2)
+        zpcorr  += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)+10]); // ped 4 high gain ZP ADCs
+      else if(digit.GetSector(0) == 3){
+        if(digit.GetSector(1)==1)      zemcorr += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)+20]); // ped 4 high gain ZEM1 ADCs
+        else if(digit.GetSector(1)==2) zemcorr += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)+22]); // ped 4 high gain ZEM2 ADCs
+      }
     }
+    if(zncorr<0)  zncorr=0;
+    if(zpcorr<0)  zpcorr=0;
+    if(zemcorr<0) zemcorr=0;
 
     // reconstruct the event
-    ReconstructEvent(loader, znraw, zpraw, zemraw);
+    printf("\n \t ZDCReco from digits-> Ev.#%d ZN = %.0f, ZP = %.0f, ZEM = %.0f\n",iEvent,zncorr,zpcorr,zemcorr);
+    ReconstructEvent(loader, zncorr, zpcorr, zemcorr);
   }
 
   loader->UnloadDigits();
@@ -187,7 +176,14 @@ void AliZDCReconstructor::Reconstruct(AliRunLoader* runLoader) const
 void AliZDCReconstructor::Reconstruct(AliRunLoader* runLoader, 
                                       AliRawReader* rawReader) const
 {
-// local ZDC reconstruction for raw data
+  // *** Local ZDC reconstruction for raw data
+  
+  // Calibration data
+  int runNumber = 0;
+  AliZDCCalibData *calibda = GetCalibData(runNumber);  
+  
+  Float_t meanPed[47];
+  for(Int_t jj=0; jj<47; jj++) meanPed[jj] = calibda->GetMeanPed(jj);
 
   AliLoader* loader = runLoader->GetLoader("ZDCLoader");
   if (!loader) return;
@@ -198,42 +194,34 @@ void AliZDCReconstructor::Reconstruct(AliRunLoader* runLoader,
     runLoader->GetEvent(iEvent++);
 
     // loop over raw data digits
-    Int_t znraw=0, zpraw=0, zemraw=0;
+    Float_t zncorr=0, zpcorr=0, zemcorr=0;
     AliZDCRawStream digit(rawReader);
     while (digit.Next()) {
       if(digit.IsADCDataWord()){
         if(digit.GetADCGain() == 0){
-          printf("ADC value = %d\n",digit.GetADCValue());
-          if(digit.GetSector(0) == 1)     znraw  += digit.GetADCValue();
-          else if(digit.GetSector(0) == 2) zpraw  += digit.GetADCValue();
-          else if(digit.GetSector(0) == 3) zemraw += digit.GetADCValue();
-        }
+          if(digit.GetSector(0) == 1)     zncorr  += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)]); // pedestals for high gain ZN ADCs;
+          else if(digit.GetSector(0) == 2) zpcorr  += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)+10]); // pedestals for high gain ZP ADCs;
+          else if(digit.GetSector(0) == 3) zemcorr += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)+20]); // pedestals for high gain ZEM ADCs;
+       }
       }
     }
+    if(zncorr<0)  zncorr=0;
+    if(zpcorr<0)  zpcorr=0;
+    if(zemcorr<0) zemcorr=0;
+    
     // reconstruct the event
-    ReconstructEvent(loader, znraw, zpraw, zemraw);
+    printf("\n\t ZDCReco from raw-> Ev.#%d ZN = %.0f, ZP = %.0f, ZEM = %.0f\n",iEvent,zncorr,zpcorr,zemcorr);
+    ReconstructEvent(loader, zncorr, zpcorr, zemcorr);
   }
 
   loader->UnloadRecPoints();
 }
 
 //_____________________________________________________________________________
-void AliZDCReconstructor::ReconstructEvent(AliLoader* loader, Int_t znraw,
-                                           Int_t zpraw, Int_t zemraw) const
+void AliZDCReconstructor::ReconstructEvent(AliLoader* loader, Float_t zncorr,
+       Float_t zpcorr, Float_t zemcorr) const
 {
-// reconstruct one event
-
-//  if AliDebug(1,Form("\n     ---     znraw = %d, zpraw = %d, zemraw = %d\n",znraw, zpraw, zemraw);
-    
-  //  ---      Pedestal subtraction
-  Int_t zncorr, zpcorr, zemcorr, meanPed=50;
-  zncorr  = znraw  - 5*meanPed;
-  zpcorr  = zpraw  - 5*meanPed;
-  zemcorr = zemraw - 2*meanPed;
-  if(zncorr<0)  zncorr=0;
-  if(zpcorr<0)  zpcorr=0;
-  if(zemcorr<0) zemcorr=0;
-//  if AliDebug(1,Form("\n    zncorr = %d, zpcorr = %d, zemcorr = %d\n",zncorr,zpcorr,zemcorr);
+  // ***** Reconstruct one event
   
   //  ---      ADCchannel -> photoelectrons
   // NB-> PM gain = 10^(5), ADC resolution = 6.4*10^(-7)
@@ -242,7 +230,7 @@ void AliZDCReconstructor::ReconstructEvent(AliLoader* loader, Int_t znraw,
   znphe  = zncorr/convFactor;
   zpphe  = zpcorr/convFactor;
   zemphe = zemcorr/convFactor;
-//  if AliDebug(1,Form("\n    znphe = %f, zpphe = %f, zemphe = %f\n",znphe, zpphe, zemphe);
+  //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 
@@ -259,13 +247,13 @@ void AliZDCReconstructor::ReconstructEvent(AliLoader* loader, Int_t znraw,
   zdcenergy = znenergy+zpenergy;
   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 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); 
+  //  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 incident spectator nucleons
   Int_t nDetSpecN, nDetSpecP;
@@ -276,8 +264,6 @@ void AliZDCReconstructor::ReconstructEvent(AliLoader* loader, Int_t znraw,
   Int_t nGenSpecN=0, nGenSpecP=0, nGenSpec=0;
   Double_t impPar=0;
   // Cut value for Ezem (GeV)
-  // [1] ### Results in Chiara's PhD thesis -> 0<b<15 fm (Dec 2001)
-  //Float_t eZEMCut = 360.; 
   // [2] ### Results from a new production  -> 0<b<18 fm (Apr 2002)
   Float_t eZEMCut = 420.;
   Float_t deltaEZEMSup = 690.; 
@@ -287,29 +273,19 @@ void AliZDCReconstructor::ReconstructEvent(AliLoader* loader, Int_t znraw,
     nGenSpecP = (Int_t) (fZPCen->Eval(zpenergy));
     nGenSpec  = (Int_t) (fZDCCen->Eval(zdcenergy));
     impPar    = fbCen->Eval(zdcenergy);
-    //printf("    fZNCen = %f, fZPCen = %f, fZDCCen = %f\n",fZNCen->Eval(znenergy),
-    //            fZPCen->Eval(zpenergy),fZDCCen->Eval(zdcenergy));
   }
   else if(zemenergy < (eZEMCut-deltaEZEMInf)){
     nGenSpecN = (Int_t) (fZNPer->Eval(znenergy)); 
     nGenSpecP = (Int_t) (fZPPer->Eval(zpenergy));
     nGenSpec  = (Int_t) (fZDCPer->Eval(zdcenergy));
     impPar    = fbPer->Eval(zdcenergy);
-    //printf("    fZNPer = %f, fZPPer = %f, fZDCPer = %f\n",fZNPer->Eval(znenergy),
-    //            fZPPer->Eval(zpenergy),fZDCPer->Eval(zdcenergy));
   }
   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);
-    //printf("    Nspec ZEM = %f, Nspec ZDC = %f\n",fZEMsp->Eval(znenergy),fZDCPer->Eval(zdcenergy));
   }
-  // [1] ### Results in Chiara's PhD thesis -> 0<b<15 fm (Dec 2001)
-  /*if(znenergy>158.5)  nGenSpecN = (Int_t) (fZEMn->Eval(zemenergy));
-    if(zpenergy>58.91)  nGenSpecP = (Int_t) (fZEMp->Eval(zemenergy));
-    if(zdcenergy>220.4) nGenSpec  = (Int_t)(fZEMsp->Eval(zemenergy));
-    if(zdcenergy>225.)  impPar    =          fZEMb->Eval(zemenergy);*/
   // [2] ### Results from a new production  -> 0<b<18 fm (Apr 2002)
   if(znenergy>162.)  nGenSpecN = (Int_t) (fZEMn->Eval(zemenergy));
   if(zpenergy>59.75)  nGenSpecP = (Int_t) (fZEMp->Eval(zemenergy));
@@ -322,14 +298,13 @@ void AliZDCReconstructor::ReconstructEvent(AliLoader* loader, Int_t znraw,
   else if(nGenSpecP<0) nGenSpecP=0;
   if(nGenSpec>207)     nGenSpec=207;
   else if(nGenSpec<0)  nGenSpec=0;
-  //printf("    NRecSpecN = %d, NRecSpecP = %d, NRecSpec = %d\n",nGenSpecN,nGenSpecP,nGenSpec);
   
   //  ---      Number of participants
   Int_t nPart, nPartTot;
   nPart = 207-nGenSpecN-nGenSpecP;
   nPartTot = 207-nGenSpec;
-  //printf("   ###     nPart(ZP+ZN) = %d, nPart(ZDC) = %d, b = %f fm\n",nPart,nPartTot,impPar);
-//  if AliDebug(1,Form("       ###     nPart = %d, b = %f fm\n",nPartTot,impPar);
+  printf("\t  ZDCeventReco-> ZNEn = %.0f GeV, ZPEn = %.0f GeV, ZEMEn = %.0f GeV\n",
+       znenergy, zpenergy, zemenergy);
 
   // create the output tree
   loader->MakeTree("R");
@@ -368,3 +343,23 @@ void AliZDCReconstructor::FillESD(AliRunLoader* runLoader,
 
   loader->UnloadRecPoints();
 }
+
+//_____________________________________________________________________________
+AliZDCCalibData* AliZDCReconstructor::GetCalibData(int runNumber) const
+{
+
+  //printf("\n\t AliZDCReconstructor::GetCalibData \n");
+  //fStorage->PrintSelectionList();
+  //AliCDBEntry *entry = fStorage->Get("DBlocal/ZDC/Calib/Data",runNumber);
+
+  
+  AliCDBStorage *fStorage = AliCDBManager::Instance()->GetStorage("local://DBlocal");
+  AliCDBEntry  *entry = fStorage->Get("ZDC/Calib/Data",1);
+  
+  AliZDCCalibData *calibda = (AliZDCCalibData*) entry->GetObject();
+
+  AliCDBManager::Instance()->Destroy();
+
+  return calibda;
+
+}
index 771c58e436686b8a401821dcd1634f3f68970d8f..79e57ad08de1751bb4f03b33051ee82299d8e5b4 100644 (file)
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "AliReconstructor.h"
+#include "AliCDBManager.h"
+#include "AliCDBStorage.h"
+#include "AliZDCCalibData.h"
 
 class TF1;
 class AliLoader;
 
-
 class AliZDCReconstructor: public AliReconstructor {
 public:
   AliZDCReconstructor();
   virtual ~AliZDCReconstructor();
 
-  virtual void         Reconstruct(AliRunLoader* runLoader) const;
-  virtual void         Reconstruct(AliRunLoader* runLoader, 
-                                   AliRawReader* rawReader) const;
-  virtual void         Reconstruct(TTree* digitsTree, TTree* clustersTree) const { AliReconstructor::Reconstruct(digitsTree,clustersTree);}
-  virtual void         Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const {AliReconstructor::Reconstruct(rawReader,clustersTree);}
-  virtual void         FillESD(AliRunLoader* runLoader, AliESD* esd) const;
-  virtual void         FillESD(TTree* digitsTree, TTree* clustersTree, 
-                              AliESD* esd) const {
-    AliReconstructor::FillESD(digitsTree,clustersTree,esd);
-  }
-  virtual void         FillESD(AliRawReader* rawReader, TTree* clustersTree, 
-                              AliESD* esd) const {
-    AliReconstructor::FillESD(rawReader,clustersTree,esd);
-  }
-  virtual void         FillESD(AliRunLoader* runLoader, 
-                              AliRawReader* rawReader, AliESD* esd) const {
-    AliReconstructor::FillESD(runLoader,rawReader,esd);
-  }
+  virtual void   Reconstruct(AliRunLoader* runLoader) const;
+  virtual void   Reconstruct(AliRunLoader* runLoader,
+                 AliRawReader* rawReader) const;
+  virtual void   Reconstruct(TTree* digitsTree, TTree* clustersTree) const 
+                 {AliReconstructor::Reconstruct(digitsTree,clustersTree);}
+  virtual void   Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const 
+                 {AliReconstructor::Reconstruct(rawReader,clustersTree);}
+  virtual void   FillESD(AliRunLoader* runLoader, AliESD* esd) const;
+  virtual void   FillESD(TTree* digitsTree, TTree* clustersTree, AliESD* esd) const 
+                 {AliReconstructor::FillESD(digitsTree,clustersTree,esd);}
+  virtual void   FillESD(AliRawReader* rawReader, TTree* clustersTree, AliESD* esd) const 
+                 {AliReconstructor::FillESD(rawReader,clustersTree,esd);}
+  virtual void   FillESD(AliRunLoader* runLoader, AliRawReader* rawReader, AliESD* esd) const 
+                 {AliReconstructor::FillESD(runLoader,rawReader,esd);}
+  
+  void   GetStorage(const char* uri) {fStorage = AliCDBManager::Instance()->GetStorage(uri);}
+  AliZDCCalibData *GetCalibData(int runNumber) const; 
 
 private:
   AliZDCReconstructor(const AliZDCReconstructor& reconstructor);
   AliZDCReconstructor& operator = (const AliZDCReconstructor& reconstructor);
 
-  void                 ReconstructEvent(AliLoader* loader, Int_t znraw,
-                                        Int_t zpraw, Int_t zemraw) const;
+  void   ReconstructEvent(AliLoader* loader, Float_t zncorr, Float_t zpcorr, Float_t zemcorr) const;
 
   TF1*   fZNCen;     //! Nspectator n true vs. EZN
   TF1*   fZNPer;     //! Nspectator n true vs. EZN
@@ -60,8 +60,10 @@ private:
   TF1*   fZEMp;      //! Nspectators p from ZEM energy
   TF1*   fZEMsp;     //! Nspectators from ZEM energy
   TF1*   fZEMb;      //! b from ZEM energy
+  
+  AliCDBStorage *fStorage; //! storage
 
-  ClassDef(AliZDCReconstructor, 0)   // class for the ZDC reconstruction
+  ClassDef(AliZDCReconstructor, 1)   // class for the ZDC reconstruction
 };
 
 #endif