CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
TrajSeedMatcher Class Reference

#include <TrajSeedMatcher.h>

Classes

struct  Configuration
 
struct  MatchInfo
 
class  MatchingCuts
 
class  MatchingCutsV1
 
class  MatchingCutsV2
 
struct  SCHitMatch
 
struct  SeedWithInfo
 

Public Member Functions

std::vector< TrajSeedMatcher::SeedWithInfooperator() (const GlobalPoint &candPos, const float energy)
 
 TrajSeedMatcher (TrajectorySeedCollection const &seeds, math::XYZPoint const &vprim, Configuration const &cfg, edm::EventSetup const &iSetup, MeasurementTrackerEvent const &measTkEvt)
 
 ~TrajSeedMatcher ()=default
 

Static Public Member Functions

static edm::ParameterSetDescription makePSetDescription ()
 

Private Member Functions

void clearCache ()
 
auto ftsFromVertexToPoint (GlobalPoint const &point, GlobalPoint const &vertex, float energy, int charge) const
 
size_t getNrHitsRequired (const int nrValidLayers) const
 
int getNrValidLayersAlongTraj (const SCHitMatch &hit1, const SCHitMatch &hit2, const GlobalPoint &candPos, const float energy, const int charge)
 
int getNrValidLayersAlongTraj (const DetId &hitId, const TrajectoryStateOnSurface &hitTrajState) const
 
const TrajectoryStateOnSurfacegetTrajStateFromPoint (const TrackingRecHit &hit, const FreeTrajectoryState &initialState, const GlobalPoint &point, const PropagatorWithMaterial &propagator)
 
const TrajectoryStateOnSurfacegetTrajStateFromVtx (const TrackingRecHit &hit, const TrajectoryStateOnSurface &initialState, const PropagatorWithMaterial &propagator)
 
bool layerHasValidHits (const DetLayer &layer, const TrajectoryStateOnSurface &hitSurState, const Propagator &propToLayerFromState) const
 
TrajectoryStateOnSurface makeTrajStateOnSurface (const GlobalPoint &pos, const float energy, const int charge) const
 
std::vector< SCHitMatchprocessSeed (const TrajectorySeed &seed, const GlobalPoint &candPos, const float energy, const TrajectoryStateOnSurface &initialTrajState)
 

Static Private Member Functions

static float getZVtxFromExtrapolation (const GlobalPoint &primeVtxPos, const GlobalPoint &hitPos, const GlobalPoint &candPos)
 

Private Attributes

PropagatorWithMaterial backwardPropagator_
 
Configuration const & cfg_
 
DetLayerGeometry const & detLayerGeom_
 
PropagatorWithMaterial forwardPropagator_
 
MagneticField const & magField_
 
MagneticField const & magFieldParam_
 
MeasurementTrackerEvent const & measTkEvt_
 
NavigationSchool const & navSchool_
 
TrajectorySeedCollection const & seeds_
 
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurfacetrajStateFromPointNegChargeCache_
 
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurfacetrajStateFromPointPosChargeCache_
 
std::unordered_map< int, TrajectoryStateOnSurfacetrajStateFromVtxNegChargeCache_
 
std::unordered_map< int, TrajectoryStateOnSurfacetrajStateFromVtxPosChargeCache_
 
const GlobalPoint vprim_
 

Static Private Attributes

static constexpr float kElectronMass_ = 0.000511
 

Detailed Description

Definition at line 54 of file TrajSeedMatcher.h.

Constructor & Destructor Documentation

◆ TrajSeedMatcher()

TrajSeedMatcher::TrajSeedMatcher ( TrajectorySeedCollection const &  seeds,
math::XYZPoint const &  vprim,
TrajSeedMatcher::Configuration const &  cfg,
edm::EventSetup const &  iSetup,
MeasurementTrackerEvent const &  measTkEvt 
)
explicit

Definition at line 102 of file TrajSeedMatcher.cc.

References HLT_2024v14_cff::seeds.

