ATLAS Offline Software
xAODMuonSimHit_V1.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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_mcBarcode{preFixStr+"mcBarcode"};
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 
52  const float e = kineticEnergy();
53  return std::sqrt(1. - std::min(std::pow(mass() / (e > std::numeric_limits<float>::epsilon() ? e : 1.f), 2),1.));
54 }
56  VectorMap<3> lPos{acc_localPos(*this).data()};
57  lPos = vec;
58 }
59 ConstVectorMap<3> MuonSimHit_v1::localPosition() const { return ConstVectorMap<3>{acc_localPos(*this).data()};}
60 
62  VectorMap<3> lPos{acc_localDir(*this).data()};
63  lPos = vec;
64 }
65 ConstVectorMap<3> MuonSimHit_v1::localDirection() const { return ConstVectorMap<3>{acc_localDir(*this).data()};}
66 
68  if (!m_hepMCLink) {
69  const unsigned short eventIndex = acc_mcEventIndex(*this);
72  std::unique_ptr<HepMcParticleLink> link = std::make_unique<HepMcParticleLink>();
73 
74  HepMcParticleLink::ExtendedBarCode barcode {acc_mcBarcode(*this),
75  eventIndex,
76  flag, HepMcParticleLink::IS_BARCODE}; // FIXME barcode-based
77  link->setExtendedBarCode(std::move(barcode));
78  return *m_hepMCLink.set(std::move(link));
79  }
80  return (*m_hepMCLink);
81 }
83  m_hepMCLink.release();
84  acc_mcEventIndex(*this) = link.eventIndex();
85  acc_mcBarcode(*this) = link.barcode();
86 }
87 
88 }
89 #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
xAOD::float
float
Definition: BTagging_v1.cxx:168
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:509
xAOD::MuonSimHit_v1::m_hepMCLink
CxxUtils::CachedUniquePtr< HepMcParticleLink > m_hepMCLink
Definition: MuonSimHit_v1.h:84
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:55
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
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:82
Trk::energyDeposit
@ energyDeposit
Definition: MeasurementType.h:32
xAOD::MuonSimHit_v1::operator=
MuonSimHit_v1 & operator=(const MuonSimHit_v1 &other)
Definition: xAODMuonSimHit_V1.cxx:33
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
xAOD::MuonSimHit_v1::genParticleLink
const HepMcParticleLink & genParticleLink() const
Returns the link to the HepMC particle producing this hit.
Definition: xAODMuonSimHit_V1.cxx:67
xAOD::e
setPy e
Definition: CompositeParticle_v1.cxx:166
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
master.flag
bool flag
Definition: master.py:29
xAOD::MuonSimHit_v1::localDirection
ConstVectorMap< 3 > localDirection() const
Returns the local direction of the traversing particle.
Definition: xAODMuonSimHit_V1.cxx:65
hist_file_dump.f
f
Definition: hist_file_dump.py:135
xAOD::MeasVector
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
Definition: MeasurementDefs.h:52
xAOD::MuonSimHit_v1::setLocalDirection
void setLocalDirection(MeasVector< 3 > vec)
Sets the local direction of the traversing particle.
Definition: xAODMuonSimHit_V1.cxx:61
xAOD::VectorMap
Eigen::Map< MeasVector< N > > VectorMap
Definition: MeasurementDefs.h:57
xAOD::MuonSimHit_v1::localPosition
ConstVectorMap< 3 > localPosition() const
Returns the local postion of the traversing particle.
Definition: xAODMuonSimHit_V1.cxx:59
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:59
Identifier
Definition: IdentifierFieldParser.cxx:14
EventInfoCnvParams::eventIndex
thread_local event_number_t eventIndex
Definition: IEvtIdModifierSvc.h:34