CMS 3D CMS Logo

GE0SegAlgoRU.h
Go to the documentation of this file.
1 #ifndef RecoLocalMuon_GEMSegment_GE0SegAlgoRU_h
2 #define RecoLocalMuon_GEMSegment_GE0SegAlgoRU_h
3 
27 #include "MuonSegFit.h"
28 
29 #include <vector>
30 
31 class MuonSegFit;
33 public:
35  float maxETASeeds;
36  float maxPhiSeeds;
39  float maxChi2Prune;
42  unsigned int minNumberOfHits;
43  unsigned int maxNumberOfHits;
46  };
47 
48  // originally from ME0SegmentAlgorithmBase
49  struct HitAndPosition {
50  HitAndPosition(const GEMRecHit* rh, const LocalPoint& lp, const GlobalPoint& gp, unsigned int idx)
51  : rh(rh), lp(lp), gp(gp), layer(rh->gemId().layer()), idx(idx) {}
52  const GEMRecHit* rh;
55  unsigned int layer;
56  unsigned int idx;
57  };
58  typedef std::vector<HitAndPosition> HitAndPositionContainer;
59  typedef std::vector<const HitAndPosition*> HitAndPositionPtrContainer;
60 
61  // We need to be able to flag a hit as 'used' and so need a container of bool's.
62  typedef std::vector<bool> BoolContainer;
63  typedef std::vector<std::pair<float, HitAndPositionPtrContainer> > SegmentByMetricContainer;
64 
66  explicit GE0SegAlgoRU(const edm::ParameterSet& ps);
68  ~GE0SegAlgoRU() override{};
69 
73  std::vector<GEMSegment> run(const GEMSuperChamber* chamber, const HitAndPositionContainer& rechits);
74  // The original ME0SegAlgoRU used the run(..) function above, we
75  // implement a small wrapper to use with GEMSegments fairly
76  // transparently
77  std::vector<GEMSegment> run(const GEMEnsemble& ensemble, const std::vector<const GEMRecHit*>& rechits) override;
78 
79 private:
80  //Look for segments that have at least "n_seg_min" consituents and following the associated paramters
81  void lookForSegments(const SegmentParameters& params,
82  const unsigned int n_seg_min,
84  const std::vector<unsigned int>& recHits_per_layer,
85  BoolContainer& used,
86  std::vector<GEMSegment>& segments) const;
87  //Look for any hits between the two seed hits consistent with a segment
88  void tryAddingHitsToSegment(const float maxETA,
89  const float maxPhi,
90  const float maxChi2,
91  std::unique_ptr<MuonSegFit>& current_fit,
92  HitAndPositionPtrContainer& proto_segment,
93  const BoolContainer& used,
94  HitAndPositionContainer::const_iterator i1,
95  HitAndPositionContainer::const_iterator i2) const;
96  //Remove extra hits until the segment passes "maxChi2"
97  void pruneBadHits(const float maxChi2,
98  HitAndPositionPtrContainer& proto_segment,
99  std::unique_ptr<MuonSegFit>& fit,
100  const unsigned int n_seg_min) const;
101  //Remove any overlapping segments by which has the lowset chi2
102  void addUniqueSegments(SegmentByMetricContainer& proto_segments,
103  std::vector<GEMSegment>& segments,
104  BoolContainer& used) const;
105 
106  //Are the two seed hits consistent spatially?
107  bool areHitsCloseInEta(const float maxETA, const bool beamConst, const GlobalPoint& h1, const GlobalPoint& h2) const;
108  bool areHitsCloseInGlobalPhi(const float maxPHI,
109  const unsigned int nLayDisp,
110  const GlobalPoint& h1,
111  const GlobalPoint& h2) const;
112 
113  //Add a hit to a segment
114  std::unique_ptr<MuonSegFit> addHit(HitAndPositionPtrContainer& proto_segment, const HitAndPosition& aHit) const;
115  //Does the segment have any hits on this layer?
116  bool hasHitOnLayer(const HitAndPositionPtrContainer& proto_segment, const unsigned int layer) const;
117  //Produce a new fit
118  std::unique_ptr<MuonSegFit> makeFit(const HitAndPositionPtrContainer& proto_segment) const;
119 
120  //Is this new hit btw the seeds near the segment fit?
121  bool isHitNearSegment(const float maxETA,
122  const float maxPHI,
123  const std::unique_ptr<MuonSegFit>& fit,
124  const HitAndPositionPtrContainer& proto_segment,
125  const HitAndPosition& h) const;
126  //Return a chi2 for a hit and a predicted segment extrapolation
127  float getHitSegChi2(const std::unique_ptr<MuonSegFit>& fit, const GEMRecHit& hit) const;
128  //Global point of a segment extrapolated to a Z value
129  GlobalPoint globalAtZ(const std::unique_ptr<MuonSegFit>& fit, float z) const;
130 
131  //Try adding a hit instead of another and return new or old, depending on which has the smallest chi2
132  void compareProtoSegment(std::unique_ptr<MuonSegFit>& current_fit,
133  HitAndPositionPtrContainer& current_proto_segment,
134  const HitAndPosition& new_hit) const;
135  //Try adding this hit to the segment, dont if the new chi2 is too big
136  void increaseProtoSegment(const float maxChi2,
137  std::unique_ptr<MuonSegFit>& current_fit,
138  HitAndPositionPtrContainer& current_proto_segment,
139  const HitAndPosition& new_hit) const;
140 
144 
148 
149  //Objects used to produce the segments
151 };
152 
153 #endif
std::vector< bool > BoolContainer
Definition: GE0SegAlgoRU.h:62
GE0SegAlgoRU(const edm::ParameterSet &ps)
Constructor.
Definition: GE0SegAlgoRU.cc:26
SegmentParameters wideParameters
Definition: GE0SegAlgoRU.h:147
bool isHitNearSegment(const float maxETA, const float maxPHI, const std::unique_ptr< MuonSegFit > &fit, const HitAndPositionPtrContainer &proto_segment, const HitAndPosition &h) const
std::vector< const HitAndPosition * > HitAndPositionPtrContainer
Definition: GE0SegAlgoRU.h:59
bool areHitsCloseInEta(const float maxETA, const bool beamConst, const GlobalPoint &h1, const GlobalPoint &h2) const
bool allowWideSegments
Definition: GE0SegAlgoRU.h:143
const std::string myName
Definition: GE0SegAlgoRU.h:141
void pruneBadHits(const float maxChi2, HitAndPositionPtrContainer &proto_segment, std::unique_ptr< MuonSegFit > &fit, const unsigned int n_seg_min) const
std::pair< const GEMSuperChamber *, std::map< uint32_t, const GEMEtaPartition * > > GEMEnsemble
const GEMSuperChamber * theChamber
Definition: GE0SegAlgoRU.h:150
constexpr std::array< uint8_t, layerIndexSize< TrackerTraits > > layer
float getHitSegChi2(const std::unique_ptr< MuonSegFit > &fit, const GEMRecHit &hit) const
void compareProtoSegment(std::unique_ptr< MuonSegFit > &current_fit, HitAndPositionPtrContainer &current_proto_segment, const HitAndPosition &new_hit) const
void tryAddingHitsToSegment(const float maxETA, const float maxPhi, const float maxChi2, std::unique_ptr< MuonSegFit > &current_fit, HitAndPositionPtrContainer &proto_segment, const BoolContainer &used, HitAndPositionContainer::const_iterator i1, HitAndPositionContainer::const_iterator i2) const
void addUniqueSegments(SegmentByMetricContainer &proto_segments, std::vector< GEMSegment > &segments, BoolContainer &used) const
std::vector< GEMSegment > run(const GEMSuperChamber *chamber, const HitAndPositionContainer &rechits)
Definition: GE0SegAlgoRU.cc:98
bool hasHitOnLayer(const HitAndPositionPtrContainer &proto_segment, const unsigned int layer) const
HitAndPosition(const GEMRecHit *rh, const LocalPoint &lp, const GlobalPoint &gp, unsigned int idx)
Definition: GE0SegAlgoRU.h:50
std::unique_ptr< MuonSegFit > makeFit(const HitAndPositionPtrContainer &proto_segment) const
bool areHitsCloseInGlobalPhi(const float maxPHI, const unsigned int nLayDisp, const GlobalPoint &h1, const GlobalPoint &h2) const
void lookForSegments(const SegmentParameters &params, const unsigned int n_seg_min, const HitAndPositionContainer &rechits, const std::vector< unsigned int > &recHits_per_layer, BoolContainer &used, std::vector< GEMSegment > &segments) const
SegmentParameters displacedParameters
Definition: GE0SegAlgoRU.h:146
std::vector< std::pair< float, HitAndPositionPtrContainer > > SegmentByMetricContainer
Definition: GE0SegAlgoRU.h:63
std::vector< HitAndPosition > HitAndPositionContainer
Definition: GE0SegAlgoRU.h:58
std::unique_ptr< MuonSegFit > addHit(HitAndPositionPtrContainer &proto_segment, const HitAndPosition &aHit) const
SegmentParameters stdParameters
Definition: GE0SegAlgoRU.h:145
~GE0SegAlgoRU() override
Destructor.
Definition: GE0SegAlgoRU.h:68
GlobalPoint globalAtZ(const std::unique_ptr< MuonSegFit > &fit, float z) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void increaseProtoSegment(const float maxChi2, std::unique_ptr< MuonSegFit > &current_fit, HitAndPositionPtrContainer &current_proto_segment, const HitAndPosition &new_hit) const