107  : seeds_{seeds},
108  vprim_(vprim.x(), vprim.y(), vprim.z()),
109  cfg_{cfg},
110  magField_{iSetup.getData(cfg_.magFieldToken)},
111  magFieldParam_{iSetup.getData(cfg_.paramMagFieldToken)},
113  navSchool_{iSetup.getData(cfg_.navSchoolToken)},
114  detLayerGeom_{iSetup.getData(cfg_.detLayerGeomToken)},
const edm::ESGetToken< NavigationSchool, NavigationSchoolRecord > navSchoolToken
MagneticField const & magFieldParam_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > paramMagFieldToken
TrajectorySeedCollection const & seeds_
PropagatorWithMaterial forwardPropagator_
Configuration const & cfg_
NavigationSchool const & navSchool_
DetLayerGeometry const & detLayerGeom_
MeasurementTrackerEvent const & measTkEvt_
const GlobalPoint vprim_
PropagatorWithMaterial backwardPropagator_
const edm::ESGetToken< DetLayerGeometry, RecoGeometryRecord > detLayerGeomToken
MagneticField const & magField_
static constexpr float kElectronMass_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken

◆ ~TrajSeedMatcher()

TrajSeedMatcher::~TrajSeedMatcher ( )
default

Member Function Documentation

◆ clearCache()

void TrajSeedMatcher::clearCache ( )
private

Definition at line 299 of file TrajSeedMatcher.cc.

References trajStateFromPointNegChargeCache_, trajStateFromPointPosChargeCache_, trajStateFromVtxNegChargeCache_, and trajStateFromVtxPosChargeCache_.

Referenced by operator()().

299  {
304 }
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurface > trajStateFromPointNegChargeCache_
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurface > trajStateFromPointPosChargeCache_
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxPosChargeCache_
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxNegChargeCache_

◆ ftsFromVertexToPoint()

auto TrajSeedMatcher::ftsFromVertexToPoint ( GlobalPoint const &  point,
GlobalPoint const &  vertex,
float  energy,
int  charge 
) const
inlineprivate

Definition at line 192 of file TrajSeedMatcher.h.

References cfg_, ALCARECOTkAlJpsiMuMu_cff::charge, HBHEDarkening_cff::energy, trackingTools::ftsFromVertexToPoint(), MagneticField::isDefined(), magField_, magFieldParam_, HLT_2024v14_cff::magneticField, point, TrajSeedMatcher::Configuration::useParamMagFieldIfDefined, and bphysicsOniaDQM_cfi::vertex.

Referenced by getNrValidLayersAlongTraj(), makeTrajStateOnSurface(), and processSeed().

192  {
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_;
198  }
virtual bool isDefined(const GlobalPoint &) const
True if the point is within the region where the concrete field.
Definition: MagneticField.h:40
MagneticField const & magFieldParam_
FreeTrajectoryState ftsFromVertexToPoint(MagneticField const &magField, GlobalPoint const &xmeas, GlobalPoint const &xvert, float momentum, TrackCharge charge)
Configuration const & cfg_
MagneticField const & magField_
*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

◆ getNrHitsRequired()

size_t TrajSeedMatcher::getNrHitsRequired ( const int  nrValidLayers) const
private

Definition at line 364 of file TrajSeedMatcher.cc.

References cfg_, TrajSeedMatcher::Configuration::minNrHits, and TrajSeedMatcher::Configuration::minNrHitsValidLayerBins.

Referenced by operator()().

364  {
365  for (size_t binNr = 0; binNr < cfg_.minNrHitsValidLayerBins.size(); binNr++) {
366  if (nrValidLayers < cfg_.minNrHitsValidLayerBins[binNr])
367  return cfg_.minNrHits[binNr];
368  }
369  return cfg_.minNrHits.back();
370 }
Configuration const & cfg_
const std::vector< int > minNrHitsValidLayerBins
const std::vector< unsigned int > minNrHits

◆ getNrValidLayersAlongTraj() [1/2]

int TrajSeedMatcher::getNrValidLayersAlongTraj ( const SCHitMatch hit1,
const SCHitMatch hit2,
const GlobalPoint candPos,
const float  energy,
const int  charge 
)
private

Definition at line 306 of file TrajSeedMatcher.cc.

