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

class  HitInfo
 
struct  MatchInfo
 
class  MatchingCuts
 
class  SeedWithInfo
 

Public Member Functions

std::vector< TrajSeedMatcher::SeedWithInfocompatibleSeeds (const TrajectorySeedCollection &seeds, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy)
 
void doEventSetup (const edm::EventSetup &iSetup)
 
void setMeasTkEvtHandle (edm::Handle< MeasurementTrackerEvent > handle)
 
 TrajSeedMatcher (const edm::ParameterSet &pset)
 
 ~TrajSeedMatcher ()=default
 

Static Public Member Functions

static edm::ParameterSetDescription makePSetDescription ()
 

Private Member Functions

void clearCache ()
 
size_t getNrHitsRequired (const int nrValidLayers) const
 
int getNrValidLayersAlongTraj (const HitInfo &hit1, const HitInfo &hit2, const GlobalPoint &candPos, const GlobalPoint &vprim, 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
 
TrajSeedMatcher::HitInfo match2ndToNthHit (const TrajectorySeed &seed, const FreeTrajectoryState &trajState, const size_t hitNr, const GlobalPoint &prevHitPos, const GlobalPoint &vtxPos, const PropagatorWithMaterial &propagator)
 
TrajSeedMatcher::HitInfo matchFirstHit (const TrajectorySeed &seed, const TrajectoryStateOnSurface &trajState, const GlobalPoint &vtxPos, const PropagatorWithMaterial &propagator)
 
bool passesMatchSel (const HitInfo &hit, const size_t hitNr, const float scEt, const float scEta) const
 
bool passTrajPreSel (const GlobalPoint &hitPos, const GlobalPoint &candPos) const
 
std::vector< HitInfoprocessSeed (const TrajectorySeed &seed, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy, const int charge)
 

Static Private Member Functions

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

Private Attributes

std::unique_ptr< PropagatorWithMaterialbackwardPropagator_
 
unsigned long long cacheIDMagField_
 
edm::ESHandle< DetLayerGeometrydetLayerGeom_
 
std::string detLayerGeomLabel_
 
std::unique_ptr< PropagatorWithMaterialforwardPropagator_
 
edm::ESHandle< MagneticFieldmagField_
 
std::vector< MatchingCutsmatchingCuts_
 
edm::Handle< MeasurementTrackerEventmeasTkEvt_
 
const std::vector< unsigned int > minNrHits_
 
const std::vector< int > minNrHitsValidLayerBins_
 
edm::ESHandle< NavigationSchoolnavSchool_
 
std::string navSchoolLabel_
 
std::unordered_map< std::pair< int, GlobalPoint >, TrajectoryStateOnSurfacetrajStateFromPointNegChargeCache_
 
std::unordered_map< std::pair< int, GlobalPoint >, TrajectoryStateOnSurfacetrajStateFromPointPosChargeCache_
 
std::unordered_map< int, TrajectoryStateOnSurfacetrajStateFromVtxNegChargeCache_
 
std::unordered_map< int, TrajectoryStateOnSurfacetrajStateFromVtxPosChargeCache_
 
bool useRecoVertex_
 

Static Private Attributes

static float kElectronMass_ = 0.000511
 
static float kPhiCut_ = -0.801144
 

Detailed Description

Definition at line 77 of file TrajSeedMatcher.h.

Constructor & Destructor Documentation

TrajSeedMatcher::TrajSeedMatcher ( const edm::ParameterSet pset)
explicit

Definition at line 23 of file TrajSeedMatcher.cc.

References detLayerGeomLabel_, Exception, edm::ParameterSet::getParameter(), matchingCuts_, minNrHits_, minNrHitsValidLayerBins_, navSchoolLabel_, AlCaHLTBitMon_QueryRunRegistry::string, and useRecoVertex_.

23  :
25  minNrHits_(pset.getParameter<std::vector<unsigned int> >("minNrHits")),
26  minNrHitsValidLayerBins_(pset.getParameter<std::vector<int> >("minNrHitsValidLayerBins"))
27 {
28  useRecoVertex_ = pset.getParameter<bool>("useRecoVertex");
29  navSchoolLabel_ = pset.getParameter<std::string>("navSchool");
30  detLayerGeomLabel_ = pset.getParameter<std::string>("detLayerGeom");
31  const auto cutsPSets=pset.getParameter<std::vector<edm::ParameterSet> >("matchingCuts");
32  for(const auto & cutPSet : cutsPSets){
33  matchingCuts_.push_back(MatchingCuts(cutPSet));
34  }
35 
36  if(minNrHitsValidLayerBins_.size()+1!=minNrHits_.size()){
37  throw cms::Exception("InvalidConfig")<<" minNrHitsValidLayerBins should be 1 less than minNrHits when its "<<minNrHitsValidLayerBins_.size()<<" vs "<<minNrHits_.size();
38  }
39 }
T getParameter(std::string const &) const
const std::vector< int > minNrHitsValidLayerBins_
unsigned long long cacheIDMagField_
std::vector< MatchingCuts > matchingCuts_
std::string navSchoolLabel_
std::string detLayerGeomLabel_
const std::vector< unsigned int > minNrHits_
TrajSeedMatcher::~TrajSeedMatcher ( )
default

Member Function Documentation

void TrajSeedMatcher::clearCache ( )
private

Definition at line 245 of file TrajSeedMatcher.cc.

References trajStateFromPointNegChargeCache_, trajStateFromPointPosChargeCache_, trajStateFromVtxNegChargeCache_, and trajStateFromVtxPosChargeCache_.

Referenced by compatibleSeeds().

246 {
251 }
std::unordered_map< std::pair< int, GlobalPoint >, TrajectoryStateOnSurface > trajStateFromPointNegChargeCache_
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxNegChargeCache_
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxPosChargeCache_
std::unordered_map< std::pair< int, GlobalPoint >, TrajectoryStateOnSurface > trajStateFromPointPosChargeCache_
std::vector< TrajSeedMatcher::SeedWithInfo > TrajSeedMatcher::compatibleSeeds ( const TrajectorySeedCollection seeds,
const GlobalPoint candPos,
const GlobalPoint vprim,
const float  energy 
)

Definition at line 75 of file TrajSeedMatcher.cc.

References backwardPropagator_, clearCache(), Exception, forwardPropagator_, getNrHitsRequired(), getNrValidLayersAlongTraj(), edm::ESHandleBase::isValid(), magField_, hpstanc_transforms::max, processSeed(), and SurveyInfoScenario_cff::seed.

Referenced by ElectronNHitSeedProducer::produce().

77 {
79  throw cms::Exception("LogicError") <<__FUNCTION__<<" can not make pixel seeds as event setup has not properly been called";
80  }
81 
82  clearCache();
83 
84  std::vector<SeedWithInfo> matchedSeeds;
85  for(const auto& seed : seeds) {
86  std::vector<HitInfo> matchedHitsNeg = processSeed(seed,candPos,vprim,energy,-1);
87  std::vector<HitInfo> matchedHitsPos = processSeed(seed,candPos,vprim,energy,+1);
88  int nrValidLayersPos = 0;
89  int nrValidLayersNeg = 0;
90  if(matchedHitsNeg.size()>=2){
91  nrValidLayersNeg = getNrValidLayersAlongTraj(matchedHitsNeg[0],
92  matchedHitsNeg[1],
93  candPos,vprim,energy,-1);
94  }
95  if(matchedHitsPos.size()>=2){
96  nrValidLayersPos = getNrValidLayersAlongTraj(matchedHitsPos[0],
97  matchedHitsPos[1],
98  candPos,vprim,energy,+1);
99  }
100 
101  int nrValidLayers = std::max(nrValidLayersNeg,nrValidLayersPos);
102  size_t nrHitsRequired = getNrHitsRequired(nrValidLayers);
103  //so we require the number of hits to exactly match, this is because we currently do not
104  //do any duplicate cleaning for the input seeds
105  //this means is a hit pair with a 3rd hit will appear twice (or however many hits it has)
106  //so if you did >=nrHitsRequired, you would get the same seed multiple times
107  //ideally we should fix this and clean our input seed collection so each seed is only in once
108  //also it should be studied what impact having a 3rd hit has on a GsfTrack
109  //ie will we get a significantly different result seeding with a hit pair
110  //and the same the hit pair with a 3rd hit added
111  //in that case, perhaps it should be >=
112  if(matchedHitsNeg.size()==nrHitsRequired ||
113  matchedHitsPos.size()==nrHitsRequired){
114  matchedSeeds.push_back({seed,matchedHitsPos,matchedHitsNeg,nrValidLayers});
115  }
116 
117 
118  }
119  return matchedSeeds;
120 }
std::unique_ptr< PropagatorWithMaterial > forwardPropagator_
edm::ESHandle< MagneticField > magField_
int getNrValidLayersAlongTraj(const HitInfo &hit1, const HitInfo &hit2, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy, const int charge)
size_t getNrHitsRequired(const int nrValidLayers) const
std::vector< HitInfo > processSeed(const TrajectorySeed &seed, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy, const int charge)
bool isValid() const
Definition: ESHandle.h:47
std::unique_ptr< PropagatorWithMaterial > backwardPropagator_
void TrajSeedMatcher::doEventSetup ( const edm::EventSetup iSetup)

