ATLAS Offline Software
TrackCollectionProvider.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 namespace Trk {
8 
9  //________________________________________________________________________
11  const std::string& name,
12  const IInterface* parent)
13 
15  , m_nRetrievalErrors(0)
16  {
17 
18  declareInterface<ITrackCollectionProvider>(this);
19 
20  declareProperty("InputTrkCol", m_inputCol="MooreTracks");
21 
22  declareProperty("MaxRetrievalErrors", m_maxRetrievalErrors = 10);
23 
24  }
25 
26  //________________________________________________________________________
28  = default;
29 
30  //________________________________________________________________________
32  {
33  return StatusCode::SUCCESS;
34  }
35 
36  //________________________________________________________________________
38  {
39  return StatusCode::SUCCESS;
40  }
41 
42 
43  //________________________________________________________________________
45  {
46  ATH_MSG_DEBUG("in TrackCollectionProvider::trackCollection");
47 
48  originalTracks=nullptr;
49 
50  // check if m_inputCol is a TrackCollection and exists for this event
51  // perhaps this can be done in a much nicer way on the python side ala PyUtils/checkFile.py
52  // do it here for now
53  if( !evtStore()->contains<TrackCollection>(m_inputCol) ||
54  evtStore()->retrieve(originalTracks,m_inputCol).isFailure() ) {
55 
56  originalTracks=nullptr;
57 
58  ATH_MSG_DEBUG("input track collection \'"<<m_inputCol<<"\' not found for this event");
59 
60  if(m_maxRetrievalErrors>=0) {
63  msg(MSG::FATAL)<<"Input track collection \'"<<m_inputCol<<"\' not found in first "
64  <<m_nRetrievalErrors<<" events. Aborting."<<endmsg;
65  msg(MSG::FATAL)<<"Maximum allowed number of events without the track collection "
66  <<"can be changed using the \'MaxRetrievalErrors\' option (-1 for infinite)."
67  <<endmsg;
68  return StatusCode::FAILURE;
69  }
70  }
71  return StatusCode::SUCCESS;
72  }
73  ATH_MSG_DEBUG("found "<<originalTracks->size()<<" tracks");
74 
75  // if we're here it means that the track collection m_inputCol exists in the file
76  // (it can be empty) so we change the error cutoff to process the whole file
79 
80  return StatusCode::SUCCESS;
81  }
82 
83 } // end namespace
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
Trk::TrackCollectionProvider::~TrackCollectionProvider
virtual ~TrackCollectionProvider()
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
Trk::TrackCollectionProvider::trackCollection
StatusCode trackCollection(const TrackCollection *&tracks)
Definition: TrackCollectionProvider.cxx:44
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trk::TrackCollectionProvider::m_inputCol
std::string m_inputCol
Name of input track collection.
Definition: TrackCollectionProvider.h:37
TrackCollectionProvider.h
Trk::TrackCollectionProvider::m_nRetrievalErrors
int m_nRetrievalErrors
number of retrieval errors at the beginning of the job
Definition: TrackCollectionProvider.h:39
Trk::TrackCollectionProvider::initialize
StatusCode initialize()
Definition: TrackCollectionProvider.cxx:31
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
Trk::TrackCollectionProvider::finalize
StatusCode finalize()
Definition: TrackCollectionProvider.cxx:37
test_pyathena.parent
parent
Definition: test_pyathena.py:15
DataVector< Trk::Track >
Trk::TrackCollectionProvider::m_maxRetrievalErrors
int m_maxRetrievalErrors
maximum allowed number of retrieval errors at the beginning of the job (-1 for infinite)
Definition: TrackCollectionProvider.h:40
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
Trk::TrackCollectionProvider::TrackCollectionProvider
TrackCollectionProvider(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TrackCollectionProvider.cxx:10
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.