11#include <GaudiKernel/SystemOfUnits.h>
13 constexpr double tolerance = 1. * Gaudi::Units::micrometer;
18 ATH_MSG_FATAL(
"Please provide at least one container to sort");
19 return StatusCode::FAILURE;
24 return StatusCode::SUCCESS;
32 std::ranges::copy(*hits, std::back_inserter(allSimHits));
37 const IdentifierHash hashA = m_idHelperSvc->detElementHash(a->identify());
38 const IdentifierHash hashB = m_idHelperSvc->detElementHash(a->identify());
43 if (
a->identify() != b->identify()) {
44 return a->identify() < b->identify();
47 const float dT =
a->globalTime() - b->globalTime();
48 if (std::abs(dT) > 0.1 * Gaudi::Units::picosecond) {
52 if (std::abs(
a->pdgId()) != std::abs(b->pdgId())){
53 return a->pdgId() > b->pdgId();
57 return a->genParticleLink().barcode() < b->genParticleLink().barcode();
59 if (m_removeDuplicates) {
60 std::vector<const xAOD::MuonSimHit*> dupFreeHits{};
61 dupFreeHits.reserve(allSimHits.size());
62 std::ranges::copy_if(allSimHits, std::back_inserter(dupFreeHits),
69 <<
", barcode: "<<barcode
71 return std::ranges::find_if(dupFreeHits,
75 if (barcode)
return true;
79 }) == dupFreeHits.end();
82 std::ranges::copy(dupFreeHits, std::back_inserter(allSimHits));
85 if (m_writeDeepCopy) {
86 ATH_CHECK(writeHandle.
record(std::make_unique<xAOD::MuonSimHitContainer>(),
87 std::make_unique<xAOD::MuonSimHitAuxContainer>()));
89 xAOD::MuonSimHit* newHit = writeHandle->push_back(std::make_unique<xAOD::MuonSimHit>());
90 (*newHit) = (*copy_me);
93 ATH_CHECK(writeHandle.
record(std::make_unique<xAOD::MuonSimHitContainer>(*allSimHits.asDataVector())));
95 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
DataVector adapter that acts like it holds const pointers.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
DataVector adapter that acts like it holds const pointers.
iterator begin() noexcept
Return an iterator pointing at the beginning of the collection.
iterator end() noexcept
Return an iterator pointing past the end of the collection.
int barcode() const
Return the barcode of the target particle.
SG::ReadHandleKeyArray< xAOD::MuonSimHitContainer > m_readKeys
StatusCode execute(const EventContext &ctx) const override
SG::WriteHandleKey< xAOD::MuonSimHitContainer > m_writeKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
StatusCode initialize() override
Property holding a SG store/key/clid from which a ReadHandle is made.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ConstVectorMap< 3 > localDirection() const
Returns the local direction of the traversing particle.
int pdgId() const
Returns the pdgID 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.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 3, 1 > Vector3D
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
MuonSimHitContainer_v1 MuonSimHitContainer
Define the version of the pixel cluster container.