ATLAS Offline Software
CompareMuonSegmentKeys.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include <algorithm>
8 #include <iostream>
9 #include <sstream>
10 #include <vector>
11 
13 
15  const Muon::MuonSegmentKey& sk2,
16  bool ignoreTriggerHits) {
17  std::vector<std::pair<unsigned int, int> > intersection;
18  std::set_intersection(sk1.keys().begin(), sk1.keys().end(), sk2.keys().begin(), sk2.keys().end(), std::back_inserter(intersection));
20  segment1Size = sk1.keys().size();
21  segment2Size = sk2.keys().size();
22 
23  segment1SizeTrigger = sk1.keysTrigger().size();
24  segment2SizeTrigger = sk2.keysTrigger().size();
25  std::vector<std::pair<unsigned int, int> > intersectionTrig;
26  std::set_intersection(sk1.keysTrigger().begin(), sk1.keysTrigger().end(), sk2.keysTrigger().begin(), sk2.keysTrigger().end(),
27  std::back_inserter(intersectionTrig));
28  intersectionSizeTrigger = intersectionTrig.size();
29 
30  if (intersectionSize == 0) {
31  if (segment1Size == 0 && segment2Size == 0) {
33  // overlap between second segment and the intersection also includes all hits
34  // the two segments share all hits
36  return Identical;
38  return SuperSet;
39  } else {
40  return SubSet;
41  }
44  } else {
45  return PartialOverlap;
46  }
47  }
48  return NoOverlap;
49  } else {
50  // overlap between first segment and the intersection includes all hits
52  // overlap between second segment and the intersection also includes all hits
53  // the two segments share all hits
55  if (ignoreTriggerHits) return Identical;
56 
58  // overlap between second segment and the intersection also includes all hits
59  // the two segments share all hits
61  return Identical;
63  return SuperSet;
64  } else {
65  return SubSet;
66  }
69  } else {
70  return PartialOverlap;
71  }
72  } else if (segment2Size > intersectionSize) {
73  return SubSet;
74  }
75  } else if (segment2Size == intersectionSize) {
77  // the first segment has more hits and is better
78  return SuperSet;
79  }
80  } else {
81  return PartialOverlap;
82  }
83  }
85 }
86 
88  std::ostringstream sout;
89 
90  if (result == Identical)
91  sout << "Identical";
92  else if (result == SubSet)
93  sout << "SubSet";
94  else if (result == SuperSet)
95  sout << "SuperSet";
96  else if (result == PartialOverlap)
97  sout << "PartialOverlap";
98  else if (result == NoOverlap)
99  sout << "NoOverlap";
100  else if (result == Unknown)
101  sout << "Unknown";
102  else
103  sout << "UnknownType";
104  sout << " intersects (" << intersectionSize << "," << intersectionSizeTrigger << ") seg1 (" << segment1Size << ","
105  << segment1SizeTrigger << ") "
106  << " seg2 (" << segment2Size << "," << segment2SizeTrigger << ") ";
107  return sout.str();
108 }
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
get_generator_info.result
result
Definition: get_generator_info.py:21
Muon::CompareMuonSegmentKeys::PartialOverlap
@ PartialOverlap
Definition: CompareMuonSegmentKeys.h:20
Muon::CompareMuonSegmentKeys::SubSet
@ SubSet
Definition: CompareMuonSegmentKeys.h:18
Muon::CompareMuonSegmentKeys::operator()
OverlapResult operator()(const MuonSegmentKey &sk1, const MuonSegmentKey &sk2, bool ignoreTriggerHits=false)
calculate overlap between two SegmentKey2s, if ignoreTriggerHits == true trigger hits will not be inc...
Definition: CompareMuonSegmentKeys.cxx:14
Muon::MuonSegmentKey
Class to cache the identifiers on a segment in sets that can later be used to perform an overlap remo...
Definition: MuonSegmentKey.h:24
Muon::CompareMuonSegmentKeys::segment1SizeTrigger
unsigned int segment1SizeTrigger
Definition: CompareMuonSegmentKeys.h:36
intersection
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
Definition: compareFlatTrees.cxx:25
Muon::CompareMuonSegmentKeys::segment1Size
unsigned int segment1Size
Definition: CompareMuonSegmentKeys.h:33
Muon::CompareMuonSegmentKeys::intersectionSizeTrigger
unsigned int intersectionSizeTrigger
Definition: CompareMuonSegmentKeys.h:38
Muon::CompareMuonSegmentKeys::segment2SizeTrigger
unsigned int segment2SizeTrigger
Definition: CompareMuonSegmentKeys.h:37
Muon::CompareMuonSegmentKeys::OverlapResult
OverlapResult
enum for the overlap result
Definition: CompareMuonSegmentKeys.h:16
Muon::CompareMuonSegmentKeys::Identical
@ Identical
Definition: CompareMuonSegmentKeys.h:17
Muon::MuonSegmentKey::keys
const MeasurementKeys & keys() const
access to precision hit keys
Definition: MuonSegmentKey.h:59
Muon::CompareMuonSegmentKeys::segment2Size
unsigned int segment2Size
Definition: CompareMuonSegmentKeys.h:34
Muon::CompareMuonSegmentKeys::Unknown
@ Unknown
Definition: CompareMuonSegmentKeys.h:22
Muon::CompareMuonSegmentKeys::NoOverlap
@ NoOverlap
Definition: CompareMuonSegmentKeys.h:21
Muon::CompareMuonSegmentKeys::intersectionSize
unsigned int intersectionSize
Definition: CompareMuonSegmentKeys.h:32
Muon::CompareMuonSegmentKeys::print
std::string print(const OverlapResult &result) const
print result to string
Definition: CompareMuonSegmentKeys.cxx:87
Muon::MuonSegmentKey::keysTrigger
const MeasurementKeys & keysTrigger() const
access to trigger hit keys
Definition: MuonSegmentKey.h:57
Muon::CompareMuonSegmentKeys::SuperSet
@ SuperSet
Definition: CompareMuonSegmentKeys.h:19
set_intersection
Set * set_intersection(Set *set1, Set *set2)
Perform an intersection of two sets.
CompareMuonSegmentKeys.h
MuonSegmentKey.h