ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::RecoToTruthAssociationAlg Class Reference

#include <RecoToTruthAssociationAlg.h>

Inheritance diagram for Muon::RecoToTruthAssociationAlg:
Collaboration diagram for Muon::RecoToTruthAssociationAlg:

Public Member Functions

StatusCode initialize () override
StatusCode execute (const EventContext &ctx) const override
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

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

void count_chamber_layers (const xAOD::IParticle *truth_particle, const Trk::Track *ptrk, std::vector< unsigned int > &nprecHitsPerChamberLayer, std::vector< unsigned int > &nphiHitsPerChamberLayer, std::vector< unsigned int > &ntrigEtaHitsPerChamberLayer) const
void clear_dummys (const std::vector< unsigned long long > &identifiers, std::vector< unsigned int > &vec) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKey< xAOD::TruthParticleContainerm_truthMuKey
 Key to the filtered muon truth particles.
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_muonTruthRecoLink
 Decorations for the filtered muon truth particles.
SG::ReadHandleKey< xAOD::MuonContainerm_recoMuKey
SG::WriteDecorHandleKey< xAOD::MuonContainerm_muonTruthParticleLink
 Decorations for the reconstructed muon particles.
SG::WriteDecorHandleKey< xAOD::MuonContainerm_muonTruthParticleType
SG::WriteDecorHandleKey< xAOD::MuonContainerm_muonTruthParticleOrigin
SG::WriteDecorHandleKey< xAOD::MuonContainerm_muonTruthParticleClassification
SG::WriteDecorHandleKey< xAOD::MuonContainerm_muonTruthParticleNPrecMatched
SG::WriteDecorHandleKey< xAOD::MuonContainerm_muonTruthParticleNPhiMatched
SG::WriteDecorHandleKey< xAOD::MuonContainerm_muonTruthParticleNTrigEtaMatched
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainerm_inputDecorKey
Gaudi::Property< std::vector< std::string > > m_assocTrkContainers
Gaudi::Property< std::string > m_recoLink {this, "RecoLinkName", "recoMuonLink" , "Decoration to the truth particle pointing to the muon"}
Gaudi::Property< bool > m_associateWithInDetTP {this, "AssociateWithInDetTP", false, "force use of ID track particles for association"}
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
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

Definition at line 18 of file RecoToTruthAssociationAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

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.

62{
63 return 0;
64}

◆ clear_dummys()

void Muon::RecoToTruthAssociationAlg::clear_dummys ( const std::vector< unsigned long long > & identifiers,
std::vector< unsigned int > & vec ) const
private

If the identifiers are empty then there is no change that a dummy value could be cleared from this list

Definition at line 366 of file RecoToTruthAssociationAlg.cxx.

366 {
369 if (identifiers.empty()) { return; }
370 for (unsigned int i = 0; i < vec.size(); ++i) {
371 if (vec[i] != dummy_unsigned) continue;
372 for (unsigned j = 0; j < identifiers.size(); ++j) {
373 const Identifier id{identifiers[j]};
374 if (m_idHelperSvc->measuresPhi(id)) {
375 const auto phiIdx = static_cast<PhiIndex>(i);
376 if (m_idHelperSvc->phiIndex(id) == phiIdx) {
377 vec[i] = 0;
378 break;
379 }
380 } else {
381 const auto chIdx = static_cast<ChIndex>(i);
382 if (m_idHelperSvc->chamberIndex(id) == chIdx) {
383 vec[i] = 0;
384 break;
385 }
386 }
387 }
388 }
389}
std::vector< size_t > vec
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
std::vector< Identifier > identifiers(const InDetSimDataCollection &coll)
PhiIndex
enum to classify the different phi layers in the muon spectrometer
ChIndex
enum to classify the different chamber layers in the muon spectrometer
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)

◆ count_chamber_layers()

void Muon::RecoToTruthAssociationAlg::count_chamber_layers ( const xAOD::IParticle * truth_particle,
const Trk::Track * ptrk,
std::vector< unsigned int > & nprecHitsPerChamberLayer,
std::vector< unsigned int > & nphiHitsPerChamberLayer,
std::vector< unsigned int > & ntrigEtaHitsPerChamberLayer ) const
private

Definition at line 266 of file RecoToTruthAssociationAlg.cxx.