References cfg_, ALCARECOTkAlJpsiMuMu_cff::charge, HBHEDarkening_cff::energy, forwardPropagator_, ftsFromVertexToPoint(), TrackingRecHit::geographicalId(), getTrajStateFromPoint(), getZVtxFromExtrapolation(), TrajSeedMatcher::SCHitMatch::hit, TrajSeedMatcher::SCHitMatch::hitPos, TrajSeedMatcher::Configuration::useRecoVertex, bphysicsOniaDQM_cfi::vertex, vprim_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and HLT_FULL_cff::zVertex.

Referenced by operator()().

307  {
308  double zVertex = cfg_.useRecoVertex ? vprim_.z() : getZVtxFromExtrapolation(vprim_, hit1.hitPos, candPos);
310 
311  auto firstMatchFreeTraj = ftsFromVertexToPoint(hit1.hitPos, vertex, energy, charge);
312  auto const& secondHitTraj = getTrajStateFromPoint(hit2.hit, firstMatchFreeTraj, hit1.hitPos, forwardPropagator_);
313  return getNrValidLayersAlongTraj(hit2.hit.geographicalId(), secondHitTraj);
314 }
T z() const
Definition: PV3DBase.h:61
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)
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
PropagatorWithMaterial forwardPropagator_
Configuration const & cfg_
int getNrValidLayersAlongTraj(const SCHitMatch &hit1, const SCHitMatch &hit2, const GlobalPoint &candPos, const float energy, const int charge)
const GlobalPoint vprim_
auto ftsFromVertexToPoint(GlobalPoint const &point, GlobalPoint const &vertex, float energy, int charge) const

◆ getNrValidLayersAlongTraj() [2/2]

int TrajSeedMatcher::getNrValidLayersAlongTraj ( const DetId hitId,
const TrajectoryStateOnSurface hitTrajState 
) const
private

Definition at line 316 of file TrajSeedMatcher.cc.

References alongMomentum, backwardPropagator_, NavigationSchool::compatibleLayers(), detLayerGeom_, forwardPropagator_, TrajectoryStateOnSurface::freeState(), DetLayerGeometry::idToLayer(), GeomDetEnumerators::isTrackerPixel(), nano_mu_digi_cff::layer, layerHasValidHits(), navSchool_, and oppositeToMomentum.

316  {
317  const DetLayer* detLayer = detLayerGeom_.idToLayer(hitId);
318  if (detLayer == nullptr)
319  return 0;
320 
321  const FreeTrajectoryState& hitFreeState = *hitTrajState.freeState();
322  auto const inLayers = navSchool_.compatibleLayers(*detLayer, hitFreeState, oppositeToMomentum);
323  const auto outLayers = navSchool_.compatibleLayers(*detLayer, hitFreeState, alongMomentum);
324 
325  int nrValidLayers = 1; //because our current hit is also valid and wont be included in the count otherwise
326  for (auto layer : inLayers) {
327  if (GeomDetEnumerators::isTrackerPixel(layer->subDetector())) {
328  if (layerHasValidHits(*layer, hitTrajState, backwardPropagator_))
329  nrValidLayers++;
330  }
331  }
332  for (auto layer : outLayers) {
333  if (GeomDetEnumerators::isTrackerPixel(layer->subDetector())) {
334  if (layerHasValidHits(*layer, hitTrajState, forwardPropagator_))
335  nrValidLayers++;
336  }
337  }
338  return nrValidLayers;
339 }
virtual const DetLayer * idToLayer(const DetId &detId) const
PropagatorWithMaterial forwardPropagator_
std::vector< const DetLayer * > compatibleLayers(const DetLayer &detLayer, Args &&... args) const
Returns all layers compatible.
NavigationSchool const & navSchool_
DetLayerGeometry const & detLayerGeom_
PropagatorWithMaterial backwardPropagator_
FreeTrajectoryState const * freeState(bool withErrors=true) const
bool layerHasValidHits(const DetLayer &layer, const TrajectoryStateOnSurface &hitSurState, const Propagator &propToLayerFromState) const
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)

