ATLAS Offline Software
Loading...
Searching...
No Matches
MuonR4::TruthSegToTruthPartAssocAlg Class Reference

The TruthSegToTruthPartAssocAlg associates the TruthSegments with the primary TruthParticle from the IP. More...

#include <TruthSegToTruthPartAssocAlg.h>

Inheritance diagram for MuonR4::TruthSegToTruthPartAssocAlg:
Collaboration diagram for MuonR4::TruthSegToTruthPartAssocAlg:

Public Member Functions

virtual StatusCode initialize () override final
virtual StatusCode execute (const EventContext &ctx) const override final
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
virtual void setFilterPassed (bool state, const EventContext &ctx) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

using TruthPartLink_t = ElementLink<xAOD::TruthParticleContainer>
using TruthPartDecor_t = SG::WriteDecorHandle<xAOD::MuonSegmentContainer, TruthPartLink_t>
using TruthSegLinkVec_t = std::vector<ElementLink<xAOD::MuonSegmentContainer>>
using TruthSegLinkDecor_t = SG::WriteDecorHandle<xAOD::TruthParticleContainer, TruthSegLinkVec_t>
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

void matchPileupSegments (const EventContext &ctx, const std::vector< const xAOD::TruthParticle * > &pileUpMuons, const std::vector< const xAOD::MuonSegment * > &pileUpSegments, TruthPartDecor_t &truthPartDecor, TruthSegLinkDecor_t &truthSegDecor) const
 Match truth muons without any HEPMC link with truth segments reconstructed in the MS.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 IdHelperSvc to decode the Identifiers.
SG::ReadHandleKey< xAOD::TruthParticleContainerm_truthKey {this, "TruthKey", "MuonTruthParticles"}
 Key to the truth particle container to associate.
Gaudi::Property< std::vector< std::string > > m_simHitIds {this, "SimHitIds", {}}
 List of simHit id decorations to read from the truth particle.
SG::ReadDecorHandleKeyArray< xAOD::TruthParticleContainerm_simHitKeys {this, "TruthSimHitIdKeys", {}}
 Declaration of the dependency on the simHit decorations.
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_segLinkKey {this, "SegmentToPartKey", m_truthKey, "truthSegmentLinks"}
 Declaration of the segmentLink to the truth particle.
SG::ReadHandleKey< xAOD::MuonSegmentContainerm_segmentKey {this, "SegmentKey", "MuonTruthSegments"}
 Key to the truth segment container to associate.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainerm_truthLinkKey {this, "TruthToPartKey", m_segmentKey, "truthParticleLink"}
 Key of the truthParticleLink decorated onto the segment.
Gaudi::Property< bool > m_includePileUpObjs {this, "includePileUpObjs", false}
 Property checking whether a pile-up muons shall be matched to pile-up segments.
Gaudi::Property< double > m_pileUpObjDPhiCut {this,"deltaPhiSegBkgMuon", 10.*Gaudi::Units::deg}
 Delta phi cut between particle momentum & segment position to start the extrapolation.
Gaudi::Property< double > m_pileUpObjExtpDxCut {this,"BkgMatchingExtpX0", 10.*Gaudi::Units::cm}
 Cut on the delta x0 between the bkg segment and the extrapolated parameters.
Gaudi::Property< double > m_pileUpObjExtpDyCut {this,"BkgMatchingExtpY0", 10.*Gaudi::Units::mm}
 Cut on the delta y0 between the bkg segment and the extrapolated parameters.
Gaudi::Property< double > m_pileUpObjExtpDthetaCut {this,"BkgMatchingExtpTheta", 0.5*Gaudi::Units::deg}
 Cut on the delta theta between the bkg segment and the extrapolated parameters.
Gaudi::Property< double > m_pileUpObjExtpDphiCut {this,"BkgMatchingExtpPhi", 5.*Gaudi::Units::deg}
 Cut on the delta phi between the bkg segment and the extrapolated parameters.
PublicToolHandle< ActsTrk::ITrackingGeometryToolm_trackingGeometryTool {this, "TrackingGeometryTool", ""}
 Tracking geometry tool.
ToolHandle< ActsTrk::IExtrapolationToolm_extrapolationTool {this, "ExtrapolationTool" ,"" }
 Track extrapolation tool.
const MuonGMR4::MuonDetectorManagerm_detMgr {}
 Pointer to the muon detector manager.
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

The TruthSegToTruthPartAssocAlg associates the TruthSegments with the primary TruthParticle from the IP.

At the same time, the truth particles are linked to all the associated segment candidates.

To perform the matching, the SDO identifiers decorated to the TruthParticle are compared with the SDO identifiers of the truth hits making up the truth segment.

Definition at line 28 of file TruthSegToTruthPartAssocAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

◆ TruthPartDecor_t

◆ TruthPartLink_t

◆ TruthSegLinkDecor_t

◆ TruthSegLinkVec_t

Member Function Documentation

◆ cardinality()

unsigned int AthCommonReentrantAlgorithm< Gaudi::Algorithm >::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.

64{
65 return 0;
66}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode MuonR4::TruthSegToTruthPartAssocAlg::execute ( const EventContext & ctx) const
finaloverridevirtual

Initialize the Identifier decorators

Setup a vector with the truth particles and the associated hits

List of muons from the pile-up overlay

Fetch the segment container

Setup the write decorators

List of segments from the pile-up overlay.

Check if the segment does not have a valid gen particle link

Finally sort the segments along the trajectory

Definition at line 58 of file TruthSegToTruthPartAssocAlg.cxx.