269 {
270
271 if (!truthParticle || !truthMdtHitsAcc.isAvailable(*truthParticle)) {
272 ATH_MSG_DEBUG("muon has no truth hits vector in the truth association alg");
273 nprecHitsPerChamberLayer.clear();
274 nphiHitsPerChamberLayer.clear();
275 ntrigEtaHitsPerChamberLayer.clear();
276 return;
277 }
278 const std::vector<unsigned long long>& mdtTruth = truthMdtHitsAcc(*truthParticle);
279 std::vector<unsigned long long> cscTruth;
280
281 if (m_idHelperSvc->hasCSC()) cscTruth = truthCscHitsAcc(*truthParticle);
282 const std::vector<unsigned long long>& rpcTruth = truthRpcHitsAcc(*truthParticle);
283 const std::vector<unsigned long long>& tgcTruth = truthTgcHitsAcc(*truthParticle);
284
285 for (const Trk::TrackStateOnSurface* tsit : *ptrk->trackStateOnSurfaces()) {
286 if (!tsit || !tsit->trackParameters() || !tsit->measurementOnTrack()) continue;
287 const Trk::MeasurementBase* meas = tsit->measurementOnTrack();
288 Identifier id;
289 const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(meas);
290 if (rot)
291 id = rot->identify();
292 else {
293 const Muon::CompetingMuonClustersOnTrack* crot = dynamic_cast<const Muon::CompetingMuonClustersOnTrack*>(meas);
294 if (crot && !crot->containedROTs().empty() && crot->containedROTs().front()) id = crot->containedROTs().front()->identify();
295 }
296 if (!m_idHelperSvc->isMuon(id)) continue;
297
298 bool measPhi = m_idHelperSvc->measuresPhi(id);
299 bool isTgc = m_idHelperSvc->isTgc(id);
300 ChIndex chIndex = !isTgc ? m_idHelperSvc->chamberIndex(id) : ChIndex::ChUnknown;
301 if (m_idHelperSvc->isMdt(id)) {
302 for (unsigned int i = 0; i < mdtTruth.size(); ++i) {
303 if (id == mdtTruth[i]) {
304 if (chIndex != ChIndex::ChUnknown) {
305 increment_unsigned(nprecHitsPerChamberLayer.at(toInt(chIndex)));
306 }
307 break;
308 }
309 }
310 } else if (m_idHelperSvc->hasCSC() && m_idHelperSvc->isCsc(id)) {
311 for (unsigned int i = 0; i < cscTruth.size(); ++i) {
312 if (id != cscTruth[i]) continue;
313 if (measPhi) {
314 PhiIndex index = m_idHelperSvc->phiIndex(id);
315 if (index != PhiIndex::PhiUnknown) {
316 increment_unsigned(nphiHitsPerChamberLayer.at(toInt(index)));
317 }
318 } else {
319 if (chIndex != ChIndex::ChUnknown) {
320 increment_unsigned(nprecHitsPerChamberLayer.at(toInt(chIndex)));
321 }
322 }
323 break;
324 }
325 } else if (m_idHelperSvc->isRpc(id)) {
326 for (unsigned int i = 0; i < rpcTruth.size(); ++i) {
327 if (id != rpcTruth[i]) { continue; }
328 PhiIndex index = m_idHelperSvc->phiIndex(id);
329 if (index != PhiIndex::PhiUnknown) {
330 if (measPhi) {
331 increment_unsigned(nphiHitsPerChamberLayer.at(toInt(index)));
332 } else {
333 increment_unsigned(ntrigEtaHitsPerChamberLayer.at(toInt(index)));
334 }
335 }
336 break;
337 }
338 } else if (m_idHelperSvc->isTgc(id)) {
339 for (unsigned int i = 0; i < tgcTruth.size(); ++i) {
340 if (id != tgcTruth[i]) { continue; }
341 PhiIndex index = m_idHelperSvc->phiIndex(id);
342 if (index != PhiIndex::PhiUnknown) {
343 if (measPhi) {
344 increment_unsigned(nphiHitsPerChamberLayer.at(toInt(index)));
345 } else {
346 increment_unsigned(ntrigEtaHitsPerChamberLayer.at(toInt(index)));
347 }
348 }
349 break;
350 }
351 }
352 } // end loop over TSOS
353 ATH_MSG_DEBUG("finished loop over TSOS");
354
355 // now, have to check if there are non-zero truth hits in indices without reco hits
356 clear_dummys(mdtTruth, nprecHitsPerChamberLayer);
357 clear_dummys(cscTruth, nprecHitsPerChamberLayer);
358
359 clear_dummys(cscTruth, nphiHitsPerChamberLayer);
360 clear_dummys(rpcTruth, nphiHitsPerChamberLayer);
361 clear_dummys(tgcTruth, nphiHitsPerChamberLayer);
362
363 clear_dummys(rpcTruth, ntrigEtaHitsPerChamberLayer);
364 clear_dummys(tgcTruth, ntrigEtaHitsPerChamberLayer);
365}
#define ATH_MSG_DEBUG(x)
const std::vector< std::unique_ptr< const MuonClusterOnTrack > > & containedROTs() const
returns the vector of SCT_ClusterOnTrack objects .
void clear_dummys(const std::vector< unsigned long long > &identifiers, std::vector< unsigned int > &vec) const
Identifier identify() const
return the identifier -extends MeasurementBase
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
str index
Definition DeMoScan.py:362
ChIndex chIndex(const std::string &index)
convert ChIndex name string to enum
constexpr int toInt(const EnumType enumVal)

