]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALDigitizer.cxx
Fixed error with trigger name at method SetInput
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALDigitizer.cxx
index a43de39ca16fa277c58732beeb063a2bc089f976..767fdd5cad360a0f59578f3303cbf1fda2dd696f 100644 (file)
@@ -68,6 +68,7 @@
 #include <TBrowser.h>
 #include <TObjectTable.h>
 #include <TRandom.h>
+#include <cassert>
 
 // --- AliRoot header files ---
 #include "AliLog.h"
@@ -143,7 +144,7 @@ AliEMCALDigitizer::AliEMCALDigitizer(TString alirunFileName, TString eventFolder
     fFirstEvent(0),
     fLastEvent(0),
     fControlHists(0),
-    fHists(0)
+    fHists(0),fCalibData(0x0)
 {
   // ctor
   InitParameters() ; 
@@ -204,7 +205,7 @@ AliEMCALDigitizer::AliEMCALDigitizer(AliRunDigitizer * rd)
     fFirstEvent(0),
     fLastEvent(0),
     fControlHists(0),
-    fHists(0)
+    fHists(0),fCalibData(0x0)
 {
   // ctor Init() is called by RunDigitizer
   fManager = rd ; 
@@ -240,7 +241,6 @@ void AliEMCALDigitizer::Digitize(Int_t event)
   // after that adds contributions from SDigits. This design 
   // helps to avoid scanning over the list of digits to add 
   // contribution of any new SDigit.
-  static int isTrd1Geom = -1; // -1 - mean undefined 
   static int nEMC=0; //max number of digits possible
 
   AliRunLoader *rl = AliRunLoader::GetRunLoader();
@@ -254,25 +254,20 @@ void AliEMCALDigitizer::Digitize(Int_t event)
   rl->GetEvent(readEvent);
 
   TClonesArray * digits = emcalLoader->Digits() ; 
-  digits->Clear() ;
+  digits->Delete() ;  //JLK why is this created then deleted?
 
   // Load Geometry
-  // const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
-  rl->LoadgAlice(); 
-  AliRun * gAlice = rl->GetAliRun(); 
-  AliEMCAL * emcal  = (AliEMCAL*)gAlice->GetDetector("EMCAL");
-  AliEMCALGeometry * geom = emcal->GetGeometry();
-
-  if(isTrd1Geom < 0) { 
-    AliInfo(Form(" get Geometry %s : %s ", geom->GetName(),geom->GetTitle()));
-    TString ng(geom->GetName());
-    isTrd1Geom = 0;
-    if(ng.Contains("SHISH") &&  ng.Contains("TRD1")) isTrd1Geom = 1;
-
-    if(isTrd1Geom == 0) nEMC = geom->GetNPhi()*geom->GetNZ();
-    else                nEMC = geom->GetNCells();
-    AliDebug(1,Form("nEMC %i (number cells in EMCAL) | %s | isTrd1Geom %i\n", nEMC, geom->GetName(), isTrd1Geom));
+  AliEMCALGeometry *geom = 0;
+  if (rl->GetAliRun()) {
+    AliEMCAL * emcal  = (AliEMCAL*)rl->GetAliRun()->GetDetector("EMCAL");
+    geom = emcal->GetGeometry();
   }
+  else 
+    AliFatal("Could not get AliRun from runLoader");
+
+  nEMC = geom->GetNCells();
+  AliDebug(1,Form("nEMC %i (number cells in EMCAL) | %s \n", nEMC, geom->GetName()));
+  
   Int_t absID ;
 
   digits->Expand(nEMC) ;
@@ -329,7 +324,7 @@ void AliEMCALDigitizer::Digitize(Int_t event)
   AliEMCALDigit * digit ;
   AliEMCALDigit * curSDigit ;
 
-  TClonesArray * ticks = new TClonesArray("AliEMCALTick",1000) ;
+  //  TClonesArray * ticks = new TClonesArray("AliEMCALTick",1000) ;
 
   //Put Noise contribution
   for(absID = 0; absID < nEMC; absID++){ // Nov 30, 2006 by PAI; was from 1 to nEMC
@@ -341,14 +336,22 @@ void AliEMCALDigitizer::Digitize(Int_t event)
     
     if(absID==nextSig){
       //Add SDigits from all inputs    
-      ticks->Clear() ;
-      Int_t contrib = 0 ;
-      Float_t a = digit->GetAmp() ;
-      Float_t b = TMath::Abs( a /fTimeSignalLength) ;
+      //      ticks->Clear() ;
+      //Int_t contrib = 0 ;
+
+      //Follow PHOS and comment out this timing model til a better one
+      //can be developed - JLK 28-Apr-2008
+
+      //Float_t a = digit->GetAmp() ;
+      //Float_t b = TMath::Abs( a /fTimeSignalLength) ;
       //Mark the beginning of the signal
-      new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime(),0, b);  
+      //new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime(),0, b);  
       //Mark the end of the signal     
-      new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime()+fTimeSignalLength, -a, -b);
+      //new((*ticks)[contrib++]) AliEMCALTick(digit->GetTime()+fTimeSignalLength, -a, -b);
+
+      // Calculate time as time of the largest digit
+      Float_t time = digit->GetTime() ;
+      Float_t eTime= digit->GetAmp() ;
       
       // loop over input
       for(i = 0; i< fInput ; i++){  //loop over (possible) merge sources
@@ -365,11 +368,16 @@ void AliEMCALDigitizer::Digitize(Int_t event)
          else
            primaryoffset = i ;
          curSDigit->ShiftPrimary(primaryoffset) ;
-         
-         a = curSDigit->GetAmp() ;
-         b = a /fTimeSignalLength ;
-         new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime(),0, b);  
-         new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b); 
+
+         //Remove old timing model - JLK 28-April-2008
+         //a = curSDigit->GetAmp() ;
+         //b = a /fTimeSignalLength ;
+         //new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime(),0, b);  
+         //new((*ticks)[contrib++]) AliEMCALTick(curSDigit->GetTime()+fTimeSignalLength, -a, -b); 
+         if(curSDigit->GetAmp()>eTime) {
+           eTime = curSDigit->GetAmp();
+           time = curSDigit->GetTime();
+         }
 
          *digit = *digit + *curSDigit ;  //add energies
 
@@ -385,7 +393,8 @@ void AliEMCALDigitizer::Digitize(Int_t event)
       amp *= static_cast<Float_t>(gRandom->Poisson(fMeanPhotonElectron)) / static_cast<Float_t>(fMeanPhotonElectron) ;
   
       //calculate and set time
-      Float_t time = FrontEdgeTime(ticks) ;
+      //New timing model needed - JLK 28-April-2008
+      //Float_t time = FrontEdgeTime(ticks) ;
       digit->SetTime(time) ;
 
       //Find next signal module
@@ -406,8 +415,8 @@ void AliEMCALDigitizer::Digitize(Int_t event)
                     absID, amp, nextSig));
   } // for(absID = 1; absID <= nEMC; absID++)
   
