ATLAS Offline Software
Loading...
Searching...
No Matches
RecTrackParticleContainerCnvTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 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
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(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
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
74 const Rec::TrackParticle* tp) const
75 {
76 // create the xAOD::TrackParticle, the pointer is added to the container in the function
77 return m_particleCreator->createParticle( *tp, xaod );
78 } // createParticleAndTruth
79
80 StatusCode RecTrackParticleContainerCnvTool::setParticleCreatorTool(ToolHandle<Trk::ITrackParticleCreatorTool> *tool)
81 {
82 ATH_MSG_DEBUG( "In setParticleCreatorTool" );
83 m_particleCreator = *tool;
84
85 return StatusCode::SUCCESS;
86 }
87
88} // 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 convertAndAugment(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.
virtual StatusCode convert(const Rec::TrackParticleContainer *aod, xAOD::TrackParticleContainer *xaod, const xAOD::Vertex *vtx=nullptr) const override
Function that fills an existing xAOD::TrackParticleContainer.
ToolHandle< Trk::ITrackParticleCreatorTool > m_particleCreator
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.
xAOD::TrackParticle * createParticle(xAOD::TrackParticleContainer *xaod, const Rec::TrackParticleContainer *container, const Rec::TrackParticle *tp) const
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".