Definition at line 61 of file TrajSeedMatcher.cc.

References alongMomentum, backwardPropagator_, edm::eventsetup::EventSetupRecord::cacheIdentifier(), cacheIDMagField_, detLayerGeom_, detLayerGeomLabel_, forwardPropagator_, edm::EventSetup::get(), kElectronMass_, magField_, navSchool_, navSchoolLabel_, and oppositeToMomentum.

Referenced by ElectronNHitSeedProducer::produce().

62 {
64  iSetup.get<IdealMagneticFieldRecord>().get(magField_);
65  cacheIDMagField_=iSetup.get<IdealMagneticFieldRecord>().cacheIdentifier();
66  forwardPropagator_=std::make_unique<PropagatorWithMaterial>(alongMomentum,kElectronMass_,&*(magField_));
67  backwardPropagator_=std::make_unique<PropagatorWithMaterial>(oppositeToMomentum,kElectronMass_,&*(magField_));
68  }
71 }
unsigned long long cacheIdentifier() const
edm::ESHandle< DetLayerGeometry > detLayerGeom_
std::unique_ptr< PropagatorWithMaterial > forwardPropagator_
edm::ESHandle< NavigationSchool > navSchool_
unsigned long long cacheIDMagField_
edm::ESHandle< MagneticField > magField_
std::string navSchoolLabel_
const T & get() const
Definition: EventSetup.h:56
static float kElectronMass_
std::string detLayerGeomLabel_
std::unique_ptr< PropagatorWithMaterial > backwardPropagator_
size_t TrajSeedMatcher::getNrHitsRequired ( const int  nrValidLayers) const
private