◆ getTrajStateFromPoint()

const TrajectoryStateOnSurface & TrajSeedMatcher::getTrajStateFromPoint ( const TrackingRecHit hit,
const FreeTrajectoryState initialState,
const GlobalPoint point,
const PropagatorWithMaterial propagator 
)
private

Definition at line 274 of file TrajSeedMatcher.cc.

References FreeTrajectoryState::charge(), submitPVResolutionJobs::key, point, TrackCandidateProducer_cfi::propagator, trajStateFromPointNegChargeCache_, trajStateFromPointPosChargeCache_, and heppy_batch::val.

Referenced by getNrValidLayersAlongTraj(), and processSeed().

277  {
278  auto& trajStateFromPointCache =
280 
281  auto key = std::make_pair(hit.det()->gdetIndex(), point);
282  auto res = trajStateFromPointCache.find(key);
283  if (res != trajStateFromPointCache.end())
284  return res->second;
285  else { //doesnt exist, need to make it
286  //FIXME: check for efficiency
287  auto val = trajStateFromPointCache.emplace(key, propagator.propagate(initialState, hit.det()->surface()));
288  return val.first->second;
289  }
290 }
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurface > trajStateFromPointNegChargeCache_
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurface > trajStateFromPointPosChargeCache_
Definition: Electron.h:6
TrackCharge charge() const
key
prepare the HTCondor submission files and eventually submit them
*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

◆ getTrajStateFromVtx()

const TrajectoryStateOnSurface & TrajSeedMatcher::getTrajStateFromVtx ( const TrackingRecHit hit,
const TrajectoryStateOnSurface initialState,
const PropagatorWithMaterial propagator 
)
private

Definition at line 257 of file TrajSeedMatcher.cc.

References TrajectoryStateOnSurface::charge(), submitPVResolutionJobs::key, TrackCandidateProducer_cfi::propagator, trajStateFromVtxNegChargeCache_, trajStateFromVtxPosChargeCache_, and heppy_batch::val.

Referenced by processSeed().

259  {
260  auto& trajStateFromVtxCache =
262 
263  auto key = hit.det()->gdetIndex();
264  auto res = trajStateFromVtxCache.find(key);
265  if (res != trajStateFromVtxCache.end())
266  return res->second;
267  else { //doesnt exist, need to make it
268  //FIXME: check for efficiency
269  auto val = trajStateFromVtxCache.emplace(key, propagator.propagate(initialState, hit.det()->surface()));
270  return val.first->second;
271  }
272 }
Definition: Electron.h:6
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxPosChargeCache_
key
prepare the HTCondor submission files and eventually submit them
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxNegChargeCache_

◆ getZVtxFromExtrapolation()

float TrajSeedMatcher::getZVtxFromExtrapolation ( const GlobalPoint primeVtxPos,
const GlobalPoint hitPos,
const GlobalPoint candPos 
)
staticprivate

Definition at line 245 of file TrajSeedMatcher.cc.

References LaserDQM_cfg::p1, SiStripOfflineCRack_cfg::p2, mathSSE::sqrt(), x, and PV3DBase< T, PVType, FrameType >::z().

Referenced by getNrValidLayersAlongTraj(), and processSeed().

247  {
248  auto sq = [](float x) { return x * x; };
249  auto calRDiff = [sq](const GlobalPoint& p1, const GlobalPoint& p2) {
250  return std::sqrt(sq(p2.x() - p1.x()) + sq(p2.y() - p1.y()));
251  };
252  const double r1Diff = calRDiff(primeVtxPos, hitPos);
253  const double r2Diff = calRDiff(hitPos, candPos);
254  return hitPos.z() - r1Diff * (candPos.z() - hitPos.z()) / r2Diff;
255 }
T z() const
Definition: PV3DBase.h:61
T sqrt(T t)
Definition: SSEVec.h:23

◆ layerHasValidHits()

bool TrajSeedMatcher::layerHasValidHits ( const DetLayer layer,
const TrajectoryStateOnSurface hitSurState,
const Propagator propToLayerFromState 
) const
private

