ATLAS Offline Software
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 
16 namespace 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" );
84 
85  return StatusCode::SUCCESS;
86  }
87 
88 } // namespace xAODMaker
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAODMaker::RecTrackParticleContainerCnvTool::convert
virtual StatusCode convert(const Rec::TrackParticleContainer *aod, xAOD::TrackParticleContainer *xaod, const xAOD::Vertex *vtx=nullptr) const override
Function that fills an existing xAOD::TrackParticleContainer.
Definition: RecTrackParticleContainerCnvTool.cxx:38
xAODMaker::RecTrackParticleContainerCnvTool::initialize
virtual StatusCode initialize() override
Function initialising the tool.
Definition: RecTrackParticleContainerCnvTool.cxx:30
xAODMaker
Definition: StoreGateSvc.h:72
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
ObservedTrackMap
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
Definition: ObservedTrackMap.h:50
xAODMaker::RecTrackParticleContainerCnvTool::createParticle
xAOD::TrackParticle * createParticle(xAOD::TrackParticleContainer *xaod, const Rec::TrackParticleContainer *container, const Rec::TrackParticle *tp) const
Definition: RecTrackParticleContainerCnvTool.cxx:72
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAODMaker::RecTrackParticleContainerCnvTool::convertAndAugment
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.
Definition: RecTrackParticleContainerCnvTool.cxx:64
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
xAODMaker::RecTrackParticleContainerCnvTool::RecTrackParticleContainerCnvTool
RecTrackParticleContainerCnvTool(const std::string &type, const std::string &name, const IInterface *parent)
Regular AlgTool constructor.
Definition: RecTrackParticleContainerCnvTool.cxx:18
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
Rec::TrackParticleContainer
Definition: Reconstruction/Particle/Particle/TrackParticleContainer.h:33
Rec::TrackParticle
Definition: Reconstruction/Particle/Particle/TrackParticle.h:47
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
TrackParticle.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
RecTrackParticleContainerCnvTool.h
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAODMaker::RecTrackParticleContainerCnvTool::m_particleCreator
ToolHandle< Trk::ITrackParticleCreatorTool > m_particleCreator
Definition: RecTrackParticleContainerCnvTool.h:47
TrackParticleContainer.h
xAODMaker::RecTrackParticleContainerCnvTool::setParticleCreatorTool
virtual StatusCode setParticleCreatorTool(ToolHandle< Trk::ITrackParticleCreatorTool > *tool) override
allow other algorithms to pass the tool in order to preserve initialisation
Definition: RecTrackParticleContainerCnvTool.cxx:80
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
TrackParticleContainer.h