ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_StandaloneTrackFinder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// Implementation file for class InDet::TRT_StandaloneTrackFinder
8// (c) ATLAS Detector software
11// Version 1.0 09/28/2007 Thomas Koffas
12// update by Markus Elsing
14
19
22
24// Constructor
26
28(const std::string& name, ISvcLocator* pSvcLocator)
29 : AthReentrantAlgorithm(name, pSvcLocator)
30{ }
31
33= default;
34
36// Initialisation
38
40{
41 m_total = {};
42
43 ATH_CHECK(m_segToTrackTool.retrieve());
44
45 ATH_CHECK(m_Segments.initialize());
46 ATH_CHECK(m_prdToTrackMap.initialize(!m_prdToTrackMap.key().empty()));
47 ATH_CHECK(m_finalTracks.initialize());
48
49 return StatusCode::SUCCESS;
50}
51
53// Execute
55StatusCode InDet::TRT_StandaloneTrackFinder::execute(const EventContext& ctx) const
56{
57
58 Counter_t counter {};
60
62 //
63
65 if(!segments.isValid()){
66 ATH_MSG_FATAL ("No segment with name " << m_Segments.key() << " found in StoreGate!");
67 return StatusCode::FAILURE;
68 }
69
71 const Trk::PRDtoTrackMap *prd_to_track_map_cptr = nullptr;
72 if (!m_prdToTrackMap.key().empty()) {
74 if(!prd_to_track_map.isValid()){
75 ATH_MSG_FATAL ("Failed to get " << m_prdToTrackMap.key() << ".");
76 return StatusCode::FAILURE;
77 }
78 prd_to_track_map_cptr = prd_to_track_map.cptr();
79 }
80
81 // statistics...
82 counter[kNTrtSeg] = int(segments->size());
83 ATH_MSG_DEBUG ("TRT track container size " << counter[kNTrtSeg]);
84 ATH_MSG_DEBUG ("Begin looping over all TRT segments in the event");
85 for(const Trk::Segment *base_segment: *segments) {
86
87 // Get the track segment
88 const Trk::TrackSegment *trackTRT = dynamic_cast<const Trk::TrackSegment*>(base_segment);
89
90 if(!trackTRT) {
91
92 ATH_MSG_WARNING ("No pointer to segment, should not happen !");
93 continue;
94
95 } else {
96
97 ATH_MSG_DEBUG ("--> start evaluating new segment");
98
99 // start with pt preselection, get the segment parameters
100 const Amg::VectorX& p = trackTRT->localParameters();
101 if ( std::abs(sin(p(3))/p(4)) < m_minPt*0.9 ) {
102 // Statistics...
103 counter[kNRejectedSeg]++;
104 ATH_MSG_DEBUG ("Segment pt = " << std::abs(sin(p(3))/p(4)) << " , fails pre-cut, drop it !");
105 continue;
106 }
107
108 // Check if segment has already been assigned to a BackTrack
109 if(m_segToTrackTool->segIsUsed(*trackTRT, prd_to_track_map_cptr)) {
110 // Statistics...
111 counter[kNUsedSeg]++;
112 ATH_MSG_DEBUG ("Segment excluded by BackTrack, drop it !");
113 continue;
114 }
115
116 // Get the number of the TRT track segment ROTs
117 int nROTs = trackTRT->numberOfMeasurementBases();
118 ATH_MSG_DEBUG ("Number Of ROTs " << nROTs);
119
120 bool is_toLower = false; // to handle special case
121
122 // Cases where the min number of required TRT drift circles drops to 10
123 if(nROTs <= m_minNumDriftCircles && m_oldLogic) {
124 ATH_MSG_DEBUG ("Few DCs, can we recover ?");
125
126 is_toLower = m_segToTrackTool->toLower(*trackTRT);
127 if (is_toLower) {
128 ATH_MSG_DEBUG ("We recovered this one, let's try...");
129 }
130 }
131
132 if(nROTs < m_minNumDriftCircles && !is_toLower) {
133 // statistics...
134 counter[kNRejectedSeg]++;
135 ATH_MSG_DEBUG ("Segment fails number of DC requirements, reject it");
136 }
137 else {
138 // statistics
139 counter[kNTrtSegGood]++;
140 ATH_MSG_DEBUG ("Segment considered for further processing, enter into list");
141
142 // Transform the original TRT segment into a track
143 Trk::Track* trtSeg = m_segToTrackTool->segToTrack(ctx, *trackTRT);
144 if(!trtSeg){
145 // Statistics...
146 counter[kNSegFailed]++;
147 ATH_MSG_DEBUG ("Failed to make a track out of the TRT segment!");
148 continue;
149 }
150
151 // get all TSOS
153 if((int)ttsos->size()<10) {
154 // Statistics...
155 counter[kNSegFailed]++;
156 ATH_MSG_DEBUG ("Too few ROTs on track, reject !");
157 delete trtSeg;
158 continue;
159 }
160 // add the track to list
161 m_segToTrackTool->addNewTrack(trtSeg,event_data);
162 }
163 }
164 }
165
166 // now resolve tracks
167 ATH_MSG_DEBUG ("Creating track container ");
168
169 std::unique_ptr<TrackCollection> final_tracks(m_segToTrackTool->resolveTracks(prd_to_track_map.cptr(),event_data));
170 if (!final_tracks || SG::WriteHandle<TrackCollection>(m_finalTracks,ctx).record(std::move(final_tracks)).isFailure()) {
171 ATH_MSG_WARNING ("Could not save the reconstructed TRT seeded Si tracks!");
172 return StatusCode::FAILURE;
173 }
174
175 // Update the total counters
179 {
180 std::lock_guard<std::mutex> lock(m_statMutex);
181 for (int idx=0; idx< kNCounter; ++idx) {
182 m_total[idx]+=counter[idx];
183 }
184 }
185
186 // Print common event information
187 ATH_MSG_DEBUG( counter << std::endl );
188
189 return StatusCode::SUCCESS;
190}
191
193// Finalize
195
197{
198 ATH_MSG_DEBUG( m_total << std::endl );
199 return StatusCode::SUCCESS;
200}
201
203// Dumps relevant information into the MsgStream
205
206MsgStream& InDet::TRT_StandaloneTrackFinder::dump( MsgStream& out ) const
207{
208 // out<<std::endl;
209
210 return dumpContainerNames(out);
211}
212
213
215 out<<"| counters |" << counter << std::endl;
216 return out;
217}
218
219
220
222// Dumps conditions information into the MsgStream
224
226{
227 const std::string::size_type max_width =65;
228
229 out<<std::endl
230 <<"|----------------------------------------------------------------------"
231 <<"-------------------|"<<std::endl;
232 out<<"| Location of input tracks | "<<m_Segments.key() << std::setw( max_width-m_Segments.key().size())<< " " << "|" <<std::endl;
233 out<<"| Location of output tracks | "<<m_finalTracks.key() << std::setw( max_width-m_finalTracks.key().size()) << " " << "|" <<std::endl;
234 out<<"|----------------------------------------------------------------------"
235 <<"-------------------|";
236 return out;
237}
238
240// Dumps event information into the MsgStream
242
243MsgStream& InDet::operator<<( MsgStream& out, const InDet::TRT_StandaloneTrackFinder::Counter_t &counter)
244{
245out<<std::endl
246 <<"|-------------------------------------------------------------------|" <<std::endl;
247 out<<"| Investigated |" <<std::endl;
248 out<<"| "<<std::setw(7)<<counter[InDet::TRT_StandaloneTrackFinder::kNTrtSeg] <<" input TRT segments to be investigated" <<std::endl;
249 out<<"| "<<std::setw(7)<<counter[InDet::TRT_StandaloneTrackFinder::kNUsedSeg] <<" TRT segments excluded at input (by BackTracking tracks)" <<std::endl;
250 out<<"| "<<std::setw(7)<<counter[InDet::TRT_StandaloneTrackFinder::kNRejectedSeg] <<" segments rejected in selection at input" <<std::endl;
251 out<<"|-------------------------------------------------------------------|" <<std::endl;
252 out<<"| "<<std::setw(7)<<counter[InDet::TRT_StandaloneTrackFinder::kNTrtSegGood] <<" input TRT segments after cuts" <<std::endl;
253 out<<"| "<<std::setw(7)<<counter[InDet::TRT_StandaloneTrackFinder::kNSegFailed] <<" segments failing to translate to a track (including refit)" <<std::endl;
254 out<<"| "<<std::setw(7)<<counter[InDet::TRT_StandaloneTrackFinder::kNTrkScoreZeroTotal] <<" tracks rejected by score zero" <<std::endl;
255 out<<"| "<<std::setw(7)<<counter[InDet::TRT_StandaloneTrackFinder::kNTrkSegUsedTotal] <<" excluded segments by other TRT segment" <<std::endl;
256 out<<"| "<<std::setw(7)<<counter[InDet::TRT_StandaloneTrackFinder::kNTRTTrkTotal] <<" TRT-only tracks on output" <<std::endl;
257 out<<"|-------------------------------------------------------------------|";
258 return out;
259}
260
261
263// Overload of << operator MsgStream
265
266MsgStream& operator<<(MsgStream& sl, const InDet::TRT_StandaloneTrackFinder& se)
267{
268 return se.dump(sl);
269}
270
271
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
Derived DataVector<T>.
Definition DataVector.h:795
size_type size() const noexcept
Returns the number of elements in the collection.
InDet::TRT_StandaloneTrackFinde is an algorithm which produces tracks from stand-alone TRT segments w...
static MsgStream & dumpevent(MsgStream &, const InDet::TRT_StandaloneTrackFinder::Counter_t &)
StatusCode execute(const EventContext &ctx) const
SG::ReadHandleKey< Trk::SegmentCollection > m_Segments
TRT segments to use.
MsgStream & dumpContainerNames(MsgStream &out) const
@ kNUsedSeg
Number of TRT segments excluded at input (by BackTracking tracks)
@ kNSegFailed
Number of segments failing to translate to a track (inclusing refit)
@ kNTrtSeg
Number of input TRT segments to be investigated per event.
@ kNTRTTrkTotal
Number of TRT-only tracks on output.
@ kNRejectedSeg
Number of segments rejected in selection at input.
@ kNTrkSegUsedTotal
Number of excluded segments by other TRT segments.
@ kNTrkScoreZeroTotal
Number of tracks rejected by score zero.
@ kNTrtSegGood
Number of input TRT segments after cuts per event.
MsgStream & dump(MsgStream &out) const
Print internal tool parameters and status.
SG::WriteHandleKey< TrackCollection > m_finalTracks
Tracks that will be passed out of AmbiProcessor.
SG::ReadHandleKey< Trk::PRDtoTrackMap > m_prdToTrackMap
map between PRDs and tracks to identify shared hits.
ToolHandle< ITRT_SegmentToTrackTool > m_segToTrackTool
Segment to track tool.
TRT_StandaloneTrackFinder(const std::string &name, ISvcLocator *pSvcLocator)
Standard Algotithm methods.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Base class for all TrackSegment implementations, extends the common MeasurementBase.
unsigned int numberOfMeasurementBases() const
Return the number of contained Trk::MeasurementBase (s)
Class for a generic track segment that holdes polymorphic Trk::MeasurementBase objects,...
const DataVector< const MeasurementBase > * measurementsOnTrack() const
return a pointer to a vector of MeasurementBase (NOT including any that come from outliers).
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
MsgStream & operator<<(MsgStream &, const GNNTrackFinderTritonTool &)
@ knTRTTrk
Number of TRT-only tracks on output.
@ knTrkSegUsed
Number of excluded segments by other TRT segments.
@ knTrkScoreZero
Number of tracks rejected by score zero.