ATLAS Offline Software
Loading...
Searching...
No Matches
MuonSimHit_V1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM include(s):
8
10
11namespace {
12 static const std::string preFixStr{"MuSim_"};
13 static const SG::Accessor<Identifier::value_type> acc_Identifier{preFixStr+"identifier"};
14 static const xAOD::PosAccessor<3> acc_localPos{"localPositionDim3"};
15 static const xAOD::PosAccessor<3> acc_localDir{"localDirectionDim3"};
16
17 static const SG::Accessor<unsigned short> acc_mcEventIndex{preFixStr+"mcEventIndex"};
18 static const SG::Accessor<unsigned int> acc_uniqueID{preFixStr+"uniqueID"};
19}
20
21#define IMPLEMENT_SETTER_GETTER( DTYPE, GETTER, SETTER) \
22 DTYPE MuonSimHit_v1::GETTER() const { \
23 static const SG::Accessor<DTYPE> acc{preFixStr + #GETTER}; \
24 return acc(*this); \
25 } \
26 \
27 void MuonSimHit_v1::SETTER(DTYPE value) { \
28 static const SG::Accessor<DTYPE> acc{preFixStr + #GETTER}; \
29 acc(*this) = value; \
30 }
31
32namespace xAOD {
33
35 if (this != &other) {
36 static_cast<SG::AuxElement&>(*this) = other;
37#ifndef __CLING__
39#endif
40 }
41 return (*this);
42}
43Identifier MuonSimHit_v1::identify() const { return Identifier{acc_Identifier(*this)}; }
44void MuonSimHit_v1::setIdentifier(const Identifier& id) { acc_Identifier(*this) = id.get_compact(); }
45
46IMPLEMENT_SETTER_GETTER(float, globalTime, setGlobalTime)
47IMPLEMENT_SETTER_GETTER(int, pdgId, setPdgId)
48IMPLEMENT_SETTER_GETTER(float, energyDeposit, setEnergyDeposit)
49IMPLEMENT_SETTER_GETTER(float, kineticEnergy, setKineticEnergy)
50IMPLEMENT_SETTER_GETTER(float, mass, setMass)
51IMPLEMENT_SETTER_GETTER(float, stepLength, setStepLength)
52
54 const float e = kineticEnergy();
55 return std::sqrt(1. - std::min(std::pow(mass() / (e > std::numeric_limits<float>::epsilon() ? e : 1.f), 2),1.));
56}
58 VectorMap<3> lPos{acc_localPos(*this).data()};
59 lPos = std::move(vec);
60}
61ConstVectorMap<3> MuonSimHit_v1::localPosition() const { return ConstVectorMap<3>{acc_localPos(*this).data()};}
62
64 VectorMap<3> lPos{acc_localDir(*this).data()};
65 lPos = std::move(vec);
66}
67ConstVectorMap<3> MuonSimHit_v1::localDirection() const { return ConstVectorMap<3>{acc_localDir(*this).data()};}
68
70 if (!m_hepMCLink) {
71 auto link = std::make_unique<HepMcParticleLink>(acc_uniqueID(*this),
72 acc_mcEventIndex(*this),
75 return *m_hepMCLink.set(std::move(link));
76 }
77 return (*m_hepMCLink);
78}
81 acc_mcEventIndex(*this) = link.getEventPositionInCollection(Gaudi::Hive::currentContext());
82 acc_uniqueID(*this) = link.id();
83}
84
85std::unique_ptr<const HepMcParticleLink> MuonSimHit_v1::releaseParticleLink() {
86 return m_hepMCLink.release();
87}
88
89}
90#undef IMPLEMENT_SETTER_GETTER
std::vector< size_t > vec
#define IMPLEMENT_SETTER_GETTER(DTYPE, GETTER, SETTER)
Helper class to provide type-safe access to aux data.
void setGenParticleLink(const HepMcParticleLink &link)
Sets the link to the HepMC particle producing this hit.
CxxUtils::CachedUniquePtr< HepMcParticleLink > m_hepMCLink
void setLocalDirection(MeasVector< 3 > vec)
Sets the local direction of the traversing particle.
ConstVectorMap< 3 > localDirection() const
Returns the local direction of the traversing particle.
float beta() const
returns beta (fraction of speed of light)
void setIdentifier(const Identifier &id)
Sets the global ATLAS identifier.
float mass() const
Returns the rest-mass of the traversing particle.
Identifier identify() const
Returns the global ATLAS identifier of the SimHit.
ConstVectorMap< 3 > localPosition() const
Returns the local postion of the traversing particle.
const HepMcParticleLink & genParticleLink() const
Returns the link to the HepMC particle producing this hit.
MuonSimHit_v1 & operator=(const MuonSimHit_v1 &other)
void setLocalPosition(MeasVector< 3 > vec)
Sets the local position of the traversing particle.
std::unique_ptr< const HepMcParticleLink > releaseParticleLink()
Return the pointer to the HepMC particle link and resets the cache.
MuonSimHit_v1()=default
float kineticEnergy() const
Returns the kinetic energy of the traversing particle.
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
Eigen::Map< MeasVector< N > > VectorMap
SG::Accessor< std::array< float, N > > PosAccessor
xAOD Accessor to the position
Eigen::Map< const MeasVector< N > > ConstVectorMap