ATLAS Offline Software
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 
10 namespace {
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 
31 namespace 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 }
42 Identifier MuonSimHit_v1::identify() const { return Identifier{acc_Identifier(*this)}; }
43 void MuonSimHit_v1::setIdentifier(const Identifier& id) { acc_Identifier(*this) = id.get_compact(); }
44 
45 IMPLEMENT_SETTER_GETTER(float, globalTime, setGlobalTime)
46 IMPLEMENT_SETTER_GETTER(int, pdgId, setPdgId)
47 IMPLEMENT_SETTER_GETTER(float, energyDeposit, setEnergyDeposit)
48 IMPLEMENT_SETTER_GETTER(float, kineticEnergy, setKineticEnergy)
49 IMPLEMENT_SETTER_GETTER(float, mass, setMass)
50 IMPLEMENT_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 }
60 ConstVectorMap<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 }
66 ConstVectorMap<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
xAOD::MuonSimHit_v1
Definition: MuonSimHit_v1.h:18
xAOD::MuonSimHit_v1::setIdentifier
void setIdentifier(const Identifier &id)
Sets the global ATLAS identifier.
Definition: xAODMuonSimHit_V1.cxx:43
xAOD::MuonSimHit_v1::identify
Identifier identify() const
Returns the global ATLAS identifier of the SimHit.
Definition: xAODMuonSimHit_V1.cxx:42
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
AuxStoreAccessorMacros.h
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:483
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
xAOD::other
@ other
Definition: TrackingPrimitives.h:510
xAOD::MuonSimHit_v1::m_hepMCLink
CxxUtils::CachedUniquePtr< HepMcParticleLink > m_hepMCLink
Definition: MuonSimHit_v1.h:76
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
xAOD::MuonSimHit_v1::setLocalPosition
void setLocalPosition(MeasVector< 3 > vec)
Sets the local position of the traversing particle.
Definition: xAODMuonSimHit_V1.cxx:56
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:9
IMPLEMENT_SETTER_GETTER
#define IMPLEMENT_SETTER_GETTER(DTYPE, GETTER, SETTER)
Definition: xAODMuonSimHit_V1.cxx:20
xAOD::MuonSimHit_v1::setGenParticleLink
void setGenParticleLink(const HepMcParticleLink &link)
Sets the link to the HepMC particle producing this hit.
Definition: xAODMuonSimHit_V1.cxx:78
Trk::energyDeposit
@ energyDeposit
Definition: MeasurementType.h:32
xAOD::MuonSimHit_v1::operator=
MuonSimHit_v1 & operator=(const MuonSimHit_v1 &other)
Definition: xAODMuonSimHit_V1.cxx:33
xAOD::MuonSimHit_v1::genParticleLink
const HepMcParticleLink & genParticleLink() const
Returns the link to the HepMC particle producing this hit.
Definition: xAODMuonSimHit_V1.cxx:68
xAOD::float
float
Definition: BTagging_v1.cxx:168
xAOD::e
setPy e
Definition: CompositeParticle_v1.cxx:166
xAOD::MuonSimHit_v1::localDirection
ConstVectorMap< 3 > localDirection() const
Returns the local direction of the traversing particle.
Definition: xAODMuonSimHit_V1.cxx:66
hist_file_dump.f
f
Definition: hist_file_dump.py:141
xAOD::MeasVector
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
Definition: MeasurementDefs.h:53
xAOD::MuonSimHit_v1::setLocalDirection
void setLocalDirection(MeasVector< 3 > vec)
Sets the local direction of the traversing particle.
Definition: xAODMuonSimHit_V1.cxx:62
runIDPVM.pdgId
pdgId
Definition: runIDPVM.py:90
xAOD::VectorMap
Eigen::Map< MeasVector< N > > VectorMap
Definition: MeasurementDefs.h:58
xAOD::MuonSimHit_v1::localPosition
ConstVectorMap< 3 > localPosition() const
Returns the local postion of the traversing particle.
Definition: xAODMuonSimHit_V1.cxx:60
MuonSimHit_v1.h
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
xAOD::ConstVectorMap
Eigen::Map< const MeasVector< N > > ConstVectorMap
Definition: MeasurementDefs.h:60
Identifier
Definition: IdentifierFieldParser.cxx:14