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 () override
virtual void process (const EventContext &ctx, SiChargedDiodeCollection &chargedDiodes, PixelRDO_Collection &rdoCollection, CLHEP::HepRandomEngine *rndmEngine) const override
 AthAlgTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters:
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

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() [2/2]

RD53SimTool::RD53SimTool ( )
private

Member Function Documentation

◆ AthAlgTool()

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

Constructor with parameters:

Definition at line 31 of file AthAlgTool.cxx.

◆ 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

◆ initialize()

StatusCode RD53SimTool::initialize ( )
overridevirtual

Reimplemented from FrontEndSimTool.

Definition at line 26 of file RD53SimTool.cxx.

26 {
28 ATH_MSG_DEBUG("RD53SimTool::initialize()");
29 return StatusCode::SUCCESS;
30}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
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.

◆ 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 ( const EventContext & ctx,
SiChargedDiodeCollection & chargedDiodes,
PixelRDO_Collection & rdoCollection,
CLHEP::HepRandomEngine * rndmEngine ) const
overridevirtual

Implements FrontEndSimTool.

Definition at line 32 of file RD53SimTool.cxx.

34 {
35 const PixelID* pixelId = static_cast<const PixelID*>(chargedDiodes.element()->getIdHelper());
36 const IdentifierHash moduleHash = pixelId->wafer_hash(chargedDiodes.identify()); // wafer hash
37 Identifier moduleID = pixelId->wafer_id(chargedDiodes.element()->identify());
38
39 int barrel_ec = pixelId->barrel_ec(chargedDiodes.element()->identify());
40 if (std::abs(barrel_ec) != m_BarrelEC) {
41 return;
42 }
43
44 SG::ReadCondHandle<PixelChargeCalibCondData> calibDataHandle(m_chargeDataKey, ctx);
45 const PixelChargeCalibCondData *calibData = *calibDataHandle;
46
47 int overflowToT = 14; //for RD53 (aka ITkPixV2) chip, not FEI4
48
49 // Add cross-talk
50 auto xtalk = m_chipSim.crossTalk();
51 crossTalk(xtalk, chargedDiodes);
52
53 if (m_doNoise) {
54 // Add thermal noise
55 thermalNoise(m_thermalNoise, chargedDiodes, rndmEngine);
56 // Add random noise
57 randomNoise(chargedDiodes, m_chipSim, m_numberOfBcid, calibData, rndmEngine, m_pixelReadout.get());
58 }
59
60 // Add random diabled pixels
61 randomDisable(chargedDiodes, m_chipSim, rndmEngine); // FIXME How should we handle disabling pixels in Overlay jobs?
62
63 for (auto &[mapId,mapDiode]:chargedDiodes) {//cannot be const ref, mapDiode will be altered
64 Identifier diodeID = chargedDiodes.getId(mapId);
65 double charge = mapDiode.charge();
66 unsigned int FE = m_pixelReadout->getFE(diodeID, moduleID);
67 InDetDD::PixelDiodeType type = m_pixelReadout->getDiodeType(diodeID);
69 SiHelper::disabled(mapDiode, true, true);
70 continue;//invalid frontend
71 }
72 // Apply analogue threshold, timing simulation
73 const auto &thresholds = calibData->getThresholds(type, moduleHash, FE);
74 double threshold = PixelDigitization::randomThreshold(thresholds, rndmEngine);
75
76 if (charge > threshold) {
77 int bunchSim = 0;
78 if (mapDiode.totalCharge().fromTrack()) {
79 bunchSim = static_cast<int>(std::floor((getG4Time(mapDiode.totalCharge()) + m_timeOffset) / m_bunchSpace));
80 //Timewalk implementation
81 if(m_doTimeWalk){
82 if(charge < (threshold + m_overDrive)){
83 const int timeWalk = 25; // Here it is assumed that the maximum value of timewalk is one bunch crossing (25ns)
84 bunchSim = static_cast<int>(std::floor((getG4Time(mapDiode.totalCharge()) + m_timeOffset + timeWalk) / m_bunchSpace));
85 }
86 }
87 } else {
88 bunchSim = CLHEP::RandFlat::shootInt(rndmEngine, m_numberOfBcid);
89 }
90
91 if (bunchSim < 0 || bunchSim > m_numberOfBcid) {
92 SiHelper::belowThreshold(mapDiode, true, true);
93 } else {
94 SiHelper::SetBunch(mapDiode, bunchSim);
95 }
96 } else {
97 SiHelper::belowThreshold(mapDiode, true, true);
98 }
99
100 // charge to ToT conversion
101 double tot = calibData->getToT(type, moduleHash, FE, charge);
102 double totsig = calibData->getTotRes(moduleHash, FE, tot);
103 int nToT = generateToT(rndmEngine, tot,totsig, std::make_pair(0,overflowToT));
104 auto thresh = m_chipSim.totThreshold();
105
106 if (nToT <= thresh) {
107 SiHelper::belowThreshold(mapDiode, true, true);
108 }
109
110 // Filter events
111 if (SiHelper::isMaskOut(mapDiode)) {
112 continue;
113 }
114 if (SiHelper::isDisabled(mapDiode)) {
115 continue;
116 }
117
118 if (!m_pixelConditionsTool->isActive(moduleHash, diodeID, ctx)) {
119 SiHelper::disabled(mapDiode, true, true);
120 continue;
121 }
122
123 int flag = mapDiode.flag();
124 int bunch = (flag >> 8) & 0xff;
125
126 InDetDD::SiReadoutCellId cellId = mapDiode.getReadoutCell();
127 const Identifier id_readout = chargedDiodes.element()->identifierFromCellId(cellId);
128
129 // Front-End simulation
130 if (bunch >= 0 && bunch < m_numberOfBcid) {
131 Pixel1RawData* p_rdo = new Pixel1RawData(id_readout, nToT, bunch, 0, bunch);
132 rdoCollection.push_back(p_rdo);
133 p_rdo = nullptr;
134 }
135 }
136}
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:355
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0).
Definition PixelID.h:595
IdentifierHash wafer_hash(Identifier wafer_id) const
wafer hash from id
Definition PixelID.h:378
Gaudi::Property< bool > m_doTimeWalk
Definition RD53SimTool.h:39
ITkPixSimulationParameters m_chipSim
Definition RD53SimTool.h:36
Gaudi::Property< int > m_overDrive
Definition RD53SimTool.h:42
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 >, and AthCheckedComponent<::AthAlgTool >.