Definition at line 324 of file TrajSeedMatcher.cc.

References minNrHits_, and minNrHitsValidLayerBins_.

Referenced by compatibleSeeds().

325 {
326  for(size_t binNr=0;binNr<minNrHitsValidLayerBins_.size();binNr++){
327  if(nrValidLayers<minNrHitsValidLayerBins_[binNr]) return minNrHits_[binNr];
328  }
329  return minNrHits_.back();
330 
331 }
const std::vector< int > minNrHitsValidLayerBins_
const std::vector< unsigned int > minNrHits_
int TrajSeedMatcher::getNrValidLayersAlongTraj ( const HitInfo hit1,
const HitInfo hit2,
const GlobalPoint candPos,
const GlobalPoint vprim,
const float  energy,
const int  charge 
)
private

Definition at line 263 of file TrajSeedMatcher.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, forwardPropagator_, TrackingRecHit::geographicalId(), FTSFromVertexToPointFactory::get(), getTrajStateFromPoint(), getZVtxFromExtrapolation(), TrajSeedMatcher::HitInfo::hit(), magField_, TrajSeedMatcher::HitInfo::pos(), useRecoVertex_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and CombinatorialSeedGeneratorForCosmicsRegionalReconstruction_cfi::zVertex.

Referenced by compatibleSeeds().

