ATLAS Offline Software
Loading...
Searching...
No Matches
GSFTrackParticleMapCnvAlg.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// Gaudi/Athena include(s):
7
8// EDM include(s):
14// Local include(s):
16
17namespace xAODMaker {
18
20 ISvcLocator* svcLoc )
21 : AthAlgorithm( name, svcLoc ) {
22
23 declareProperty( "AODContainerName", m_aodContainerName = "TrackParticleCandidate" );
24 declareProperty( "xAODContainerName", m_xaodContainerName = "InDetTrackParticles" );
25 declareProperty( "AODContainerNameGSF", m_aodContainerNameGSF = "GSFTrackParticleCandidate" );
26 declareProperty( "xAODContainerNameGSF", m_xaodContainerNameGSF = "GSFTrackParticles" );
27 declareProperty( "TrackMapName", m_trackMapName="GSFTrackAssociation", "Old new Track Map Name" );
28
29 }
30
32
33 ATH_MSG_INFO( "Initializing" );
34 ATH_MSG_INFO( "AODContainerNameGSF = " << m_aodContainerNameGSF );
35 ATH_MSG_INFO( "xAODContainerName = " << m_xaodContainerName );
36 ATH_MSG_INFO( "AODContainerNameGSF = " << m_aodContainerNameGSF );
37 ATH_MSG_INFO( "xAODContainerNameGSF = " << m_xaodContainerNameGSF );
38
39
40 // Return gracefully:
41 return StatusCode::SUCCESS;
42 }
43
45
47
48 // Retrieve the track particles from AOD
50 if( !aodContainer ) {
51 ATH_MSG_WARNING("No AOD TrackParticle container found in TES: StoreGate Key = " <<m_aodContainerName);
52 return StatusCode::SUCCESS;
53 }
54 ATH_MSG_DEBUG( "Retrieved particles with key: " << m_aodContainerName );
55
56
57 // Retrieve the GSF track particles from AOD
58 const Rec::TrackParticleContainer* aodContainerGSF = evtStore()->tryConstRetrieve<Rec::TrackParticleContainer>(m_aodContainerNameGSF );
59 if( !aodContainerGSF ) {
60 ATH_MSG_WARNING("No AOD GSFTrackParticle container found in TES: StoreGate Key = " << m_aodContainerNameGSF);
61 return StatusCode::SUCCESS;
62 }
63 ATH_MSG_DEBUG( "Retrieved particles with key: " << m_aodContainerNameGSF );
64
65 // Retrieve the GSF track particles from xAOD
67 if( !xaodContainerGSF ) {
68 ATH_MSG_WARNING("No xAOD GSFTrackParticle container found in TES: StoreGate Key = " << m_xaodContainerNameGSF);
69 return StatusCode::SUCCESS;
70 }
71 ATH_MSG_DEBUG( "Retrieved particles with key: " << m_xaodContainerNameGSF );
72
73 // Retrieve the GSF -> Trk associations
74 const TrackParticleAssocs *trkassocs = nullptr;
75 StatusCode sc=evtStore()->retrieve( trkassocs, m_trackMapName ) ;
76
77 if( sc.isFailure()) {
78 ATH_MSG_WARNING( "Could not retrieve " << m_trackMapName);
79 return StatusCode::SUCCESS;
80 }
81
83
84 // Loop over the GSF track particles from the AOD and the GSF ones from xAOD
85 // assuming they are aligned
87 Rec::TrackParticleContainer::const_iterator aodEnd = aodContainerGSF->end();
88
89 xAOD::TrackParticleContainer::const_iterator xaod = xaodContainerGSF->begin();
90 xAOD::TrackParticleContainer::const_iterator xaodEnd = xaodContainerGSF->end();
91
92 for ( ; aod != aodEnd && xaod != xaodEnd; ++aod, ++xaod){
94
95 if ( !trkassocs->assocs(*aod, associatedElems) ){
96 ATH_MSG_WARNING("Missing link from GSF track particle to original TP");
97 continue;
98 }
99
100 // Old link to AOD container
101 ElementLink<Rec::TrackParticleContainer> oldLink(associatedElems.at(0), *aodContainer);
102
103 // New link to xAOD container of non-GSF track particles
105 newLink.resetWithKeyAndIndex( m_xaodContainerName, oldLink.index() );
106
107 // Set new link as a decoration of the new GSF track particle
108 if(newLink.isValid()){
109 newLink.toPersistent();
111 originalTrackParticleDec ("originalTrackParticle");
112 originalTrackParticleDec (**xaod) = newLink;
113 }
114 }
115
116 // Return gracefully:
117 return StatusCode::SUCCESS;
118 }
119
120} // namespace xAODMaker
121
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
DataVector adapter that acts like it holds const pointers.
Helpers for checking error return status codes and reporting errors.
Helper class to provide type-safe access to aux data.
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
DataVector adapter that acts like it holds const pointers.
ElementProxy at(size_type n)
Access an element, as an lvalue.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
Helper class to provide type-safe access to aux data.
Definition Decorator.h:59
bool assocs(const Rec::TrackParticle *object, ConstDataVector< Rec::TrackParticleContainer > &associatedElems) const
Retrieve all the associated-to objects which have been associated to the given.
std::string m_xaodContainerNameGSF
The name of the xAOD GSF TrackParticle container.
std::string m_xaodContainerName
The name of the xAOD non-GSF TrackParticle container.
std::string m_trackMapName
The name of the map from AOD GSF TrackParticles to AOD TrackParticles.
GSFTrackParticleMapCnvAlg(const std::string &name, ISvcLocator *svcLoc)
Regular algorithm constructor.
std::string m_aodContainerNameGSF
The name of the AOD GSF TrackParticle container.
std::string m_aodContainerName
The name of the AOD GSF TrackParticle container.
virtual StatusCode initialize()
Function initialising the algorithm.
virtual StatusCode execute()
Function executing the algorithm.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".