58 {
59
60 const xAOD::TruthParticleContainer* truthParticles{nullptr};
61 ATH_CHECK(SG::get(truthParticles, m_truthKey, ctx));
62
63 using IdDecorHandle_t = SG::ReadDecorHandle<xAOD::TruthParticleContainer, std::vector<unsigned long long>>;
64 using SegLink_t = ElementLink<xAOD::MuonSegmentContainer>;
65 using SegLinkVec_t = std::vector<SegLink_t>;
66 SG::WriteDecorHandle<xAOD::TruthParticleContainer, SegLinkVec_t> segLinkDecor{m_segLinkKey ,ctx};
67
69 std::vector<IdDecorHandle_t> idDecorHandles{};
70 for (const SG::ReadDecorHandleKey<xAOD::TruthParticleContainer>& hitKey : m_simHitKeys) {
71 idDecorHandles.emplace_back(hitKey, ctx);
72 }
74 using IdSet_t = std::unordered_set<Identifier>;
75 using TruthTuple_t = std::tuple<const xAOD::TruthParticle*, IdSet_t>;
76 std::vector<TruthTuple_t> truthPartWithIds{};
78 std::vector<const xAOD::TruthParticle*> bkgMuons{};
79 truthPartWithIds.reserve(truthParticles->size());
80 for (const xAOD::TruthParticle* truthMuon : *truthParticles){
81 segLinkDecor(*truthMuon).clear();
82 IdSet_t assocIds{};
83 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" - Truth muon "<<truthMuon->pt()<<", eta: "<<truthMuon->eta()
84 <<", phi: "<<(truthMuon->phi() / 1._degree)<<", id: "<< HepMC::uniqueID(truthMuon));
85 for (const IdDecorHandle_t& hitDecor : idDecorHandles) {
86 std::ranges::transform(hitDecor(*truthMuon), std::inserter(assocIds, assocIds.begin()),
87 [this](unsigned long long rawId){
88 const Identifier id{rawId};
89 ATH_MSG_VERBOSE(" --- associated hit id: "<<m_idHelperSvc->toString(id));
90 return id;
91 });
92 }
93 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Truth muon with pt: "<<(truthMuon->pt() / 1_GeV)
94 <<", eta: "<<truthMuon->eta()<<", phi: "<<truthMuon->phi()
95 <<", uniqueID: "<<HepMC::uniqueID(truthMuon)<<", associated hits: "<<assocIds.size());
96 if (assocIds.empty()) {
97 bkgMuons.push_back(truthMuon);
98 } else {
99 truthPartWithIds.emplace_back(std::make_tuple(truthMuon, std::move(assocIds)));
100 }
101 }
103 const xAOD::MuonSegmentContainer* segments{nullptr};
104 ATH_CHECK(SG::get(segments, m_segmentKey, ctx));
105
107 TruthPartDecor_t truthLinkDecor{m_truthLinkKey, ctx};
109 std::vector<const xAOD::MuonSegment*> bkgSegments{};
110
111 for (const xAOD::MuonSegment* segment : *segments){
112 std::unordered_set<const xAOD::MuonSimHit*> simHits = getMatchingSimHits(*segment);
113 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" - Reconstructed truth segment "
115 <<", chamberId: "<<Muon::MuonStationIndex::chName(segment->chamberIndex())
116 <<", phi: "<<segment->sector()<<", nPrecHits: "<<segment->nPrecisionHits()
117 <<", nDoF: "<<segment->numberDoF()<<" sim hits: "<<simHits.size());
118 if (msgLvl(MSG::VERBOSE)){
119 std::vector<const xAOD::MuonSimHit*> sortedHits{simHits.begin(), simHits.end()};
120 std::ranges::sort(sortedHits, [](const xAOD::MuonSimHit* a, const xAOD::MuonSimHit* b){
121 return a->identify() < b->identify();
122 });
123 for (const xAOD::MuonSimHit* hit: sortedHits) {
124 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Associated sim hit: "<<m_idHelperSvc->toString(hit->identify())
125 <<", locPos: "<<Amg::toString(xAOD::toEigen(hit->localPosition()))
126 <<", locDir: "<<Amg::toString(xAOD::toEigen(hit->localDirection()))
127 <<", "<<hit->genParticleLink());
128 }
129 }
131 if (!(*simHits.begin())->genParticleLink().isValid()) {
132 bkgSegments.push_back(segment);
133 truthLinkDecor(*segment) = TruthPartLink_t{};
134 continue;
135 }
136 /* now find the truth particle with all associated hits */
137 const auto best_itr = std::ranges::max_element(truthPartWithIds,
138 [&simHits](const TruthTuple_t& truthTupleA,
139 const TruthTuple_t& truthTupleB) {
140 return countMatched(simHits, std::get<1>(truthTupleA)) <
141 countMatched(simHits, std::get<1>(truthTupleB));
142 });
143 if (best_itr == truthPartWithIds.end()) {
144 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" - No truth particle matched the truth hits of the segment");
145 continue;
146 }
147 if (1.*countMatched(simHits, std::get<1>(*best_itr)) < 0.5* simHits.size()) {
148 if (msgLvl(MSG::VERBOSE)) {
149 for (const auto& [truthMuon, assocIds]: truthPartWithIds){
150 std::stringstream unMatchedStr{};
151 unsigned int counts{0};
152 for (const xAOD::MuonSimHit* hit: simHits) {
153 if (!assocIds.count(hit->identify())){
154 unMatchedStr<<" *** "<<m_idHelperSvc->toString(hit->identify())<<std::endl;
155 } else {
156 ++counts;
157 }
158 }
159 if (!counts) {
160 continue;
161 }
162 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Truth muon "<<truthMuon->pt()<<", eta: "<<truthMuon->eta()
163 <<", "<<truthMuon->phi()<<", barcode: "<<HepMC::uniqueID(truthMuon)<<", matched hits: "
164 <<counts<<", unmatched: "<<std::endl<<unMatchedStr.str());
165 }
166 }
167 continue;
168 }
169 const xAOD::TruthParticle* truthPart{std::get<0>(*best_itr)};
170 segLinkDecor(*truthPart).emplace_back(segments, segment->index());
171 truthLinkDecor(*segment) = TruthPartLink_t{truthParticles, truthPart->index()};
172
173 }
175 for (const xAOD::TruthParticle* truthMuon : *truthParticles){
176 const Amg::Vector3D dir = Amg::Vector3D{truthMuon->px(), truthMuon->py(), truthMuon->pz()}.normalized();
177 const xAOD::TruthVertex* vtx{truthMuon->prodVtx()};
178 const Amg::Vector3D pos = (vtx? Amg::Vector3D{vtx->x(), vtx->y(), vtx->z()} : Amg::Vector3D::Zero());
179 SegLinkVec_t& linkedSegs{segLinkDecor(*truthMuon)};
180 std::ranges::sort(linkedSegs,[&pos, &dir](const SegLink_t& linkA, const SegLink_t& linkB){
181 return dir.dot((*linkA)->position() - pos) <
182 dir.dot((*linkB)->position() - pos);
183 });
184 }
185 return StatusCode::SUCCESS;
186 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t a
bool msgLvl(const MSG::Level lvl) const
size_type size() const noexcept
Returns the number of elements in the collection.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_truthLinkKey
Key of the truthParticleLink decorated onto the segment.
ElementLink< xAOD::TruthParticleContainer > TruthPartLink_t
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthKey
Key to the truth particle container to associate.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
IdHelperSvc to decode the Identifiers.
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_segLinkKey
Declaration of the segmentLink to the truth particle.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_segmentKey
Key to the truth segment container to associate.
SG::ReadDecorHandleKeyArray< xAOD::TruthParticleContainer > m_simHitKeys
Declaration of the dependency on the simHit decorations.
SG::WriteDecorHandle< xAOD::MuonSegmentContainer, TruthPartLink_t > TruthPartDecor_t
size_t index() const
Return the index of this element within its container.
float z() const
Vertex longitudinal distance along the beam line form the origin.
float y() const
Vertex y displacement.
float x() const
Vertex x displacement.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 3, 1 > Vector3D
int uniqueID(const T &p)
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
std::string toString(const Parameters &pars)
Dumps the parameters into a string with labels in front of each number.
std::unordered_set< const xAOD::MuonSimHit * > getMatchingSimHits(const xAOD::MuonSegment &segment)
: Returns all sim hits matched to a xAOD::MuonSegment
ElementLink< MuonR4::SegmentContainer > SegLink_t
Abrivation of the link to the reco segment container.
std::vector< SegLink_t > SegLinkVec_t
unsigned int countMatched(const simHitSet &truthHits, const simHitSet &recoHits)
const std::string & chName(ChIndex index)
convert ChIndex into a 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".
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
Definition MuonSimHit.h:12
TruthParticle_v1 TruthParticle
Typedef to implementation.
MuonSegment_v1 MuonSegment
Reference the current persistent version:
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthCommonReentrantAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 94 of file AthCommonReentrantAlgorithm.cxx.