267 {
268  double zVertex = useRecoVertex_ ? vprim.z() : getZVtxFromExtrapolation(vprim,hit1.pos(),candPos);
269  GlobalPoint vertex(vprim.x(),vprim.y(),zVertex);
270 
271  FreeTrajectoryState firstHitFreeTraj = FTSFromVertexToPointFactory::get(*magField_,hit1.pos(),
272  vertex, energy, charge);
273  const TrajectoryStateOnSurface& secondHitTraj = getTrajStateFromPoint(*hit2.hit(),firstHitFreeTraj,hit1.pos(),*forwardPropagator_);
274  return getNrValidLayersAlongTraj(hit2.hit()->geographicalId(),secondHitTraj);
275 }
static FreeTrajectoryState get(MagneticField const &magField, GlobalPoint const &xmeas, GlobalPoint const &xvert, float momentum, TrackCharge charge)
std::unique_ptr< PropagatorWithMaterial > forwardPropagator_
T y() const
Definition: PV3DBase.h:63
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)
edm::ESHandle< MagneticField > magField_
int getNrValidLayersAlongTraj(const HitInfo &hit1, const HitInfo &hit2, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy, const int charge)
T z() const
Definition: PV3DBase.h:64
T x() const
Definition: PV3DBase.h:62
int TrajSeedMatcher::getNrValidLayersAlongTraj ( const DetId hitId,
const TrajectoryStateOnSurface hitTrajState 
) const
private

Definition at line 277 of file TrajSeedMatcher.cc.

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

278 {
279 
280  const DetLayer* detLayer = detLayerGeom_->idToLayer(hitId);
281  if(detLayer==nullptr) return 0;
282 
283  const FreeTrajectoryState& hitFreeState = *hitTrajState.freeState();
284  const std::vector<const DetLayer*> inLayers = navSchool_->compatibleLayers(*detLayer,hitFreeState,oppositeToMomentum);
285  const std::vector<const DetLayer*> outLayers = navSchool_->compatibleLayers(*detLayer,hitFreeState,alongMomentum);
286 
287  int nrValidLayers=1; //because our current hit is also valid and wont be included in the count otherwise
288  int nrPixInLayers=0;
289  int nrPixOutLayers=0;
290  for(auto layer : inLayers){
291  if(GeomDetEnumerators::isTrackerPixel(layer->subDetector())){
292  nrPixInLayers++;
293  if(layerHasValidHits(*layer,hitTrajState,*backwardPropagator_)) nrValidLayers++;
294  }
295  }
296  for(auto layer : outLayers){
297  if(GeomDetEnumerators::isTrackerPixel(layer->subDetector())){
298  nrPixOutLayers++;
299  if(layerHasValidHits(*layer,hitTrajState,*forwardPropagator_)) nrValidLayers++;
300  }
301  }
302  return nrValidLayers;
303 }
edm::ESHandle< DetLayerGeometry > detLayerGeom_
std::unique_ptr< PropagatorWithMaterial > forwardPropagator_
edm::ESHandle< NavigationSchool > navSchool_
FreeTrajectoryState const * freeState(bool withErrors=true) const
std::vector< const DetLayer * > compatibleLayers(const DetLayer &detLayer, Args &&...args) const
Returns all layers compatible.
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)
virtual const DetLayer * idToLayer(const DetId &detId) const
std::unique_ptr< PropagatorWithMaterial > backwardPropagator_
bool layerHasValidHits(const DetLayer &layer, const TrajectoryStateOnSurface &hitSurState, const Propagator &propToLayerFromState) const
const TrajectoryStateOnSurface & TrajSeedMatcher::getTrajStateFromPoint ( const TrackingRecHit hit,
const FreeTrajectoryState initialState,
const GlobalPoint point,
const PropagatorWithMaterial propagator 
)
private

Definition at line 197 of file TrajSeedMatcher.cc.

References FreeTrajectoryState::charge(), TrackingRecHit::det(), GeomDet::gdetIndex(), crabWrapper::key, point, Propagator::propagate(), GeomDet::surface(), trajStateFromPointNegChargeCache_, trajStateFromPointPosChargeCache_, and heppy_batch::val.

Referenced by getNrValidLayersAlongTraj(), and match2ndToNthHit().

198 {
199 
200  auto& trajStateFromPointCache = initialState.charge()==1 ? trajStateFromPointPosChargeCache_ :
202 
203  auto key = std::make_pair(hit.det()->gdetIndex(),point);
204  auto res = trajStateFromPointCache.find(key);
205  if(res!=trajStateFromPointCache.end()) return res->second;
206  else{ //doesnt exist, need to make it
207  //FIXME: check for efficiency
208  auto val = trajStateFromPointCache.emplace(key,propagator.propagate(initialState,hit.det()->surface()));
209  return val.first->second;
210  }
211 }
std::unordered_map< std::pair< int, GlobalPoint >, TrajectoryStateOnSurface > trajStateFromPointNegChargeCache_
int gdetIndex() const
Definition: GeomDet.h:103
TrackCharge charge() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
Definition: Electron.h:4
std::unordered_map< std::pair< int, GlobalPoint >, TrajectoryStateOnSurface > trajStateFromPointPosChargeCache_
const GeomDet * det() const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
*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 TrajectoryStateOnSurface & TrajSeedMatcher::getTrajStateFromVtx ( const TrackingRecHit hit,
const TrajectoryStateOnSurface initialState,
const PropagatorWithMaterial propagator 
)
private