◆ 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 Muon::RecoToTruthAssociationAlg::execute ( const EventContext & ctx) const
override

Link the truth particle to the muon

Check first if the truth link already exists

The last judge is a simple dR cut but this will hopefully never trigger

Zero supression do not want to store meaningless zeros

Decorate the results

Patch for STACO muons: Copy the truth information from the muon back to the combined track to avoid file corruptions reported in ATLASRECTS-6454

one more thing: need to have muonlink set for all truth particles to avoid ELReset errors

Definition at line 91 of file RecoToTruthAssociationAlg.cxx.

91 {
92 const xAOD::TruthParticleContainer* muonTruthContainer{nullptr};
93 ATH_CHECK(SG::get(muonTruthContainer, m_truthMuKey , ctx));
94 std::unique_ptr<SG::WriteDecorHandle<xAOD::TruthParticleContainer, ElementLink<xAOD::MuonContainer>>> muonTruthParticleRecoLink{};
95 if (!m_muonTruthRecoLink.empty()) {
96 muonTruthParticleRecoLink = std::make_unique<SG::WriteDecorHandle<xAOD::TruthParticleContainer, ElementLink<xAOD::MuonContainer>>>(m_muonTruthRecoLink, ctx);
97 }
98
99 SG::WriteDecorHandle<xAOD::MuonContainer, ElementLink<xAOD::TruthParticleContainer> > muonTruthParticleLink(m_muonTruthParticleLink,
100 ctx);
101 if (!muonTruthParticleLink.isValid()) {
102 ATH_MSG_WARNING("muon particle container not valid");
103 return StatusCode::FAILURE;
104 }
105 SG::WriteDecorHandle<xAOD::MuonContainer, int> muonTruthParticleType(m_muonTruthParticleType, ctx);
106 SG::WriteDecorHandle<xAOD::MuonContainer, int> muonTruthParticleOrigin(m_muonTruthParticleOrigin, ctx);
107 SG::WriteDecorHandle<xAOD::MuonContainer, unsigned int> muonTruthParticleClassification(m_muonTruthParticleClassification, ctx);
108 SG::WriteDecorHandle<xAOD::MuonContainer, std::vector<unsigned int> > muonTruthParticleNPrecMatched(m_muonTruthParticleNPrecMatched,
109 ctx);
110 SG::WriteDecorHandle<xAOD::MuonContainer, std::vector<unsigned int> > muonTruthParticleNPhiMatched(m_muonTruthParticleNPhiMatched, ctx);
111 SG::WriteDecorHandle<xAOD::MuonContainer, std::vector<unsigned int> > muonTruthParticleNTrigEtaMatched(m_muonTruthParticleNTrigEtaMatched, ctx);
112
113 // add link to reco muons and viceversa
114 bool saw_staco = false;
115 bool decor_staco = false;
116
117 // loop over muons
118 for (const xAOD::Muon* muon : *muonTruthParticleLink) {
119 // use primary track particle to get the truth link (except for the case of STACO, where we must use the ID track particle, as the
120 // combined is not truth-matched)
121 ATH_MSG_DEBUG("muon with pT " << muon->pt() << " MeV, eta: " << muon->eta() << ", phi " << muon->phi() << " and author "
122 << muon->author());
123 const xAOD::TrackParticle* tp = nullptr;
124 const bool useID = m_associateWithInDetTP || muon->author() == xAOD::Muon::Author::STACO || muon->author() == xAOD::Muon::Author::MuGirl;
125
126 using enum xAOD::Muon::TrackParticleType;
127 tp = muon->trackParticle(useID ?InnerDetectorTrackParticle : Primary);
128
129 bool foundTruth{false}, setOrigin{false};
130 if (tp) {
131 // Associate reco with truth muon. Loop over reconstructed muons, get track particle for each one.
132 // Each track particle should carry a link to the corresponding truth particle. Then compare this truth particle link with the
133 // given truth muon particle
134 if (acc_origin.isAvailable(*tp) && acc_origin(*tp) != 0) {
135 muonTruthParticleOrigin(*muon) = acc_origin(*tp);
136 muonTruthParticleType(*muon) = acc_type(*tp);
137 muonTruthParticleClassification(*muon) = acc_classification(*tp);
138 setOrigin = true;
139 }
140
141 ElementLink<xAOD::TruthParticleContainer> truthLink;
142 if (acc_link.isAvailable(*tp)) {
143 truthLink = acc_link(*tp);
144 } else {
145 ATH_MSG_DEBUG("Could not find any truth link associated with track having pt:"<<tp->pt()<<" MeV, eta: "<<tp->eta()<<", phi: "<<tp->phi()<<", charge: "<<tp->charge()<<". d0:"<<tp->d0()<<", z0: "<<tp->z0());
146 }
147
148 if (truthLink.isValid()) {
149 ATH_MSG_VERBOSE(" Got valid truth link for muon author " << muon->author() << " uniqueID " << HepMC::uniqueID(*truthLink));
150 // loop over truth particles
151 for (const xAOD::TruthParticle* truthParticle : *muonTruthContainer) {
152 if (!MC::isStable(truthParticle)) continue;
153 ATH_MSG_DEBUG("Got truth muon with uniqueID " << HepMC::uniqueID(truthParticle) << " pt " << truthParticle->pt());
154 if ( !HepMC::is_sim_descendant(*truthLink, truthParticle)) {
155 ATH_MSG_VERBOSE("UniqueID truth link: " << HepMC::uniqueID(*truthLink)
156 << " is not decendant of " << HepMC::uniqueID(truthParticle));
157 continue;
158 }
159 ATH_MSG_VERBOSE("Truth muon uniqueID matches -> creating link with truth particle " << HepMC::uniqueID(*truthLink));
160 foundTruth = true;
162 ElementLink<xAOD::TruthParticleContainer> muonTruthLink{*muonTruthContainer,
163 truthParticle->index(),
164 ctx};
165 muonTruthLink.toPersistent();
166 muonTruthParticleLink(*muon) = muonTruthLink;
167 if (!setOrigin) {
168 muonTruthParticleOrigin(*muon) = acc_origin(*tp);
169 muonTruthParticleType(*muon) = acc_type(*tp);
170 muonTruthParticleClassification(*muon) = acc_classification(*tp);
171 setOrigin = true;
172 }
174 if (muonTruthParticleRecoLink && muonTruthParticleRecoLink->operator()(*truthParticle).isValid()){
175 const xAOD::Muon* decor_muon = *muonTruthParticleRecoLink->operator()(*truthParticle);
176 ATH_MSG_VERBOSE("Truth particle is already decorated with reco muon "<<decor_muon->pt()*1.e-3
177 <<" eta: "<<decor_muon->eta()<<" phi: "<<decor_muon->phi()<<" charge: "<<
178 decor_muon->charge()<<" author: "<<decor_muon->author()<<" all authors: "<<
179 decor_muon->allAuthors());
180
181 // Check first if the exiting muon has a better author
182 if (MuonCombined::authorRank(decor_muon->author()) < MuonCombined::authorRank(muon->author())){
183 ATH_MSG_DEBUG("Author of the decorated muon is better than the one of the new candidate");
184 continue;
185 }
187 if (deltaR2(muon,truthParticle) >= deltaR2(muon, decor_muon)) continue;
188 }
189
190
191 ElementLink<xAOD::MuonContainer> muonLink{muon, *muonTruthParticleLink, ctx};
192
194 std::vector<unsigned int> nprecHitsPerChamberLayer(toInt(ChIndex::ChIndexMax), dummy_unsigned);
195 std::vector<unsigned int> nphiHitsPerChamberLayer(toInt(PhiIndex::PhiIndexMax), dummy_unsigned);
196 std::vector<unsigned int> ntrigEtaHitsPerChamberLayer(toInt(PhiIndex::PhiIndexMax), dummy_unsigned);
197
198 constexpr std::array<xAOD::Muon::Author, 3> author_sel{xAOD::Muon::Author::MuidCo,
199 xAOD::Muon::Author::MuidSA,
200 xAOD::Muon::Author::MuGirl};
201 count_chamber_layers(std::ranges::any_of(author_sel, [muon](const auto a ){ return muon->isAuthor(a); })
202 ? truthParticle
203 : nullptr,
204 tp->track(), nprecHitsPerChamberLayer, nphiHitsPerChamberLayer, ntrigEtaHitsPerChamberLayer);
206 muonTruthParticleNPrecMatched(*muon) = nprecHitsPerChamberLayer;
207 muonTruthParticleNPhiMatched(*muon) = nphiHitsPerChamberLayer;
208 muonTruthParticleNTrigEtaMatched(*muon) = ntrigEtaHitsPerChamberLayer;
209
210 if (muonTruthParticleRecoLink) (*muonTruthParticleRecoLink)(*truthParticle) = muonLink;
211 break;
212 }
213 } else {
214 ATH_MSG_DEBUG("Invalid truth link");
215 }
216 } else {
217 ATH_MSG_WARNING("Could not find the appropiate track particle for muon with pT: " << muon->pt() * 1.e-3 << " GeV, eta: "
218 << muon->eta() << ", phi: " << muon->phi()
219 << " author: " << muon->author());
220 }
221
222 if (!setOrigin) {
223 muonTruthParticleOrigin(*muon) = 0;
224 muonTruthParticleType(*muon) = 0;
225 muonTruthParticleClassification(*muon) = 0;
226 }
227 if (!foundTruth) {
228 muonTruthParticleLink(*muon) = ElementLink<xAOD::TruthParticleContainer>();
229 // add these empty vectors
230 muonTruthParticleNPrecMatched(*muon) = std::vector<unsigned int>{};
231 muonTruthParticleNPhiMatched(*muon) = std::vector<unsigned int>{};
232 muonTruthParticleNTrigEtaMatched(*muon) = std::vector<unsigned int>{};
233 }
236 if (muon->author() == xAOD::Muon::Author::STACO) {
237 const xAOD::TrackParticle* cmb_trk = muon->trackParticle(xAOD::Muon::CombinedTrackParticle);
238 if (!cmb_trk){
239 ATH_MSG_WARNING("Even a STACO muon should have a combined track");
240 continue;
241 } else {
242 if (!saw_staco) {
243 saw_staco = true;
244 decor_staco = !dec_origin.isAvailable (*cmb_trk);
245 }
246 if (decor_staco) {
247 dec_origin(*cmb_trk) = acc_origin(*muon);
248 dec_classification(*cmb_trk) = acc_classification(*muon);
249 dec_type(*cmb_trk) = acc_type(*muon);
250 dec_link(*cmb_trk) = acc_link(*muon);
251 }
252 }
253 }
254 }
256 if (muonTruthParticleRecoLink && !muonTruthParticleRecoLink->isAvailable()) {
257 for (const xAOD::TruthParticle* truthParticle : **muonTruthParticleRecoLink) {
258 ATH_MSG_DEBUG("no reco muon link set, add an empty one");
259 (*muonTruthParticleRecoLink)(*truthParticle) = ElementLink<xAOD::MuonContainer>();
260 }
261 }
262
263 return StatusCode::SUCCESS;
264}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static Double_t a
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_muonTruthParticleOrigin
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_muonTruthParticleNPhiMatched
Gaudi::Property< bool > m_associateWithInDetTP
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_muonTruthRecoLink
Decorations for the filtered muon truth particles.
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_muonTruthParticleClassification
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_muonTruthParticleType
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_muonTruthParticleLink
Decorations for the reconstructed muon particles.
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_muonTruthParticleNTrigEtaMatched
void count_chamber_layers(const xAOD::IParticle *truth_particle, const Trk::Track *ptrk, std::vector< unsigned int > &nprecHitsPerChamberLayer, std::vector< unsigned int > &nphiHitsPerChamberLayer, std::vector< unsigned int > &ntrigEtaHitsPerChamberLayer) const
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthMuKey
Key to the filtered muon truth particles.
SG::WriteDecorHandleKey< xAOD::MuonContainer > m_muonTruthParticleNPrecMatched
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
virtual double pt() const
The transverse momentum ( ) of the particle.
float charge() const
uint16_t allAuthors() const
Get all the authors of this Muon.
Author author() const
float z0() const
Returns the parameter.
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
float d0() const
Returns the parameter.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
float charge() const
Returns the charge.
int uniqueID(const T &p)
bool is_sim_descendant(const T1 &p1, const T2 &p2)
Method to check if the first particle is a descendant of the second in the simulation,...
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
int authorRank(const xAOD::Muon::Author a)
Definition TagBase.h:24
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
double deltaR2(double rapidity1, double phi1, double rapidity2, double phi2)
from bare rapidity,phi
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
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.