◆ 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 57 of file FrontEndSimTool.h.

57 {
58 this, "BarrelEC", 0, "Index of barrel or endcap"
59 };

◆ m_bunchSpace

double FrontEndSimTool::m_bunchSpace {25.0}
staticconstexprprotectedinherited

Definition at line 39 of file FrontEndSimTool.h.

39{25.0};

◆ m_chargeDataKey

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

Definition at line 53 of file FrontEndSimTool.h.

53 {
54 this, "PixelChargeCalibCondData", "PixelChargeCalibCondData", "Pixel charge calibration data"
55 };

◆ m_chipSim

ITkPixSimulationParameters RD53SimTool::m_chipSim {}
private

Definition at line 36 of file RD53SimTool.h.

36{};

◆ m_cosmics

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

Definition at line 65 of file FrontEndSimTool.h.

65 {
66 this, "Cosmics", false, "Is this for Cosmics simulation?"
67 };

◆ 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 61 of file FrontEndSimTool.h.

61 {
62 this, "DoNoise", true, "Flag of noise simulation"
63 };

◆ m_doTimeWalk

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

Definition at line 39 of file RD53SimTool.h.

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

◆ 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 40 of file FrontEndSimTool.h.

40{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 42 of file RD53SimTool.h.

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

◆ m_pixelConditionsTool

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

Definition at line 44 of file FrontEndSimTool.h.

44 {
45 this, "PixelConditionsSummaryTool", "PixelConditionsSummaryTool", "Tool to retrieve Pixel Conditions summary"
46 };

◆ m_pixelReadout

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

Definition at line 48 of file FrontEndSimTool.h.

48 {
49 this, "PixelReadoutManager", "PixelReadoutManager", "Pixel readout manager"
50 };

◆ m_thermalNoise

double FrontEndSimTool::m_thermalNoise {160.0}
protectedinherited

Definition at line 43 of file FrontEndSimTool.h.

43{160.0}; //default noise level

◆ m_timeJitter

double FrontEndSimTool::m_timeJitter {0.0}
protectedinherited

Definition at line 42 of file FrontEndSimTool.h.

42{0.0};

◆ m_timeOffset

double FrontEndSimTool::m_timeOffset {5.0}
protectedinherited

Definition at line 41 of file FrontEndSimTool.h.

41{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: