ATLAS Offline Software
Loading...
Searching...
No Matches
xAODMuonSimHit_V1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM include(s):
7
9
10namespace {
11 static const std::string preFixStr{"MuSim_"};
12 static const SG::AuxElement::Accessor<Identifier::value_type> acc_Identifier{preFixStr+"identifier"};
13 static const xAOD::PosAccessor<3> acc_localPos{"localPositionDim3"};
14 static const xAOD::PosAccessor<3> acc_localDir{"localDirectionDim3"};
15
16 static const SG::AuxElement::Accessor<unsigned short> acc_mcEventIndex{preFixStr+"mcEventIndex"};
17 static const SG::AuxElement::Accessor<unsigned int> acc_uniqueID{preFixStr+"uniqueID"};
18}
19
20#define IMPLEMENT_SETTER_GETTER( DTYPE, GETTER, SETTER) \
21 DTYPE MuonSimHit_v1::GETTER() const { \
22 static const SG::AuxElement::Accessor<DTYPE> acc{preFixStr + #GETTER}; \
23 return acc(*this); \
24 } \
25 \
26 void MuonSimHit_v1::SETTER(DTYPE value) { \
27 static const SG::AuxElement::Accessor<DTYPE> acc{preFixStr + #GETTER}; \
28 acc(*this) = value; \
29 }
30
31namespace xAOD {
32
34 if (this != &other) {
35 static_cast<SG::AuxElement&>(*this) = other;
36#ifndef __CLING__
37 m_hepMCLink.release();
38#endif
39 }
40 return (*this);
41}
42Identifier MuonSimHit_v1::identify() const { return Identifier{acc_Identifier(*this)}; }
43void MuonSimHit_v1::setIdentifier(const Identifier& id) { acc_Identifier(*this) = id.get_compact(); }
44
45IMPLEMENT_SETTER_GETTER(float, globalTime, setGlobalTime)
46IMPLEMENT_SETTER_GETTER(int, pdgId, setPdgId)
47IMPLEMENT_SETTER_GETTER(float, energyDeposit, setEnergyDeposit)
48IMPLEMENT_SETTER_GETTER(float, kineticEnergy, setKineticEnergy)
49IMPLEMENT_SETTER_GETTER(float, mass, setMass)
50IMPLEMENT_SETTER_GETTER(float, stepLength, setStepLength)
51
53 const float e = kineticEnergy();
54 return std::sqrt(1. - std::min(std::pow(mass() / (e > std::numeric_limits<float>::epsilon() ? e : 1.f), 2),1.));
55}
57 VectorMap<3> lPos{acc_localPos(*this).data()};
58 lPos = std::move(vec);
59}
60ConstVectorMap<3> MuonSimHit_v1::localPosition() const { return ConstVectorMap<3>{acc_localPos(*this).data()};}
61
63 VectorMap<3> lPos{acc_localDir(*this).data()};
64 lPos = std::move(vec);
65}
66ConstVectorMap<3> MuonSimHit_v1::localDirection() const { return ConstVectorMap<3>{acc_localDir(*this).data()};}
67
69 if (!m_hepMCLink) {
70 auto link = std::make_unique<HepMcParticleLink>(acc_uniqueID(*this),
71 acc_mcEventIndex(*this),
74 return *m_hepMCLink.set(std::move(link));
75 }
76 return (*m_hepMCLink);
77}
79 m_hepMCLink.release();
80 acc_mcEventIndex(*this) = link.eventIndex();
81 acc_uniqueID(*this) = link.id();
82}
83
84}
85#undef IMPLEMENT_SETTER_GETTER
std::vector< size_t > vec
#define IMPLEMENT_SETTER_GETTER(DTYPE, GETTER, SETTER)
Base class for elements of a container that can have aux data.
Definition AuxElement.h:483
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
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.
MuonSimHit_v1()=default
float kineticEnergy() const
Returns the kinetic energy of the traversing particle.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
SG::AuxElement::Accessor< std::array< float, N > > PosAccessor
xAOD Accessor to the position
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
Eigen::Map< MeasVector< N > > VectorMap
Eigen::Map< const MeasVector< N > > ConstVectorMap