Definition at line 182 of file TrajSeedMatcher.cc.

References TrajectoryStateOnSurface::charge(), TrackingRecHit::det(), GeomDet::gdetIndex(), crabWrapper::key, Propagator::propagate(), GeomDet::surface(), trajStateFromVtxNegChargeCache_, trajStateFromVtxPosChargeCache_, and heppy_batch::val.

Referenced by matchFirstHit().

183 {
184  auto& trajStateFromVtxCache = initialState.charge()==1 ? trajStateFromVtxPosChargeCache_ :
186 
187  auto key = hit.det()->gdetIndex();
188  auto res = trajStateFromVtxCache.find(key);
189  if(res!=trajStateFromVtxCache.end()) return res->second;
190  else{ //doesnt exist, need to make it
191  //FIXME: check for efficiency
192  auto val = trajStateFromVtxCache.emplace(key,propagator.propagate(initialState,hit.det()->surface()));
193  return val.first->second;
194  }
195 }
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxNegChargeCache_
int gdetIndex() const
Definition: GeomDet.h:103
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxPosChargeCache_
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
Definition: Electron.h:4
const GeomDet * det() const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
float TrajSeedMatcher::getZVtxFromExtrapolation ( const GlobalPoint primeVtxPos,
const GlobalPoint hitPos,
const GlobalPoint candPos 
)
staticprivate

Definition at line 162 of file TrajSeedMatcher.cc.

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

Referenced by getNrValidLayersAlongTraj(), and processSeed().

164 {
165  auto sq = [](float x){return x*x;};
166  auto calRDiff = [sq](const GlobalPoint& p1,const GlobalPoint& p2){
167  return std::sqrt(sq(p2.x()-p1.x()) + sq(p2.y()-p1.y()));
168  };
169  const double r1Diff = calRDiff(primeVtxPos,hitPos);
170  const double r2Diff = calRDiff(hitPos,candPos);
171  return hitPos.z() - r1Diff*(candPos.z()-hitPos.z())/r2Diff;
172 }
T y() const
Definition: PV3DBase.h:63
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
double p2[4]
Definition: TauolaWrapper.h:90
double p1[4]
Definition: TauolaWrapper.h:89
T x() const
Definition: PV3DBase.h:62
bool TrajSeedMatcher::layerHasValidHits ( const DetLayer layer,
const TrajectoryStateOnSurface hitSurState,
const Propagator propToLayerFromState 
) const
private

Definition at line 305 of file TrajSeedMatcher.cc.

References GeometricSearchDet::compatibleDets(), gsfElectronCkfTrackCandidateMaker_cff::estimator, MeasurementTrackerEvent::idToDet(), MeasurementDetWithData::isActive(), and measTkEvt_.

Referenced by getNrValidLayersAlongTraj().

307 {
308  //FIXME: do not hardcode with werid magic numbers stolen from ancient tracking code
309  //its taken from https://cmssdt.cern.ch/dxr/CMSSW/source/RecoTracker/TrackProducer/interface/TrackProducerBase.icc#165
310  //which inspires this code
311  Chi2MeasurementEstimator estimator(30.,-3.0,0.5,2.0,0.5,1.e12); // same as defauts....
312 
313  const std::vector<GeometricSearchDet::DetWithState>& detWithState = layer.compatibleDets(hitSurState,propToLayerFromState,estimator);
314  if(detWithState.empty()) return false;
315  else{
316  DetId id = detWithState.front().first->geographicalId();
318  if(measDet.isActive()) return true;
319  else return false;
320  }
321 }
MeasurementDetWithData idToDet(const DetId &id) const
Previous MeasurementDetSystem interface.
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: DetId.h:18
edm::Handle< MeasurementTrackerEvent > measTkEvt_
edm::ParameterSetDescription TrajSeedMatcher::makePSetDescription ( )
static

