20 std::stringstream sstr{};
23 <<
", pT: "<<acc_pt(segment);
25 sstr<<
", hits: "<<hitSet.size()<<std::endl;
26 std::vector<const xAOD::MuonSimHit*> hits{hitSet.begin(), hitSet.end()};
27 std::ranges::sort(hits, [](
const auto*
a,
const auto* b){
return a->identify() < b->identify(); });
29 sstr<<
" --- "<<idHelperSvc->toString(hit->identify())<<
", pdgId:"<<hit->pdgId()
30 <<
", e: "<<hit->kineticEnergy()<<
", link: "<<hit->genParticleLink()<<std::endl;
34 inline std::string
print(
const std::vector<const xAOD::MuonSegment*>& segments) {
35 std::stringstream sstr{};
37 sstr<<
" **** "<<
print(*seg)<<std::endl;
48 return StatusCode::SUCCESS;
58 std::map<int, std::vector<const xAOD::MuonSegment*>> bkgParticles{};
63 ATH_MSG_VERBOSE(__func__<<
"() "<<__LINE__<<
" - Try to associate other truth segments to "<<
65 if (truth ==
nullptr) {
68 const int trackId = (*simHits.begin())->genParticleLink().id();
69 ATH_MSG_VERBOSE(__func__<<
"() "<<__LINE__<<
" - No associated truth particle found. Rely on track id:"<<trackId);
70 bkgParticles[trackId].push_back(segment);
73 ATH_MSG_VERBOSE(__func__<<
"() "<<__LINE__<<
" - Found truth particle with "<<truth->
pt()<<
", eta: "<<truth->
eta()
74 <<
", phi: "<<truth->
phi()<<
", charge: "<<truth->
charge());
76 if(matched == segment) {
79 ATH_CHECK(matched->container() == segments);
80 links.emplace_back(*segments, matched->index());
85 for (
const auto& [trackId, assocSegs] : bkgParticles){
87 <<assocSegs.size()<<
" segments\n"<<
print(assocSegs));
91 if (matched == segment) {
94 ATH_CHECK(matched->container() == segments);
95 links.emplace_back(*segments, matched->index());
100 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Handle class for adding a decoration to an object.
void print(char *figname, TCanvas *c1)
ElementLink< xAOD::MuonSegmentContainer > SegLink_t
std::vector< SegLink_t > SegLinkVec_t
ElementLink implementation for ROOT usage.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segmentKey
Declare the input truth segment key.
virtual StatusCode execute(const EventContext &ctx) const override final
SG::ReadDecorHandleKey< xAOD::MuonSegmentContainer > m_truthPartLinkKey
Declare the dependency on the truth particle link.
virtual StatusCode initialize() override final
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_connectKey
Declare the decoration written by the algorithm.
Helper class to provide constant type-safe access to aux data.
Handle class for adding a decoration to an object.
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
int etaIndex() const
Returns the eta index, which corresponds to stationEta in the offline identifiers (and the ).
virtual double pt() const override final
The transverse momentum ( ) of the particle.
double charge() const
Physical charge.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
This header ties the generic definitions in this package.
const xAOD::TruthParticle * getTruthMatchedParticle(const xAOD::MuonSegment &segment)
Returns the particle truth-matched to the segment.
std::unordered_set< const xAOD::MuonSimHit * > getMatchingSimHits(const xAOD::MuonSegment &segment)
: Returns all sim hits matched to a xAOD::MuonSegment
std::vector< const xAOD::MuonSegment * > getTruthSegments(const xAOD::TruthParticle &truthMuon)
Returns the segments associated to the truth muon.
std::vector< SegLink_t > SegLinkVec_t
std::string print(const cont_t &container)
Print a space point container to string.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
TruthParticle_v1 TruthParticle
Typedef to implementation.
MuonSegment_v1 MuonSegment
Reference the current persistent version: