File indexing completed on 2023-03-17 11:19:18
0001 #ifndef DTSegment_DTCombinatorialPatternReco_h
0002 #define DTSegment_DTCombinatorialPatternReco_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "RecoLocalMuon/DTSegment/src/DTRecSegment2DBaseAlgo.h"
0015 #include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
0016
0017
0018 namespace edm {
0019 class ParameterSet;
0020 class EventSetup;
0021
0022 }
0023 class DTSegmentUpdator;
0024 class DTSegmentCleaner;
0025 class DTHitPairForFit;
0026 class DTSegmentCand;
0027 class MuonGeometryRecord;
0028
0029
0030 #include <deque>
0031 #include <functional>
0032 #include <unordered_set>
0033 #include <utility>
0034 #include <vector>
0035
0036 #include "Geometry/DTGeometry/interface/DTGeometry.h"
0037 #include "FWCore/Framework/interface/ESHandle.h"
0038 #include "FWCore/Utilities/interface/ESGetToken.h"
0039 #include "RecoLocalMuon/DTSegment/src/DTSegmentCand.h"
0040
0041
0042
0043
0044
0045 class DTCombinatorialPatternReco : public DTRecSegment2DBaseAlgo {
0046 public:
0047
0048 DTCombinatorialPatternReco(const edm::ParameterSet& pset, edm::ConsumesCollector);
0049
0050
0051 ~DTCombinatorialPatternReco() override;
0052
0053
0054
0055
0056 edm::OwnVector<DTSLRecSegment2D> reconstruct(const DTSuperLayer* sl,
0057 const std::vector<DTRecHit1DPair>& hits) override;
0058
0059
0060 std::string algoName() const override { return theAlgoName; }
0061
0062
0063
0064 void setES(const edm::EventSetup& setup) override;
0065
0066 protected:
0067 private:
0068 friend class DTCombinatorialPatternReco4D;
0069
0070
0071
0072
0073 std::vector<std::shared_ptr<DTHitPairForFit>> initHits(const DTSuperLayer* sl,
0074 const std::vector<DTRecHit1DPair>& hits);
0075
0076
0077 std::vector<DTSegmentCand*> buildSegments(const DTSuperLayer* sl,
0078 const std::vector<std::shared_ptr<DTHitPairForFit>>& hits);
0079
0080
0081 std::vector<DTSegmentCand::AssPoint> findCompatibleHits(const LocalPoint& pos,
0082 const LocalVector& dir,
0083 const std::vector<std::shared_ptr<DTHitPairForFit>>& hits);
0084
0085
0086 DTSegmentCand* buildBestSegment(std::vector<DTSegmentCand::AssPoint>& assHits, const DTSuperLayer* sl);
0087
0088 bool checkDoubleCandidates(std::vector<DTSegmentCand*>& segs, DTSegmentCand* seg);
0089
0090
0091
0092 void buildPointsCollection(std::vector<DTSegmentCand::AssPoint>& points,
0093 std::deque<std::shared_ptr<DTHitPairForFit>>& pointsNoLR,
0094 std::vector<DTSegmentCand*>& candidates,
0095 const DTSuperLayer* sl);
0096
0097 private:
0098 std::string theAlgoName;
0099 unsigned int theMaxAllowedHits;
0100 double theAlphaMaxTheta;
0101 double theAlphaMaxPhi;
0102 bool debug;
0103 bool usePairs;
0104 DTSegmentUpdator* theUpdator;
0105 DTSegmentCleaner* theCleaner;
0106
0107 edm::ESHandle<DTGeometry> theDTGeometry;
0108 const edm::ESGetToken<DTGeometry, MuonGeometryRecord> theDTGeometryToken;
0109
0110 public:
0111
0112 class TriedPattern {
0113 public:
0114 typedef std::vector<short unsigned int> values;
0115
0116
0117 TriedPattern() : hash_(1) { values_.reserve(8); }
0118
0119
0120 bool operator==(const TriedPattern& other) const {
0121 return (hash_ == other.hash_) &&
0122 (values_ == other.values_);
0123 }
0124
0125
0126 template <class T>
0127 inline void hash_combine(std::size_t& seed, const T& v) {
0128 std::hash<T> hasher;
0129 seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
0130 }
0131
0132
0133 void push_back(short unsigned int i) {
0134 hash_combine(hash_, i);
0135 values_.push_back(i);
0136 }
0137
0138
0139 size_t hash() const { return hash_; }
0140
0141
0142 typedef values::const_iterator const_iterator;
0143 const_iterator begin() const { return values_.begin(); }
0144 const_iterator end() const { return values_.end(); }
0145 values::size_type size() const { return values_.size(); }
0146
0147
0148 class HashFunction {
0149 public:
0150 size_t operator()(const TriedPattern& p) const { return p.hash(); }
0151 };
0152
0153 private:
0154 values values_;
0155 size_t hash_;
0156 };
0157 typedef std::unordered_set<TriedPattern, TriedPattern::HashFunction> TriedPatterns;
0158
0159 private:
0160 TriedPatterns theTriedPattern;
0161 };
0162
0163 inline std::size_t hash_value(const DTCombinatorialPatternReco::TriedPattern& t) { return t.hash(); }
0164
0165 #endif