ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimOverlapRemovalTool Class Reference

Remove (mark) duplicate tracks This tool takes FPGATrackSimTrack as input and mark their status of passing/failing the overlap removal criteria. More...

#include <FPGATrackSimOverlapRemovalTool.h>

Inheritance diagram for FPGATrackSimOverlapRemovalTool:
Collaboration diagram for FPGATrackSimOverlapRemovalTool:

Public Member Functions

 FPGATrackSimOverlapRemovalTool (const std::string &, const std::string &, const IInterface *)
 FPGATrackSimOverlapRemovalTool ()=delete
StatusCode initialize () override
StatusCode runOverlapRemoval (std::vector< FPGATrackSimRoad > &roads)
StatusCode runOverlapRemoval (std::vector< FPGATrackSimTrack > &tracks)
void setDoSecondStage (bool v)
bool getDoSecondStage () const
ORAlgo getAlgorithm () const
StatusCode removeOverlapping (FPGATrackSimTrack &track1, FPGATrackSimTrack &track2)
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static bool compareTrackQuality (const FPGATrackSimTrack &track1, const FPGATrackSimTrack &track2)

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode runOverlapRemoval_fast (std::vector< FPGATrackSimTrack > &tracks)
StatusCode runOverlapRemoval_v2 (std::vector< FPGATrackSimTrack > &tracks)
int countOverlappingHits_v2 (const FPGATrackSimTrack &track1, const FPGATrackSimTrack &track2) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Static Private Member Functions

static bool compareTrackQuality_v2 (const FPGATrackSimTrack &track1, const FPGATrackSimTrack &track2)
static int countRealHits_v2 (const FPGATrackSimTrack &track)

Private Attributes

Gaudi::Property< bool > m_do2ndStage { this, "DoSecondStage", false, "Do second stage of not?"}
Gaudi::Property< int > m_NumOfHitPerGrouping { this, "NumOfHitPerGrouping", 5, "Number of hits pre grouping"}
Gaudi::Property< float > m_minChi2 { this, "MinChi2", 40, "Minimum chi2 requirement for tracks being considered in OR"}
Gaudi::Property< bool > m_roadSliceOR { this, "roadSliceOR", true, "Do slice-wise overlap removal for roads (Hough-only)"}
Gaudi::Property< int > m_localMaxWindowSize { this, "localMaxWindowSize", 0, "Only create roads that are a local maximum within this window size. Set this to 0 to turn off local max filtering"}
Gaudi::Property< unsigned > m_imageSize_x { this, "nBins_x", 0, "number of bins in, eg, phi_track"}
Gaudi::Property< unsigned > m_imageSize_y { this, "nBins_y", 0, "number of bins in, eg, q/pT"}
Gaudi::Property< std::string > m_algorithm { this, "ORAlgo", "Normal", "Overlap removal algorithm"}
Gaudi::Property< bool > m_doFastOR { this, "doFastOR", false, "Use fast overlap removal algorithm instead of default"}
Gaudi::Property< bool > m_compareAllHits {this, "compareAllHits", true, "Compare all hits to all other hits when comparing two tracks"}
Gaudi::Property< bool > m_useV2OR {this, "useV2OR", true, "Use v2 overlap removal algorithm (worst-to-best sorting)"}
ToolHandle< GenericMonitoringToolm_monTool {this,"MonTool", "", "Monitoring tool"}
ORAlgo m_algo {ORAlgo::Normal}
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Remove (mark) duplicate tracks This tool takes FPGATrackSimTrack as input and mark their status of passing/failing the overlap removal criteria.

Definition at line 35 of file FPGATrackSimOverlapRemovalTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ FPGATrackSimOverlapRemovalTool() [1/2]

FPGATrackSimOverlapRemovalTool::FPGATrackSimOverlapRemovalTool ( const std::string & algname,
const std::string & name,
const IInterface * ifc )

Definition at line 14 of file FPGATrackSimOverlapRemovalTool.cxx.

14 :
15 AthAlgTool(algname, name, ifc)
16{
17}
AthAlgTool()
Default constructor:

◆ FPGATrackSimOverlapRemovalTool() [2/2]

FPGATrackSimOverlapRemovalTool::FPGATrackSimOverlapRemovalTool ( )
delete

Member Function Documentation

◆ compareTrackQuality()

bool FPGATrackSimOverlapRemovalTool::compareTrackQuality ( const FPGATrackSimTrack & track1,
const FPGATrackSimTrack & track2 )
static

Definition at line 194 of file FPGATrackSimOverlapRemovalTool.cxx.

195{
196 std::vector<const FPGATrackSimHit*> hitsInTrack1;
197 for ( const auto& hit_ptr : track1.getFPGATrackSimHitPtrs()) {
198 if (!hit_ptr) throw std::runtime_error("Null hit pointer in countOverlappingHits_v2: tracks should not have unassigned layers");
199 if (hit_ptr->isReal()) hitsInTrack1.push_back(hit_ptr.get());
200 }
201
202 std::vector<const FPGATrackSimHit*> hitsInTrack2;
203 for ( const auto& hit_ptr: track2.getFPGATrackSimHitPtrs()){
204 if (!hit_ptr) throw std::runtime_error("Null hit pointer in countOverlappingHits_v2: tracks should not have unassigned layers");
205 if (hit_ptr->isReal()) hitsInTrack2.push_back(hit_ptr.get());
206 }
207
208 // If one track has more hits than the other, it's better.
209 // Return true if track 2 is better than track 1.
210 // Otherwise, decide based on chi2.
211 bool goodOrder = true;
212 if (hitsInTrack1.size() == hitsInTrack2.size()) {
213 // Surprising number of cases where the chi2 is actually identical.
214 // In these cases, let's default to the track ID number as the next most important property.
215 // So put it higher since we are considering later tracks to be better.
216 if (track1.getChi2ndof() == track2.getChi2ndof() && track1.getTrackID() < track2.getTrackID()) goodOrder = false;
217 // Now assuming they're different, we want them in decreasing chi2 order
218 else if (track1.getChi2ndof() < track2.getChi2ndof()) goodOrder = false;
219 } else if (hitsInTrack1.size() > hitsInTrack2.size()) {
220 goodOrder = false;
221 }
222
223 return goodOrder;
224
225}
const std::vector< std::shared_ptr< const FPGATrackSimHit > > & getFPGATrackSimHitPtrs() const
float getChi2ndof() const

◆ compareTrackQuality_v2()

bool FPGATrackSimOverlapRemovalTool::compareTrackQuality_v2 ( const FPGATrackSimTrack & track1,
const FPGATrackSimTrack & track2 )
staticprivate

Definition at line 277 of file FPGATrackSimOverlapRemovalTool.cxx.

278{
279 // Count real hits in each track
280 int nHits1 = countRealHits_v2(track1);
281 int nHits2 = countRealHits_v2(track2);
282
283 // Sort worst to best: fewer hits is worse, higher chi2 is worse
284 // Return true if track1 should come before track2 (i.e., track1 is worse)
285
286 // First compare number of hits
287 if (nHits1 != nHits2) {
288 return nHits1 < nHits2; // Fewer hits = worse
289 }
290
291 // Same number of hits: compare chi2 (higher is worse)
292 float chi2_1 = track1.getChi2ndof();
293 float chi2_2 = track2.getChi2ndof();
294
295 // Then compare chi2
296 if (std::abs(chi2_1 - chi2_2) > std::numeric_limits<float>::epsilon()) {
297 return chi2_1 > chi2_2; // Higher chi2 = worse
298 }
299
300 // Tie-breaker:
301 // in case of same number of hits and same chi2, use track ID (higher ID = worse)
302 return track1.getTrackID() > track2.getTrackID();
303}
static int countRealHits_v2(const FPGATrackSimTrack &track)

◆ countOverlappingHits_v2()

int FPGATrackSimOverlapRemovalTool::countOverlappingHits_v2 ( const FPGATrackSimTrack & track1,
const FPGATrackSimTrack & track2 ) const
private

Definition at line 315 of file FPGATrackSimOverlapRemovalTool.cxx.

316{
317 // Use the existing functions from FPGATrackSimHoughFunctions
318 if (m_compareAllHits) {
319 return findNCommonHitsGlobal(track1, track2);
320 } else {
321 return findNCommonHits(track1, track2);
322 }
323}
int findNCommonHitsGlobal(const FPGATrackSimTrack &Track1, const FPGATrackSimTrack &Track2)
int findNCommonHits(const FPGATrackSimTrack &Track1, const FPGATrackSimTrack &Track2)

◆ countRealHits_v2()

int FPGATrackSimOverlapRemovalTool::countRealHits_v2 ( const FPGATrackSimTrack & track)
staticprivate

Definition at line 305 of file FPGATrackSimOverlapRemovalTool.cxx.

306{
307 int nHits = 0;
308 for (const auto& hit_ptr : track.getFPGATrackSimHitPtrs()) {
309 if (!hit_ptr) throw std::runtime_error("Null hit pointer in countRealHits_v2: tracks should not have unassigned layers");
310 if (hit_ptr->isReal()) nHits++;
311 }
312 return nHits;
313}
static const uint32_t nHits

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getAlgorithm()

ORAlgo FPGATrackSimOverlapRemovalTool::getAlgorithm ( ) const
inline

◆ getDoSecondStage()

bool FPGATrackSimOverlapRemovalTool::getDoSecondStage ( ) const
inline

Definition at line 50 of file FPGATrackSimOverlapRemovalTool.h.

50{ return m_do2ndStage; }

◆ initialize()

StatusCode FPGATrackSimOverlapRemovalTool::initialize ( )
override

Definition at line 19 of file FPGATrackSimOverlapRemovalTool.cxx.

20{
21 ATH_MSG_INFO( "FPGATrackSimOverlapRemovalTool::initialize()" );
22
23 if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve());
24
25 // Check road OR
27 ATH_MSG_WARNING("LocalMaxOR only being run per hough slice (i.e. this tool does nothing) since roadSliceOR is turned off");
28
29
30 // Setup OR algorithm
31 if(m_algorithm == "Normal") m_algo=ORAlgo::Normal;
32 else if(m_algorithm == "Invert") m_algo=ORAlgo::InvertGrouping;
33 else
34 {
35 ATH_MSG_ERROR("initialize(): OR algorithm doesn't exist. ");
36 return StatusCode::FAILURE;
37 }
38 ATH_MSG_DEBUG("Overlap removal algorithm is "<<m_algorithm.value());
39
40 return StatusCode::SUCCESS;
41}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
ToolHandle< GenericMonitoringTool > m_monTool
Gaudi::Property< std::string > m_algorithm

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ removeOverlapping()

StatusCode FPGATrackSimOverlapRemovalTool::removeOverlapping ( FPGATrackSimTrack & track1,
FPGATrackSimTrack & track2 )

Definition at line 120 of file FPGATrackSimOverlapRemovalTool.cxx.

120 {
121
122 // Hit comparison
123 struct HitCompare {
124 bool operator()(const FPGATrackSimHit* a, const FPGATrackSimHit* b) const {
125 auto hash_a = a->getIdentifierHash();
126 auto hash_b = b->getIdentifierHash();
127 if ( hash_a == hash_b ) {
128 auto phi_a = a->getPhiIndex();
129 auto phi_b = b->getPhiIndex();
130 if ( phi_a == phi_b ) {
131 auto eta_a = a->getEtaIndex();
132 auto eta_b = b->getEtaIndex();
133 if ( eta_a == eta_b) {
134 auto layer_a = a->getPhysLayer();
135 auto layer_b = b->getPhysLayer();
136 return layer_a < layer_b;
137 }
138 return eta_a < eta_b;
139 }
140 return phi_a < phi_b;
141 }
142 return hash_a < hash_b;
143 }
144 };
145 std::set<const FPGATrackSimHit*, HitCompare > hitsInTrack1;
146 for ( const auto& hit_ptr : track1.getFPGATrackSimHitPtrs()) {
147 if (!hit_ptr) throw std::runtime_error("Null hit pointer in compareTrackQuality: tracks should not have unassigned layers");
148 if (hit_ptr->isReal()) hitsInTrack1.insert(hit_ptr.get());
149 }
150
151 std::set<const FPGATrackSimHit*, HitCompare> hitsInTrack2;
152 for ( const auto& hit_ptr: track2.getFPGATrackSimHitPtrs()){
153 if (!hit_ptr) throw std::runtime_error("Null hit pointer in compareTrackQuality: tracks should not have unassigned layers");
154 if (hit_ptr->isReal()) hitsInTrack2.insert(hit_ptr.get());
155 }
156
157 std::vector<const FPGATrackSimHit*> sharedHits;
158 std::set_intersection( hitsInTrack1.begin(), hitsInTrack1.end(),
159 hitsInTrack2.begin(), hitsInTrack2.end(),
160 std::back_inserter(sharedHits),
161 HitCompare() );
162
163 // Number of real hits in track 1, number of real hits in track 2, number of shared hits, number of non-shared hits (?)
164 int nHitsInTrack1 = hitsInTrack1.size();
165 int nHitsInTrack2 = hitsInTrack2.size();
166 int nSharedHits = sharedHits.size();
167 // Original version seems to be only track 1; I want to compare each pair only once so
168 // let's make this the most conservative option (i.e. smallest number) ?
169 int nonOverlappingHits = std::min(nHitsInTrack1 - nSharedHits, nHitsInTrack2 - nSharedHits);
170
171 // Now check if these pass our criteria for overlapping. If not, just return.
173 // Here decision is based on number of overlapping hits.
174 // Consider these overlapping if they share >= m_NumOfHitPerGrouping
175 if(nSharedHits < m_NumOfHitPerGrouping) return StatusCode::SUCCESS;
176
177 } else if(getAlgorithm() == ORAlgo::InvertGrouping) {
178 // This is the opposite: duplicates of number of unique hits is <= m_NumOfHitPerGrouping.
179 if(nonOverlappingHits > m_NumOfHitPerGrouping) return StatusCode::SUCCESS;
180
181 } else {
182 // Unknown.
183 return StatusCode::FAILURE;
184 }
185
186 // Made it here: these tracks are overlapping.
187 // But we already sorted them such that track 2 is the one
188 // we want to keep, so we can just set track 1 to be removed.
189 track1.setPassedOR(0);
190
191 return StatusCode::SUCCESS;
192}
static Double_t a
void setPassedOR(unsigned int)

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ runOverlapRemoval() [1/2]

StatusCode FPGATrackSimOverlapRemovalTool::runOverlapRemoval ( std::vector< FPGATrackSimRoad > & roads)

Definition at line 66 of file FPGATrackSimOverlapRemovalTool.cxx.

67{
68 if (roads.empty()) return StatusCode::SUCCESS;
69
70 if (!m_roadSliceOR) return StatusCode::SUCCESS;
71 size_t in = roads.size();
72
73 // Hough image
74 vector2D<FPGATrackSimRoad*> acc(m_imageSize_y, m_imageSize_x);
75
76 // Slice-wise duplicate removal: accept only one road (with most hits) per bin
77 for (auto &r: roads)
78 {
79 FPGATrackSimRoad* & old = acc(r.getYBin(), r.getXBin());
80 if (!old) old = new FPGATrackSimRoad (r);
81 else if (r.getNHitLayers() > old->getNHitLayers()) *old = r;
82 else if (r.getNHitLayers() == old->getNHitLayers() && r.getNHits() > old->getNHits()) *old = r;
83 }
84
85 // Reformat to vector
86 roads.clear();
87 for (unsigned y = 0; y < m_imageSize_y; y++)
88 for (unsigned x = 0; x < m_imageSize_x; x++)
89 if (FPGATrackSimRoad *tempPtr = acc(y, x); tempPtr && isLocalMax(acc, x, y, m_localMaxWindowSize)/*All-slices local max*/) {
90 roads.emplace_back(*tempPtr);
91 acc(y, x) = nullptr;
92 }
93 else {
94 delete acc(y,x);
95 acc(y,x) = nullptr;
96 }
97
98 ATH_MSG_DEBUG("Input: " << in << " Output: " << roads.size());
99 return StatusCode::SUCCESS;
100}
bool isLocalMax(vector2D< FPGATrackSimRoad * > const &acc, unsigned x, unsigned y, int localMaxWindowSize)
#define y
#define x
int r
Definition globals.cxx:22

◆ runOverlapRemoval() [2/2]

StatusCode FPGATrackSimOverlapRemovalTool::runOverlapRemoval ( std::vector< FPGATrackSimTrack > & tracks)

Definition at line 102 of file FPGATrackSimOverlapRemovalTool.cxx.

103{
104
105 // Do fast OR instead of requested
106 if (m_doFastOR) return runOverlapRemoval_fast(tracks);
107
108 // Otherwise, proceed
109 ATH_MSG_DEBUG("Beginning runOverlapRemoval()");
110
111 ATH_MSG_DEBUG("Tracks in event: " << tracks.size());
112
113
114 if (m_useV2OR)
115 return runOverlapRemoval_v2(tracks);
116 return ::runOverlapRemoval(tracks, m_minChi2.value(), m_NumOfHitPerGrouping, getAlgorithm(), m_monTool, m_compareAllHits);
117}
StatusCode runOverlapRemoval_v2(std::vector< FPGATrackSimTrack > &tracks)
StatusCode runOverlapRemoval_fast(std::vector< FPGATrackSimTrack > &tracks)

◆ runOverlapRemoval_fast()

StatusCode FPGATrackSimOverlapRemovalTool::runOverlapRemoval_fast ( std::vector< FPGATrackSimTrack > & tracks)
private

Definition at line 227 of file FPGATrackSimOverlapRemovalTool.cxx.

228{
229 ATH_MSG_DEBUG("Beginning fast overlap removal");
230
231 // Sort tracks in order of increasing quality.
232 // This way, once a track has been eliminated in a comparison, we don't
233 // need to check it against any other tracks - they will always be
234 // better than it.
235 std::sort(std::begin(tracks),
236 std::end(tracks),
238
239 // Now compare every pair of tracks.
240 // Set passedOR to 0 for the worst one (first one)
241 // if they are found to overlap.
242 for (unsigned int i=0; i < tracks.size(); i++) {
243
244 // Skip track i if bad chi2.
245 if (tracks.at(i).getChi2ndof() > m_minChi2.value()) {
246 tracks.at(i).setPassedOR(0);
247 continue;
248 }
249
250 // Now check against all other tracks.
251 for (unsigned int j=i+1; j< tracks.size(); j++) {
252
253 // Uniquely comparing tracks i and j here.
254
255 // If have set track i to 0 in a previous comparison,
256 // no need to look at it any more - we're done with it.
257 if (!tracks.at(i).passedOR()) break;
258
259 // Ignore j if its chi2 is bad.
260 if (tracks.at(j).getChi2ndof() > m_minChi2.value()) tracks.at(j).setPassedOR(0);
261
262 // If we just set track j to zero for bad chi2,
263 // no need to do the comparison.
264 if (!tracks.at(j).passedOR()) continue;
265
266 // If we're still here, two at least semi-decent tracks.
267 // Compare them and remove one if necessary.
268 ATH_CHECK(removeOverlapping(tracks.at(i),tracks.at(j)));
269
270 }
271 }
272
273 return StatusCode::SUCCESS;
274}
static bool compareTrackQuality(const FPGATrackSimTrack &track1, const FPGATrackSimTrack &track2)
StatusCode removeOverlapping(FPGATrackSimTrack &track1, FPGATrackSimTrack &track2)
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ runOverlapRemoval_v2()

StatusCode FPGATrackSimOverlapRemovalTool::runOverlapRemoval_v2 ( std::vector< FPGATrackSimTrack > & tracks)
private

Definition at line 325 of file FPGATrackSimOverlapRemovalTool.cxx.

326{
327 ATH_MSG_DEBUG("Beginning v2 overlap removal on " << tracks.size() << " tracks");
328
329 // First pass: mark tracks with bad chi2
330 for (auto& track : tracks) {
331 if (track.getChi2ndof() > m_minChi2.value()) {
332 track.setPassedOR(0);
333 }
334 }
335
336 // Sort tracks from worst to best quality using v2 comparison
337 // After sorting: index 0 = worst track (fewest hits, highest chi2)
338 // last index = best track (most hits, lowest chi2)
339 std::sort(tracks.begin(), tracks.end(), compareTrackQuality_v2);
340
341 // Process from worst to best
342 // For each track at index i, compare with better tracks (j > i)
343 // If overlap found, mark track i as rejected and move to next
344 for (size_t i = 0; i < tracks.size(); i++) {
345
346 // Skip if already rejected (bad chi2 or previous overlap)
347 if (!tracks[i].passedOR()) continue;
348
349 // Compare with all better tracks (j > i)
350 for (size_t j = i + 1; j < tracks.size(); j++) {
351
352 // Skip if track j already rejected
353 if (!tracks[j].passedOR()) continue;
354
355 // Count overlapping hits
356 int nOverlapping = countOverlappingHits_v2(tracks[i], tracks[j]);
357
358 // Check if tracks overlap based on algorithm
359 bool isOverlap = false;
360 if (m_algo == ORAlgo::Normal) {
361 isOverlap = (nOverlapping >= m_NumOfHitPerGrouping);
362 } else if (m_algo == ORAlgo::InvertGrouping) {
363 // For InvertGrouping: overlap if non-overlapping hits <= threshold
364 int nHits_i = countRealHits_v2(tracks[i]);
365 int nHits_j = countRealHits_v2(tracks[j]);
366 int nonOverlapping = std::min(nHits_i - nOverlapping, nHits_j - nOverlapping);
367 isOverlap = (nonOverlapping <= m_NumOfHitPerGrouping);
368 }
369
370 if (isOverlap) {
371 // Track i overlaps with better track j -> reject track i
372 tracks[i].setPassedOR(0);
373 ATH_MSG_DEBUG("Track " << i << " rejected due to overlap with better track " << j);
374
375 // No need to compare track i with any more tracks
376 break;
377 }
378 }
379 }
380
381 // Count survivors for monitoring
382 int nSurvivors = 0;
383 for (const auto& track : tracks) {
384 if (track.passedOR()) nSurvivors++;
385 }
386 ATH_MSG_DEBUG("V2 OR complete: " << nSurvivors << " tracks surviving out of " << tracks.size());
387
388 return StatusCode::SUCCESS;
389}
int countOverlappingHits_v2(const FPGATrackSimTrack &track1, const FPGATrackSimTrack &track2) const
static bool compareTrackQuality_v2(const FPGATrackSimTrack &track1, const FPGATrackSimTrack &track2)

◆ setDoSecondStage()

void FPGATrackSimOverlapRemovalTool::setDoSecondStage ( bool v)
inline

Definition at line 49 of file FPGATrackSimOverlapRemovalTool.h.

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_algo

ORAlgo FPGATrackSimOverlapRemovalTool::m_algo {ORAlgo::Normal}
private

Definition at line 73 of file FPGATrackSimOverlapRemovalTool.h.

73{ORAlgo::Normal}; // Internal ORAlgo enum for faster compare

◆ m_algorithm

Gaudi::Property<std::string> FPGATrackSimOverlapRemovalTool::m_algorithm { this, "ORAlgo", "Normal", "Overlap removal algorithm"}
private

Definition at line 67 of file FPGATrackSimOverlapRemovalTool.h.

67{ this, "ORAlgo", "Normal", "Overlap removal algorithm"};

◆ m_compareAllHits

Gaudi::Property<bool> FPGATrackSimOverlapRemovalTool::m_compareAllHits {this, "compareAllHits", true, "Compare all hits to all other hits when comparing two tracks"}
private

Definition at line 69 of file FPGATrackSimOverlapRemovalTool.h.

69{this, "compareAllHits", true, "Compare all hits to all other hits when comparing two tracks"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_do2ndStage

Gaudi::Property<bool> FPGATrackSimOverlapRemovalTool::m_do2ndStage { this, "DoSecondStage", false, "Do second stage of not?"}
private

Definition at line 60 of file FPGATrackSimOverlapRemovalTool.h.

60{ this, "DoSecondStage", false, "Do second stage of not?"};

◆ m_doFastOR

Gaudi::Property<bool> FPGATrackSimOverlapRemovalTool::m_doFastOR { this, "doFastOR", false, "Use fast overlap removal algorithm instead of default"}
private

Definition at line 68 of file FPGATrackSimOverlapRemovalTool.h.

68{ this, "doFastOR", false, "Use fast overlap removal algorithm instead of default"};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_imageSize_x

Gaudi::Property<unsigned> FPGATrackSimOverlapRemovalTool::m_imageSize_x { this, "nBins_x", 0, "number of bins in, eg, phi_track"}
private

Definition at line 65 of file FPGATrackSimOverlapRemovalTool.h.

65{ this, "nBins_x", 0, "number of bins in, eg, phi_track"};

◆ m_imageSize_y

Gaudi::Property<unsigned> FPGATrackSimOverlapRemovalTool::m_imageSize_y { this, "nBins_y", 0, "number of bins in, eg, q/pT"}
private

Definition at line 66 of file FPGATrackSimOverlapRemovalTool.h.

66{ this, "nBins_y", 0, "number of bins in, eg, q/pT"};

◆ m_localMaxWindowSize

Gaudi::Property<int> FPGATrackSimOverlapRemovalTool::m_localMaxWindowSize { this, "localMaxWindowSize", 0, "Only create roads that are a local maximum within this window size. Set this to 0 to turn off local max filtering"}
private

Definition at line 64 of file FPGATrackSimOverlapRemovalTool.h.

64{ this, "localMaxWindowSize", 0, "Only create roads that are a local maximum within this window size. Set this to 0 to turn off local max filtering"};

◆ m_minChi2

Gaudi::Property<float> FPGATrackSimOverlapRemovalTool::m_minChi2 { this, "MinChi2", 40, "Minimum chi2 requirement for tracks being considered in OR"}
private

Definition at line 62 of file FPGATrackSimOverlapRemovalTool.h.

62{ this, "MinChi2", 40, "Minimum chi2 requirement for tracks being considered in OR"};

◆ m_monTool

ToolHandle<GenericMonitoringTool> FPGATrackSimOverlapRemovalTool::m_monTool {this,"MonTool", "", "Monitoring tool"}
private

Definition at line 71 of file FPGATrackSimOverlapRemovalTool.h.

71{this,"MonTool", "", "Monitoring tool"};

◆ m_NumOfHitPerGrouping

Gaudi::Property<int> FPGATrackSimOverlapRemovalTool::m_NumOfHitPerGrouping { this, "NumOfHitPerGrouping", 5, "Number of hits pre grouping"}
private

Definition at line 61 of file FPGATrackSimOverlapRemovalTool.h.

61{ this, "NumOfHitPerGrouping", 5, "Number of hits pre grouping"};

◆ m_roadSliceOR

Gaudi::Property<bool> FPGATrackSimOverlapRemovalTool::m_roadSliceOR { this, "roadSliceOR", true, "Do slice-wise overlap removal for roads (Hough-only)"}
private

Definition at line 63 of file FPGATrackSimOverlapRemovalTool.h.

63{ this, "roadSliceOR", true, "Do slice-wise overlap removal for roads (Hough-only)"};

◆ m_useV2OR

Gaudi::Property<bool> FPGATrackSimOverlapRemovalTool::m_useV2OR {this, "useV2OR", true, "Use v2 overlap removal algorithm (worst-to-best sorting)"}
private

Definition at line 70 of file FPGATrackSimOverlapRemovalTool.h.

70{this, "useV2OR", true, "Use v2 overlap removal algorithm (worst-to-best sorting)"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: