ATLAS Offline Software
Loading...
Searching...
No Matches
RecTrackParticleContainerCnvTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id$
6// EDM include(s):
10
11// Local include(s):
13
14
15
16namespace xAODMaker {
17
19 const std::string& name,
20 const IInterface* parent )
21 : AthAlgTool( type, name, parent ),
22 m_particleCreator("Trk::TrackParticleCreatorTool/TrackParticleCreatorTool")
23 {
24
25 // Declare the interface(s) provided by the tool:
26 declareInterface< IRecTrackParticleContainerCnvTool >( this );
27 declareProperty( "TrackParticleCreator" , m_particleCreator );
28 }
29
31 // Greet the user:
32 ATH_MSG_DEBUG( "Initializing RecTrackParticleContainerCnvTool" );
33 ATH_CHECK( m_particleCreator.retrieve() );
34
35 return StatusCode::SUCCESS;
36 }
37
38 StatusCode RecTrackParticleContainerCnvTool::convert( const EventContext& ctx, const Rec::TrackParticleContainer* aod,
39 xAOD::TrackParticleContainer* xaod, const xAOD::Vertex* /*vtx*/ ) const {
40
41 ATH_MSG_DEBUG( "Sizes of containers before conversion: aod, xaod: " << aod->size() << ", " << xaod->size() );
44
45 for( ;itr!=end;++itr ) {
46 // Create the xAOD object:
47 if (!(*itr)) {
48 ATH_MSG_WARNING("Empty element in container!");
49 continue;
50 }
51 xAOD::TrackParticle* particle = createParticle(ctx, xaod, aod, *itr);
52
53 if(!particle){
54 ATH_MSG_WARNING("Failed to create a TrackParticle");
55 continue;
56 }
57 }
58
59 ATH_MSG_DEBUG( "Sizes of containers after conversion: aod, xaod: " << aod->size() << ", " << xaod->size() );
60
61 return StatusCode::SUCCESS;
62 }
63
64 StatusCode RecTrackParticleContainerCnvTool::convertAndAugment( const EventContext& /*ctx*/, const Rec::TrackParticleContainer* aod,
65 xAOD::TrackParticleContainer* xaod, const ObservedTrackMap* trk_map, const xAOD::Vertex* /*vtx*/ ) const {
66
67 ATH_MSG_DEBUG( "Sizes of containers before conversion: aod, xaod, trk_map: " << aod->size() << ", " << xaod->size() << ", "<< trk_map->size() );
68 ATH_MSG_DEBUG( "convertAndAugment should not be called using IRecTrackParticleContainerCnvTool!" );
69 return StatusCode::FAILURE;
70 }
71
75 const Rec::TrackParticle* tp) const
76 {
77 // create the xAOD::TrackParticle, the pointer is added to the container in the function
78 return m_particleCreator->createParticle( ctx, *tp, xaod );
79 } // createParticleAndTruth
80
81 StatusCode RecTrackParticleContainerCnvTool::setParticleCreatorTool(ToolHandle<Trk::ITrackParticleCreatorTool> *tool)
82 {
83 ATH_MSG_DEBUG( "In setParticleCreatorTool" );
84 m_particleCreator = *tool;
85
86 return StatusCode::SUCCESS;
87 }
88
89} // namespace xAODMaker
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
std::map< int, std::tuple< Trk::Track *, double, xAOD::RejectionStep, xAOD::RejectionReason, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, float, float, int, std::vector< xAOD::RejectionStep >, std::vector< xAOD::RejectionReason > > > ObservedTrackMap
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
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.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual StatusCode convert(const EventContext &ctx, const Rec::TrackParticleContainer *aod, xAOD::TrackParticleContainer *xaod, const xAOD::Vertex *vtx=nullptr) const override
Function that fills an existing xAOD::TrackParticleContainer.
virtual StatusCode convertAndAugment(const EventContext &ctx, const Rec::TrackParticleContainer *aod, xAOD::TrackParticleContainer *xaod, const ObservedTrackMap *trk_map, const xAOD::Vertex *vtx=nullptr) const override
Function that fills an existing xAOD::TrackParticleContainer and augments track particles.
ToolHandle< Trk::ITrackParticleCreatorTool > m_particleCreator
xAOD::TrackParticle * createParticle(const EventContext &ctx, xAOD::TrackParticleContainer *xaod, const Rec::TrackParticleContainer *container, const Rec::TrackParticle *tp) const
virtual StatusCode setParticleCreatorTool(ToolHandle< Trk::ITrackParticleCreatorTool > *tool) override
allow other algorithms to pass the tool in order to preserve initialisation
virtual StatusCode initialize() override
Function initialising the tool.
RecTrackParticleContainerCnvTool(const std::string &type, const std::string &name, const IInterface *parent)
Regular AlgTool constructor.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".