ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_TrackExtensionAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9// Store gate handles
12
14// Constructor
16
18(const std::string& name,ISvcLocator* pSvcLocator) :
19 AthReentrantAlgorithm(name, pSvcLocator) {
20}
21
23// Initialisation
25
27 // Get tool for track ectension to TRT
28
29 ATH_CHECK(m_trtExtension.retrieve());
30
31 ATH_CHECK( m_inputTracksKey.initialize() );
32 ATH_CHECK( m_outputTracksKey.initialize() );
33
34 return StatusCode::SUCCESS;
35}
36
38// Execute
40
41StatusCode InDet::TRT_TrackExtensionAlg::execute(const EventContext& ctx) const {
42
43 Counter_t counter;
44 // Get input tracks collection
46 if (not inputTracks.isValid()) {
47 ATH_MSG_DEBUG("Could not find input track collection " << m_inputTracksKey);
48 return StatusCode::SUCCESS;
49 }
50
51 std::unique_ptr<InDet::ITRT_TrackExtensionTool::IEventData>
52 event_data_p( m_trtExtension->newEvent(ctx) );
53
54 // Loop through all input track and output tracks collection production
56 ATH_CHECK( outputTracks.record(std::make_unique<TrackExtensionMap>()) );
57
58 TrackCollection::const_iterator trk,trkEnd = inputTracks->end();
59 //We create this structure outside the loop,
60 //the vectors are cleared/resized inside the loop but
61 //we try to "retain capacity"
63 for (trk = inputTracks->begin(); trk != trkEnd; ++trk) {
64 if ( !(*trk) ) continue;
65 ++counter.m_nTracks;
66
67 std::vector<const Trk::MeasurementBase*>& trkExt = m_trtExtension->extendTrack(ctx, *(*trk), *event_data_p,used);
68 if( trkExt.empty() ) {continue;}
69 outputTracks->insert( std::make_pair((*trk), trkExt) );
70 ++counter.m_nTracksExtended;
71 }
72
73 {
74 std::lock_guard<std::mutex> lock(m_counterMutex);
75 m_totalCounts += counter;
76 }
77
78 if (msgLvl(MSG::DEBUG)) {
79 dumpEvent(msg(MSG::DEBUG), counter);
80 msg(MSG::DEBUG) << endmsg;
81 }
82 return StatusCode::SUCCESS;
83}
84
86// Finalize
88
90 if (msgLvl(MSG::INFO)) {
91 dumpEvent(msg(MSG::INFO), m_totalCounts);
92 dumpConditions(msg(MSG::INFO));
93 }
94 return StatusCode::SUCCESS;
95}
96
97
99// Dumps conditions information into the MsgStream
101
102MsgStream& InDet::TRT_TrackExtensionAlg::dumpConditions( MsgStream& out ) const {
103 int n = 65-m_trtExtension.type().size();
104 std::string s1; for(int i=0; i<n; ++i) s1.append(" "); s1.append("|");
105 n = 65-m_inputTracksKey.key().size();
106 std::string s2; for(int i=0; i<n; ++i) s2.append(" "); s2.append("|");
107 n = 65-m_outputTracksKey.key().size();
108 std::string s3; for(int i=0; i<n; ++i) s3.append(" "); s3.append("|");
109
110 out<<"|----------------------------------------------------------------"
111 <<"----------------------------------------------------|"
112 <<std::endl;
113 out<<"| Tool for tracks extension to TRT | "<<m_trtExtension.type()
114 <<s1<<std::endl;
115 out<<"| Location of input tracks | "<<m_inputTracksKey.key()
116 <<s2<<std::endl;
117 out<<"| Extended tracks location | "<<m_outputTracksKey.key()
118 <<s3<<std::endl;
119 out<<"|----------------------------------------------------------------"
120 <<"----------------------------------------------------|"
121 <<std::endl;
122 return out;
123}
124
126// Dumps event information into the ostream
128
130
131 out<<"|-------------------------------------------------------------------";
132 out<<"-----------------------------|"
133 <<std::endl;
134 out<<"| Investigated "
135 <<std::setw(7)<< counter.m_nTracks <<" input tracks and extended "
136 <<std::setw(7)<< counter.m_nTracksExtended <<" tracks |"
137 <<std::endl;
138 out<<"|-------------------------------------------------------------------";
139 out<<"-----------------------------|"
140 <<std::endl;
141 return out;
142}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
bool msgLvl(const MSG::Level lvl) const
An algorithm that can be simultaneously executed in multiple threads.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
static MsgStream & dumpEvent(MsgStream &out, const Counter_t &counter)
MsgStream & dumpConditions(MsgStream &out) const
TRT_TrackExtensionAlg(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode execute(const EventContext &ctx) const
SG::ReadHandleKey< TrackCollection > m_inputTracksKey
SG::WriteHandleKey< TrackExtensionMap > m_outputTracksKey
ToolHandle< ITRT_TrackExtensionTool > m_trtExtension
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
holding In fact this class is here in order to allow STL container for all features This class is sho...