ATLAS Offline Software
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
10 #include "StoreGate/ReadHandle.h"
11 #include "StoreGate/WriteHandle.h"
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() );
33 
34  return StatusCode::SUCCESS;
35 }
36 
38 // Execute
40 
41 StatusCode InDet::TRT_TrackExtensionAlg::execute(const EventContext& ctx) const {
42 
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)) {
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 
102 MsgStream& 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 }
used
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
WriteHandle.h
Handle class for recording to StoreGate.
InDet::TRT_TrackExtensionAlg::execute
StatusCode execute(const EventContext &ctx) const
Definition: TRT_TrackExtensionAlg.cxx:41
python.TrigInDetConfig.inputTracks
inputTracks
Definition: TrigInDetConfig.py:183
lumiFormat.i
int i
Definition: lumiFormat.py:85
InDet::TRT_TrackExtensionAlg::Counter_t
Definition: TRT_TrackExtensionAlg.h:62
beamspotman.n
n
Definition: beamspotman.py:731
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
InDet::TRT_TrackExtensionAlg::m_trtExtension
ToolHandle< ITRT_TrackExtensionTool > m_trtExtension
Definition: TRT_TrackExtensionAlg.h:74
TrackCollection.h
TRT_TrackExtensionAlg.h
InDet::TRT_TrackExtensionAlg::TRT_TrackExtensionAlg
TRT_TrackExtensionAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TRT_TrackExtensionAlg.cxx:18
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
InDet::TRT_TrackExtensionAlg::dumpEvent
static MsgStream & dumpEvent(MsgStream &out, const Counter_t &counter)
Definition: TRT_TrackExtensionAlg.cxx:129
ReadCellNoiseFromCoolCompare.s3
s3
Definition: ReadCellNoiseFromCoolCompare.py:380
TrackExtensionMap.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
InDet::TRT_TrackExtensionAlg::m_outputTracksKey
SG::WriteHandleKey< TrackExtensionMap > m_outputTracksKey
Definition: TRT_TrackExtensionAlg.h:78
InDet::TRT_TrackExtensionAlg::finalize
StatusCode finalize()
Definition: TRT_TrackExtensionAlg.cxx:89
InDet::TRT_TrackExtensionAlg::m_inputTracksKey
SG::ReadHandleKey< TrackCollection > m_inputTracksKey
Definition: TRT_TrackExtensionAlg.h:77
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
InDet::TRT_TrackExtensionAlg::dumpConditions
MsgStream & dumpConditions(MsgStream &out) const
Definition: TRT_TrackExtensionAlg.cxx:102
DEBUG
#define DEBUG
Definition: page_access.h:11
ReadCellNoiseFromCoolCompare.s2
s2
Definition: ReadCellNoiseFromCoolCompare.py:379
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
ReadHandle.h
Handle class for reading from StoreGate.
test_pyathena.counter
counter
Definition: test_pyathena.py:15
InDet::TRT_TrackExtensionAlg::initialize
StatusCode initialize()
Definition: TRT_TrackExtensionAlg.cxx:26