Definition at line 341 of file TrajSeedMatcher.cc.

References MeasurementDetWithData::hasBadComponents(), MeasurementTrackerEvent::idToDet(), MeasurementDetWithData::isActive(), nano_mu_digi_cff::layer, and measTkEvt_.

Referenced by getNrValidLayersAlongTraj().

343  {
344  //FIXME: do not hardcode with weird magic numbers stolen from ancient tracking code
345  //its taken from https://cmssdt.cern.ch/dxr/CMSSW/source/RecoTracker/TrackProducer/interface/TrackProducerBase.icc#165
346  //which inspires this code
347  Chi2MeasurementEstimator estimator(30., -3.0, 0.5, 2.0, 0.5, 1.e12); // same as defauts....
348 
349  const std::vector<GeometricSearchDet::DetWithState>& detWithState =
350  layer.compatibleDets(hitSurState, propToLayerFromState, estimator);
351  if (detWithState.empty())
352  return false;
353  else {
354  DetId id = detWithState.front().first->geographicalId();
356  //Below, measDet.hasBadComponents handles the check that a Pixel module has or not errors like FED25
357  if (measDet.isActive() && !measDet.hasBadComponents(detWithState.front().second))
358  return true;
359  else
360  return false;
361  }
362 }
MeasurementDetWithData idToDet(const DetId &id) const
Previous MeasurementDetSystem interface.
Definition: DetId.h:17
MeasurementTrackerEvent const & measTkEvt_
bool hasBadComponents(const TrajectoryStateOnSurface &tsos) const

◆ makePSetDescription()

edm::ParameterSetDescription TrajSeedMatcher::makePSetDescription ( )
static

Definition at line 118 of file TrajSeedMatcher.cc.

References common_cff::defaults, submitPVResolutionJobs::desc, eostools::move(), and or.

Referenced by ElectronNHitSeedProducer::fillDescriptions().

118  {
120  desc.add<bool>("useRecoVertex", false);
121  desc.add<bool>("enableHitSkipping", false);
122  desc.add<bool>("requireExactMatchCount", true);
123  desc.add<bool>("useParamMagFieldIfDefined", true);
124  desc.add<edm::ESInputTag>("paramMagField", edm::ESInputTag{"", "ParabolicMf"});
125  desc.add<edm::ESInputTag>("navSchool", edm::ESInputTag{"", "SimpleNavigationSchool"});
126  desc.add<edm::ESInputTag>("detLayerGeom", edm::ESInputTag{"", "hltESPGlobalDetLayerGeometry"});
127  desc.add<std::vector<int> >("minNrHitsValidLayerBins", {4});
128  desc.add<std::vector<unsigned int> >("minNrHits", {2, 3});
129 
131  auto cutDescCases = 1 >> (edm::ParameterDescription<double>("dPhiMax", 0.04, true) and
132  edm::ParameterDescription<double>("dRZMax", 0.09, true) and
133  edm::ParameterDescription<double>("dRZMaxLowEtThres", 20., true) and
134  edm::ParameterDescription<std::vector<double> >("dRZMaxLowEtEtaBins", {1., 1.5}, true) and
135  edm::ParameterDescription<std::vector<double> >("dRZMaxLowEt", {0.09, 0.15, 0.09}, true)) or
136  2 >> (edm::ParameterDescription<std::vector<double> >("dPhiMaxHighEt", {0.003}, true) and
137  edm::ParameterDescription<std::vector<double> >("dPhiMaxHighEtThres", {0.0}, true) and
138  edm::ParameterDescription<std::vector<double> >("dPhiMaxLowEtGrad", {0.0}, true) and
139  edm::ParameterDescription<std::vector<double> >("dRZMaxHighEt", {0.005}, true) and
140  edm::ParameterDescription<std::vector<double> >("dRZMaxHighEtThres", {30}, true) and
141  edm::ParameterDescription<std::vector<double> >("dRZMaxLowEtGrad", {-0.002}, true) and
142  edm::ParameterDescription<std::vector<double> >("etaBins", {}, true));
143  cutsDesc.ifValue(edm::ParameterDescription<int>("version", 1, true), std::move(cutDescCases));
144 
146  defaults.addParameter<double>("dPhiMax", 0.04);
147  defaults.addParameter<double>("dRZMax", 0.09);
148  defaults.addParameter<double>("dRZMaxLowEtThres", 0.09);
149  defaults.addParameter<std::vector<double> >("dRZMaxLowEtEtaBins", std::vector<double>{1., 1.5});
150  defaults.addParameter<std::vector<double> >("dRZMaxLowEt", std::vector<double>{0.09, 0.09, 0.09});
151  defaults.addParameter<int>("version", 1);
152  desc.addVPSet("matchingCuts", cutsDesc, std::vector<edm::ParameterSet>{defaults, defaults, defaults});
153  return desc;
154 }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
HLT enums.
def move(src, dest)
Definition: eostools.py:511

