19 #include <TBenchmark.h> 21 #include <TObjectTable.h> 47 Double_t HeavisideTheta(Double_t x)
51 if (x > 0.) signal = 1.;
56 Double_t AnalogFastORFunction(Double_t *x, Double_t *par)
69 return (((0.8*(-((TMath::Power(C1,2)*C2*TMath::Power(TMath::E(),(-t + t0)/(C1*R1))*
70 TMath::Power(R1,2)*R2)/(C1*R1 - C2*R2)) +
71 C1*C2*R1*R2*(1 - (C2*TMath::Power(TMath::E(),(-t + t0)/(C2*R2))*R2)/(-(C1*R1) + C2*R2)))*v0*
72 HeavisideTheta(t - t0))/tr
74 (TMath::Power(C1,2)*C2*TMath::Power(TMath::E(),(-1.*t + t0 + 1.25*tr)/(C1*R1))*
75 TMath::Power(R1,2)*R2)/(C1*R1 - C2*R2) +
76 (C1*TMath::Power(C2,2)*TMath::Power(TMath::E(),(-1.*t + t0 + 1.25*tr)/(C2*R2))*
77 R1*TMath::Power(R2,2))/(C1*R1 - C2*R2))*v0*
78 HeavisideTheta(t - t0 - 1.25*tr))/tr)/(C2*R1));
98 fMeanPhotonElectron(0),
103 fTimeDelayFromOCDB(0),
104 fTimeResolutionPar0(0),
105 fTimeResolutionPar1(0),
108 fADCchannelECDecal(0),
110 fTimeChannelDecal(0),
112 fEventFolderName(
""),
269 Int_t readEvent = event ;
273 AliDebug(1,Form(
"Adding event %d from input stream 0 %s %s",
278 TClonesArray * digits = emcalLoader->
Digits() ;
285 AliFatal(
"Could not get AliRun from runLoader");
293 AliDebug(1,Form(
"nEMC %i (number cells in EMCAL) | %s \n", nEMC, geom->GetName()));
295 digits->Expand(nEMC) ;
304 sdigArray->AddAt(emcalLoader->
SDigits(), 0) ;
307 Int_t embed = kFALSE;
308 for(i = 1 ; i <
fInput ; i++)
320 AliFatal(
"Run Loader of second event not available!");
327 AliInfo(Form(
"Adding event %d from input stream %d %s %s", readEvent, i,
fInputFileNames[i].Data(), tempo.Data())) ;
335 AliFatal(
"Loader of second input not found");
343 AliFatal(
"EMCAL Loader of second event not available!");
348 if(!emcalLoader2->
SDigits())
continue;
350 TClonesArray* sdigits2 = emcalLoader2->
SDigits();
351 sdigArray->AddAt(sdigits2, i) ;
355 if( sdigits2->GetEntriesFast() <= 0 )
continue;
365 Int_t nextSig = nEMC + 1 ;
366 TClonesArray * sdigits ;
367 for(i = 0 ; i <
fInput ; i++)
369 if(i > 0 && embed)
continue;
371 sdigits =
dynamic_cast<TClonesArray *
>(sdigArray->At(i)) ;
378 if (sdigits->GetEntriesFast() <= 0 )
391 Int_t curNext = sd->
GetId() ;
392 if(curNext < nextSig)
394 AliDebug(1,Form(
"input %i : #sdigits %i \n",i, sdigits->GetEntriesFast()));
398 AliDebug(1,Form(
"FIRST tower with signal %i \n", nextSig));
400 TArrayI index(fInput) ;
408 Float_t timeResolution = 0;
410 for(absID = 0; absID < nEMC; absID++)
415 Float_t noiseTime = 0.;
417 new((*digits)[absID])
AliEMCALDigit( -1, -1, absID, 0., noiseTime,kFALSE);
423 AliDebug(1,
"Digit pointer is null");
430 Float_t time = digit->
GetTime() ;
435 if(embed) nInputs = 1;
436 for(i = 0; i< nInputs ; i++)
439 TClonesArray* sdtclarr =
dynamic_cast<TClonesArray *
>(sdigArray->At(i));
442 Int_t sDigitEntries = sdtclarr->GetEntriesFast();
444 if(sDigitEntries > index[i] ) curSDigit =
dynamic_cast<AliEMCALDigit*
>(sdtclarr->At(index[i])) ;
448 while(curSDigit && (curSDigit->
GetId() == absID))
451 Int_t primaryoffset = i ;
461 *digit = *digit + *curSDigit ;
465 if( sDigitEntries > index[i] ) curSDigit =
dynamic_cast<AliEMCALDigit*
>(sdtclarr->At(index[i])) ;
477 energy *=
static_cast<Float_t
>(gRandom->Poisson(fluct)) / fluct ;
484 for(i = 0 ; i < nInputs ; i++)
486 sdigits =
dynamic_cast<TClonesArray *
>(sdigArray->At(i)) ;
490 Int_t curNext = nextSig ;
491 if(sdigits->GetEntriesFast() > index[i])
494 if ( tmpdigit ) curNext = tmpdigit->
GetId() ;
497 if(curNext < nextSig) nextSig = curNext ;
516 AliDebug(10,Form(
" absID %5i energy %f nextSig %5i\n",
517 absID, energy, nextSig));
527 for(Int_t input = 1; input<
fInput; input++)
529 TClonesArray *realDigits =
dynamic_cast<TClonesArray*
> (sdigArray->At(input));
532 AliDebug(1,
"No sdigits to merge\n");
536 for(Int_t i2 = 0 ; i2 < realDigits->GetEntriesFast() ; i2++)
539 if ( !digit2 )
continue;
542 if ( !digit )
continue;
546 Float_t time2 = digit2->
GetTime();
553 AliDebug(1,Form(
"digit 1: Abs ID %d, amp %f, type %d, time %e; digit2: Abs ID %d, amp %f, type %d, time %e\n",
554 digit ->GetId(),digit ->GetAmplitude(), digit ->GetType(), digit->
GetTime(),
568 AliDebug(1,Form(
"Embedded digit: Abs ID %d, amp %f, type %d\n",
585 for(i = 0 ; i < nEMC ; i++)
590 digits->RemoveAt(i) ;
606 digits->RemoveAt(i) ;
628 Int_t ndigits = digits->GetEntriesFast();
630 if(idigit != ndigits)
631 AliFatal(Form(
"Total number of digits in array %d different to expected %d",ndigits,idigit));
633 AliDebug(1,Form(
"Number of recorded digits is %d",ndigits));
655 AliFatal(
"Did not get geometry from EMCALLoader");
666 Bool_t bCell = geom->
GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
667 if(!bCell) Error(
"DigitizeEnergyTime",
"Wrong cell id number : absId %i ", absId) ;
717 AliFatal(
"Did not get geometry from EMCALLoader");
722 Int_t absId = digit->
GetId();
730 Bool_t bCell = geom->
GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
731 if (!bCell) Error(
"Decalibrate",
"Wrong cell id number : absId %i ", absId) ;
739 Float_t factor = 1./(adcChannel/adcChannelOnline);
741 *digit = *digit * factor;
764 AliFatal(
"Did not get geometry from EMCALLoader");
775 Bool_t bCell = geom->
GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
776 if(!bCell) Error(
"CalibrateADCTime",
"Wrong cell id number : absId %i ", absId) ;
809 Error(
"Digitize",
"Give a version name different from %s",
fEventFolderName.Data() ) ;
813 if (strstr(option,
"print"))
819 if(strstr(option,
"tim"))
842 AliFatal(
"Did not get the AliEMCAL pointer");
854 TClonesArray* digitsTMP =
new TClonesArray(
"AliEMCALDigit", nTRU*96);
855 TClonesArray* digitsTRG =
new TClonesArray(
"AliEMCALTriggerRawDigit", nTRU*96);
858 for (ievent = fFirstEvent; ievent <=
fLastEvent; ievent++)
873 (emcalLoader->
TreeD())->Fill();
879 digitsTRG ->Clear(
"C");
880 digitsTMP ->Clear(
"C");
884 if(strstr(option,
"deb"))
886 if(strstr(option,
"table")) gObjectTable->Print();
895 if(strstr(option,
"tim"))
898 Float_t cputime =
gBenchmark->GetCpuTime(
"EMCALDigitizer");
899 Float_t avcputime = cputime;
900 if(nEvents==0) avcputime = 0 ;
901 AliInfo(Form(
"Digitize: took %f seconds for Digitizing %f seconds per event", cputime, avcputime)) ;
938 if (!emcalLoader)
AliFatal(
"Did not get the Loader");
950 TClonesArray* sdigits = emcalLoader->
SDigits();
952 TClonesArray *digits = (TClonesArray*)sdigits->Clone();
954 AliDebug(999,Form(
"=== %d SDigits to trigger digits ===",digits->GetEntriesFast()));
956 TIter NextDigit(digits);
959 if (
IsDead(digit))
continue;
963 Int_t
id = digit->GetId();
968 AliDebug(1,Form(
"trigger digit id: %d from cell id: %d\n",trgid,
id));
988 Int_t *timeSamples =
new Int_t[nSamples];
990 NextDigit = TIter(digitsTMP);
995 Int_t
id = digit->GetId();
996 Float_t time = 50.e-9;
998 Double_t depositedEnergy = 0.;
999 for (Int_t j = 1; j <= digit->GetNprimary(); j++) depositedEnergy += digit->GetDEPrimary(j);
1004 if (depositedEnergy) {
1005 depositedEnergy += gRandom->Gaus(0., .08);
1006 DigitalFastOR(time, depositedEnergy, timeSamples, nSamples);
1008 for (Int_t j=0;j<nSamples;j++) {
1010 timeSamples[j] = ((j << 16) | (timeSamples[j] & 0xFFFF));
1020 delete [] timeSamples;
1022 if (digits && digits->GetEntriesFast()) digits->Clear(
"C");
1037 const Int_t reso = 12;
1038 const Double_t vFSR = 2.;
1040 const Double_t dNe = 125/1.3;
1041 const Double_t vA = .136e-6;
1042 const Double_t rise = 50e-9;
1044 const Double_t kTimeBinWidth = 25E-9;
1046 Double_t vV = 1000. * dE * dNe * vA;
1048 TF1 signalF(
"signal", AnalogFastORFunction, 0, nSamples * kTimeBinWidth, 3);
1049 signalF.SetParameter( 0, vV );
1050 signalF.SetParameter( 1, time );
1051 signalF.SetParameter( 2, rise );
1053 for (Int_t iTime=0; iTime<nSamples; iTime++)
1057 Double_t sig = signalF.Eval(iTime * kTimeBinWidth);
1058 if (TMath::Abs(sig) > vFSR/2.)
1061 timeSamples[iTime] = (1 << reso) - 1;
1065 AliDebug(999,Form(
"iTime: %d sig: %f\n",iTime,sig));
1066 timeSamples[iTime] = ((1 << reso) / vFSR) * sig + 0.5;
1079 if ( emcalLoader == 0 )
1081 AliFatal(
"Could not obtain the AliEMCALLoader");
1099 for (index = 1 ; index <
fInput ; index++)
1103 fEventNames[index] = tempo.Remove(tempo.Length()-1) ;
1128 AliWarning(
"Simulation Parameters not available in OCDB?");
1136 Warning(
"InitParameters",
"No noise added\n") ;
1154 AliDebug(2,Form(
"Mean Photon Electron %d, Gain Fluct. %2.1f; Noise: APD %f, Time %f; Digit Threshold %d,Time Resolution Par0 %g Par1 %g,NADCEC %d",
1173 printf(
"Print: \n------------------- %s -------------", GetName() ) ;
1188 for (index = 0 ; index < nStreams ; index++)
1210 if(emcalLoader)
printf(
"\nWriting digits to %s", emcalLoader->GetDigitsFileName().Data()) ;
1211 else printf(
"\nNULL LOADER");
1213 printf(
"\nWith following parameters:\n") ;
1216 printf(
"---------------------------------------------------\n") ;
1219 printf(
"Print: AliEMCALDigitizer not initialized") ;
1230 TClonesArray * digits = emcalLoader->
Digits() ;
1231 TClonesArray * sdigits = emcalLoader->
SDigits() ;
1233 printf(
"\n #Digits: %d : sdigits %d ", digits->GetEntriesFast(), sdigits->GetEntriesFast()) ;
1236 if(strstr(option,
"all"))
1240 printf(
"\nEMC digits (with primaries):\n") ;
1241 printf(
"\n Id Amplitude Time Index Nprim: Primaries list \n") ;
1244 for (index = 0 ; index < digits->GetEntries() ; index++)
1249 printf(
"\n%6d %8f %6.5e %4d %2d : ",
1252 for (iprimary=0; iprimary<digit->
GetNprimary(); iprimary++) {
1260 else printf(
"NULL LOADER, cannot print\n");
1280 for(i = 1 ; i <
fInput ; i++)
1292 else AliFatal(
"Did not get the loader");
1310 const TClonesArray * digits = emcalLoader->
Digits() ;
1312 TTree * treeD = emcalLoader->
TreeD();
1316 treeD = emcalLoader->
TreeD();
1320 Int_t bufferSize = 32000 ;
1321 TBranch * digitsBranch = 0;
1322 if ((digitsBranch = treeD->GetBranch(
"EMCAL")))
1324 digitsBranch->SetAddress(&digits);
1325 AliWarning(
"Digits Branch already exists. Not all digits will be visible");
1328 treeD->Branch(
"EMCAL",
"TClonesArray",&digits,bufferSize);
1341 else AliFatal(
"Loader not available");
1352 TTree* treeD = emcalLoader->
TreeD();
1356 treeD = emcalLoader->
TreeD();
1360 Int_t bufferSize = 32000;
1362 if (TBranch* triggerBranch = treeD->GetBranch(branchName))
1364 triggerBranch->SetAddress(&digits);
1368 treeD->Branch(branchName,
"TClonesArray",&digits,bufferSize);
1372 else AliFatal(
"Loader not available");
1383 Int_t absId = digit->
GetId();
1401 AliFatal(
"Did not get the Loader");
1408 AliWarning(
"Could not access pedestal data! No dead channel removal applied");
1416 AliFatal(
"Did not get geometry from EMCALLoader");
1427 Bool_t bCell = geom->
GetCellIndex(absId, iSupMod, nModule, nIphi, nIeta) ;
1429 if (!bCell) Error(
"IsDead",
"Wrong cell id number : absId %i ", absId) ;
1432 Int_t channelStatus = (Int_t)(caloPed->
GetDeadMap(iSupMod))->GetBinContent(ieta,iphi);
static AliRunLoader * Instance()
Int_t GetEventNumber() const
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
Int_t GetNCells(void) const
void InitParameters()
/ Parameter initialization for digitizer
Double_t GetTimeDelay() const
static const TString & GetDefaultEventFolderName()
void Print(Option_t *option="") const
Int_t fInput
Number of files to merge.
Double_t GetTimeResolutionPar0() const
AliDigitizationInput * fDigInput
Float_t GetTime(void) const
EMCal trigger raw digits.
void DigitizeEnergyTime(Float_t &energy, Float_t &time, Int_t absId)
AliCaloCalibPedestal * PedestalData()
Float_t fGainFluctuations
Correct fMeanPhotonElectron by the gain fluctuations.
virtual void Print(const Option_t *opt) const
Dump raw digit info.
AliEMCALSDigitizer * fSDigitizer
SDigitization object.
Int_t LoadSDigits(Option_t *detectors="all", Option_t *opt="READ")
Float_t fADCchannelECDecal
Decalibration width of one ADC channel in EC section (GeV)
AliEMCALSimParam * SimulationParameters()
AliLoader * GetDetectorLoader(const char *detname)
void DecalibrateTrigger(AliEMCALDigit *digit)
Float_t Calibrate(Float_t amp) const
Convert the amplitude back to energy in GeV.
Double_t fTimeResolutionPar0
Time resolution of FEE electronics.
static AliEMCALSimParam * GetInstance()
Get Instance.
Float_t GetPinNoise() const
Float_t Digitize(Float_t energy) const
Digitize the energy.
Double_t fTimeDelay
Time delay to mimick roughly data delay.
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
TString * fEventNames
List of event names to merge.
#define AliWarning(message)
void CalibrateADCTime(Float_t &adc, Float_t &time, Int_t absId)
Give access to hits, digits, recpoints arrays and OCDB.
Int_t GetNTotalTRU() const
Bool_t GetFastORIndexFromCellIndex(const Int_t id, Int_t &idx) const
Int_t fFirstEvent
First event to process.
static AliRunLoader * Open(const char *filename="galice.root", const char *eventfoldername=AliConfig::GetDefaultEventFolderName(), Option_t *option="READ")
void GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta, Int_t &iphi, Int_t &ieta) const
Int_t fNADCEC
Number of channels in EC section ADC.
void SetTime(Float_t time)
TString GetFileName() const
Double_t IsTimeDelayFromOCDB() const
void UnloadDigits() const
Float_t TimeOfNoise(void)
Calculates the time signal generated by noise.
Float_t GetADCchannelOnline(Int_t module, Int_t column, Int_t row) const
Bool_t GetCellIndex(Int_t absId, Int_t &nSupMod, Int_t &nModule, Int_t &nIphi, Int_t &nIeta) const
Int_t GetNprimary() const
Int_t fLastEvent
Last event to process.
Int_t fMeanPhotonElectron
Number of photon electrons per GeV deposited energy.
AliRunLoader * GetRunLoader()
EMCal digitization maker.
Float_t GetADCchannelDecal(Int_t module, Int_t column, Int_t row) const
void Unload()
Unloads the SDigits and Digits.
Double_t fTimeResolutionPar1
Time resolution of FEE electronics.
Int_t GetNInputStreams() const
virtual void MakeDigitsContainer() const
Float_t GetTimeChannelDecal(Int_t supermodule, Int_t column, Int_t row) const
Container of simulation parameters.
void ShiftPrimary(Int_t shift)
Shifts primary number to BIG offset, to separate primary in different TreeK.
virtual AliEMCALGeometry * GetGeometry() const
Float_t fTimeChannel
Calibration time width for one channel.
Int_t GetIndexInList() const
EMCal summable digits maker.
Int_t GetNumberOfEvents()
Double_t GetTimeNoise() const
Bool_t Init()
Initializations, it makes all memory allocations.
Base Class for EMCAL description.
Int_t GetDigitThreshold() const
pedestal/bad map monitoring and calibration tools
void SetIndexInList(Int_t val)
#define AliFatal(message)
Int_t GetMeanPhotonElectron() const
Bool_t fDefaultInit
! Says if the task was created by defaut ctor (only parameters are initialized)
TString fEventFolderName
skowron: name of EFN to read data from in stand alone mode
Int_t GetEvent(Int_t evno)
Float_t GetADCchannel(Int_t module, Int_t column, Int_t row) const
void Digitize(Int_t event)
#define AliDebug(logLevel, message)
void PrintDigits(Option_t *option)
Utility method for printing digit information.
Int_t GetPrimary(Int_t index) const
Double_t GetTimeResolutionPar1() const
Float_t fADCchannelEC
Calibration width of one ADC channel in EC section (GeV)
virtual Int_t WriteDigits(Option_t *opt="") const
void Digits2FastOR(TClonesArray *digitsTMP, TClonesArray *digitsTRG)
const TString & GetSDigitsFileName() const
void DigitalFastOR(Double_t time, Double_t dE, Int_t timeSamples[], Int_t nSamples)
Int_t fDigitThreshold
Threshold for storing digits in EMC, ACD units.
Double_t fTimeNoise
Electronics noise in EMC, time.
Float_t GetTimeChannel(Int_t supermodule, Int_t column, Int_t row, Int_t bc) const
void UnloadSDigits() const
AliEMCALDigitizer()
Default constructor.
Float_t GetADCpedestal(Int_t module, Int_t column, Int_t row) const
virtual ~AliEMCALDigitizer()
Destructor.
AliEMCALCalibData * CalibData()
Float_t fADCpedestalEC
Calibration pedestal for one ADC channel.
AliDetector * GetDetector(const char *name) const
#define AliError(message)
AliEMCALCalibTime * CalibTime()
AliEMCALCalibTime * fCalibTime
Time Calibration data pointer.
static AliEMCALGeometry * GetInstance()
AliEMCALCalibData * fCalibData
Energy Calibration data pointer.
Bool_t IsDead(AliEMCALDigit *digit)
static AliRunLoader * GetRunLoader(const char *eventfoldername)
void Print1(Option_t *option)
Print info, call all prints.
Bool_t fTimeDelayFromOCDB
Recover time delay from data.
Float_t GetTimeResolution(Float_t energy) const
TString * fInputFileNames
List of file names to merge.
Float_t fPinNoise
Electronics noise in EMC, APD.
Bool_t fInit
! To avoid overwriting existing files
Float_t GetAmplitude() const
Float_t GetGainFluctuations() const
const int OVERFLOWCUT
sample overflow
Float_t fTimeChannelDecal
Calibration time width for one channel.
EMCal geometry, singleton.
Int_t fDigitsInRun
! Total number of digits in one run
AliRun * GetAliRun() const
void SetEventRange(Int_t first=0, Int_t last=-1)
void SetAmplitude(Float_t amp)