CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TrajSeedMatcher.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_EgammaElectronAlgos_TrajSeedMatcher_h
2 #define RecoEgamma_EgammaElectronAlgos_TrajSeedMatcher_h
3 
4 //******************************************************************************
5 //
6 // Part of the refactorisation of of the E/gamma pixel matching for 2017 pixels
7 // This refactorisation converts the monolithic approach to a series of
8 // independent producer modules, with each modules performing a specific
9 // job as recommended by the 2017 tracker framework
10 //
11 //
12 // The module is based of PixelHitMatcher (the seed based functions) but
13 // extended to match on an arbitary number of hits rather than just doublets.
14 // It is also aware of how many layers the supercluster trajectory passed through
15 // and uses that information to determine how many hits to require
16 // Other than that, its a direct port and follows what PixelHitMatcher did
17 //
18 //
19 // Author : Sam Harper (RAL), 2017
20 //
21 //*******************************************************************************
22 
24 
27 
38 
42 
43 namespace edm {
44  class ConsumesCollector;
45  class EventSetup;
47  class ParameterSet;
49 } // namespace edm
50 
52 class TrackingRecHit;
53 
55 public:
56  struct SCHitMatch {
57  const DetId detId = 0;
62  const float et = 0.f;
63  const float eta = 0.f;
64  const float phi = 0.f;
65  const int charge = 0;
66  const int nrClus = 0;
67  };
68 
69  struct MatchInfo {
70  const DetId detId;
71  const float dRZPos;
72  const float dRZNeg;
73  const float dPhiPos;
74  const float dPhiNeg;
75  };
76 
77  struct SeedWithInfo {
79  const std::vector<MatchInfo> matchInfos;
80  const int nrValidLayers;
81  };
82 
83  class MatchingCuts {
84  public:
86  virtual ~MatchingCuts() {}
87  virtual bool operator()(const SCHitMatch& scHitMatch) const = 0;
88  };
89 
90  class MatchingCutsV1 : public MatchingCuts {
91  public:
92  explicit MatchingCutsV1(const edm::ParameterSet& pset);
93  bool operator()(const SCHitMatch& scHitMatch) const override;
94 
95  private:
96  float getDRZCutValue(const float scEt, const float scEta) const;
97 
98  private:
99  const double dPhiMax_;
100  const double dRZMax_;
101  const double dRZMaxLowEtThres_;
102  const std::vector<double> dRZMaxLowEtEtaBins_;
103  const std::vector<double> dRZMaxLowEt_;
104  };
105 
106  class MatchingCutsV2 : public MatchingCuts {
107  public:
108  explicit MatchingCutsV2(const edm::ParameterSet& pset);
109  bool operator()(const SCHitMatch& scHitMatch) const override;
110 
111  private:
112  size_t getBinNr(float eta) const;
113  float getCutValue(float et, float highEt, float highEtThres, float lowEtGrad) const {
114  return highEt + std::min(0.f, et - highEtThres) * lowEtGrad;
115  }
116 
117  private:
119  std::vector<double> dRZHighEt_, dRZHighEtThres_, dRZLowEtGrad_;
120  std::vector<double> etaBins_;
121  };
122 
123 public:
124  struct Configuration {
126 
131 
132  const bool useRecoVertex;
133  const bool enableHitSkipping;
136 
137  //these two variables determine how hits we require
138  //based on how many valid layers we had
139  //right now we always need atleast two hits
140  //also highly dependent on the seeds you pass in
141  //which also require a given number of hits
142  const std::vector<unsigned int> minNrHits;
143  const std::vector<int> minNrHitsValidLayerBins;
144 
145  const std::vector<std::unique_ptr<MatchingCuts> > matchingCuts;
146  };
147 
149  math::XYZPoint const& vprim,
150  Configuration const& cfg,
151  edm::EventSetup const& iSetup,
153  ~TrajSeedMatcher() = default;
154 
156 
157  std::vector<TrajSeedMatcher::SeedWithInfo> operator()(const GlobalPoint& candPos, const float energy);
158 
159 private:
160  std::vector<SCHitMatch> processSeed(const TrajectorySeed& seed,
161  const GlobalPoint& candPos,
162  const float energy,
163  const TrajectoryStateOnSurface& initialTrajState);
164 
165  static float getZVtxFromExtrapolation(const GlobalPoint& primeVtxPos,
166  const GlobalPoint& hitPos,
167  const GlobalPoint& candPos);
168 
170  const TrajectoryStateOnSurface& initialState,
172 
174  const FreeTrajectoryState& initialState,
175  const GlobalPoint& point,
177 
178  TrajectoryStateOnSurface makeTrajStateOnSurface(const GlobalPoint& pos, const float energy, const int charge) const;
179  void clearCache();
180 
182  const SCHitMatch& hit1, const SCHitMatch& hit2, const GlobalPoint& candPos, const float energy, const int charge);
183 
184  int getNrValidLayersAlongTraj(const DetId& hitId, const TrajectoryStateOnSurface& hitTrajState) const;
185 
186  bool layerHasValidHits(const DetLayer& layer,
187  const TrajectoryStateOnSurface& hitSurState,
188  const Propagator& propToLayerFromState) const;
189 
190  size_t getNrHitsRequired(const int nrValidLayers) const;
191 
192  inline auto ftsFromVertexToPoint(GlobalPoint const& point, GlobalPoint const& vertex, float energy, int charge) const {
193  //parameterised b-fields may not be valid for entire detector, just tracker volume
194  //however need we ecal so we auto select based on the position
195  bool useMagFieldParam = cfg_.useParamMagFieldIfDefined && magFieldParam_.isDefined(point);
196  auto const& magneticField = useMagFieldParam ? magFieldParam_ : magField_;
197  return trackingTools::ftsFromVertexToPoint(magneticField, point, vertex, energy, charge);
198  }
199 
200 private:
201  static constexpr float kElectronMass_ = 0.000511;
202 
205 
207 
213 
216 
217  std::unordered_map<int, TrajectoryStateOnSurface> trajStateFromVtxPosChargeCache_;
218  std::unordered_map<int, TrajectoryStateOnSurface> trajStateFromVtxNegChargeCache_;
219 
222 };
223 
224 #endif
std::vector< SCHitMatch > processSeed(const TrajectorySeed &seed, const GlobalPoint &candPos, const float energy, const TrajectoryStateOnSurface &initialTrajState)
MatchingCutsV1(const edm::ParameterSet &pset)
tuple propagator
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurface > trajStateFromPointNegChargeCache_
tuple cfg
Definition: looper.py:296
MatchingCutsV2(const edm::ParameterSet &pset)
const edm::ESGetToken< NavigationSchool, NavigationSchoolRecord > navSchoolToken
std::vector< double > dRZLowEtGrad_
const TrajectoryStateOnSurface & getTrajStateFromVtx(const TrackingRecHit &hit, const TrajectoryStateOnSurface &initialState, const PropagatorWithMaterial &propagator)
Configuration(const edm::ParameterSet &pset, edm::ConsumesCollector &&cc)
std::vector< double > dPhiLowEtGrad_
MagneticField const & magFieldParam_
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurface > trajStateFromPointPosChargeCache_
FreeTrajectoryState ftsFromVertexToPoint(MagneticField const &magField, GlobalPoint const &xmeas, GlobalPoint const &xvert, float momentum, TrackCharge charge)
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > paramMagFieldToken
TrajectoryStateOnSurface makeTrajStateOnSurface(const GlobalPoint &pos, const float energy, const int charge) const
tuple magneticField
~TrajSeedMatcher()=default
const std::vector< double > dRZMaxLowEt_
static float getZVtxFromExtrapolation(const GlobalPoint &primeVtxPos, const GlobalPoint &hitPos, const GlobalPoint &candPos)
const TrajectoryStateOnSurface & getTrajStateFromPoint(const TrackingRecHit &hit, const FreeTrajectoryState &initialState, const GlobalPoint &point, const PropagatorWithMaterial &propagator)
constexpr std::array< uint8_t, layerIndexSize > layer
const std::vector< std::unique_ptr< MatchingCuts > > matchingCuts
std::vector< TrajSeedMatcher::SeedWithInfo > operator()(const GlobalPoint &candPos, const float energy)
std::vector< double > etaBins_
TrajectorySeedCollection const & seeds_
PropagatorWithMaterial forwardPropagator_
Configuration const & cfg_
static edm::ParameterSetDescription makePSetDescription()
bool operator()(const SCHitMatch &scHitMatch) const override
const std::vector< int > minNrHitsValidLayerBins
std::vector< TrajectorySeed > TrajectorySeedCollection
const TrajectorySeed & seed
NavigationSchool const & navSchool_
virtual bool isDefined(const GlobalPoint &) const
True if the point is within the region where the concrete field.
Definition: MagneticField.h:40
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxPosChargeCache_
int getNrValidLayersAlongTraj(const SCHitMatch &hit1, const SCHitMatch &hit2, const GlobalPoint &candPos, const float energy, const int charge)
const std::vector< MatchInfo > matchInfos
virtual bool operator()(const SCHitMatch &scHitMatch) const =0
std::vector< double > dPhiHighEt_
DetLayerGeometry const & detLayerGeom_
size_t getNrHitsRequired(const int nrValidLayers) const
size_t getBinNr(float eta) const
bool operator()(const SCHitMatch &scHitMatch) const override
const TrackingRecHit & hit
float getDRZCutValue(const float scEt, const float scEta) const
TrajSeedMatcher(TrajectorySeedCollection const &seeds, math::XYZPoint const &vprim, Configuration const &cfg, edm::EventSetup const &iSetup, MeasurementTrackerEvent const &measTkEvt)
Definition: DetId.h:17
const std::vector< double > dRZMaxLowEtEtaBins_
std::unordered_map< std::pair< int, GlobalPoint >, T, HashIntGlobalPointPair > IntGlobalPointPairUnorderedMap
Definition: utils.h:20
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
MeasurementTrackerEvent const & measTkEvt_
const GlobalPoint vprim_
auto ftsFromVertexToPoint(GlobalPoint const &point, GlobalPoint const &vertex, float energy, int charge) const
std::vector< double > dPhiHighEtThres_
PropagatorWithMaterial backwardPropagator_
const edm::ESGetToken< DetLayerGeometry, RecoGeometryRecord > detLayerGeomToken
MagneticField const & magField_
static constexpr float kElectronMass_
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxNegChargeCache_
bool layerHasValidHits(const DetLayer &layer, const TrajectoryStateOnSurface &hitSurState, const Propagator &propToLayerFromState) const
const std::vector< unsigned int > minNrHits
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken
std::vector< double > dRZHighEtThres_
std::vector< double > dRZHighEt_
float getCutValue(float et, float highEt, float highEtThres, float lowEtGrad) const