◆ makeTrajStateOnSurface()

TrajectoryStateOnSurface TrajSeedMatcher::makeTrajStateOnSurface ( const GlobalPoint pos,
const float  energy,
const int  charge 
) const
private

Definition at line 292 of file TrajSeedMatcher.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, HBHEDarkening_cff::energy, ftsFromVertexToPoint(), and vprim_.

Referenced by operator()().

294  {
295  auto freeTS = ftsFromVertexToPoint(pos, vprim_, energy, charge);
296  return TrajectoryStateOnSurface(freeTS, *PerpendicularBoundPlaneBuilder{}(freeTS.position(), freeTS.momentum()));
297 }
const GlobalPoint vprim_
auto ftsFromVertexToPoint(GlobalPoint const &point, GlobalPoint const &vertex, float energy, int charge) const

◆ operator()()

std::vector< TrajSeedMatcher::SeedWithInfo > TrajSeedMatcher::operator() ( const GlobalPoint candPos,
const float  energy 
)

Definition at line 156 of file TrajSeedMatcher.cc.

References cfg_, clearCache(), HBHEDarkening_cff::energy, getNrHitsRequired(), getNrValidLayersAlongTraj(), makeTrajStateOnSurface(), WZElectronSkims53X_cff::max, processSeed(), TrajSeedMatcher::Configuration::requireExactMatchCount, fileCollector::seed, and seeds_.

156  {
157  clearCache();
158 
159  std::vector<SeedWithInfo> matchedSeeds;
160 
161  //these are super expensive functions
162  TrajectoryStateOnSurface scTrajStateOnSurfNeg = makeTrajStateOnSurface(candPos, energy, -1);
163  TrajectoryStateOnSurface scTrajStateOnSurfPos = makeTrajStateOnSurface(candPos, energy, 1);
164 
165  for (const auto& seed : seeds_) {
166  std::vector<SCHitMatch> matchedHitsNeg = processSeed(seed, candPos, energy, scTrajStateOnSurfNeg);
167  std::vector<SCHitMatch> matchedHitsPos = processSeed(seed, candPos, energy, scTrajStateOnSurfPos);
168 
169  int nrValidLayersPos = 0;
170  int nrValidLayersNeg = 0;
171  if (matchedHitsNeg.size() >= 2) {
172  nrValidLayersNeg = getNrValidLayersAlongTraj(matchedHitsNeg[0], matchedHitsNeg[1], candPos, energy, -1);
173  }
174  if (matchedHitsPos.size() >= 2) {
175  nrValidLayersPos = getNrValidLayersAlongTraj(matchedHitsPos[0], matchedHitsPos[1], candPos, energy, +1);
176  }
177 
178  int nrValidLayers = std::max(nrValidLayersNeg, nrValidLayersPos);
179  size_t nrHitsRequired = getNrHitsRequired(nrValidLayers);
180  bool matchCountPasses;
182  // If the input seed collection is not cross-cleaned, an exact match is necessary to
183  // prevent redundant seeds.
184  matchCountPasses = matchedHitsNeg.size() == nrHitsRequired || matchedHitsPos.size() == nrHitsRequired;
185  } else {
186  matchCountPasses = matchedHitsNeg.size() >= nrHitsRequired || matchedHitsPos.size() >= nrHitsRequired;
187  }
188  if (matchCountPasses) {
189  matchedSeeds.push_back({seed, makeMatchInfoVector(matchedHitsPos, matchedHitsNeg), nrValidLayers});
190  }
191  }
192  return matchedSeeds;
193 }
std::vector< SCHitMatch > processSeed(const TrajectorySeed &seed, const GlobalPoint &candPos, const float energy, const TrajectoryStateOnSurface &initialTrajState)
size_t getNrHitsRequired(const int nrValidLayers) const
TrajectorySeedCollection const & seeds_
Configuration const & cfg_
int getNrValidLayersAlongTraj(const SCHitMatch &hit1, const SCHitMatch &hit2, const GlobalPoint &candPos, const float energy, const int charge)
TrajectoryStateOnSurface makeTrajStateOnSurface(const GlobalPoint &pos, const float energy, const int charge) const

