//_________________________________________________________________________________
// --- ROOT system ---
-#include "TROOT.h"
-#include "TTree.h"
-#include "TSystem.h"
-#include "TBenchmark.h"
-#include "TList.h"
-#include "TH1.h"
-#include "TBrowser.h"
-#include "TObjectTable.h"
+#include <TROOT.h>
+#include <TTree.h>
+#include <TSystem.h>
+#include <TBenchmark.h>
+#include <TList.h>
+#include <TH1.h>
+#include <TBrowser.h>
+#include <TObjectTable.h>
+#include <TRandom.h>
+#include <cassert>
// --- AliRoot header files ---
+#include "AliLog.h"
#include "AliRun.h"
#include "AliRunDigitizer.h"
#include "AliRunLoader.h"
+#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
#include "AliEMCALDigit.h"
#include "AliEMCAL.h"
#include "AliEMCALLoader.h"
//____________________________________________________________________________
- AliEMCALDigitizer::AliEMCALDigitizer():AliDigitizer("",""),
- fInput(0),
- fInputFileNames(0x0),
- fEventNames(0x0)
+AliEMCALDigitizer::AliEMCALDigitizer()
+ : AliDigitizer("",""),
+ fDefaultInit(kTRUE),
+ fDigitsInRun(0),
+ fInit(0),
+ fInput(0),
+ fInputFileNames(0x0),
+ fEventNames(0x0),
+ fDigitThreshold(0),
+ fMeanPhotonElectron(0),
+ fPedestal(0),
+ fSlope(0),
+ fPinNoise(0),
+ fTimeResolution(0),
+ fTimeThreshold(0),
+ fTimeSignalLength(0),
+ fADCchannelEC(0),
+ fADCpedestalEC(0),
+ fNADCEC(0),
+ fEventFolderName(""),
+ fFirstEvent(0),
+ fLastEvent(0),
+ fControlHists(0),
+ fHists(0),fCalibData(0x0)
{
// ctor
InitParameters() ;
- fDefaultInit = kTRUE ;
fManager = 0 ; // We work in the standalong mode
- fEventFolderName = "" ;
}
//____________________________________________________________________________
-AliEMCALDigitizer::AliEMCALDigitizer(TString alirunFileName, TString eventFolderName):
- AliDigitizer("EMCAL"+AliConfig::Instance()->GetDigitizerTaskName(), alirunFileName),
- fInputFileNames(0), fEventNames(0), fEventFolderName(eventFolderName)
+AliEMCALDigitizer::AliEMCALDigitizer(TString alirunFileName, TString eventFolderName)
+ : AliDigitizer("EMCAL"+AliConfig::Instance()->GetDigitizerTaskName(), alirunFileName),
+ fDefaultInit(kFALSE),
+ fDigitsInRun(0),
+ fInit(0),
+ fInput(0),
+ fInputFileNames(0),
+ fEventNames(0),
+ fDigitThreshold(0),
+ fMeanPhotonElectron(0),
+ fPedestal(0),
+ fSlope(0),
+ fPinNoise(0),
+ fTimeResolution(0),
+ fTimeThreshold(0),
+ fTimeSignalLength(0),
+ fADCchannelEC(0),
+ fADCpedestalEC(0),
+ fNADCEC(0),
+ fEventFolderName(eventFolderName),
+ fFirstEvent(0),
+ fLastEvent(0),
+ fControlHists(0),
+ fHists(0),fCalibData(0x0)
{
// ctor
-
InitParameters() ;
Init() ;
- fDefaultInit = kFALSE ;
fManager = 0 ; // We work in the standalong mode
}
//____________________________________________________________________________
-AliEMCALDigitizer::AliEMCALDigitizer(const AliEMCALDigitizer & d) : AliDigitizer(d)
+AliEMCALDigitizer::AliEMCALDigitizer(const AliEMCALDigitizer & d)
+ : AliDigitizer(d.GetName(),d.GetTitle()),
+ fDefaultInit(d.fDefaultInit),
+ fDigitsInRun(d.fDigitsInRun),
+ fInit(d.fInit),
+ fInput(d.fInput),
+ fInputFileNames(d.fInputFileNames),
+ fEventNames(d.fEventNames),
+ fDigitThreshold(d.fDigitThreshold),
+ fMeanPhotonElectron(d.fMeanPhotonElectron),
+ fPedestal(d.fPedestal),
+ fSlope(d.fSlope),
+ fPinNoise(d.fPinNoise),
+ fTimeResolution(d.fTimeResolution),
+ fTimeThreshold(d.fTimeThreshold),
+ fTimeSignalLength(d.fTimeSignalLength),
+ fADCchannelEC(d.fADCchannelEC),
+ fADCpedestalEC(d.fADCpedestalEC),
+ fNADCEC(d.fNADCEC),
+ fEventFolderName(d.fEventFolderName),
+ fFirstEvent(d.fFirstEvent),
+ fLastEvent(d.fLastEvent),
+ fControlHists(d.fControlHists),
+ fHists(d.fHists),fCalibData(d.fCalibData)
{
// copyy ctor
-
- SetName(d.GetName()) ;
- SetTitle(d.GetTitle()) ;
- fDigitThreshold = d.fDigitThreshold ;
- fMeanPhotonElectron = d.fMeanPhotonElectron ;
- fPedestal = d.fPedestal ;
- fSlope = d.fSlope ;
- fPinNoise = d.fPinNoise ;
- fTimeResolution = d.fTimeResolution ;
- fTimeThreshold = d.fTimeThreshold ;
- fTimeSignalLength = d.fTimeSignalLength ;
- fADCchannelEC = d.fADCchannelEC ;
- fADCpedestalEC = d.fADCpedestalEC ;
- fNADCEC = d.fNADCEC ;
- fEventFolderName = d.fEventFolderName;
}
//____________________________________________________________________________
-AliEMCALDigitizer::AliEMCALDigitizer(AliRunDigitizer * rd):
- AliDigitizer(rd,"EMCAL"+AliConfig::Instance()->GetDigitizerTaskName()),
- fEventFolderName(0)
+AliEMCALDigitizer::AliEMCALDigitizer(AliRunDigitizer * rd)
+ : AliDigitizer(rd,"EMCAL"+AliConfig::Instance()->GetDigitizerTaskName()),
+ fDefaultInit(kFALSE),
+ fDigitsInRun(0),
+ fInit(0),
+ fInput(0),
+ fInputFileNames(0),
+ fEventNames(0),
+ fDigitThreshold(0.),
+ fMeanPhotonElectron(0),
+ fPedestal(0),
+ fSlope(0.),
+ fPinNoise(0),
+ fTimeResolution(0.),
+ fTimeThreshold(0),
+ fTimeSignalLength(0),
+ fADCchannelEC(0),
+ fADCpedestalEC(0),
+ fNADCEC(0),
+ fEventFolderName(0),
+ fFirstEvent(0),
+ fLastEvent(0),
+ fControlHists(0),
+ fHists(0),fCalibData(0x0)
{
// ctor Init() is called by RunDigitizer
fManager = rd ;
fEventFolderName = fManager->GetInputFolderName(0) ;
SetTitle(dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetFileName(0));
InitParameters() ;
- fDefaultInit = kFALSE ;
}
//____________________________________________________________________________
AliEMCALDigitizer::~AliEMCALDigitizer()
{
+ //dtor
if (AliRunLoader::GetRunLoader()) {
AliLoader *emcalLoader=0;
if ((emcalLoader = AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL")))
AliDebug(1," no runloader present");
delete [] fInputFileNames ;
delete [] fEventNames ;
+
+ if(fHists) delete fHists;
}
//____________________________________________________________________________
AliRunLoader *rl = AliRunLoader::GetRunLoader();
AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
- Int_t ReadEvent = event ;
+ Int_t readEvent = event ;
// fManager is data member from AliDigitizer
if (fManager)
- ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ;
+ readEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(0))->GetCurrentEventNumber() ;
AliDebug(1,Form("Adding event %d from input stream 0 %s %s",
- ReadEvent, GetTitle(), fEventFolderName.Data())) ;
- rl->GetEvent(ReadEvent);
+ readEvent, GetTitle(), fEventFolderName.Data())) ;
+ rl->GetEvent(readEvent);
TClonesArray * digits = emcalLoader->Digits() ;
- digits->Clear() ;
+ digits->Delete() ;
// Load Geometry
- // const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
- rl->LoadgAlice();
- AliRun * gAlice = rl->GetAliRun();
- AliEMCAL * emcal = (AliEMCAL*)gAlice->GetDetector("EMCAL");
- AliEMCALGeometry * geom = emcal->GetGeometry();
+ AliEMCALGeometry *geom = 0;
+ if (rl->GetAliRun()) {
+ AliEMCAL * emcal = (AliEMCAL*)rl->GetAliRun()->GetDetector("EMCAL");
+ geom = emcal->GetGeometry();
+ }
+ else
+ AliFatal("Could not get AliRun from runLoader");
if(isTrd1Geom < 0) {
+ AliDebug(1, Form(" get Geometry %s : %s ", geom->GetName(),geom->GetTitle()));
TString ng(geom->GetName());
isTrd1Geom = 0;
if(ng.Contains("SHISH") && ng.Contains("TRD1")) isTrd1Geom = 1;
for(i = 1 ; i < fInput ; i++){
TString tempo(fEventNames[i]) ;
tempo += i ;
- rl = AliRunLoader::Open(fInputFileNames[i], tempo) ;
+
+ AliRunLoader * rl2 = AliRunLoader::GetRunLoader(tempo) ;
+
+ if (rl2==0)
+ rl2 = AliRunLoader::Open(fInputFileNames[i], tempo) ;
+
if (fManager)
- ReadEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ;
- Info("Digitize", "Adding event %d from input stream %d %s %s", ReadEvent, i, fInputFileNames[i].Data(), tempo.Data()) ;
- rl->LoadSDigits();
- rl->GetEvent(ReadEvent);
- sdigArray->AddAt(emcalLoader->SDigits(), i) ;
+ readEvent = dynamic_cast<AliStream*>(fManager->GetInputStream(i))->GetCurrentEventNumber() ;
+ Info("Digitize", "Adding event %d from input stream %d %s %s", readEvent, i, fInputFileNames[i].Data(), tempo.Data()) ;
+ rl2->LoadSDigits();
+ rl2->GetEvent(readEvent);
+ AliEMCALLoader *emcalLoader2 = dynamic_cast<AliEMCALLoader*>(rl2->GetDetectorLoader("EMCAL"));
+ sdigArray->AddAt(emcalLoader2->SDigits(), i) ;
}
//Find the first tower with signal
TClonesArray * ticks = new TClonesArray("AliEMCALTick",1000) ;
//Put Noise contribution
- for(absID = 1; absID <= nEMC; absID++){
+ for(absID = 0; absID < nEMC; absID++){ // Nov 30, 2006 by PAI; was from 1 to nEMC
Float_t amp = 0 ;
// amplitude set to zero, noise will be added later
- new((*digits)[absID-1]) AliEMCALDigit( -1, -1, absID, 0, TimeOfNoise() ) ;
+ new((*digits)[absID]) AliEMCALDigit( -1, -1, absID, 0, TimeOfNoise() ); // absID-1->absID
//look if we have to add signal?
- digit = dynamic_cast<AliEMCALDigit *>(digits->At(absID-1)) ;
+ digit = dynamic_cast<AliEMCALDigit *>(digits->At(absID)); // absID-1->absID
if(absID==nextSig){
//Add SDigits from all inputs
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));
AliEMCALHistoUtilities::FillH1(fHists, 2, double(digit->GetAmp()));
AliEMCALHistoUtilities::FillH1(fHists, 3, double(energy));
AliEMCALHistoUtilities::FillH1(fHists, 4, double(digit->GetId()));
+ // if(digit->GetId() == nEMC) {
+ // printf(" i %i \n", i );
+ // digit->Dump();
+ // assert(0);
+ //}
}
AliEMCALHistoUtilities::FillH1(fHists, 1, esum);
}
-//____________________________________________________________________________
+// //_____________________________________________________________________
Int_t AliEMCALDigitizer::DigitizeEnergy(Float_t energy, Int_t AbsId)
{
// Returns digitized value of the energy in a cell absId
- // Loader
- AliRunLoader *rl = AliRunLoader::GetRunLoader();
- AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
- (rl->GetDetectorLoader("EMCAL"));
-
- // Load EMCAL Geometry
- rl->LoadgAlice();
- AliRun * gAlice = rl->GetAliRun();
- AliEMCAL * emcal = (AliEMCAL*)gAlice->GetDetector("EMCAL");
- AliEMCALGeometry * geom = emcal->GetGeometry();
+
+ // Load Geometry
+ const AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance();
if (geom==0)
- AliFatal("Did not get geometry from EMCALLoader") ;
+ AliFatal("Did not get geometry from EMCALLoader");
Int_t iSupMod = -1;
- Int_t nTower = -1;
+ Int_t nModule = -1;
Int_t nIphi = -1;
Int_t nIeta = -1;
Int_t iphi = -1;
Int_t ieta = -1;
Int_t channel = -999;
- Bool_t bCell = geom->GetCellIndex(AbsId, iSupMod, nTower, nIphi, nIeta) ;
+ Bool_t bCell = geom->GetCellIndex(AbsId, iSupMod, nModule, nIphi, nIeta) ;
if(!bCell)
- Error("DigitizeEnergy","Wrong cell id number") ;
- geom->GetCellPhiEtaIndexInSModule(iSupMod,nTower,nIphi, nIeta,iphi,ieta);
-
- if(emcalLoader->CalibData()) {
- fADCpedestalEC = emcalLoader->CalibData()
- ->GetADCpedestal(iSupMod,ieta,iphi);
- fADCchannelEC = emcalLoader->CalibData()
- ->GetADCchannel(iSupMod,ieta,iphi);
-
- channel = static_cast<Int_t> (TMath::Ceil( (energy + fADCpedestalEC)/fADCchannelEC )) ;
+ Error("DigitizeEnergy","Wrong cell id number : AbsId %i ", AbsId) ;
+ geom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
+
+ if(fCalibData) {
+ fADCpedestalEC = fCalibData->GetADCpedestal(iSupMod,ieta,iphi);
+ fADCchannelEC = fCalibData->GetADCchannel(iSupMod,ieta,iphi);
}
+
+ channel = static_cast<Int_t> (TMath::Ceil( (energy + fADCpedestalEC)/fADCchannelEC )) ;
+
if(channel > fNADCEC )
channel = fNADCEC ;
return channel ;
+
}
//____________________________________________________________________________
}
if (strstr(option,"print")) {
+
Print();
return ;
}
// 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 ??
rl->LoadSDigits("EMCAL");
for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
- //gime->Event(ievent,"S") ;
+
rl->GetEvent(ievent);
Digitize(ievent) ; //Add prepared SDigits to digits and add the noise
//increment the total number of Digits per run
fDigitsInRun += emcalLoader->Digits()->GetEntriesFast() ;
}
- // gime->WriteDigitizer("OVERWRITE");
-
+
emcalLoader->CleanDigitizer() ;
if(strstr(option,"tim")){
gBenchmark->Stop("EMCALDigitizer");
- printf("Exec: took %f seconds for Digitizing %f seconds per event",
- gBenchmark->GetCpuTime("EMCALDigitizer"), gBenchmark->GetCpuTime("EMCALDigitizer")/nEvents ) ;
+ AliInfo(Form("Exec: took %f seconds for Digitizing %f seconds per event",
+ gBenchmark->GetCpuTime("EMCALDigitizer"), gBenchmark->GetCpuTime("EMCALDigitizer")/nEvents )) ;
}
}
//to prevent cleaning of this object while GetEvent is called
emcalLoader->GetDigitsDataLoader()->GetBaseTaskLoader()->SetDoNotReload(kTRUE);
- Print();
-
+ //PH Print();
+ //Calibration instance
+ fCalibData = emcalLoader->CalibData();
return fInit ;
}
//____________________________________________________________________________
void AliEMCALDigitizer::InitParameters()
-{ // Tune parameters - 24-nov-04
+{
+ // Parameter initialization for digitizer
+ // Tune parameters - 24-nov-04; Apr 29, 2007
- fMeanPhotonElectron = 3300 ; // electrons per GeV
- fPinNoise = 0.004;
+ fMeanPhotonElectron = 3300; // electrons per GeV
+ fPinNoise = 0.010; // 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 ??
return ;
}
// looking for the file which contains SDigits
- //AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
TString fileName( emcalLoader->GetSDigitsFileName() ) ;
if ( eventFolderName != AliConfig::GetDefaultEventFolderName()) // only if not the default folder name
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] ;
}
//__________________________________________________________________
-void AliEMCALDigitizer::PrintDigits(Option_t * option){
+void AliEMCALDigitizer::PrintDigits(Option_t * option)
+{
+ //utility method for printing digit information
+
AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL"));
TClonesArray * digits = emcalLoader->Digits() ;
TClonesArray * sdigits = emcalLoader->SDigits() ;
// -- 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);
}
TList *AliEMCALDigitizer::BookControlHists(int var)
-{ // 22-nov-04
+{
+ // 22-nov-04
+ // histograms for monitoring digitizer performance
+
Info("BookControlHists"," started ");
gROOT->cd();
const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
new TH1F("hDigiAbsId","EMCAL absId cells with fAmp > fDigitThreshold ",
geom->GetNCells(), 0.5, Double_t(geom->GetNCells())+0.5);
}
+
fHists = AliEMCALHistoUtilities::MoveHistsToList("EmcalDigiControlHists", kFALSE);
- fHists = 0;
+ fHists = 0; //huh? JLK 03-Mar-2006
return fHists;
}