Definition at line 41 of file TrajSeedMatcher.cc.

References edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addVPSet(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ElectronNHitSeedProducer::fillDescriptions().

42 {
44  desc.add<bool>("useRecoVertex",false);
45  desc.add<std::string>("navSchool","SimpleNavigationSchool");
46  desc.add<std::string>("detLayerGeom","hltESPGlobalDetLayerGeometry");
47  desc.add<std::vector<int> >("minNrHitsValidLayerBins",{4});
48  desc.add<std::vector<unsigned int> >("minNrHits",{2,3});
49 
50 
52  cutsDesc.add<double>("dPhiMax",0.04);
53  cutsDesc.add<double>("dRZMax",0.09);
54  cutsDesc.add<double>("dRZMaxLowEtThres",20.);
55  cutsDesc.add<std::vector<double> >("dRZMaxLowEtEtaBins",std::vector<double>{1.,1.5});
56  cutsDesc.add<std::vector<double> >("dRZMaxLowEt",std::vector<double>{0.09,0.15,0.09});
57  desc.addVPSet("matchingCuts",cutsDesc);
58  return desc;
59 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
TrajSeedMatcher::HitInfo TrajSeedMatcher::match2ndToNthHit ( const TrajectorySeed seed,
const FreeTrajectoryState trajState,
const size_t  hitNr,
const GlobalPoint prevHitPos,
const GlobalPoint vtxPos,
const PropagatorWithMaterial propagator 
)
private

Definition at line 225 of file TrajSeedMatcher.cc.

References getTrajStateFromPoint(), hfClusterShapes_cfi::hits, TrajectoryStateOnSurface::isValid(), and TrajectorySeed::recHits().

Referenced by processSeed().

231 {
232  const TrajectorySeed::range& hits = seed.recHits();
233  auto hitIt = hits.first+hitNr;
234 
235  if(hitIt->isValid()){
236  const TrajectoryStateOnSurface& trajState = getTrajStateFromPoint(*hitIt,initialState,prevHitPos,propagator);
237  if(trajState.isValid()){
238  return HitInfo(vtxPos,trajState,*hitIt);
239  }
240  }
241  return HitInfo();
242 
243 }
const TrajectoryStateOnSurface & getTrajStateFromPoint(const TrackingRecHit &hit, const FreeTrajectoryState &initialState, const GlobalPoint &point, const PropagatorWithMaterial &propagator)
std::pair< const_iterator, const_iterator > range
range recHits() const
TrajSeedMatcher::HitInfo TrajSeedMatcher::matchFirstHit ( const TrajectorySeed seed,
const TrajectoryStateOnSurface trajState,
const GlobalPoint vtxPos,
const PropagatorWithMaterial propagator 
)
private

Definition at line 213 of file TrajSeedMatcher.cc.

References getTrajStateFromVtx(), hfClusterShapes_cfi::hits, TrajectoryStateOnSurface::isValid(), and TrajectorySeed::recHits().

Referenced by processSeed().

214 {
215  const TrajectorySeed::range& hits = seed.recHits();
216  auto hitIt = hits.first;
217 
218  if(hitIt->isValid()){
219  const TrajectoryStateOnSurface& trajStateFromVtx = getTrajStateFromVtx(*hitIt,initialState,propagator);
220  if(trajStateFromVtx.isValid()) return HitInfo(vtxPos,trajStateFromVtx,*hitIt);
221  }
222  return HitInfo();
223 }
const TrajectoryStateOnSurface & getTrajStateFromVtx(const TrackingRecHit &hit, const TrajectoryStateOnSurface &initialState, const PropagatorWithMaterial &propagator)
std::pair< const_iterator, const_iterator > range
range recHits() const
bool TrajSeedMatcher::passesMatchSel ( const HitInfo hit,
const size_t  hitNr,
const float  scEt,
const float  scEta 
) const
private

Definition at line 253 of file TrajSeedMatcher.cc.

References Exception, and matchingCuts_.

Referenced by processSeed().

254 {
255  if(hitNr<matchingCuts_.size()){
256  return matchingCuts_[hitNr](hit,scEt,scEta);
257  }else{
258  throw cms::Exception("LogicError") <<" Error, attempting to apply selection to hit "<<hitNr<<" but only cuts for "<<matchingCuts_.size()<<" defined";
259  }
260 
261 }
std::vector< MatchingCuts > matchingCuts_
bool TrajSeedMatcher::passTrajPreSel ( const GlobalPoint hitPos,
const GlobalPoint candPos 
) const
private

Definition at line 174 of file TrajSeedMatcher.cc.

References dt, kPhiCut_, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

175 {
176  float dt = hitPos.x()*candPos.x()+hitPos.y()*candPos.y();
177  if (dt<0) return false;
178  if (dt<kPhiCut_*(candPos.perp()*hitPos.perp())) return false;
179  return true;
180 }
float dt
Definition: AMPTWrapper.h:126
T perp() const
Definition: PV3DBase.h:72
T y() const
Definition: PV3DBase.h:63
T x() const
Definition: PV3DBase.h:62
static float kPhiCut_
std::vector< TrajSeedMatcher::HitInfo > TrajSeedMatcher::processSeed ( const TrajectorySeed seed,
const GlobalPoint candPos,
const GlobalPoint vprim,
const float  energy,
const int  charge 
)
private

Definition at line 126 of file TrajSeedMatcher.cc.

References backwardPropagator_, ALCARECOTkAlJpsiMuMu_cff::charge, PV3DBase< T, PVType, FrameType >::eta(), forwardPropagator_, FTSFromVertexToPointFactory::get(), getZVtxFromExtrapolation(), magField_, match2ndToNthHit(), matchFirstHit(), matchingCuts_, TrajectorySeed::nHits(), passesMatchSel(), TrajSeedMatcher::HitInfo::pos(), funct::sin(), PV3DBase< T, PVType, FrameType >::theta(), useRecoVertex_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), and CombinatorialSeedGeneratorForCosmicsRegionalReconstruction_cfi::zVertex.

Referenced by compatibleSeeds().

128 {
129  const float candEta = candPos.eta();
130  const float candEt = energy*std::sin(candPos.theta());
131 
132  FreeTrajectoryState trajStateFromVtx = FTSFromVertexToPointFactory::get(*magField_, candPos, vprim, energy, charge);
134  TrajectoryStateOnSurface initialTrajState(trajStateFromVtx,*bpb(trajStateFromVtx.position(),
135  trajStateFromVtx.momentum()));
136 
137  std::vector<HitInfo> matchedHits;
138  HitInfo firstHit = matchFirstHit(seed,initialTrajState,vprim,*backwardPropagator_);
139  if(passesMatchSel(firstHit,0,candEt,candEta)){
140  matchedHits.push_back(firstHit);
141 
142  //now we can figure out the z vertex
143  double zVertex = useRecoVertex_ ? vprim.z() : getZVtxFromExtrapolation(vprim,firstHit.pos(),candPos);
144  GlobalPoint vertex(vprim.x(),vprim.y(),zVertex);
145 
146  FreeTrajectoryState firstHitFreeTraj = FTSFromVertexToPointFactory::get(*magField_, firstHit.pos(),
147  vertex, energy, charge) ;
148 
149  GlobalPoint prevHitPos = firstHit.pos();
150  for(size_t hitNr=1;hitNr<matchingCuts_.size() && hitNr<seed.nHits();hitNr++){
151  HitInfo hit = match2ndToNthHit(seed,firstHitFreeTraj,hitNr,prevHitPos,vertex,*forwardPropagator_);
152  if(passesMatchSel(hit,hitNr,candEt,candEta)){
153  matchedHits.push_back(hit);
154  prevHitPos = hit.pos();
155  }else break;
156  }
157  }
158  return matchedHits;
159 }
static FreeTrajectoryState get(MagneticField const &magField, GlobalPoint const &xmeas, GlobalPoint const &xvert, float momentum, TrackCharge charge)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::unique_ptr< PropagatorWithMaterial > forwardPropagator_
T y() const
Definition: PV3DBase.h:63
TrajSeedMatcher::HitInfo matchFirstHit(const TrajectorySeed &seed, const TrajectoryStateOnSurface &trajState, const GlobalPoint &vtxPos, const PropagatorWithMaterial &propagator)
static float getZVtxFromExtrapolation(const GlobalPoint &primeVtxPos, const GlobalPoint &hitPos, const GlobalPoint &candPos)
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
edm::ESHandle< MagneticField > magField_
std::vector< MatchingCuts > matchingCuts_
TrajSeedMatcher::HitInfo match2ndToNthHit(const TrajectorySeed &seed, const FreeTrajectoryState &trajState, const size_t hitNr, const GlobalPoint &prevHitPos, const GlobalPoint &vtxPos, const PropagatorWithMaterial &propagator)
T z() const
Definition: PV3DBase.h:64
bool passesMatchSel(const HitInfo &hit, const size_t hitNr, const float scEt, const float scEta) const
T eta() const
Definition: PV3DBase.h:76
unsigned int nHits() const
T x() const
Definition: PV3DBase.h:62
std::unique_ptr< PropagatorWithMaterial > backwardPropagator_
void TrajSeedMatcher::setMeasTkEvtHandle ( edm::Handle< MeasurementTrackerEvent handle)
inline

Member Data Documentation

std::unique_ptr<PropagatorWithMaterial> TrajSeedMatcher::backwardPropagator_
private
unsigned long long TrajSeedMatcher::cacheIDMagField_
private

Definition at line 220 of file TrajSeedMatcher.h.

Referenced by doEventSetup().

edm::ESHandle<DetLayerGeometry> TrajSeedMatcher::detLayerGeom_
private

Definition at line 224 of file TrajSeedMatcher.h.

Referenced by doEventSetup(), and getNrValidLayersAlongTraj().

std::string TrajSeedMatcher::detLayerGeomLabel_
private

Definition at line 226 of file TrajSeedMatcher.h.

Referenced by doEventSetup(), and TrajSeedMatcher().

std::unique_ptr<PropagatorWithMaterial> TrajSeedMatcher::forwardPropagator_
private
float TrajSeedMatcher::kElectronMass_ = 0.000511
staticprivate

Definition at line 216 of file TrajSeedMatcher.h.

Referenced by doEventSetup().

float TrajSeedMatcher::kPhiCut_ = -0.801144
staticprivate

Definition at line 217 of file TrajSeedMatcher.h.

Referenced by passTrajPreSel().

edm::ESHandle<MagneticField> TrajSeedMatcher::magField_
private
std::vector<MatchingCuts> TrajSeedMatcher::matchingCuts_
private

Definition at line 229 of file TrajSeedMatcher.h.

Referenced by passesMatchSel(), processSeed(), and TrajSeedMatcher().

edm::Handle<MeasurementTrackerEvent> TrajSeedMatcher::measTkEvt_
private

Definition at line 222 of file TrajSeedMatcher.h.

Referenced by layerHasValidHits().

const std::vector<unsigned int> TrajSeedMatcher::minNrHits_
private

Definition at line 236 of file TrajSeedMatcher.h.

Referenced by getNrHitsRequired(), and TrajSeedMatcher().

const std::vector<int> TrajSeedMatcher::minNrHitsValidLayerBins_
private

Definition at line 237 of file TrajSeedMatcher.h.

Referenced by getNrHitsRequired(), and TrajSeedMatcher().

edm::ESHandle<NavigationSchool> TrajSeedMatcher::navSchool_
private

Definition at line 223 of file TrajSeedMatcher.h.

Referenced by doEventSetup(), and getNrValidLayersAlongTraj().

std::string TrajSeedMatcher::navSchoolLabel_
private

Definition at line 225 of file TrajSeedMatcher.h.

Referenced by doEventSetup(), and TrajSeedMatcher().

std::unordered_map<std::pair<int,GlobalPoint>,TrajectoryStateOnSurface> TrajSeedMatcher::trajStateFromPointNegChargeCache_
private

Definition at line 243 of file TrajSeedMatcher.h.

Referenced by clearCache(), and getTrajStateFromPoint().

std::unordered_map<std::pair<int,GlobalPoint>,TrajectoryStateOnSurface> TrajSeedMatcher::trajStateFromPointPosChargeCache_
private

Definition at line 242 of file TrajSeedMatcher.h.

Referenced by clearCache(), and getTrajStateFromPoint().

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

Definition at line 240 of file TrajSeedMatcher.h.

Referenced by clearCache(), and getTrajStateFromVtx().

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

Definition at line 239 of file TrajSeedMatcher.h.

Referenced by clearCache(), and getTrajStateFromVtx().

bool TrajSeedMatcher::useRecoVertex_
private

Definition at line 228 of file TrajSeedMatcher.h.

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