◆ processSeed()

std::vector< TrajSeedMatcher::SCHitMatch > TrajSeedMatcher::processSeed ( const TrajectorySeed seed,
const GlobalPoint candPos,
const float  energy,
const TrajectoryStateOnSurface initialTrajState 
)
private

Definition at line 195 of file TrajSeedMatcher.cc.

References backwardPropagator_, cfg_, ALCARECOTkAlJpsiMuMu_cff::charge, TrajectoryStateOnSurface::charge(), TrajSeedMatcher::Configuration::enableHitSkipping, HBHEDarkening_cff::energy, PV3DBase< T, PVType, FrameType >::eta(), forwardPropagator_, ftsFromVertexToPoint(), getTrajStateFromPoint(), getTrajStateFromVtx(), getZVtxFromExtrapolation(), TrajectoryStateOnSurface::isValid(), match(), oniaPATMuonsWithTrigger_cff::matches, TrajSeedMatcher::Configuration::matchingCuts, PV3DBase< T, PVType, FrameType >::phi(), rpcPointValidation_cfi::recHit, fileCollector::seed, funct::sin(), PV3DBase< T, PVType, FrameType >::theta(), TrajSeedMatcher::Configuration::useRecoVertex, bphysicsOniaDQM_cfi::vertex, vprim_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and HLT_FULL_cff::zVertex.

Referenced by operator()().

198  {
199  //next try passing these variables in once...
200  const float candEta = candPos.eta();
201  const float candEt = energy * std::sin(candPos.theta());
202  const int charge = initialTrajState.charge();
203 
204  std::vector<SCHitMatch> matches;
205  FreeTrajectoryState firstMatchFreeTraj;
206  GlobalPoint prevHitPos;
208  const auto nCuts = cfg_.matchingCuts.size();
209  for (size_t iHit = 0;
210  matches.size() < nCuts && iHit < seed.nHits() && (cfg_.enableHitSkipping || iHit == matches.size());
211  iHit++) {
212  auto const& recHit = *(seed.recHits().begin() + iHit);
213 
214  if (!recHit.isValid()) {
215  continue;
216  }
217 
218  const bool doFirstMatch = matches.empty();
219 
220  auto const& trajState = doFirstMatch
221  ? getTrajStateFromVtx(recHit, initialTrajState, backwardPropagator_)
222  : getTrajStateFromPoint(recHit, firstMatchFreeTraj, prevHitPos, forwardPropagator_);
223  if (!trajState.isValid()) {
224  continue;
225  }
226 
227  auto const& vtxForMatchObject = doFirstMatch ? vprim_ : vertex;
228  auto match = makeSCHitMatch(vtxForMatchObject, trajState, recHit, candEt, candEta, candPos.phi(), charge, 1);
229 
230  if ((*cfg_.matchingCuts[matches.size()])(match)) {
231  matches.push_back(match);
232  if (doFirstMatch) {
233  //now we can figure out the z vertex
234  double zVertex = cfg_.useRecoVertex ? vprim_.z() : getZVtxFromExtrapolation(vprim_, match.hitPos, candPos);
236  firstMatchFreeTraj = ftsFromVertexToPoint(match.hitPos, vertex, energy, charge);
237  }
238  prevHitPos = match.hitPos;
239  }
240  }
241  return matches;
242 }
const TrajectoryStateOnSurface & getTrajStateFromVtx(const TrackingRecHit &hit, const TrajectoryStateOnSurface &initialState, const PropagatorWithMaterial &propagator)
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T eta() const
Definition: PV3DBase.h:73
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
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)
const std::vector< std::unique_ptr< MatchingCuts > > matchingCuts
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
PropagatorWithMaterial forwardPropagator_
Configuration const & cfg_
const GlobalPoint vprim_
auto ftsFromVertexToPoint(GlobalPoint const &point, GlobalPoint const &vertex, float energy, int charge) const
PropagatorWithMaterial backwardPropagator_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72

