ATLAS Offline Software
Loading...
Searching...
No Matches
RD53SimTool Class Reference

#include <RD53SimTool.h>

Inheritance diagram for RD53SimTool:
Collaboration diagram for RD53SimTool:

Public Member Functions

 RD53SimTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual ~RD53SimTool ()
virtual void process (SiChargedDiodeCollection &chargedDiodes, PixelRDO_Collection &rdoCollection, CLHEP::HepRandomEngine *rndmEngine) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Protected Attributes

int m_numberOfBcid {1}
double m_timeOffset {5.0}
double m_timeJitter {0.0}
double m_thermalNoise {160.0}
ToolHandle< IInDetConditionsToolm_pixelConditionsTool
ServiceHandle< InDetDD::IPixelReadoutManagerm_pixelReadout
SG::ReadCondHandleKey< PixelChargeCalibCondDatam_chargeDataKey
Gaudi::Property< int > m_BarrelEC
Gaudi::Property< bool > m_doNoise
Gaudi::Property< bool > m_cosmics

Static Protected Attributes

static constexpr double m_bunchSpace {25.0}

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

 RD53SimTool ()
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ITkPixSimulationParameters m_chipSim {}
Gaudi::Property< bool > m_doTimeWalk
Gaudi::Property< int > m_overDrive
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 26 of file RD53SimTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ RD53SimTool() [1/2]

RD53SimTool::RD53SimTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 22 of file RD53SimTool.cxx.

22 :
23 FrontEndSimTool(type, name, parent) {
24}

◆ ~RD53SimTool()

RD53SimTool::~RD53SimTool ( )
virtualdefault

◆ RD53SimTool() [2/2]

RD53SimTool::RD53SimTool ( )
private

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode RD53SimTool::finalize ( )
virtual

Reimplemented from FrontEndSimTool.

Definition at line 34 of file RD53SimTool.cxx.

34 {
35 ATH_MSG_DEBUG("RD53SimTool::finalize()");
36 return StatusCode::SUCCESS;
37}
#define ATH_MSG_DEBUG(x)

◆ initialize()

StatusCode RD53SimTool::initialize ( )
virtual

Reimplemented from FrontEndSimTool.

Definition at line 28 of file RD53SimTool.cxx.

28 {
30 ATH_MSG_DEBUG("RD53SimTool::initialize()");
31 return StatusCode::SUCCESS;
32}
#define ATH_CHECK
Evaluate an expression and check for errors.
virtual StatusCode initialize() override

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & FrontEndSimTool::interfaceID ( )
inlinestaticinherited

Definition at line 35 of file FrontEndSimTool.h.

