|
ATLAS Offline Software
|
Go to the documentation of this file.
6 #include "CLHEP/Random/RandGaussZiggurat.h"
16 #include "CLHEP/Random/RandomEngine.h"
17 #include <CLHEP/Random/Randomize.h>
20 using CLHEP::RandFlat;
21 using CLHEP::RandGaussZiggurat;
52 return StatusCode::FAILURE;
77 ATH_MSG_ERROR(
" Unable to retrieve CaloIdManager from DetectoreStore");
78 return StatusCode::FAILURE;
86 ATH_MSG_ERROR(
" Unable to retrieve LArOnlineId from DetectoreStore");
87 return StatusCode::FAILURE;
98 return StatusCode::SUCCESS;
110 return StatusCode::FAILURE;
116 const LArHitEMap* hitmapPtr_DigiHSTruth =
nullptr;
119 hitmapPtr_DigiHSTruth = hitmap_DigitHSTruth.
cptr();
130 DigitContainer->reserve(it_end);
136 std::unique_ptr<LArDigitContainer> DigitContainer_DigiHSTruth =
nullptr;
138 DigitContainer_DigiHSTruth = std::make_unique<LArDigitContainer>();
139 DigitContainer_DigiHSTruth->
reserve(it_end);
142 const std::vector<std::pair<float,float> >* TimeE;
143 const std::vector<std::pair<float,float> >* TimeE_DigiHSTruth =
nullptr;
146 CLHEP::HepRandomEngine * engine = rngWrapper->
getEngine(context);
150 for( ;
it!=it_end;++
it)
157 const auto& hitlist_DigiHSTruth=hitmapPtr_DigiHSTruth->
GetCell(
it);
158 TimeE_DigiHSTruth = &(hitlist_DigiHSTruth.getData());
165 bool missing=!(badFebs->
status(febId).good());
173 LArDigit* Digit_DigiHSTruth =
nullptr;
176 Digit_DigiHSTruth, TimeE,
digit, engine,
178 DigitContainer->push_back(Digit);
179 if (DigitContainer_DigiHSTruth){
180 DigitContainer_DigiHSTruth->
push_back(Digit_DigiHSTruth);
189 ATH_MSG_DEBUG(
" number of created digits = " << DigitContainer->size());
193 if ( DigitContainer_DigiHSTruth ){
195 ATH_CHECK(DigitContainer_DigiHSTruthHandle.
record( std::move(DigitContainer_DigiHSTruth) ) );
199 return StatusCode::SUCCESS;
203 const EventContext& ctx,
209 const std::vector<std::pair<float, float>>* TimeE,
211 CLHEP::HepRandomEngine* engine,
212 const std::vector<std::pair<float, float>>* TimeE_DigiHSTruth)
const {
213 bool createDigit_DigiHSTruth =
true;
215 int sampleGainChoice{2};
220 short Adc_DigiHSTruth;
224 std::vector<short> AdcSample_DigiHSTruth(
m_NSamples);
251 autoCorrNoise=*autoCorrNoiseHdl;
295 ATH_MSG_DEBUG(
" number of hit for this cell " << TimeE->size());
305 if( this->
ConvertHits2Samples(ctx, cellId,ch_id,initialGain,TimeE, Samples).isFailure() ) {
306 return StatusCode::SUCCESS;
309 if( this->
ConvertHits2Samples(ctx, cellId,ch_id,initialGain,TimeE_DigiHSTruth, Samples_DigiHSTruth).isFailure() ) {
310 return StatusCode::SUCCESS;
322 rndmGain= rndmEvtDigit->
gain();
323 auto polynom_adc2mev =adc2MeVs->
ADC2MEV(cellId,rndmEvtDigit->
gain());
324 if (polynom_adc2mev.size() > 1) {
325 float adc2energy =
SF * polynom_adc2mev[1];
326 const std::vector<short> & rndm_digit_samples = rndmEvtDigit->
samples() ;
327 float Pedestal = pedestal->
pedestal(ch_id,rndmEvtDigit->
gain());
329 ATH_MSG_WARNING(
" Pedestal not found in database for this channel offID " << cellId <<
" Use sample 0 for random");
330 Pedestal = rndm_digit_samples[0];
332 ATH_MSG_DEBUG(
" Params for inverting LAr Digitization: pedestal " << Pedestal <<
" adc2energy " << adc2energy);
339 if (larOFC.
cptr() !=
nullptr) {
342 if (ofc_a.size()>0) {
343 for (
unsigned int j=0;j<ofc_a.size();j++) sumOfc += ofc_a.
at(j);
345 if (sumOfc>0) adc0 = polynom_adc2mev[0] *
SF /sumOfc;
350 if ((
int)(rndm_digit_samples.size()) <
m_NSamples) {
352 "Less digit Samples than requested in digitization for cell "
353 << ch_id.
get_compact() <<
" Digit has " << rndm_digit_samples.size()
354 <<
" samples. Digitization request " <<
m_NSamples);
355 nmax = rndm_digit_samples.size();
359 rAdc = (rndm_digit_samples[
i] - Pedestal ) * adc2energy + adc0;
360 rndm_energy_samples[
i] = rAdc ;
377 float samp2=Samples[sampleGainChoice-ihecshift]*MeV2GeV;
381 float Samp2_DigiHSTruth=Samples_DigiHSTruth[sampleGainChoice-ihecshift]*MeV2GeV;
382 if ( Samp2_DigiHSTruth <=
m_EnergyThresh ) createDigit_DigiHSTruth =
false;
395 ATH_MSG_DEBUG(
" Pedestal not found for medium gain ,cellID " << cellId <<
" assume 1000 ");
399 if ( polynom_adc2mev.size() < 2) {
401 return StatusCode::SUCCESS;
403 pseudoADC3 = Samples[sampleGainChoice-ihecshift]/(polynom_adc2mev[1])/
SF + Pedestal ;
422 if (
igain != initialGain ){
426 else Samples[
i] = 0.;
431 return StatusCode::SUCCESS;
434 if( this->
ConvertHits2Samples(ctx, cellId,ch_id,
igain,TimeE_DigiHSTruth, Samples_DigiHSTruth) == StatusCode::FAILURE ) {
435 return StatusCode::SUCCESS;
449 bool addedNoise=
false;
466 const std::vector<float>& CorGen =
472 return StatusCode::FAILURE;
475 RandGaussZiggurat::shootArray(engine,
m_NSamples, Rndm, 0., 1.);
480 for (
int j = 0; j <=
i; j++) {
482 Noise[
i] += Rndm[j] * CorGen[
index];
484 Noise[
i] = Noise[
i] * SigmaNoise;
498 double SigmaNoiseZB = 0.;
499 double SigmaNoise = 0.;
500 double SigmaExtraNoise = 0.;
502 SigmaNoiseZB =
noise->noise(ch_id, rndmEvtDigit->
gain());
507 SigmaNoiseZB =
noise;
517 auto polynom_adc2mevZB =
519 auto polynom_adc2mev = adc2MeVs->
ADC2MEV(cellId,
igain);
520 if (polynom_adc2mevZB.size() > 1 && polynom_adc2mev.size() > 1) {
521 if (polynom_adc2mev[1] > 0.) {
522 SigmaNoiseZB = SigmaNoiseZB * (polynom_adc2mevZB[1]) /
523 (polynom_adc2mev[1]);
524 if (SigmaNoise > SigmaNoiseZB)
525 SigmaExtraNoise = sqrt(SigmaNoise * SigmaNoise -
526 SigmaNoiseZB * SigmaNoiseZB);
529 RandGaussZiggurat::shootArray(engine,
m_NSamples, Rndm, 0.,
532 Noise[
i] = SigmaExtraNoise * Rndm[
i];
543 ATH_MSG_WARNING(
" pedestal not found for cellId " << cellId <<
" assume 1000" );
547 if (polynom_adc2mev.size() < 2) {
549 return StatusCode::SUCCESS;
552 energy2adc=1./(polynom_adc2mev[1])/
SF;
559 if (larOFC.
cptr() !=
nullptr) {
562 if (ofc_a.size()>0) {
563 for (
unsigned int j=0;j<ofc_a.size();j++) sumOfc+= ofc_a.
at(j);
565 if ((polynom_adc2mev[1])>0 && sumOfc>0) Pedestal = Pedestal - (polynom_adc2mev[0])/(polynom_adc2mev[1])/sumOfc;
566 ATH_MSG_DEBUG(
" Params for final LAr Digitization gain: " <<
igain <<
" pedestal: " << Pedestal <<
" energy2adc: " << energy2adc);
572 double xAdc_DigiHSTruth = 0;
575 xAdc = Samples[
i]*energy2adc + Noise[
i] + Pedestal + 0.5;
577 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Noise[
i] + Pedestal + 0.5;
583 float flatRndm = RandFlat::shoot(engine);
584 xAdc = Samples[
i]*energy2adc + Pedestal + flatRndm;
586 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Pedestal + flatRndm;
591 xAdc = Samples[
i]*energy2adc + Pedestal + 0.5;
593 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Pedestal + 0.5;
605 else Adc = (
short) xAdc;
610 if (xAdc_DigiHSTruth <0) Adc_DigiHSTruth=0;
611 else if (xAdc_DigiHSTruth >=
MAXADC) Adc_DigiHSTruth=
MAXADC;
612 else Adc_DigiHSTruth = (
short) xAdc_DigiHSTruth;
613 AdcSample_DigiHSTruth[
i] = Adc_DigiHSTruth;
617 ATH_MSG_DEBUG(
" Sample " <<
i <<
" Energy= " << Samples[
i] <<
" Adc=" << Adc);
629 createDigit_DigiHSTruth =
false;
630 Digit_DigiHSTruth =
nullptr;
633 if (Samples_DigiHSTruth[
i] != 0)
634 createDigit_DigiHSTruth =
true;
638 new LArDigit(ch_id,
igain, std::move(AdcSample_DigiHSTruth));
641 return StatusCode::SUCCESS;
648 const std::vector<std::pair<float,float> > *TimeE,
staticVecDouble_t &sampleList)
const
670 nsamples_der = ShapeDer.size();
674 return StatusCode::FAILURE;
685 std::vector<std::pair<float,float> >::const_iterator
first = TimeE->begin();
686 std::vector<std::pair<float,float> >::const_iterator last = TimeE->end();
688 while (
first != last)
691 time = (*first).second;
709 int ishift=(
int)(rint(
time*(1./25.)));
718 if (j<nsamples_der && std::abs(ShapeDer[j])<10. )
719 sampleList[
i] += (Shape[j]- ShapeDer[j]*dtime)*
energy ;
720 else sampleList[
i] += Shape[j]*
energy ;
730 float timeBinWidth = 25./24.*3.;
738 int ishift = (
int)(
time*(1./25.));
741 tbin = (
int)(fmod(
time,25)/timeBinWidth);
747 tbin = (
int)(fmod(-
time,25)/timeBinWidth);
750 double dtime =
time - ( 25.*((
float)(ishift)) - timeBinWidth*tbin);
756 nsamples_der = ShapeDer.size();
766 if (j<nsamples_der && std::abs(ShapeDer[j])<10. )
767 sampleList[
i] += (Shape[j]- ShapeDer[j]*dtime)*
energy ;
768 else sampleList[
i] += Shape[j]*
energy ;
777 return StatusCode::SUCCESS;
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
SG::ReadCondHandleKey< ILArOFC > m_OFCKey
def retrieve(aClass, aKey=None)
virtual float pedestal(const HWIdentifier &id, int gain) const =0
const LArVectorProxy ADC2MEV(const HWIdentifier &id, int gain) const
SeedingOptionType
Options for seeding option=0 is setSeed as in MC20 option=1 is setSeedLegacy as in MC16 option=2 is s...
SG::ReadCondHandleKey< ILArShape > m_shapeKey
Gaudi::Property< bool > m_NoiseInEMEC
Gaudi::Property< bool > m_NoiseInFCAL
const_pointer_type cptr()
Dereference the pointer.
bool is_lar_fcal(Identifier id) const
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
SG::ReadCondHandleKey< LArAutoCorrNoise > m_autoCorrNoiseKey
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
static constexpr int s_MaxNSamples
void setSeedLegacy(const std::string &algName, size_t slot, uint64_t ev, uint64_t run, uint64_t offset, SeedingOptionType seeding, EventContext::ContextEvt_t evt=EventContext::INVALID_CONTEXT_EVT)
Set the random seed using a string (e.g.
Conditions-Data class holding LAr Bad Channel or Bad Feb information.
SG::ReadCondHandleKey< LArBadFebCont > m_badFebKey
Gaudi::Property< uint32_t > m_randomSeedOffset
const LArEM_ID * getEM_ID(void) const
Gaudi::Property< bool > m_NoiseOnOff
virtual ShapeRef_t ShapeDer(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
SG::ReadHandleKey< LArHitEMap > m_hitMapKey_DigiHSTruth
const std::vector< short > & samples() const
const float SF[NF]
Cross sections for Fluor.
const LArFCAL_ID * m_larfcal_id
const LArOnlineID * m_laronline_id
StatusCode buildBitMask(const std::vector< std::string > &problemsToMask, MsgStream &msg)
void reserve(unsigned int size)
Set the desired capacity.
value_type get_compact() const
Get the compact id.
virtual StatusCode initialize()
Gaudi::Property< bool > m_RndmEvtOverlay
ServiceHandle< IAthRNGSvc > m_rndmGenSvc
const std::string & key() const
Return the StoreGate ID for the referenced object.
const std::vector< float > & autoCorrSqrt(const HWIdentifier &id, int gain) const
bool cellShouldBeMasked(const LArBadChannelCont *bcCont, const HWIdentifier &hardwareId) const
LArBC_t status(const HWIdentifier channel) const
Query the status of a particular channel or FEB This is the main client access method.
SG::ReadCondHandleKey< ILArNoise > m_noiseKey
const LArHitList & GetCell(const unsigned int index) const
Definition of CaloDetDescrManager.
SG::ReadCondHandleKey< ILArfSampl > m_fSamplKey
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadCondHandleKey< LArBadChannelCont > m_bcContKey
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKey
Gaudi::Property< bool > m_Windows
const LARLIST & getData() const
Gaudi::Property< bool > m_NoiseInEMB
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
const LArHEC_ID * getHEC_ID(void) const
This class initializes the Calo (LAr and Tile) offline identifiers.
SG::ReadCondHandleKey< LArADC2MeV > m_adc2mevKey
value_type at(size_t i) const
Vector indexing with bounds check.
Liquid Argon digit base class.
::StatusCode StatusCode
StatusCode definition for legacy code.
Gaudi::Property< bool > m_roundingNoNoise
virtual const float & FSAMPL(const HWIdentifier &id) const =0
const LArFCAL_ID * getFCAL_ID(void) const
boost::container::static_vector< float, s_MaxNSamples > staticVecFloat_t
double m_HighGainThresh[4]
LArBadChannelMask m_bcMask
StatusCode MakeDigit(const EventContext &ctx, const Identifier &cellId, const HWIdentifier &ch_id, LArDigit *&Digit, DataPool< LArDigit > &dataItemsPool, LArDigit *&Digit_DigiHSTruth, const std::vector< std::pair< float, float > > *TimeE, const LArDigit *rndm_digit, CLHEP::HepRandomEngine *engine, const std::vector< std::pair< float, float > > *TimeE_DigiHSTruth=nullptr) const
Gaudi::Property< int > m_NSamples
bool is_lar_hec(Identifier id) const
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
StatusCode ConvertHits2Samples(const EventContext &ctx, const Identifier &cellId, HWIdentifier ch_id, CaloGain::CaloGain igain, const std::vector< std::pair< float, float > > *TimeE, staticVecDouble_t &sampleList) const
const LArDigit * GetDigit(unsigned int index) const
HWIdentifier feb_Id(int barrel_ec, int pos_neg, int feedthrough, int slot) const
Create feb_Id from fields.
double m_LowGainThresh[4]
Gaudi::Property< bool > m_usePhase
boost::container::static_vector< double, s_MaxNSamples > staticVecDouble_t
LArHitEMapToDigitAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< bool > m_NoiseInHEC
const LArEM_ID * m_larem_id
A wrapper class for event-slot-local random engines.
int barrel_ec(const Identifier id) const
return barrel_ec according to :
value_type push_back(value_type pElem)
Add an element to the end of the collection.
StatusCode initialize(bool used=true)
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
const LArHEC_ID * m_larhec_id
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
bool is_em_endcap_inner(const Identifier id) const
test if the id belongs to the EM Endcap inner wheel
Gaudi::Property< std::vector< std::string > > m_problemsToMask
Gaudi::Property< bool > m_isMcOverlay
Gaudi::Property< bool > m_pedestalNoise
SG::WriteHandleKey< LArDigitContainer > m_DigitContainerName_DigiHSTruth
CaloGain::CaloGain gain() const
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
def time(flags, cells_name, *args, **kw)
#define ATH_MSG_WARNING(x)
SG::WriteHandleKey< LArDigitContainer > m_DigitContainerName
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
virtual StatusCode execute(const EventContext &context) const
virtual OFCRef_t OFC_a(const HWIdentifier &id, int gain, int tbin=0) const =0
access to OFCs by online ID, gain, and tbin (!=0 for testbeam)
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Gaudi::Property< double > m_EnergyThresh
const CaloCell_ID * m_calocell_id
int GetNbCells(void) const
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting
bool is_lar_em(Identifier id) const
Gaudi::Property< std::string > m_randomStreamName
SG::ReadHandleKey< LArHitEMap > m_hitMapKey
Gaudi::Property< int > m_firstSample
interface to a tool that returns the time offset of the current trigger. Used by PileUpMergeSvc
Gaudi::Property< bool > m_doDigiTruth
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Proxy for accessing a range of float values like a vector.
Gaudi::Property< bool > m_useLegacyRandomSeeds
virtual ShapeRef_t Shape(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
const_pointer_type cptr()