Member Data Documentation

◆ backwardPropagator_

PropagatorWithMaterial TrajSeedMatcher::backwardPropagator_
private

Definition at line 215 of file TrajSeedMatcher.h.

Referenced by getNrValidLayersAlongTraj(), and processSeed().

◆ cfg_

Configuration const& TrajSeedMatcher::cfg_
private

◆ detLayerGeom_

DetLayerGeometry const& TrajSeedMatcher::detLayerGeom_
private

Definition at line 212 of file TrajSeedMatcher.h.

Referenced by getNrValidLayersAlongTraj().

◆ forwardPropagator_

PropagatorWithMaterial TrajSeedMatcher::forwardPropagator_
private

Definition at line 214 of file TrajSeedMatcher.h.

Referenced by getNrValidLayersAlongTraj(), and processSeed().

◆ kElectronMass_

constexpr float TrajSeedMatcher::kElectronMass_ = 0.000511
staticprivate

Definition at line 201 of file TrajSeedMatcher.h.

◆ magField_

MagneticField const& TrajSeedMatcher::magField_
private

Definition at line 208 of file TrajSeedMatcher.h.

Referenced by ftsFromVertexToPoint().

◆ magFieldParam_

MagneticField const& TrajSeedMatcher::magFieldParam_
private

Definition at line 209 of file TrajSeedMatcher.h.

Referenced by ftsFromVertexToPoint().

◆ measTkEvt_

MeasurementTrackerEvent const& TrajSeedMatcher::measTkEvt_
private

Definition at line 210 of file TrajSeedMatcher.h.

Referenced by layerHasValidHits().

◆ navSchool_

NavigationSchool const& TrajSeedMatcher::navSchool_
private

Definition at line 211 of file TrajSeedMatcher.h.

Referenced by getNrValidLayersAlongTraj().

◆ seeds_

TrajectorySeedCollection const& TrajSeedMatcher::seeds_
private

Definition at line 203 of file TrajSeedMatcher.h.

Referenced by operator()().

◆ trajStateFromPointNegChargeCache_

IntGlobalPointPairUnorderedMap<TrajectoryStateOnSurface> TrajSeedMatcher::trajStateFromPointNegChargeCache_
private

Definition at line 221 of file TrajSeedMatcher.h.

Referenced by clearCache(), and getTrajStateFromPoint().

◆ trajStateFromPointPosChargeCache_

IntGlobalPointPairUnorderedMap<TrajectoryStateOnSurface> TrajSeedMatcher::trajStateFromPointPosChargeCache_
private

Definition at line 220 of file TrajSeedMatcher.h.

Referenced by clearCache(), and getTrajStateFromPoint().

◆ trajStateFromVtxNegChargeCache_

std::unordered_map<int, TrajectoryStateOnSurface> TrajSeedMatcher::trajStateFromVtxNegChargeCache_
private

Definition at line 218 of file TrajSeedMatcher.h.

Referenced by clearCache(), and getTrajStateFromVtx().

◆ trajStateFromVtxPosChargeCache_

std::unordered_map<int, TrajectoryStateOnSurface> TrajSeedMatcher::trajStateFromVtxPosChargeCache_
private

Definition at line 217 of file TrajSeedMatcher.h.

Referenced by clearCache(), and getTrajStateFromVtx().

◆ vprim_

const GlobalPoint TrajSeedMatcher::vprim_
private