]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALSDigitizer.cxx
fix error during merging (https://savannah.cern.ch/bugs/index.php?70729)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALSDigitizer.cxx
index 1ba3a8fc279ce7d05ef1e8f5bb061bcfff105ef5..24de52b9e2f76fb397744eaefece08c8016cdc68 100644 (file)
@@ -170,6 +170,17 @@ void AliEMCALSDigitizer::InitParameters()
     Fatal("InitParameters", "Sampling factor not set !") ; 
   }
 
+  // Get the parameters from the OCDB via the loader
+  AliRunLoader *rl = AliRunLoader::Instance();
+  AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
+  AliEMCALSimParam * simParam = 0x0;
+  if(emcalLoader) simParam = emcalLoader->SimulationParameters();
+       
+  if(!simParam){
+       simParam = AliEMCALSimParam::GetInstance();
+       AliWarning("Simulation Parameters not available in OCDB?");
+  }
+       
   //
   //JLK 26-Jun-2008 THIS SHOULD HAVE BEEN EXPLAINED AGES AGO:
   //
@@ -180,12 +191,12 @@ void AliEMCALSDigitizer::InitParameters()
   //Digitize() and Calibrate() methods
   //
   // Initializes parameters
-  fA         = AliEMCALSimParam::GetInstance()->GetA(); //0;
-  fB         = AliEMCALSimParam::GetInstance()->GetB(); //1.e+6;  // Changed 24 Apr 2007. Dynamic range now 2 TeV
+  fA         = simParam->GetA(); //0;
+  fB         = simParam->GetB(); //1.e+6;  // Changed 24 Apr 2007. Dynamic range now 2 TeV
   fSampling  = geom->GetSampling();
 
   // threshold for deposit energy of hit
-  fECPrimThreshold  = AliEMCALSimParam::GetInstance()->GetECPrimaryThreshold();//0.05;// GeV // 22-may-07 was 0// 24-nov-04 - was 1.e-6;
+  fECPrimThreshold  = simParam->GetECPrimaryThreshold();//0.05;// GeV // 22-may-07 was 0// 24-nov-04 - was 1.e-6;
   
   AliDebug(2,Form("Print: \n------------------- %s -------------\n",GetName()));
   AliDebug(2,Form("   fInit                                 %i\n", int(fInit)));
@@ -220,7 +231,8 @@ void AliEMCALSDigitizer::Exec(Option_t *option)
 
     return ; 
   }
-  
+
   if(strstr(option,"tim"))
     gBenchmark->Start("EMCALSDigitizer");
 
@@ -258,7 +270,8 @@ void AliEMCALSDigitizer::Exec(Option_t *option)
 
     Int_t nSdigits = 0 ;
     Int_t i;
-    AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(); 
+
+       AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(); 
     for ( i = 0 ; i < hits->GetEntries() ; i++ ) {
       AliEMCALHit * hit = dynamic_cast<AliEMCALHit*>(hits->At(i)) ;
       AliEMCALDigit * curSDigit = 0 ;
@@ -272,13 +285,13 @@ void AliEMCALSDigitizer::Exec(Option_t *option)
          // Assign primary number only if deposited energy is significant
          curSDigit =  new AliEMCALDigit( hit->GetPrimary(),
                                          hit->GetIparent(), hit->GetId(), 
-                                         Digitize(energy), hit->GetTime(), 
+                                         Digitize(energy), hit->GetTime(),kFALSE,
                                          -1, energy ) ;
          else
-           curSDigit =  new AliEMCALDigit( -1               
-                                           -1               ,
+           curSDigit =  new AliEMCALDigit( -1, 
+                                           -1,
                                            hit->GetId(), 
-                                           Digitize(energy), hit->GetTime(), 
+                                           Digitize(energy), hit->GetTime(),kFALSE,
                                            -1, energy ) ;
       } else {
        Warning("Exec"," abs id %i is bad \n", hit->GetId());
@@ -344,7 +357,7 @@ void AliEMCALSDigitizer::Exec(Option_t *option)
 }
 
 //__________________________________________________________________
-Int_t AliEMCALSDigitizer::Digitize(Float_t energy)const {
+Float_t AliEMCALSDigitizer::Digitize(Float_t energy)const {
   // Digitize the energy
   //
   //JLK 26-Jun-2008 EXPLANATION LONG OVERDUE:
@@ -362,11 +375,12 @@ Int_t AliEMCALSDigitizer::Digitize(Float_t energy)const {
     AliWarning(Form("Too big or too small energy %f",aSignal));
     aSignal = TMath::Sign((Double_t)2147483647,aSignal);
   }
-  return (Int_t ) aSignal;
+
+  return (Float_t ) aSignal;
 }
 
 //__________________________________________________________________
-Float_t AliEMCALSDigitizer::Calibrate(Int_t amp)const {
+Float_t AliEMCALSDigitizer::Calibrate(Float_t amp)const {
   //
   // Convert the amplitude back to energy in GeV
   //
@@ -435,14 +449,15 @@ void AliEMCALSDigitizer::PrintSDigits(Option_t * option)
     //loop over digits
     AliEMCALDigit * digit;
     printf("\n   Id  Amplitude    Time          Index Nprim: Primaries list \n") ;    
-    Int_t index, isum=0;
+       Int_t   index = 0;
+    Float_t isum  = 0.;
     char * tempo = new char[8192]; 
     for (index = 0 ; index < sdigits->GetEntries() ; index++) {
       digit = dynamic_cast<AliEMCALDigit *>( sdigits->At(index) ) ;
-      sprintf(tempo, "\n%6d  %8d    %6.5e %4d      %2d :",
-             digit->GetId(), digit->GetAmp(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;  
+      sprintf(tempo, "\n%6d  %8f    %6.5e %4d      %2d :",
+             digit->GetId(), digit->GetAmplitude(), digit->GetTime(), digit->GetIndexInList(), digit->GetNprimary()) ;  
       printf("%s",tempo);
-      isum += digit->GetAmp();
+      isum += digit->GetAmplitude();
       
       Int_t iprimary;
       for (iprimary=0; iprimary<digit->GetNprimary(); iprimary++) {
@@ -450,8 +465,8 @@ void AliEMCALSDigitizer::PrintSDigits(Option_t * option)
        printf("%s",tempo); 
       }         
     }
-    delete tempo ;
-    printf("\n** Sum %i : %10.3f GeV/c **\n ", isum, Calibrate(isum));
+    delete [] tempo ;
+    printf("\n** Sum %2.3f : %10.3f GeV/c **\n ", isum, Calibrate(isum));
   } else printf("\n");
 }