90{
91 // If we didn't find any symlinks to add, just return the collection
92 // from the base class. Otherwise, return the extended collection.
93 if (!m_extendedExtraObjects.empty()) {
95 }
97}
An algorithm that can be simultaneously executed in multiple threads.

◆ filterPassed()

virtual bool AthCommonReentrantAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Definition at line 96 of file AthCommonReentrantAlgorithm.h.

96 {
97 return execState( ctx ).filterPassed();
98 }
virtual bool filterPassed(const EventContext &ctx) const

◆ initialize()

StatusCode MuonR4::TruthSegToTruthPartAssocAlg::initialize ( )
finaloverridevirtual

Definition at line 43 of file TruthSegToTruthPartAssocAlg.cxx.

43 {
44 ATH_CHECK(m_truthKey.initialize());
45 for (const std::string& hitIds : m_simHitIds) {
46 m_simHitKeys.emplace_back(m_truthKey, hitIds);
47 }
48 ATH_CHECK(m_simHitKeys.initialize());
49 ATH_CHECK(m_segLinkKey.initialize());
50 ATH_CHECK(m_segmentKey.initialize());
51 ATH_CHECK(m_truthLinkKey.initialize());
52 ATH_CHECK(m_idHelperSvc.retrieve());
53 ATH_CHECK(m_trackingGeometryTool.retrieve(EnableTool{m_includePileUpObjs}));
54 ATH_CHECK(m_extrapolationTool.retrieve(EnableTool{m_includePileUpObjs}));
56 return StatusCode::SUCCESS;
57 }
const ServiceHandle< StoreGateSvc > & detStore() const
Gaudi::Property< std::vector< std::string > > m_simHitIds
List of simHit id decorations to read from the truth particle.
const MuonGMR4::MuonDetectorManager * m_detMgr
Pointer to the muon detector manager.
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
Tracking geometry tool.
ToolHandle< ActsTrk::IExtrapolationTool > m_extrapolationTool
Track extrapolation tool.
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

◆ matchPileupSegments()