-  ticks->Delete() ;
-  delete ticks ;
+  //ticks->Delete() ;
+  //delete ticks ;
 
   delete sdigArray ; //We should not delete its contents
 
@@ -424,7 +433,6 @@ void AliEMCALDigitizer::Digitize(Int_t event)
   digits->Compress() ;  
   
   Int_t ndigits = digits->GetEntriesFast() ; 
-  digits->Expand(ndigits) ;
   
   //Set indexes in list of digits and fill hists.
   AliEMCALHistoUtilities::FillH1(fHists, 0, Double_t(ndigits));
@@ -513,8 +521,9 @@ void AliEMCALDigitizer::Exec(Option_t *option)
   // Post Digitizer to the white board
   emcalLoader->PostDigitizer(this) ;
   
-  if (fLastEvent == -1) 
+  if (fLastEvent == -1)  {
     fLastEvent = rl->GetNumberOfEvents() - 1 ;
+  }
   else if (fManager) 
     fLastEvent = fFirstEvent ; // what is this ??
 
@@ -612,19 +621,22 @@ Bool_t AliEMCALDigitizer::Init()
 //____________________________________________________________________________ 
 void AliEMCALDigitizer::InitParameters()
 { 
-  //parameter initialization for digitizer
-  // Tune parameters - 24-nov-04
+  // Parameter initialization for digitizer
+  // Tune parameters - 24-nov-04; Apr 29, 2007
+  // New parameters JLK 14-Apr-2008
 
-  fMeanPhotonElectron = 3300 ; // electrons per GeV 
-  fPinNoise           = 0.004; 
+  fMeanPhotonElectron = 4400;  // electrons per GeV 
+  fPinNoise           = 0.037; // pin noise in GEV from analysis test beam data 
   if (fPinNoise == 0. ) 
     Warning("InitParameters", "No noise added\n") ; 
   fDigitThreshold     = fPinNoise * 3; // 3 * sigma
   fTimeResolution     = 0.3e-9 ; // 300 psc
   fTimeSignalLength   = 1.0e-9 ;
 
-  fADCchannelEC    = 0.00305; // 200./65536 - width of one ADC channel in GeV
-  fADCpedestalEC   = 0.009 ;  // GeV
+  // These defaults are normally not used. 
+  // Values are read from calibration database instead
+  fADCchannelEC    = 0.0153; // Update 24 Apr 2007: 250./16/1024 - width of one ADC channel in GeV
+  fADCpedestalEC   = 0.0 ;  // GeV
   fNADCEC          = (Int_t) TMath::Power(2,16) ;  // number of channels in Tower ADC - 65536
 
   fTimeThreshold      = 0.001*10000000 ; // Means 1 MeV in terms of SDigits amplitude ??
@@ -670,6 +682,7 @@ void AliEMCALDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
       return ;
     }
     // need to increase the arrays
+    // MvL: This code only works when fInput == 1, I think.
     TString tempo = fInputFileNames[fInput-1] ; 
     delete [] fInputFileNames ; 
     fInputFileNames = new TString[fInput+1] ; 
@@ -685,6 +698,7 @@ void AliEMCALDigitizer::MixWith(TString alirunFileName, TString eventFolderName)
     fInput++ ;
 }  
 
+//__________________________________________________________________
 void AliEMCALDigitizer::Print1(Option_t * option)
 { // 19-nov-04 - just for convinience
   Print(); 
@@ -815,8 +829,10 @@ void AliEMCALDigitizer::WriteDigits()
   // -- create Digits branch
   Int_t bufferSize = 32000 ;    
   TBranch * digitsBranch = 0;
-  if ((digitsBranch = treeD->GetBranch("EMCAL")))
+  if ((digitsBranch = treeD->GetBranch("EMCAL"))) {
     digitsBranch->SetAddress(&digits);
+    AliWarning("Digits Branch already exists. Not all digits will be visible");
+  }
   else
     treeD->Branch("EMCAL","TClonesArray",&digits,bufferSize);
   //digitsBranch->SetTitle(fEventFolderName);
@@ -829,12 +845,14 @@ void AliEMCALDigitizer::WriteDigits()
 
 }
 
+//__________________________________________________________________
 void AliEMCALDigitizer::Browse(TBrowser* b)
 {
   if(fHists) b->Add(fHists);
   TTask::Browse(b);
 }
 
+//__________________________________________________________________
 TList *AliEMCALDigitizer::BookControlHists(int var)
 { 
   // 22-nov-04
@@ -858,6 +876,7 @@ TList *AliEMCALDigitizer::BookControlHists(int var)
   return fHists;
 }
 
+//__________________________________________________________________
 void AliEMCALDigitizer::SaveHists(const char* name, Bool_t kSingleKey, const char* opt)
 {
   AliEMCALHistoUtilities::SaveListOfHists(fHists, name, kSingleKey, opt);