static const InterfaceID IID_IFrontEndSimTool("FrontEndSimTool", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ process()

void RD53SimTool::process ( SiChargedDiodeCollection & chargedDiodes,
PixelRDO_Collection & rdoCollection,
CLHEP::HepRandomEngine * rndmEngine ) const
virtual

Implements FrontEndSimTool.

Definition at line 39 of file RD53SimTool.cxx.

40 {
41 const PixelID* pixelId = static_cast<const PixelID*>(chargedDiodes.element()->getIdHelper());
42 const IdentifierHash moduleHash = pixelId->wafer_hash(chargedDiodes.identify()); // wafer hash
43 Identifier moduleID = pixelId->wafer_id(chargedDiodes.element()->identify());
44
45 int barrel_ec = pixelId->barrel_ec(chargedDiodes.element()->identify());
46 if (std::abs(barrel_ec) != m_BarrelEC) {
47 return;
48 }
49
50 const EventContext& ctx{Gaudi::Hive::currentContext()};
51 SG::ReadCondHandle<PixelChargeCalibCondData> calibDataHandle(m_chargeDataKey, ctx);
52 const PixelChargeCalibCondData *calibData = *calibDataHandle;
53
54 int overflowToT = 14; //for RD53 (aka ITkPixV2) chip, not FEI4
55
56 // Add cross-talk
57 auto xtalk = m_chipSim.crossTalk();
58 crossTalk(xtalk, chargedDiodes);
59
60 if (m_doNoise) {
61 // Add thermal noise
62 thermalNoise(m_thermalNoise, chargedDiodes, rndmEngine);
63 // Add random noise
64 randomNoise(chargedDiodes, m_chipSim, m_numberOfBcid, calibData, rndmEngine, m_pixelReadout.get());
65 }
66
67 // Add random diabled pixels
68 randomDisable(chargedDiodes, m_chipSim, rndmEngine); // FIXME How should we handle disabling pixels in Overlay jobs?
69
70 for (auto &[mapId,mapDiode]:chargedDiodes) {//cannot be const ref, mapDiode will be altered
71 Identifier diodeID = chargedDiodes.getId(mapId);
72 double charge = mapDiode.charge();
73 unsigned int FE = m_pixelReadout->getFE(diodeID, moduleID);
74 InDetDD::PixelDiodeType type = m_pixelReadout->getDiodeType(diodeID);
76 SiHelper::disabled(mapDiode, true, true);
77 continue;//invalid frontend
78 }
79 // Apply analogue threshold, timing simulation
80 const auto &thresholds = calibData->getThresholds(type, moduleHash, FE);
81 double threshold = PixelDigitization::randomThreshold(thresholds, rndmEngine);
82
83 if (charge > threshold) {
84 int bunchSim = 0;
85 if (mapDiode.totalCharge().fromTrack()) {
86 bunchSim = static_cast<int>(std::floor((getG4Time(mapDiode.totalCharge()) + m_timeOffset) / m_bunchSpace));
87 //Timewalk implementation
88 if(m_doTimeWalk){
89 if(charge < (threshold + m_overDrive)){
90 const int timeWalk = 25; // Here it is assumed that the maximum value of timewalk is one bunch crossing (25ns)
91 bunchSim = static_cast<int>(std::floor((getG4Time(mapDiode.totalCharge()) + m_timeOffset + timeWalk) / m_bunchSpace));
92 }
93 }
94 } else {
95 bunchSim = CLHEP::RandFlat::shootInt(rndmEngine, m_numberOfBcid);
96 }
97
98 if (bunchSim < 0 || bunchSim > m_numberOfBcid) {
99 SiHelper::belowThreshold(mapDiode, true, true);
100 } else {
101 SiHelper::SetBunch(mapDiode, bunchSim);
102 }
103 } else {
104 SiHelper::belowThreshold(mapDiode, true, true);
105 }
106
107 // charge to ToT conversion
108 double tot = calibData->getToT(type, moduleHash, FE, charge);
109 double totsig = calibData->getTotRes(moduleHash, FE, tot);
110 int nToT = generateToT(rndmEngine, tot,totsig, std::make_pair(0,overflowToT));
111 auto thresh = m_chipSim.totThreshold();
112
113 if (nToT <= thresh) {
114 SiHelper::belowThreshold(mapDiode, true, true);
115 }
116
117 // Filter events
118 if (SiHelper::isMaskOut(mapDiode)) {
119 continue;
120 }
121 if (SiHelper::isDisabled(mapDiode)) {
122 continue;
123 }
124
125 if (!m_pixelConditionsTool->isActive(moduleHash, diodeID, ctx)) {
126 SiHelper::disabled(mapDiode, true, true);
127 continue;
128 }
129
130 int flag = mapDiode.flag();
131 int bunch = (flag >> 8) & 0xff;
132
133 InDetDD::SiReadoutCellId cellId = mapDiode.getReadoutCell();
134 const Identifier id_readout = chargedDiodes.element()->identifierFromCellId(cellId);
135
136 // Front-End simulation
137 if (bunch >= 0 && bunch < m_numberOfBcid) {
138 Pixel1RawData* p_rdo = new Pixel1RawData(id_readout, nToT, bunch, 0, bunch);
139 rdoCollection.push_back(p_rdo);
140 p_rdo = nullptr;
141 }
142 }
143}
double charge(const T &p)
Definition AtlasPID.h:997
value_type push_back(value_type pElem)
SG::ReadCondHandleKey< PixelChargeCalibCondData > m_chargeDataKey
ServiceHandle< InDetDD::IPixelReadoutManager > m_pixelReadout
static constexpr double m_bunchSpace
ToolHandle< IInDetConditionsTool > m_pixelConditionsTool
Gaudi::Property< bool > m_doNoise
Gaudi::Property< int > m_BarrelEC
virtual Identifier identify() const override final
identifier of this detector element (inline)
PixelChargeCalib::Thresholds getThresholds(InDetDD::PixelDiodeType type, unsigned int moduleHash, unsigned int FE) const
float getToT(InDetDD::PixelDiodeType type, unsigned int moduleHash, unsigned int FE, float Q) const
float getTotRes(unsigned int moduleHash, unsigned int FE, float Q) const
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition PixelID.h:360
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition PixelID.h:600
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition PixelID.h:383
Gaudi::Property< bool > m_doTimeWalk
Definition RD53SimTool.h:40
ITkPixSimulationParameters m_chipSim
Definition RD53SimTool.h:37
Gaudi::Property< int > m_overDrive
Definition RD53SimTool.h:43
virtual Identifier identify() const override final
const InDetDD::SolidStateDetectorElementBase * element() const
static bool isMaskOut(SiChargedDiode &chDiode)
Definition SiHelper.h:171
static void SetBunch(SiChargedDiode &chDiode, int bunch, MsgStream *log=nullptr)
Definition SiHelper.h:129
static void disabled(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition SiHelper.h:93
static void belowThreshold(SiChargedDiode &chDiode, bool flag, bool mask=false)
Definition SiHelper.h:84
static bool isDisabled(SiChargedDiode &chDiode)
Definition SiHelper.h:179
constexpr uint32_t invalidFrontEnd
const T * getIdHelper(StoreGateSvc *pDetStore, const std::string &helperName)
void randomDisable(SiChargedDiodeCollection &chargedDiodes, const PixelModuleData *moduleData, CLHEP::HepRandomEngine *rndmEngine)
void crossTalk(double crossTalk, SiChargedDiodeCollection &chargedDiodes)
void thermalNoise(double thermalNoise, SiChargedDiodeCollection &chargedDiodes, CLHEP::HepRandomEngine *rndmEngine)
double randomThreshold(const PixelChargeCalib::Thresholds &t, CLHEP::HepRandomEngine *pEngine)
void randomNoise(SiChargedDiodeCollection &chargedDiodes, const PixelModuleData *moduleData, int nBcid, const PixelChargeCalibCondData *chargeCalibData, CLHEP::HepRandomEngine *rndmEngine, InDetDD::IPixelReadoutManager *pixelReadout)
int generateToT(CLHEP::HepRandomEngine *rndmEngine, double mean, double sd, const std::pair< int, int > &range)
double getG4Time(const SiTotalCharge &totalCharge)
bool flag
Definition master.py:29

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_BarrelEC

Gaudi::Property<int> FrontEndSimTool::m_BarrelEC
protectedinherited
Initial value:
{
this, "BarrelEC", 0, "Index of barrel or endcap"
}

Definition at line 68 of file FrontEndSimTool.h.

68 {
69 this, "BarrelEC", 0, "Index of barrel or endcap"
70 };

◆ m_bunchSpace

double FrontEndSimTool::m_bunchSpace {25.0}
staticconstexprprotectedinherited

Definition at line 50 of file FrontEndSimTool.h.

50{25.0};

◆ m_chargeDataKey

SG::ReadCondHandleKey<PixelChargeCalibCondData> FrontEndSimTool::m_chargeDataKey
protectedinherited
Initial value:
{
this, "PixelChargeCalibCondData", "PixelChargeCalibCondData", "Pixel charge calibration data"
}

Definition at line 64 of file FrontEndSimTool.h.

64 {
65 this, "PixelChargeCalibCondData", "PixelChargeCalibCondData", "Pixel charge calibration data"
66 };

◆ m_chipSim

ITkPixSimulationParameters RD53SimTool::m_chipSim {}
private

Definition at line 37 of file RD53SimTool.h.

37{};

◆ m_cosmics

Gaudi::Property<bool> FrontEndSimTool::m_cosmics
protectedinherited
Initial value:
{
this, "Cosmics", false, "Is this for Cosmics simulation?"
}

Definition at line 76 of file FrontEndSimTool.h.

76 {
77 this, "Cosmics", false, "Is this for Cosmics simulation?"
78 };

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doNoise

Gaudi::Property<bool> FrontEndSimTool::m_doNoise
protectedinherited
Initial value:
{
this, "DoNoise", true, "Flag of noise simulation"
}

Definition at line 72 of file FrontEndSimTool.h.

72 {
73 this, "DoNoise", true, "Flag of noise simulation"
74 };

◆ m_doTimeWalk

Gaudi::Property<bool> RD53SimTool::m_doTimeWalk
private
Initial value:
{
this, "DoTimeWalk",false,"include time-walk effects"
}

Definition at line 40 of file RD53SimTool.h.

40 {
41 this, "DoTimeWalk",false,"include time-walk effects"
42 };

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_numberOfBcid

int FrontEndSimTool::m_numberOfBcid {1}
protectedinherited

Definition at line 51 of file FrontEndSimTool.h.

51{1}; //assumed same for all positions

◆ m_overDrive

Gaudi::Property<int> RD53SimTool::m_overDrive
private
Initial value:
{
this, "OverDrive",150,"value of overdrive (in-time threshold - absolute threshold) in electrons"
}

Definition at line 43 of file RD53SimTool.h.

43 {
44 this, "OverDrive",150,"value of overdrive (in-time threshold - absolute threshold) in electrons"
45 };

◆ m_pixelConditionsTool

ToolHandle<IInDetConditionsTool> FrontEndSimTool::m_pixelConditionsTool
protectedinherited
Initial value:
{
this, "PixelConditionsSummaryTool", "PixelConditionsSummaryTool", "Tool to retrieve Pixel Conditions summary"
}

Definition at line 55 of file FrontEndSimTool.h.

55 {
56 this, "PixelConditionsSummaryTool", "PixelConditionsSummaryTool", "Tool to retrieve Pixel Conditions summary"
57 };

◆ m_pixelReadout

ServiceHandle<InDetDD::IPixelReadoutManager> FrontEndSimTool::m_pixelReadout
protectedinherited
Initial value:
{
this, "PixelReadoutManager", "PixelReadoutManager", "Pixel readout manager"
}

Definition at line 59 of file FrontEndSimTool.h.

59 {
60 this, "PixelReadoutManager", "PixelReadoutManager", "Pixel readout manager"
61 };

◆ m_thermalNoise

double FrontEndSimTool::m_thermalNoise {160.0}
protectedinherited

Definition at line 54 of file FrontEndSimTool.h.

54{160.0}; //default noise level

◆ m_timeJitter

double FrontEndSimTool::m_timeJitter {0.0}
protectedinherited

Definition at line 53 of file FrontEndSimTool.h.

53{0.0};

◆ m_timeOffset

double FrontEndSimTool::m_timeOffset {5.0}
protectedinherited

Definition at line 52 of file FrontEndSimTool.h.

52{5.0};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: