25 minNrHits_(pset.getParameter<
std::vector<unsigned
int> >(
"minNrHits")),
26 minNrHitsValidLayerBins_(pset.getParameter<
std::vector<
int> >(
"minNrHitsValidLayerBins"))
31 const auto cutsPSets=pset.
getParameter<std::vector<edm::ParameterSet> >(
"matchingCuts");
32 for(
const auto & cutPSet : cutsPSets){
44 desc.
add<
bool>(
"useRecoVertex",
false);
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});
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});
58 defaults.addParameter<
double>(
"dPhiMax",0.04);
59 defaults.addParameter<
double>(
"dRZMax",0.09);
60 defaults.addParameter<
double>(
"dRZMaxLowEtThres",0.09);
61 defaults.addParameter<std::vector<double> >(
"dRZMaxLowEtEtaBins",std::vector<double>{1.,1.5});
62 defaults.addParameter<std::vector<double> >(
"dRZMaxLowEt",std::vector<double>{0.09,0.09,0.09});
80 std::vector<TrajSeedMatcher::SeedWithInfo>
85 throw cms::Exception(
"LogicError") <<__FUNCTION__<<
" can not make pixel seeds as event setup has not properly been called";
90 std::vector<SeedWithInfo> matchedSeeds;
91 for(
const auto&
seed : seeds) {
92 std::vector<HitInfo> matchedHitsNeg =
processSeed(
seed,candPos,vprim,energy,-1);
93 std::vector<HitInfo> matchedHitsPos =
processSeed(
seed,candPos,vprim,energy,+1);
94 int nrValidLayersPos = 0;
95 int nrValidLayersNeg = 0;
96 if(matchedHitsNeg.size()>=2){
99 candPos,vprim,energy,-1);
101 if(matchedHitsPos.size()>=2){
104 candPos,vprim,energy,+1);
107 int nrValidLayers =
std::max(nrValidLayersNeg,nrValidLayersPos);
118 if(matchedHitsNeg.size()==nrHitsRequired ||
119 matchedHitsPos.size()==nrHitsRequired){
120 matchedSeeds.push_back({
seed,matchedHitsPos,matchedHitsNeg,nrValidLayers});
131 std::vector<TrajSeedMatcher::HitInfo>
135 const float candEta = candPos.
eta();
141 trajStateFromVtx.momentum()));
143 std::vector<HitInfo> matchedHits;
146 matchedHits.push_back(firstHit);
159 matchedHits.push_back(hit);
160 prevHitPos = hit.
pos();
171 auto sq = [](
float x){
return x*
x;};
175 const double r1Diff = calRDiff(primeVtxPos,hitPos);
176 const double r2Diff = calRDiff(hitPos,candPos);
177 return hitPos.
z() - r1Diff*(candPos.
z()-hitPos.
z())/r2Diff;
182 float dt = hitPos.
x()*candPos.
x()+hitPos.
y()*candPos.
y();
183 if (dt<0)
return false;
194 auto res = trajStateFromVtxCache.find(
key);
195 if(
res!=trajStateFromVtxCache.end())
return res->second;
199 return val.first->second;
210 auto res = trajStateFromPointCache.find(
key);
211 if(res!=trajStateFromPointCache.end())
return res->second;
215 return val.first->second;
222 auto hitIt = hits.first;
224 if(hitIt->isValid()){
226 if(trajStateFromVtx.
isValid())
return HitInfo(vtxPos,trajStateFromVtx,*hitIt);
239 auto hitIt = hits.first+hitNr;
241 if(hitIt->isValid()){
244 return HitInfo(vtxPos,trajState,*hitIt);
264 throw cms::Exception(
"LogicError") <<
" Error, attempting to apply selection to hit "<<hitNr<<
" but only cuts for "<<
matchingCuts_.size()<<
" defined";
272 const float energy,
const int charge)
287 if(detLayer==
nullptr)
return 0;
295 int nrPixOutLayers=0;
296 for(
auto layer : inLayers){
302 for(
auto layer : outLayers){
308 return nrValidLayers;
319 const std::vector<GeometricSearchDet::DetWithState>& detWithState = layer.
compatibleDets(hitSurState,propToLayerFromState,estimator);
320 if(detWithState.empty())
return false;
322 DetId id = detWithState.front().first->geographicalId();
342 detId_(hit.geographicalId()),
343 pos_(hit.globalPosition()),
348 dPhi_ = pointPair.dPhi();
354 const std::vector<HitInfo>& posCharge,
355 const std::vector<HitInfo>& negCharge,
357 seed_(seed),nrValidLayers_(nrValidLayers)
359 size_t nrHitsMax =
std::max(posCharge.size(),negCharge.size());
360 for(
size_t hitNr=0;hitNr<nrHitsMax;hitNr++){
361 DetId detIdPos = hitNr<posCharge.size() ? posCharge[hitNr].detId() :
DetId(0);
365 DetId detIdNeg = hitNr<negCharge.size() ? negCharge[hitNr].detId() :
DetId(0);
369 if(detIdPos!=detIdNeg && (detIdPos.
rawId()!=0 && detIdNeg.
rawId()!=0)){
370 cms::Exception(
"LogicError")<<
" error in "<<__FILE__<<
", "<<__LINE__<<
" hits to be combined have different detIDs, this should not be possible and nothing good will come of it";
378 dPhiMax_(pset.getParameter<double>(
"dPhiMax")),
379 dRZMax_(pset.getParameter<double>(
"dRZMax")),
380 dRZMaxLowEtThres_(pset.getParameter<double>(
"dRZMaxLowEtThres")),
381 dRZMaxLowEtEtaBins_(pset.getParameter<
std::vector<double> >(
"dRZMaxLowEtEtaBins")),
382 dRZMaxLowEt_(pset.getParameter<
std::vector<double> >(
"dRZMaxLowEt"))
403 const float absEta =
std::abs(scEta);
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
std::unordered_map< std::pair< int, GlobalPoint >, TrajectoryStateOnSurface > trajStateFromPointNegChargeCache_
MeasurementDetWithData idToDet(const DetId &id) const
Previous MeasurementDetSystem interface.
void doEventSetup(const edm::EventSetup &iSetup)
std::vector< TrajSeedMatcher::SeedWithInfo > compatibleSeeds(const TrajectorySeedCollection &seeds, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy)
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxNegChargeCache_
static FreeTrajectoryState get(MagneticField const &magField, GlobalPoint const &xmeas, GlobalPoint const &xvert, float momentum, TrackCharge charge)
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
DetId detId(size_t hitNr) const
TrackCharge charge() const
const TrajectoryStateOnSurface & getTrajStateFromVtx(const TrackingRecHit &hit, const TrajectoryStateOnSurface &initialState, const PropagatorWithMaterial &propagator)
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxPosChargeCache_
Sin< T >::type sin(const T &t)
edm::ESHandle< DetLayerGeometry > detLayerGeom_
float dRZPos(size_t hitNr) const
bool passTrajPreSel(const GlobalPoint &hitPos, const GlobalPoint &candPos) const
std::unique_ptr< PropagatorWithMaterial > forwardPropagator_
const std::vector< int > minNrHitsValidLayerBins_
float getDRZCutValue(const float scEt, const float scEta) const
TrajSeedMatcher::HitInfo matchFirstHit(const TrajectorySeed &seed, const TrajectoryStateOnSurface &trajState, const GlobalPoint &vtxPos, const PropagatorWithMaterial &propagator)
TrackCharge charge() const
static float getZVtxFromExtrapolation(const GlobalPoint &primeVtxPos, const GlobalPoint &hitPos, const GlobalPoint &candPos)
const Plane & surface() const
The nominal surface of the GeomDet.
SeedWithInfo(const TrajectorySeed &seed, const std::vector< HitInfo > &posCharge, const std::vector< HitInfo > &negCharge, int nrValidLayers)
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
MatchingCuts(const edm::ParameterSet &pset)
const TrajectoryStateOnSurface & getTrajStateFromPoint(const TrackingRecHit &hit, const FreeTrajectoryState &initialState, const GlobalPoint &point, const PropagatorWithMaterial &propagator)
const double dRZMaxLowEtThres_
Geom::Theta< T > theta() const
uint32_t rawId() const
get the raw id
bool operator()(const HitInfo &hit, const float scEt, const float scEta) const
edm::ESHandle< NavigationSchool > navSchool_
unsigned long long cacheIDMagField_
std::unordered_map< std::pair< int, GlobalPoint >, TrajectoryStateOnSurface > trajStateFromPointPosChargeCache_
def defaults(locpath, dataType, var)
static edm::ParameterSetDescription makePSetDescription()
std::vector< TrajectorySeed > TrajectorySeedCollection
edm::ESHandle< MagneticField > magField_
const GeomDet * det() const
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)
int getNrValidLayersAlongTraj(const HitInfo &hit1, const HitInfo &hit2, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy, const int charge)
std::vector< MatchInfo > matchInfo_
FreeTrajectoryState const * freeState(bool withErrors=true) const
std::vector< const DetLayer * > compatibleLayers(const DetLayer &detLayer, Args &&...args) const
Returns all layers compatible.
Abs< T >::type abs(const T &t)
std::pair< const_iterator, const_iterator > range
float dPhiPos(size_t hitNr) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
const std::vector< double > dRZMaxLowEtEtaBins_
size_t getNrHitsRequired(const int nrValidLayers) const
const GlobalPoint & pos() const
GlobalPoint position() const
std::string navSchoolLabel_
const GlobalTrajectoryParameters & globalParameters() const
edm::Handle< MeasurementTrackerEvent > measTkEvt_
static float kElectronMass_
bool passesMatchSel(const HitInfo &hit, const size_t hitNr, const float scEt, const float scEta) const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
bool isTrackerPixel(const GeomDetEnumerators::SubDetector m)
const TrackingRecHit * hit() const
unsigned int nHits() const
const std::vector< double > dRZMaxLowEt_
TrajSeedMatcher(const edm::ParameterSet &pset)
std::vector< HitInfo > processSeed(const TrajectorySeed &seed, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy, const int charge)
std::string detLayerGeomLabel_
float dRZNeg(size_t hitNr) const
DetId geographicalId() const
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
*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
float dPhiNeg(size_t hitNr) const
const std::vector< unsigned int > minNrHits_