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){
33 int version=cutPSet.getParameter<
int>(
"version");
36 matchingCuts_.emplace_back(std::make_unique<MatchingCutsV1>(cutPSet));
39 matchingCuts_.emplace_back(std::make_unique<MatchingCutsV2>(cutPSet));
42 throw cms::Exception(
"InvalidConfig") <<
" Error TrajSeedMatcher::TrajSeedMatcher pixel match cuts version "<<version<<
" not recognised"<<std::endl;
54 desc.
add<
bool>(
"useRecoVertex",
false);
56 desc.
add<
std::string>(
"detLayerGeom",
"hltESPGlobalDetLayerGeometry");
57 desc.
add<std::vector<int> >(
"minNrHitsValidLayerBins",{4});
58 desc.
add<std::vector<unsigned int> >(
"minNrHits",{2,3});
82 defaults.
addParameter<std::vector<double> >(
"dRZMaxLowEtEtaBins",std::vector<double>{1.,1.5});
83 defaults.
addParameter<std::vector<double> >(
"dRZMaxLowEt",std::vector<double>{0.09,0.09,0.09});
102 std::vector<TrajSeedMatcher::SeedWithInfo>
107 throw cms::Exception(
"LogicError") <<__FUNCTION__<<
" can not make pixel seeds as event setup has not properly been called";
112 std::vector<SeedWithInfo> matchedSeeds;
113 for(
const auto&
seed : seeds) {
114 std::vector<SCHitMatch> matchedHitsNeg =
processSeed(
seed,candPos,vprim,energy,-1);
115 std::vector<SCHitMatch> matchedHitsPos =
processSeed(
seed,candPos,vprim,energy,+1);
116 int nrValidLayersPos = 0;
117 int nrValidLayersNeg = 0;
118 if(matchedHitsNeg.size()>=2){
121 candPos,vprim,energy,-1);
123 if(matchedHitsPos.size()>=2){
126 candPos,vprim,energy,+1);
129 int nrValidLayers =
std::max(nrValidLayersNeg,nrValidLayersPos);
140 if(matchedHitsNeg.size()==nrHitsRequired ||
141 matchedHitsPos.size()==nrHitsRequired){
142 matchedSeeds.push_back({
seed,matchedHitsPos,matchedHitsNeg,nrValidLayers});
153 std::vector<TrajSeedMatcher::SCHitMatch>
157 const float candEta = candPos.
eta();
163 trajStateFromVtx.momentum()));
165 std::vector<SCHitMatch> matchedHits;
169 matchedHits.push_back(firstHit);
183 matchedHits.push_back(hit);
184 prevHitPos = hit.
hitPos();
195 auto sq = [](
float x){
return x*
x;};
199 const double r1Diff = calRDiff(primeVtxPos,hitPos);
200 const double r2Diff = calRDiff(hitPos,candPos);
201 return hitPos.
z() - r1Diff*(candPos.
z()-hitPos.
z())/r2Diff;
206 float dt = hitPos.
x()*candPos.
x()+hitPos.
y()*candPos.
y();
207 if (dt<0)
return false;
220 auto res = trajStateFromVtxCache.find(
key);
221 if(
res!=trajStateFromVtxCache.end())
return res->second;
225 return val.first->second;
239 auto res = trajStateFromPointCache.find(
key);
240 if(res!=trajStateFromPointCache.end())
return res->second;
244 return val.first->second;
254 auto hitIt = hits.first;
256 if(hitIt->isValid()){
258 if(trajStateFromVtx.
isValid())
return SCHitMatch(vtxPos,trajStateFromVtx,*hitIt);
271 auto hitIt = hits.first+hitNr;
273 if(hitIt->isValid()){
297 throw cms::Exception(
"LogicError") <<
" Error, attempting to apply selection to hit "<<hitNr<<
" but only cuts for "<<
matchingCuts_.size()<<
" defined";
304 const float energy,
const int charge)
319 if(detLayer==
nullptr)
return 0;
327 int nrPixOutLayers=0;
328 for(
auto layer : inLayers){
334 for(
auto layer : outLayers){
340 return nrValidLayers;
351 const std::vector<GeometricSearchDet::DetWithState>& detWithState = layer.
compatibleDets(hitSurState,propToLayerFromState,estimator);
352 if(detWithState.empty())
return false;
354 DetId id = detWithState.front().first->geographicalId();
374 detId_(hit.geographicalId()),
375 hitPos_(hit.globalPosition()),
377 et_(0),eta_(0),phi_(0),charge_(0),nrClus_(0)
381 dPhi_ = pointPair.dPhi();
387 const std::vector<SCHitMatch>& posCharge,
388 const std::vector<SCHitMatch>& negCharge,
390 seed_(seed),nrValidLayers_(nrValidLayers)
392 size_t nrHitsMax =
std::max(posCharge.size(),negCharge.size());
393 for(
size_t hitNr=0;hitNr<nrHitsMax;hitNr++){
394 DetId detIdPos = hitNr<posCharge.size() ? posCharge[hitNr].detId() :
DetId(0);
398 DetId detIdNeg = hitNr<negCharge.size() ? negCharge[hitNr].detId() :
DetId(0);
402 if(detIdPos!=detIdNeg && (detIdPos.
rawId()!=0 && detIdNeg.
rawId()!=0)){
403 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";
411 dPhiMax_(pset.getParameter<double>(
"dPhiMax")),
412 dRZMax_(pset.getParameter<double>(
"dRZMax")),
413 dRZMaxLowEtThres_(pset.getParameter<double>(
"dRZMaxLowEtThres")),
414 dRZMaxLowEtEtaBins_(pset.getParameter<
std::vector<double> >(
"dRZMaxLowEtEtaBins")),
415 dRZMaxLowEt_(pset.getParameter<
std::vector<double> >(
"dRZMaxLowEt"))
436 const float absEta =
std::abs(scEta);
445 dPhiHighEt_(pset.getParameter<
std::vector<double> >(
"dPhiMaxHighEt")),
446 dPhiHighEtThres_(pset.getParameter<
std::vector<double> >(
"dPhiMaxHighEtThres")),
447 dPhiLowEtGrad_(pset.getParameter<
std::vector<double> >(
"dPhiMaxLowEtGrad")),
448 dRZHighEt_(pset.getParameter<
std::vector<double> >(
"dRZMaxHighEt")),
449 dRZHighEtThres_(pset.getParameter<
std::vector<double> >(
"dRZMaxHighEtThres")),
450 dRZLowEtGrad_(pset.getParameter<
std::vector<double> >(
"dRZMaxLowEtGrad")),
451 etaBins_(pset.getParameter<
std::vector<double> >(
"etaBins"))
453 auto binSizeCheck = [](
size_t sizeEtaBins,
const std::vector<double>& vec,
const std::string&
name){
454 if(vec.size()!=sizeEtaBins+1){
455 throw cms::Exception(
"InvalidConfig")<<
" when constructing TrajSeedMatcher::MatchingCutsV2 "<<
name<<
" has "<<vec.size()<<
" bins, it should be equal to #bins of etaBins+1"<<sizeEtaBins+1;
470 if(dPhiMax>=0 &&
std::abs(scHitMatch.
dPhi()) > dPhiMax)
return false;
472 if(dRZMax>=0 &&
std::abs(scHitMatch.
dRZ()) > dRZMax)
return false;
481 for(
size_t etaNr=0;etaNr<
etaBins_.size();etaNr++){
482 if(absEta<
etaBins_[etaNr])
return etaNr;
MatchingCutsV1(const edm::ParameterSet &pset)
const GlobalPoint & hitPos() const
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)
MatchingCutsV2(const edm::ParameterSet &pset)
DetId detId(size_t hitNr) const
std::vector< double > dRZLowEtGrad_
TrackCharge charge() const
const TrajectoryStateOnSurface & getTrajStateFromVtx(const TrackingRecHit &hit, const TrajectoryStateOnSurface &initialState, const PropagatorWithMaterial &propagator)
std::vector< double > dPhiLowEtGrad_
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxPosChargeCache_
const TrackingRecHit * hit() const
bool passesMatchSel(const SCHitMatch &hit, const size_t hitNr) const
Sin< T >::type sin(const T &t)
edm::ESHandle< DetLayerGeometry > detLayerGeom_
Geom::Phi< T > phi() const
float dRZPos(size_t hitNr) const
bool passTrajPreSel(const GlobalPoint &hitPos, const GlobalPoint &candPos) const
constexpr uint32_t rawId() const
get the raw id
std::unique_ptr< PropagatorWithMaterial > forwardPropagator_
const std::vector< int > minNrHitsValidLayerBins_
const double dRZMaxLowEtThres_
TrackCharge charge() const
const std::vector< double > dRZMaxLowEt_
static float getZVtxFromExtrapolation(const GlobalPoint &primeVtxPos, const GlobalPoint &hitPos, const GlobalPoint &candPos)
const Plane & surface() const
The nominal surface of the GeomDet.
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
const TrajectoryStateOnSurface & getTrajStateFromPoint(const TrackingRecHit &hit, const FreeTrajectoryState &initialState, const GlobalPoint &point, const PropagatorWithMaterial &propagator)
Geom::Theta< T > theta() const
edm::ESHandle< NavigationSchool > navSchool_
std::vector< double > etaBins_
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
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
std::vector< MatchInfo > matchInfo_
FreeTrajectoryState const * freeState(bool withErrors=true) const
void addParameter(std::string const &name, T const &value)
std::vector< const DetLayer * > compatibleLayers(const DetLayer &detLayer, Args &&...args) const
Returns all layers compatible.
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::vector< std::unique_ptr< MatchingCuts > > matchingCuts_
Abs< T >::type abs(const T &t)
std::pair< const_iterator, const_iterator > range
void setExtra(float et, float eta, float phi, int charge, int nrClus)
float dPhiPos(size_t hitNr) const
bool operator()(const SCHitMatch &scHitMatch) const override
bool operator()(const SCHitMatch &scHitMatch) const override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< double > dPhiHighEt_
size_t getNrHitsRequired(const int nrValidLayers) const
size_t getBinNr(float eta) const
GlobalPoint position() const
std::string navSchoolLabel_
float getDRZCutValue(const float scEt, const float scEta) const
const std::vector< double > dRZMaxLowEtEtaBins_
const GlobalTrajectoryParameters & globalParameters() const
edm::Handle< MeasurementTrackerEvent > measTkEvt_
static float kElectronMass_
std::vector< double > dPhiHighEtThres_
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
TrajSeedMatcher::SCHitMatch match2ndToNthHit(const TrajectorySeed &seed, const FreeTrajectoryState &trajState, const size_t hitNr, const GlobalPoint &prevHitPos, const GlobalPoint &vtxPos, const PropagatorWithMaterial &propagator)
unsigned int nHits() const
SeedWithInfo(const TrajectorySeed &seed, const std::vector< SCHitMatch > &posCharge, const std::vector< SCHitMatch > &negCharge, int nrValidLayers)
TrajSeedMatcher(const edm::ParameterSet &pset)
std::string detLayerGeomLabel_
float dRZNeg(size_t hitNr) const
DetId geographicalId() const
virtual const DetLayer * idToLayer(const DetId &detId) const
int getNrValidLayersAlongTraj(const SCHitMatch &hit1, const SCHitMatch &hit2, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy, const int charge)
std::unique_ptr< PropagatorWithMaterial > backwardPropagator_
bool layerHasValidHits(const DetLayer &layer, const TrajectoryStateOnSurface &hitSurState, const Propagator &propToLayerFromState) const
TrajSeedMatcher::SCHitMatch matchFirstHit(const TrajectorySeed &seed, const TrajectoryStateOnSurface &trajState, const GlobalPoint &vtxPos, const PropagatorWithMaterial &propagator)
bool isTrackerPixel(GeomDetEnumerators::SubDetector m)
*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
std::vector< double > dRZHighEtThres_
std::vector< double > dRZHighEt_
float dPhiNeg(size_t hitNr) const
float getCutValue(float et, float highEt, float highEtThres, float lowEtGrad) const
std::vector< SCHitMatch > processSeed(const TrajectorySeed &seed, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy, const int charge)
const std::vector< unsigned int > minNrHits_