#include "AliEMCALCalibData.h"
#include "AliEMCALSimParam.h"
#include "AliEMCALRawDigit.h"
+#include "AliCaloCalibPedestal.h"
namespace
{
//Put Noise contribution, smear time and energy
Float_t timeResolution = 0;
for(absID = 0; absID < nEMC; absID++){ // Nov 30, 2006 by PAI; was from 1 to nEMC
+
+ if (IsDead(absID)) continue; // Don't instantiate dead digits
+
Float_t energy = 0 ;
// amplitude set to zero, noise will be added later
}
//_____________________________________________________________________
-void AliEMCALDigitizer::DecalibrateEnergy(Double_t& energy, const Int_t absId)
+void AliEMCALDigitizer::Decalibrate(AliEMCALDigit *digit)
{
// Load Geometry
- const AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance();
+ const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
- if (geom==0){
+ if (!geom) {
AliFatal("Did not get geometry from EMCALLoader");
return;
}
+ Int_t absId = digit->GetId();
Int_t iSupMod = -1;
Int_t nModule = -1;
Int_t nIphi = -1;
Int_t nIeta = -1;
Int_t iphi = -1;
Int_t ieta = -1;
+
Bool_t bCell = geom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
- if(!bCell)
- Error("DigitizeEnergyTime","Wrong cell id number : absId %i ", absId) ;
+
+ if (!bCell) Error("Decalibrate","Wrong cell id number : absId %i ", absId) ;
geom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
- if(fCalibData) {
+ if (fCalibData) {
fADCchannelEC = fCalibData->GetADCchannel(iSupMod,ieta,iphi);
+ float factor = 1./(fADCchannelEC/0.0162);
+
+ *digit = *digit * factor;
}
-
- energy /= fADCchannelEC/0.0162;
}
//_____________________________________________________________________
nEvents = fLastEvent - fFirstEvent + 1;
Int_t ievent = -1;
- TClonesArray* digitsTMP = new TClonesArray("AliEMCALDigit", 32*96);
- TClonesArray* digitsTRG = new TClonesArray("AliEMCALRawDigit", 32*96);
+ AliEMCALGeometry *geom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
+ const Int_t nTRU = geom->GetNTotalTRU();
+ TClonesArray* digitsTMP = new TClonesArray("AliEMCALDigit", nTRU*96);
+ TClonesArray* digitsTRG = new TClonesArray("AliEMCALRawDigit", nTRU*96);
rl->LoadSDigits("EMCAL");
for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) {
AliRunLoader *runLoader = AliRunLoader::Instance();
- AliRun* run = runLoader->GetAliRun();
-
AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL"));
- if(!emcalLoader){
- AliFatal("Did not get the Loader");
- }
- else {
- AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(run->GetDetector("EMCAL"));
- if(emcal){
- AliEMCALGeometry* geom = emcal->GetGeometry();
+ if (!emcalLoader) AliFatal("Did not get the Loader");
+
+ const AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance();
// build FOR from simulated digits
// and xfer to the corresponding TRU input (mapping)
- TClonesArray* digits = emcalLoader->SDigits();
-
+ TClonesArray* sdigits = emcalLoader->SDigits();
+
+ TClonesArray *digits = (TClonesArray*)sdigits->Clone();
+
AliDebug(999,Form("=== %d SDigits to trigger digits ===",digits->GetEntriesFast()));
TIter NextDigit(digits);
while (AliEMCALDigit* digit = (AliEMCALDigit*)NextDigit())
{
+ if (IsDead(digit)) continue;
+
+ Decalibrate(digit);
+
Int_t id = digit->GetId();
Int_t trgid;
}
if (AliDebugLevel()) printf("Number of TRG digits: %d\n",digitsTMP->GetEntriesFast());
-
- TF1 g4noiseF("g4noise","[0]*exp(-0.5*((x-[1])/[2])**4)",-10,10);
- g4noiseF.SetParameter( 0, 1 ); //
- g4noiseF.SetParameter( 1, 0 ); //
- g4noiseF.SetParameter( 2, .2 ); //
- Int_t nSamples = 32;
+ Int_t nSamples = geom->GetNTotalTRU();
Int_t *timeSamples = new Int_t[nSamples];
NextDigit = TIter(digitsTMP);
if (AliDebugLevel()) printf("Deposited Energy: %f\n", depositedEnergy);
// FIXME: Check digit time!
- if (depositedEnergy)
- {
-// depositedEnergy += depositedEnergy * g4noiseF.GetRandom();
-
- DecalibrateEnergy(depositedEnergy, id);
-
+ if (depositedEnergy) {
+ depositedEnergy += gRandom->Gaus(0., .08);
DigitalFastOR(time, depositedEnergy, timeSamples, nSamples);
- for (Int_t j=0;j<nSamples;j++)
- {
- timeSamples[j] = ((j << 12) & 0xFF000) | (timeSamples[j] & 0xFFF);
+ for (Int_t j=0;j<nSamples;j++) {
+ if (AliDebugLevel()) printf("timeSamples[%d]: %d\n",j,timeSamples[j]);
+ timeSamples[j] = ((j << 16) | (timeSamples[j] & 0xFFFF));
}
new((*digitsTRG)[digitsTRG->GetEntriesFast()]) AliEMCALRawDigit(id, timeSamples, nSamples);
-
- if (AliDebugLevel()) ((AliEMCALRawDigit*)digitsTRG->At(digitsTRG->GetEntriesFast() - 1))->Print("");
+
+ if (AliDebugLevel()) ((AliEMCALRawDigit*)digitsTRG->At(digitsTRG->GetEntriesFast() - 1))->Print("");
}
}
}
delete [] timeSamples;
- }// AliEMCAL exists
- else AliFatal("Could not get AliEMCAL");
- }// loader exists
-
+
+ if (digits && digits->GetEntriesFast()) digits->Delete();
}
//____________________________________________________________________________
{
// parameters:
// id: 0..95
- const Int_t reso = 11; // 11-bit resolution ADC
- const Double_t vFSR = 1; // Full scale input voltage range
+ const Int_t reso = 12; // 11-bit resolution ADC
+ const Double_t vFSR = 2.; // Full scale input voltage range 2V (p-p)
// const Double_t dNe = 125; // signal of the APD per MeV of energy deposit in a tower: 125 photo-e-/MeV @ M=30
const Double_t dNe = 125/1.3; // F-ALTRO max V. FEE: factor 4
const Double_t vA = .136e-6; // CSP output range: 0.136uV/e-
{
// FIXME: add noise (probably not simply Gaussian) according to DA measurements
// probably plan an access to OCDB
-
- timeSamples[iTime] = int((TMath::Power(2, reso) / vFSR) * signalF.Eval(iTime * kTimeBinWidth) + 0.5);
+ Double_t sig = signalF.Eval(iTime * kTimeBinWidth);
+ if (TMath::Abs(sig) > vFSR/2.) {
+ AliError("Signal overflow!");
+ timeSamples[iTime] = (1 << reso) - 1;
+ } else {
+ AliDebug(999,Form("iTime: %d sig: %f\n",iTime,sig));
+ timeSamples[iTime] = ((1 << reso) / vFSR) * sig + 0.5;
+ }
}
}
else AliFatal("Loader not available");
}
+//__________________________________________________________________
+Bool_t AliEMCALDigitizer::IsDead(AliEMCALDigit *digit)
+{
+ AliRunLoader *runLoader = AliRunLoader::Instance();
+ AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL"));
+ if (!emcalLoader) AliFatal("Did not get the Loader");
+
+ AliCaloCalibPedestal *caloPed = emcalLoader->PedestalData();
+ if (!caloPed) {
+ AliWarning("Could not access pedestal data! No dead channel removal applied");
+ return kFALSE;
+ }
+
+ // Load Geometry
+ const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
+ if (!geom) AliFatal("Did not get geometry from EMCALLoader");
+
+ Int_t absId = digit->GetId();
+ Int_t iSupMod = -1;
+ Int_t nModule = -1;
+ Int_t nIphi = -1;
+ Int_t nIeta = -1;
+ Int_t iphi = -1;
+ Int_t ieta = -1;
+
+ Bool_t bCell = geom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
+
+ if (!bCell) Error("IsDead","Wrong cell id number : absId %i ", absId) ;
+ geom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
+
+ Int_t channelStatus = (Int_t)(caloPed->GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
+
+ if (channelStatus == AliCaloCalibPedestal::kDead)
+ return kTRUE;
+ else
+ return kFALSE;
+}
+
+
+//__________________________________________________________________
+Bool_t AliEMCALDigitizer::IsDead(Int_t absId)
+{
+ AliRunLoader *runLoader = AliRunLoader::Instance();
+ AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL"));
+ if (!emcalLoader) AliFatal("Did not get the Loader");
+
+ AliCaloCalibPedestal *caloPed = emcalLoader->PedestalData();
+ if (!caloPed) {
+ AliWarning("Could not access pedestal data! No dead channel removal applied");
+ return kFALSE;
+ }
+
+ // Load Geometry
+ const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
+ if (!geom) AliFatal("Did not get geometry from EMCALLoader");
+
+ Int_t iSupMod = -1;
+ Int_t nModule = -1;
+ Int_t nIphi = -1;
+ Int_t nIeta = -1;
+ Int_t iphi = -1;
+ Int_t ieta = -1;
+
+ Bool_t bCell = geom->GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
+
+ if (!bCell) Error("IsDead","Wrong cell id number : absId %i ", absId) ;
+ geom->GetCellPhiEtaIndexInSModule(iSupMod,nModule,nIphi, nIeta,iphi,ieta);
+
+ Int_t channelStatus = (Int_t)(caloPed->GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
+
+ if (channelStatus == AliCaloCalibPedestal::kDead)
+ return kTRUE;
+ else
+ return kFALSE;
+}
+