88{
89 // If we didn't find any symlinks to add, just return the collection
90 // from the base class. Otherwise, return the extended collection.
91 if (!m_extendedExtraObjects.empty()) {
93 }
95}
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 Muon::RecoToTruthAssociationAlg::initialize ( )
override

Definition at line 48 of file RecoToTruthAssociationAlg.cxx.

48 {
49 ATH_CHECK(m_idHelperSvc.retrieve());
50 ATH_CHECK(m_truthMuKey.initialize());
51 ATH_CHECK(m_recoMuKey.initialize());
52
53 if (m_recoLink.empty()){
55 } else {
57 }
58
59 ATH_CHECK(m_muonTruthRecoLink.initialize(!m_recoLink.empty()));
67 for (const std::string& trk_coll : m_assocTrkContainers.value()){
68 m_inputDecorKey.emplace_back(trk_coll + ".truthParticleLink");
69 }
70
71 m_inputDecorKey.emplace_back(m_truthMuKey, SG::AuxTypeRegistry::instance().getName(acc_origin.auxid()));
72 m_inputDecorKey.emplace_back(m_truthMuKey, SG::AuxTypeRegistry::instance().getName(acc_type.auxid()));
73 if (m_idHelperSvc->hasMDT()) {
74 m_inputDecorKey.emplace_back(m_truthMuKey, SG::AuxTypeRegistry::instance().getName(truthMdtHitsAcc.auxid()));
75 }
76 if (m_idHelperSvc->hasRPC()) {
77 m_inputDecorKey.emplace_back(m_truthMuKey, SG::AuxTypeRegistry::instance().getName(truthRpcHitsAcc.auxid()));
78 }
79 if (m_idHelperSvc->hasTGC()) {
80 m_inputDecorKey.emplace_back(m_truthMuKey, SG::AuxTypeRegistry::instance().getName(truthTgcHitsAcc.auxid()));
81 }
82 if (m_idHelperSvc->hasCSC()) {
83 m_inputDecorKey.emplace_back(m_truthMuKey, SG::AuxTypeRegistry::instance().getName(truthCscHitsAcc.auxid()));
84 }
85
86 ATH_CHECK(m_inputDecorKey.initialize());
87 return StatusCode::SUCCESS;
88}
SG::ReadHandleKey< xAOD::MuonContainer > m_recoMuKey
SG::ReadDecorHandleKeyArray< xAOD::IParticleContainer > m_inputDecorKey
Gaudi::Property< std::vector< std::string > > m_assocTrkContainers
Gaudi::Property< std::string > m_recoLink
static AuxTypeRegistry & instance()
Return the singleton registry instance.