void MuonR4::TruthSegToTruthPartAssocAlg::matchPileupSegments ( const EventContext & ctx,
const std::vector< const xAOD::TruthParticle * > & pileUpMuons,
const std::vector< const xAOD::MuonSegment * > & pileUpSegments,
TruthPartDecor_t & truthPartDecor,
TruthSegLinkDecor_t & truthSegDecor ) const
private

Match truth muons without any HEPMC link with truth segments reconstructed in the MS.

Parameters
ctxEventContext to access the geometry & conditions
pileUpMuonsList of background muons
pileUpSegmentsList of pile-up segments to match
truthPartDecorDecorator to decorate the associated muon to the segment
truthSegDecorDecorator to pin the pile-up segments to the truth muon

First check on the distance of closest approach

Definition at line 187 of file TruthSegToTruthPartAssocAlg.cxx.

191 {
192
193 if (!m_includePileUpObjs) {
194 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" - Matching between pile-up segments & muons is disabled");
195 return;
196 }
197 if (pileUpMuons.empty() || pileUpSegments.empty()) {
198 ATH_MSG_DEBUG(__func__<<"() "<<__LINE__<<" - Segments ("<<pileUpSegments.size()<<") or muons ("
199 <<pileUpMuons.size()<<") are empty -> nothing to do");
200 return;
201 }
202 if (msgLvl(MSG::DEBUG)) {
203 std::stringstream sstr{};
204 for (const xAOD::TruthParticle* bkgMuon : pileUpMuons) {
205 sstr<<" *** pT: "<<(bkgMuon->pt() / 1_GeV)<<", eta: "<<bkgMuon->eta()
206 <<", phi: "<<(bkgMuon->phi() / 1_degree)<<", pdgId: "<<bkgMuon->pdgId()
207 <<", pos: "<<Amg::toString(vertexPos(*bkgMuon))
208 <<", uid: "<<bkgMuon->uid() <<std::endl;
209 }
210 sstr<<"\n To these segments: "<<std::endl;
211 unsigned int counter{0};
212 for (const xAOD::MuonSegment* bkgSeg : pileUpSegments) {
213 sstr<<" "<<(counter++)<<") "<<Amg::toString(bkgSeg->position())
214 <<", phi: "<<(bkgSeg->position().phi() / 1_degree)<<", eta: "<<(bkgSeg->position().eta())
215 <<", pT: "<< (acc_pt(*bkgSeg) / 1_GeV)
216 <<" chamberId: "<<Muon::MuonStationIndex::chName(bkgSeg->chamberIndex())
217 <<", sector: "<<bkgSeg->sector()<<", nPrecHits: "<<bkgSeg->nPrecisionHits()
218 <<", chi2: "<<(bkgSeg->chiSquared() / std::max(bkgSeg->numberDoF(), 1.f))
219 <<", nDoF: "<<bkgSeg->numberDoF()<<std::endl;
220 }
221 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - \nMatch the following muons "<<std::endl<<sstr.str());
222 }
223 std::vector<char> segmentMatched(pileUpSegments.size(), 0);
224
225 const ActsTrk::GeometryContext& gctx{m_trackingGeometryTool->getGeometryContext(ctx)};
226 const Acts::GeometryContext tgContext = gctx.context();
227
228 for (const xAOD::TruthParticle* bkgMuon : pileUpMuons) {
229 const Acts::Vector4 fourPos = vertexPos(*bkgMuon);
230 const Acts::Vector4 fourMom = ActsTrk::convertMomToActs(Amg::Vector3D{bkgMuon->px(), bkgMuon->py(), bkgMuon->pz()},
231 bkgMuon->m());
232 const Amg::Vector3D threeMom = fourMom.block<3,1>(0,0);
233 const Amg::Vector3D start = ActsTrk::convertPosFromActs(fourPos).first;
234 auto startSurf = Acts::Surface::makeShared<Acts::PlaneSurface>(Amg::getTranslate3D(start));
235
236
237 Acts::BoundMatrix initialCov{Acts::BoundMatrix::Identity()};
238
239 auto initialPars = Acts::BoundTrackParameters::create(tgContext, startSurf, fourPos, threeMom.unit(),
240 bkgMuon->charge() / threeMom.mag(),
241 initialCov, Acts::ParticleHypothesis::muon());
242 if(!initialPars.ok()) {
243 ATH_MSG_WARNING(__func__<<"() "<<__LINE__<<" - Failed to create start parameters");
244 continue;
245 }
246 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Created new start parameters "<<Amg::toString(fourPos)<<", "
247 <<Amg::toString(threeMom / 1_GeV) <<", pT: "<<(threeMom.perp() / 1_GeV)
248 <<", eta: "<<threeMom.eta()<<", phi: "<<(threeMom.phi() / 1_degree)<<", q: "<<bkgMuon->charge());
249
250 for (std::size_t sIdx =0 ; sIdx < pileUpSegments.size(); ++sIdx) {
251 // Skip already matched segments
252 if (segmentMatched[sIdx]) {
253 continue;
254 }
255 const xAOD::MuonSegment* bkgSeg = pileUpSegments[sIdx];
256 if (acc_q(*bkgSeg) != bkgMuon->charge()) {
257 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Segment charge does not match");
258 continue;
259 }
260 const Amg::Vector3D segPos = bkgSeg->position();
261 const Amg::Vector3D segDir = bkgSeg->direction();
263 const double lDist = std::abs(Amg::lineDistance(segPos, segDir, start, threeMom.unit()));
264 const double dPhi = std::abs(segPos.deltaPhi(threeMom));
265 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Segment "<<sIdx<<", "<<Amg::toString(segPos)
266 <<", "<<Amg::toString(segDir) <<", lDist: "<<lDist<<", dPhi: "<<(dPhi / 1_degree));
267 if (dPhi > m_pileUpObjDPhiCut) {
268 continue;
269 }
270 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Start extrapolation");
271 const auto* sector = m_detMgr->getSectorEnvelope(bkgSeg->chamberIndex(), bkgSeg->sector(), bkgSeg->etaIndex());
272 auto propPars = m_extrapolationTool->propagate(ctx, *initialPars, sector->surface());
273 if (!propPars) {
274 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Extrapolation failed.");
275 continue;
276 }
278 const Amg::Vector2D dPosExtp = propPars->localPosition() - (sector->globalToLocalTrans(gctx) * segPos).segment<2>(0);
279 const double dThetaExtp = std::abs(segDir.theta() - propPars->theta());
280 const double dPhiExtp = std::abs(segDir.phi() - propPars->phi());
281 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Parameter difference: "<<Amg::toString(dPosExtp)
282 <<", dTheta:"<<(dThetaExtp / 1._degree)<<", dPhi: "<<(dPhiExtp / 1._degree));
283
284
285 if (std::abs(dPosExtp.x()) > m_pileUpObjExtpDxCut || std::abs(dPosExtp.y()) > m_pileUpObjExtpDyCut ||
286 dThetaExtp > m_pileUpObjExtpDthetaCut || dPhiExtp > m_pileUpObjExtpDphiCut) {
287 ATH_MSG_VERBOSE(__func__<<"() "<<__LINE__<<" - Parameters differ too much. Cut values"
289 continue;
290 }
291 truthPartDecor(*bkgSeg) = TruthPartLink_t{truthSegDecor.cptr(), bkgMuon->index()};
292 truthSegDecor(*bkgMuon).emplace_back(truthPartDecor.cptr(), bkgSeg->index());
293 segmentMatched[sIdx] = true;
294 }
295 }
296 }
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Acts::GeometryContext context() const
Gaudi::Property< bool > m_includePileUpObjs
Property checking whether a pile-up muons shall be matched to pile-up segments.
Gaudi::Property< double > m_pileUpObjExtpDthetaCut
Cut on the delta theta between the bkg segment and the extrapolated parameters.
Gaudi::Property< double > m_pileUpObjDPhiCut
Delta phi cut between particle momentum & segment position to start the extrapolation.
Gaudi::Property< double > m_pileUpObjExtpDyCut
Cut on the delta y0 between the bkg segment and the extrapolated parameters.
Gaudi::Property< double > m_pileUpObjExtpDphiCut
Cut on the delta phi between the bkg segment and the extrapolated parameters.
Gaudi::Property< double > m_pileUpObjExtpDxCut
Cut on the delta x0 between the bkg segment and the extrapolated parameters.
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 ).
std::pair< Amg::Vector3D, double > convertPosFromActs(const Acts::Vector4 &actsPos)
Converts an Acts 4-vector into a pair of an Athena spatial vector and the passed time.
Acts::Vector4 convertMomToActs(const Amg::Vector3D &threeMom, const double mass=0.)
Converts a three momentum vector from Athena together with the associated particle mass into an Acts ...
Amg::Transform3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis
double lineDistance(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
: Calculates the shortest distance between two lines
Eigen::Matrix< double, 2, 1 > Vector2D
bool dPhi(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonReentrantAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Definition at line 100 of file AthCommonReentrantAlgorithm.h.

100 {
102 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const

◆ sysExecute()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 85 of file AthCommonReentrantAlgorithm.cxx.

77{
78 return BaseAlg::sysExecute (ctx);
79}

◆ sysInitialize()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in HypoBase, and InputMakerBase.

Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.

107 {
109
110 if (sc.isFailure()) {
111 return sc;
112 }
113
114 ServiceHandle<ICondSvc> cs("CondSvc",name());
115 for (auto h : outputHandles()) {
116 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
117 // do this inside the loop so we don't create the CondSvc until needed
118 if ( cs.retrieve().isFailure() ) {
119 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
120 return StatusCode::SUCCESS;
121 }
122 if (cs->regHandle(this,*h).isFailure()) {
124 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
125 << " with CondSvc");
126 }
127 }
128 }
129 return sc;
130}
#define ATH_MSG_ERROR(x)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

Member Data Documentation

◆ m_detMgr

const MuonGMR4::MuonDetectorManager* MuonR4::TruthSegToTruthPartAssocAlg::m_detMgr {}
private

Pointer to the muon detector manager.

Definition at line 84 of file TruthSegToTruthPartAssocAlg.h.

84{};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonReentrantAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 114 of file AthCommonReentrantAlgorithm.h.

◆ m_extrapolationTool

ToolHandle<ActsTrk::IExtrapolationTool> MuonR4::TruthSegToTruthPartAssocAlg::m_extrapolationTool {this, "ExtrapolationTool" ,"" }
private

Track extrapolation tool.

Definition at line 82 of file TruthSegToTruthPartAssocAlg.h.

82{this, "ExtrapolationTool" ,"" };

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuonR4::TruthSegToTruthPartAssocAlg::m_idHelperSvc {this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

IdHelperSvc to decode the Identifiers.

Definition at line 53 of file TruthSegToTruthPartAssocAlg.h.

53{this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_includePileUpObjs

Gaudi::Property<bool> MuonR4::TruthSegToTruthPartAssocAlg::m_includePileUpObjs {this, "includePileUpObjs", false}
private

Property checking whether a pile-up muons shall be matched to pile-up segments.

Definition at line 67 of file TruthSegToTruthPartAssocAlg.h.

67{this, "includePileUpObjs", false};

◆ m_pileUpObjDPhiCut

Gaudi::Property<double> MuonR4::TruthSegToTruthPartAssocAlg::m_pileUpObjDPhiCut {this,"deltaPhiSegBkgMuon", 10.*Gaudi::Units::deg}
private

Delta phi cut between particle momentum & segment position to start the extrapolation.

Definition at line 69 of file TruthSegToTruthPartAssocAlg.h.

69{this,"deltaPhiSegBkgMuon", 10.*Gaudi::Units::deg};

◆ m_pileUpObjExtpDphiCut

Gaudi::Property<double> MuonR4::TruthSegToTruthPartAssocAlg::m_pileUpObjExtpDphiCut {this,"BkgMatchingExtpPhi", 5.*Gaudi::Units::deg}
private

Cut on the delta phi between the bkg segment and the extrapolated parameters.

Definition at line 77 of file TruthSegToTruthPartAssocAlg.h.

77{this,"BkgMatchingExtpPhi", 5.*Gaudi::Units::deg};

◆ m_pileUpObjExtpDthetaCut

Gaudi::Property<double> MuonR4::TruthSegToTruthPartAssocAlg::m_pileUpObjExtpDthetaCut {this,"BkgMatchingExtpTheta", 0.5*Gaudi::Units::deg}
private

Cut on the delta theta between the bkg segment and the extrapolated parameters.

Definition at line 75 of file TruthSegToTruthPartAssocAlg.h.

75{this,"BkgMatchingExtpTheta", 0.5*Gaudi::Units::deg};

◆ m_pileUpObjExtpDxCut

Gaudi::Property<double> MuonR4::TruthSegToTruthPartAssocAlg::m_pileUpObjExtpDxCut {this,"BkgMatchingExtpX0", 10.*Gaudi::Units::cm}
private

Cut on the delta x0 between the bkg segment and the extrapolated parameters.

Definition at line 71 of file TruthSegToTruthPartAssocAlg.h.

71{this,"BkgMatchingExtpX0", 10.*Gaudi::Units::cm};

◆ m_pileUpObjExtpDyCut

Gaudi::Property<double> MuonR4::TruthSegToTruthPartAssocAlg::m_pileUpObjExtpDyCut {this,"BkgMatchingExtpY0", 10.*Gaudi::Units::mm}
private

Cut on the delta y0 between the bkg segment and the extrapolated parameters.

Definition at line 73 of file TruthSegToTruthPartAssocAlg.h.

73{this,"BkgMatchingExtpY0", 10.*Gaudi::Units::mm};

◆ m_segLinkKey

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> MuonR4::TruthSegToTruthPartAssocAlg::m_segLinkKey {this, "SegmentToPartKey", m_truthKey, "truthSegmentLinks"}
private

Declaration of the segmentLink to the truth particle.

Definition at line 61 of file TruthSegToTruthPartAssocAlg.h.

61{this, "SegmentToPartKey", m_truthKey, "truthSegmentLinks"};

◆ m_segmentKey

SG::ReadHandleKey<xAOD::MuonSegmentContainer> MuonR4::TruthSegToTruthPartAssocAlg::m_segmentKey {this, "SegmentKey", "MuonTruthSegments"}
private

Key to the truth segment container to associate.

Definition at line 63 of file TruthSegToTruthPartAssocAlg.h.

63{this, "SegmentKey", "MuonTruthSegments"};

◆ m_simHitIds

Gaudi::Property<std::vector<std::string> > MuonR4::TruthSegToTruthPartAssocAlg::m_simHitIds {this, "SimHitIds", {}}
private

List of simHit id decorations to read from the truth particle.

Definition at line 57 of file TruthSegToTruthPartAssocAlg.h.

57{this, "SimHitIds", {}};

◆ m_simHitKeys

SG::ReadDecorHandleKeyArray<xAOD::TruthParticleContainer> MuonR4::TruthSegToTruthPartAssocAlg::m_simHitKeys {this, "TruthSimHitIdKeys", {}}
private

Declaration of the dependency on the simHit decorations.

Definition at line 59 of file TruthSegToTruthPartAssocAlg.h.

59{this, "TruthSimHitIdKeys", {}};

◆ m_trackingGeometryTool

PublicToolHandle<ActsTrk::ITrackingGeometryTool> MuonR4::TruthSegToTruthPartAssocAlg::m_trackingGeometryTool {this, "TrackingGeometryTool", ""}
private

Tracking geometry tool.

Definition at line 80 of file TruthSegToTruthPartAssocAlg.h.

80{this, "TrackingGeometryTool", ""};

◆ m_truthKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> MuonR4::TruthSegToTruthPartAssocAlg::m_truthKey {this, "TruthKey", "MuonTruthParticles"}
private

Key to the truth particle container to associate.

Definition at line 55 of file TruthSegToTruthPartAssocAlg.h.

55{this, "TruthKey", "MuonTruthParticles"};

◆ m_truthLinkKey

SG::WriteDecorHandleKey<xAOD::MuonSegmentContainer> MuonR4::TruthSegToTruthPartAssocAlg::m_truthLinkKey {this, "TruthToPartKey", m_segmentKey, "truthParticleLink"}
private

Key of the truthParticleLink decorated onto the segment.

Definition at line 65 of file TruthSegToTruthPartAssocAlg.h.

65{this, "TruthToPartKey", m_segmentKey, "truthParticleLink"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: