16 declareInterface<IMuonSegmentOverlapRemovalTool>(
this);
24 return StatusCode::SUCCESS;
33 std::vector<std::pair<MuonSegmentKey, MuonSegment*>> goodSegments;
34 goodSegments.reserve(segments.
size());
35 std::vector<MuonSegment*> segmentsToErase;
50 bool insertAsGood =
true;
53 for (std::pair<MuonSegmentKey, MuonSegment*>& good_seg : goodSegments) {
59 double chi2good = fq1 ? fq1->
chiSquared() : 1e10;
60 double chi2current = fq2 ? fq2->
chiSquared() : 1e10;
62 if (chi2good > chi2current) {
67 segmentsToErase.push_back(good_seg.second);
69 good_seg.second = seg;
73 segmentsToErase.push_back(seg);
80 segmentsToErase.push_back(seg);
87 segmentsToErase.push_back(good_seg.second);
89 good_seg.second = seg;
102 segmentsToErase.push_back(good_seg.second);
104 good_seg.second = seg;
105 insertAsGood =
false;
113 segmentsToErase.push_back(seg);
114 insertAsGood =
false;
120 segmentsToErase.push_back(good_seg.second);
122 good_seg.second = seg;
123 insertAsGood =
false;
132 segmentsToErase.push_back(seg);
133 insertAsGood =
false;
140 segmentsToErase.push_back(seg);
142 insertAsGood =
false;
148 ATH_MSG_WARNING(
" Got invalid return argument comparing segments: " << compareSegmentKeys.
print(overlapResult));
156 goodSegments.emplace_back(std::move(sk), seg);
165 if (to_erase ==
dynamic_cast<MuonSegment*
>(tseg)) {
175 std::set<MuonSegment*> segmentsToBeKept;
176 unsigned int nsegments = 0;
180 ATH_MSG_DEBUG(
" removing duplicate from MuonSegmentCombination with " << nstations <<
" stations");
184 for (
unsigned int i = 0; i < nstations; ++i) {
189 if (!stationSegs || stationSegs->empty())
continue;
191 nsegments += stationSegs->size();
195 segmentsToBeKept.insert(cleanedSegments.begin(), cleanedSegments.end());
199 if (nsegments == segmentsToBeKept.size()) {
204 std::unique_ptr<MuonSegmentCombination> newCombi = std::make_unique<MuonSegmentCombination>();
207 for (
unsigned int i = 0; i < nstations; ++i) {
212 if (!stationSegs || stationSegs->empty())
continue;
214 std::unique_ptr<std::vector<std::unique_ptr<MuonSegment>>> segVec =
215 std::make_unique<std::vector<std::unique_ptr<MuonSegment>>>();
216 segVec->reserve(stationSegs->size());
219 for (
const std::unique_ptr<MuonSegment>& seg : *stationSegs) {
220 if (!segmentsToBeKept.count(seg.get())) {
223 segVec->emplace_back(seg->clone());
227 if (!segVec->empty()) newCombi->addSegments(std::move(segVec));
230 ATH_MSG_DEBUG(
" removed " << nsegments - segmentsToBeKept.size() <<
" duplicates, new size " << segmentsToBeKept.size());
239 ATH_MSG_DEBUG(
" working on segment vector of size " << segments.size());
244 std::vector<std::pair<MuonSegmentKey, MuonSegment*>> goodSegments;
245 goodSegments.reserve(segments.size());
248 for (
const std::unique_ptr<MuonSegment>& seg : segments) {
255 bool insertAsGood(
true);
258 for (std::pair<MuonSegmentKey, MuonSegment*>& good_seg : goodSegments) {
264 double chi2good = fq1 ? fq1->
chiSquared() : 1e10;
265 double chi2current = fq2 ? fq2->
chiSquared() : 1e10;
267 if (chi2good > chi2current) {
273 good_seg.second = seg.get();
277 insertAsGood =
false;
282 insertAsGood =
false;
289 good_seg.second = seg.get();
290 insertAsGood =
false;
303 good_seg.second = seg.get();
310 insertAsGood =
false;
317 good_seg.second = seg.get();
318 insertAsGood =
false;
327 insertAsGood =
false;
335 insertAsGood =
false;
341 ATH_MSG_WARNING(
" Got invalid return argument comparing segments: " << compareSegmentKeys.
print(overlapResult));
349 goodSegments.emplace_back(sk, seg.get());
354 for (
const std::pair<MuonSegmentKey, MuonSegment*>& good_seg : goodSegments) { cleanedSegments.push_back(good_seg.second); }
355 ATH_MSG_DEBUG(
" Segments after removal " << cleanedSegments.size() <<
" total number of removed segments "
356 << segments.size() - cleanedSegments.size());
358 return cleanedSegments;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
DataModel_detail::iterator< DataVector > iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
iterator erase(iterator position)
Remove element at a given position.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
Class to hold a set of MuonSegments belonging together.
std::vector< std::unique_ptr< MuonSegment > > SegmentVec
SegmentVec * stationSegments(unsigned int index) const
Access to segments in a given station.
unsigned int numberOfStations() const
Number of stations with segment.
Class to cache the identifiers on a segment in sets that can later be used to perform an overlap remo...
This is the common class for 3D segments used in the muon spectrometer.
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
double chiSquared() const
returns the of the overall track fit
Base class for all TrackSegment implementations, extends the common MeasurementBase.
const FitQuality * fitQuality() const
return the FitQuality object, returns NULL if no FitQuality is defined
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
DataVector< Trk::Segment > SegmentCollection
unsigned int intersectionSize
unsigned int segment1Size
std::string print(const OverlapResult &result) const
print result to string
OverlapResult
enum for the overlap result
unsigned int segment2SizeTrigger
unsigned int segment2Size
unsigned int segment1SizeTrigger