CMS 3D CMS Logo

DTCombinatorialPatternReco.h
Go to the documentation of this file.
1 #ifndef DTSegment_DTCombinatorialPatternReco_h
2 #define DTSegment_DTCombinatorialPatternReco_h
3 
13 /* Base Class Headers */
15 #include <boost/unordered_set.hpp>
16 
17 /* Collaborating Class Declarations */
18 namespace edm {
19  class ParameterSet;
20  class EventSetup;
21  // class ESHandle;
22 } // namespace edm
23 class DTSegmentUpdator;
24 class DTSegmentCleaner;
25 class DTHitPairForFit;
26 class DTSegmentCand;
27 
28 /* C++ Headers */
29 #include <vector>
30 #include <deque>
31 #include <utility>
32 
36 
37 /* ====================================================================== */
38 
39 /* Class DTCombinatorialPatternReco Interface */
40 
42 public:
45 
47  ~DTCombinatorialPatternReco() override;
48 
49  /* Operations */
50 
52  edm::OwnVector<DTSLRecSegment2D> reconstruct(const DTSuperLayer* sl,
53  const std::vector<DTRecHit1DPair>& hits) override;
54 
56  std::string algoName() const override { return theAlgoName; }
57 
60  void setES(const edm::EventSetup& setup) override;
61 
62 protected:
63 private:
65 
66  // typedef std::pair<DTHitPairForFit*, DTEnums::DTCellSide> AssPoint;
67 
68  // create the DTHitPairForFit from the pairs for easy use
69  std::vector<std::shared_ptr<DTHitPairForFit>> initHits(const DTSuperLayer* sl,
70  const std::vector<DTRecHit1DPair>& hits);
71 
72  // search for candidate, starting from pairs of hits in different layers
73  std::vector<DTSegmentCand*> buildSegments(const DTSuperLayer* sl,
74  const std::vector<std::shared_ptr<DTHitPairForFit>>& hits);
75 
76  // find all the hits compatible with the candidate
77  std::vector<DTSegmentCand::AssPoint> findCompatibleHits(const LocalPoint& pos,
78  const LocalVector& dir,
79  const std::vector<std::shared_ptr<DTHitPairForFit>>& hits);
80 
81  // build segments from hits collection
82  DTSegmentCand* buildBestSegment(std::vector<DTSegmentCand::AssPoint>& assHits, const DTSuperLayer* sl);
83 
84  bool checkDoubleCandidates(std::vector<DTSegmentCand*>& segs, DTSegmentCand* seg);
85 
88  void buildPointsCollection(std::vector<DTSegmentCand::AssPoint>& points,
89  std::deque<std::shared_ptr<DTHitPairForFit>>& pointsNoLR,
90  std::vector<DTSegmentCand*>& candidates,
91  const DTSuperLayer* sl);
92 
93 private:
95  unsigned int theMaxAllowedHits;
98  bool debug;
99  bool usePairs;
100  DTSegmentUpdator* theUpdator; // the updator and fitter
101  DTSegmentCleaner* theCleaner; // the cleaner
102 
104 
105 public:
106  // The type must be public, as otherwise the global 'hash_value' function can't locate it
107  class TriedPattern {
108  public:
109  typedef std::vector<short unsigned int> values;
110 
111  // empty costructor
112  TriedPattern() : hash_(1) { values_.reserve(8); }
113 
114  // equality operator
115  bool operator==(const TriedPattern& other) const {
116  return (hash_ == other.hash_) && // cheap
117  (values_ == other.values_); // expensive last resort
118  }
119 
121  void push_back(short unsigned int i) {
122  boost::hash_combine(hash_, i);
123  values_.push_back(i);
124  }
127  size_t hash() const { return hash_; }
128 
129  // some extra methods to look like a std::vector
130  typedef values::const_iterator const_iterator;
131  const_iterator begin() const { return values_.begin(); }
132  const_iterator end() const { return values_.end(); }
133  values::size_type size() const { return values_.size(); }
134 
135  private:
136  values values_;
137  size_t hash_;
138  };
139  typedef boost::unordered_set<TriedPattern> TriedPatterns;
140 
141 private:
142  TriedPatterns theTriedPattern;
143 };
144 
145 inline std::size_t hash_value(const DTCombinatorialPatternReco::TriedPattern& t) { return t.hash(); }
146 #endif // DTSegment_DTCombinatorialPatternReco_h
bool operator==(const TriedPattern &other) const
uint16_t size_type
edm::ESHandle< DTGeometry > theDTGeometry
std::string algoName() const override
return the algo name
std::size_t hash_value(const DTCombinatorialPatternReco::TriedPattern &t)
void push_back(short unsigned int i)
push back value, and update the hash
boost::unordered_set< TriedPattern > TriedPatterns
HLT enums.