◆ 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()

◆ 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.

75{
76 return BaseAlg::sysExecute (ctx);
77}

◆ 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.

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

Gaudi::Property<bool> Muon::RecoToTruthAssociationAlg::m_associateWithInDetTP {this, "AssociateWithInDetTP", false, "force use of ID track particles for association"}
private

Definition at line 74 of file RecoToTruthAssociationAlg.h.

74{this, "AssociateWithInDetTP", false, "force use of ID track particles for association"};

◆ m_assocTrkContainers

Gaudi::Property<std::vector<std::string> > Muon::RecoToTruthAssociationAlg::m_assocTrkContainers
private
Initial value:
{this, "TrackContainers", {"CombinedMuonTrackParticles",
"ExtrapolatedMuonTrackParticles",
"MSOnlyExtrapolatedMuonTrackParticles"},
"Collection of track containers to be decorated before this alg can be scheduled. truthLink decoration exploited "}

Definition at line 69 of file RecoToTruthAssociationAlg.h.

69 {this, "TrackContainers", {"CombinedMuonTrackParticles",
70 "ExtrapolatedMuonTrackParticles",
71 "MSOnlyExtrapolatedMuonTrackParticles"},
72 "Collection of track containers to be decorated before this alg can be scheduled. truthLink decoration exploited "};

◆ 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_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::RecoToTruthAssociationAlg::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 76 of file RecoToTruthAssociationAlg.h.

76{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_inputDecorKey

SG::ReadDecorHandleKeyArray<xAOD::IParticleContainer> Muon::RecoToTruthAssociationAlg::m_inputDecorKey
private
Initial value:
{
this, "TrkTruthLinkKeys", {},
"Declare the decoration dependencies of this algorithm. Steer via TrackContainers property"}

Definition at line 66 of file RecoToTruthAssociationAlg.h.

66 {
67 this, "TrkTruthLinkKeys", {},
68 "Declare the decoration dependencies of this algorithm. Steer via TrackContainers property"};

◆ m_muonTruthParticleClassification

SG::WriteDecorHandleKey<xAOD::MuonContainer> Muon::RecoToTruthAssociationAlg::m_muonTruthParticleClassification
private
Initial value:
{
this, "MuonTruthParticleClassification", m_recoMuKey, "truthClassification",
"muon truth classification auxdata name; name will be reset in initialize() based on m_muonName"}

Definition at line 51 of file RecoToTruthAssociationAlg.h.

51 {
52 this, "MuonTruthParticleClassification", m_recoMuKey, "truthClassification",
53 "muon truth classification auxdata name; name will be reset in initialize() based on m_muonName"};

◆ m_muonTruthParticleLink

SG::WriteDecorHandleKey<xAOD::MuonContainer> Muon::RecoToTruthAssociationAlg::m_muonTruthParticleLink
private
Initial value:
{
this, "MuonTruthParticleLink", m_recoMuKey, "truthParticleLink",
"muon truth particle link auxdata name; name will be reset in initialize() based on m_muonName"}

Decorations for the reconstructed muon particles.

Definition at line 42 of file RecoToTruthAssociationAlg.h.

42 {
43 this, "MuonTruthParticleLink", m_recoMuKey, "truthParticleLink",
44 "muon truth particle link auxdata name; name will be reset in initialize() based on m_muonName"};

◆ m_muonTruthParticleNPhiMatched

SG::WriteDecorHandleKey<xAOD::MuonContainer> Muon::RecoToTruthAssociationAlg::m_muonTruthParticleNPhiMatched
private
Initial value:
{
this, "MuonTruthParticleNPhiMatched", m_recoMuKey, "nphiMatchedHitsPerChamberLayer",
"muon vector of number of phi matched hits per chamber layer auxdata name; name will be reset in initialize() based on m_muonName"}

Definition at line 58 of file RecoToTruthAssociationAlg.h.

58 {
59 this, "MuonTruthParticleNPhiMatched", m_recoMuKey, "nphiMatchedHitsPerChamberLayer",
60 "muon vector of number of phi matched hits per chamber layer auxdata name; name will be reset in initialize() based on m_muonName"};

◆ m_muonTruthParticleNPrecMatched

SG::WriteDecorHandleKey<xAOD::MuonContainer> Muon::RecoToTruthAssociationAlg::m_muonTruthParticleNPrecMatched
private
Initial value:
{
this, "MuonTruthParticleNPrecMatched", m_recoMuKey, "nprecMatchedHitsPerChamberLayer",
"muon vector of number of precision matched hits per chamber layer auxdata name; name will be reset in initialize() based on "
"m_muonName"}

Definition at line 54 of file RecoToTruthAssociationAlg.h.

54 {
55 this, "MuonTruthParticleNPrecMatched", m_recoMuKey, "nprecMatchedHitsPerChamberLayer",
56 "muon vector of number of precision matched hits per chamber layer auxdata name; name will be reset in initialize() based on "
57 "m_muonName"};

◆ m_muonTruthParticleNTrigEtaMatched

SG::WriteDecorHandleKey<xAOD::MuonContainer> Muon::RecoToTruthAssociationAlg::m_muonTruthParticleNTrigEtaMatched
private
Initial value:
{
this, "MuonTruthParticleNTrigEtaMatched", m_recoMuKey, "ntrigEtaMatchedHitsPerChamberLayer",
"muon vector of number of phi matched hits per chamber layer auxdata name; name will be reset in initialize() based on m_muonName"}

Definition at line 61 of file RecoToTruthAssociationAlg.h.

61 {
62 this, "MuonTruthParticleNTrigEtaMatched", m_recoMuKey, "ntrigEtaMatchedHitsPerChamberLayer",
63 "muon vector of number of phi matched hits per chamber layer auxdata name; name will be reset in initialize() based on m_muonName"};

◆ m_muonTruthParticleOrigin

SG::WriteDecorHandleKey<xAOD::MuonContainer> Muon::RecoToTruthAssociationAlg::m_muonTruthParticleOrigin
private
Initial value:
{
this, "MuonTruthParticleOrigin", m_recoMuKey, "truthOrigin",
"muon truth origin auxdata name; name will be reset in initialize() based on m_muonName"}

Definition at line 48 of file RecoToTruthAssociationAlg.h.

48 {
49 this, "MuonTruthParticleOrigin", m_recoMuKey, "truthOrigin",
50 "muon truth origin auxdata name; name will be reset in initialize() based on m_muonName"};

◆ m_muonTruthParticleType

SG::WriteDecorHandleKey<xAOD::MuonContainer> Muon::RecoToTruthAssociationAlg::m_muonTruthParticleType
private
Initial value:
{
this, "MuonTruthParticleType", m_recoMuKey, "truthType",
"muon truth type auxdata name; name will be reset in initialize() based on m_muonName"}

Definition at line 45 of file RecoToTruthAssociationAlg.h.

45 {
46 this, "MuonTruthParticleType", m_recoMuKey, "truthType",
47 "muon truth type auxdata name; name will be reset in initialize() based on m_muonName"};

◆ m_muonTruthRecoLink

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> Muon::RecoToTruthAssociationAlg::m_muonTruthRecoLink
private
Initial value:
{
this, "MuonTruthParticleRecoLink", m_truthMuKey, "",
"container name for muon truth particles; the full handle name, including the reco muon link auxdata, is set in initialize()"}

Decorations for the filtered muon truth particles.

Definition at line 33 of file RecoToTruthAssociationAlg.h.

33 {
34 this, "MuonTruthParticleRecoLink", m_truthMuKey, "",
35 "container name for muon truth particles; the full handle name, including the reco muon link auxdata, is set in initialize()"};

◆ m_recoLink

Gaudi::Property<std::string> Muon::RecoToTruthAssociationAlg::m_recoLink {this, "RecoLinkName", "recoMuonLink" , "Decoration to the truth particle pointing to the muon"}
private

Definition at line 73 of file RecoToTruthAssociationAlg.h.

73{this, "RecoLinkName", "recoMuonLink" , "Decoration to the truth particle pointing to the muon"};

◆ m_recoMuKey

SG::ReadHandleKey<xAOD::MuonContainer> Muon::RecoToTruthAssociationAlg::m_recoMuKey
private
Initial value:
{
this, "MuonContainerName", "Muons",
"container name for reco muon particles; the full handle name, including the reco muon link auxdata, is set in initialize()"}

Definition at line 37 of file RecoToTruthAssociationAlg.h.

37 {
38 this, "MuonContainerName", "Muons",
39 "container name for reco muon particles; the full handle name, including the reco muon link auxdata, is set in initialize()"};

◆ m_truthMuKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> Muon::RecoToTruthAssociationAlg::m_truthMuKey
private
Initial value:
{
this, "MuonTruthParticleContainerName", "MuonTruthParticles"}

Key to the filtered muon truth particles.

Definition at line 29 of file RecoToTruthAssociationAlg.h.

29 {
30 this, "MuonTruthParticleContainerName", "MuonTruthParticles"};

◆ 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: