24 : cacheIDMagField_(0),
25 paramMagFieldLabel_(pset.getParameter<
std::
string>(
"paramMagField")),
26 navSchoolLabel_(pset.getParameter<
std::
string>(
"navSchool")),
27 detLayerGeomLabel_(pset.getParameter<
std::
string>(
"detLayerGeom")),
28 useRecoVertex_(pset.getParameter<
bool>(
"useRecoVertex")),
29 enableHitSkipping_(pset.getParameter<
bool>(
"enableHitSkipping")),
30 requireExactMatchCount_(pset.getParameter<
bool>(
"requireExactMatchCount")),
31 useParamMagFieldIfDefined_(pset.getParameter<
bool>(
"useParamMagFieldIfDefined")),
32 minNrHits_(pset.getParameter<
std::vector<unsigned
int> >(
"minNrHits")),
33 minNrHitsValidLayerBins_(pset.getParameter<
std::vector<
int> >(
"minNrHitsValidLayerBins")) {
36 int version = cutPSet.getParameter<
int>(
"version");
39 matchingCuts_.emplace_back(std::make_unique<MatchingCutsV1>(cutPSet));
42 matchingCuts_.emplace_back(std::make_unique<MatchingCutsV2>(cutPSet));
45 throw cms::Exception(
"InvalidConfig") <<
" Error TrajSeedMatcher::TrajSeedMatcher pixel match cuts version " 46 << version <<
" not recognised" << std::endl;
52 <<
" TrajSeedMatcher::TrajSeedMatcher minNrHitsValidLayerBins should be 1 less than minNrHits when its " 59 desc.
add<
bool>(
"useRecoVertex",
false);
60 desc.
add<
bool>(
"enableHitSkipping",
false);
61 desc.
add<
bool>(
"requireExactMatchCount",
true);
62 desc.
add<
bool>(
"useParamMagFieldIfDefined",
true);
65 desc.
add<
std::string>(
"detLayerGeom",
"hltESPGlobalDetLayerGeometry");
66 desc.
add<std::vector<int> >(
"minNrHitsValidLayerBins", {4});
67 desc.
add<std::vector<unsigned int> >(
"minNrHits", {2, 3});
74 "dRZMaxLowEtEtaBins", std::vector<double>{1., 1.5},
true) and
76 "dRZMaxLowEt", std::vector<double>{0.09, 0.15, 0.09},
true))
or 90 defaults.
addParameter<std::vector<double> >(
"dRZMaxLowEtEtaBins", std::vector<double>{1., 1.5});
91 defaults.
addParameter<std::vector<double> >(
"dRZMaxLowEt", std::vector<double>{0.09, 0.09, 0.09});
116 <<
" can not make pixel seeds as event setup has not properly been called";
121 std::vector<SeedWithInfo> matchedSeeds;
127 for (
const auto&
seed : seeds) {
128 std::vector<SCHitMatch> matchedHitsNeg =
processSeed(
seed, candPos, vprim, energy, scTrajStateOnSurfNeg);
129 std::vector<SCHitMatch> matchedHitsPos =
processSeed(
seed, candPos, vprim, energy, scTrajStateOnSurfPos);
131 int nrValidLayersPos = 0;
132 int nrValidLayersNeg = 0;
133 if (matchedHitsNeg.size() >= 2) {
136 if (matchedHitsPos.size() >= 2) {
140 int nrValidLayers =
std::max(nrValidLayersNeg, nrValidLayersPos);
142 bool matchCountPasses;
146 matchCountPasses = matchedHitsNeg.size() == nrHitsRequired || matchedHitsPos.size() == nrHitsRequired;
148 matchCountPasses = matchedHitsNeg.size() >= nrHitsRequired || matchedHitsPos.size() >= nrHitsRequired;
150 if (matchCountPasses) {
151 matchedSeeds.push_back({
seed, matchedHitsPos, matchedHitsNeg, nrValidLayers});
163 const float candEta = candPos.
eta();
167 std::vector<SCHitMatch> matchedHits;
171 for (
size_t hitNr = 0; hitNr <
matchingCuts_.size() && hitNr < seed.
nHits(); hitNr++) {
173 if (matchedHits.empty()) {
178 matchedHits.push_back(firstHit);
184 prevHitPos = firstHit.
hitPos();
191 matchedHits.push_back(hit);
192 prevHitPos = hit.
hitPos();
205 auto sq = [](
float x) {
return x *
x; };
209 const double r1Diff = calRDiff(primeVtxPos, hitPos);
210 const double r2Diff = calRDiff(hitPos, candPos);
211 return hitPos.
z() - r1Diff * (candPos.
z() - hitPos.
z()) / r2Diff;
215 float dt = hitPos.
x() * candPos.
x() + hitPos.
y() * candPos.
y();
226 auto& trajStateFromVtxCache =
230 auto res = trajStateFromVtxCache.find(
key);
231 if (
res != trajStateFromVtxCache.end())
236 return val.first->second;
244 auto& trajStateFromPointCache =
248 auto res = trajStateFromPointCache.find(
key);
249 if (res != trajStateFromPointCache.end())
254 return val.first->second;
272 auto hitIt = hits.first;
274 if (hitIt->isValid()) {
276 if (trajStateFromVtx.
isValid())
277 return SCHitMatch(vtxPos, trajStateFromVtx, *hitIt);
289 auto hitIt = hits.first + hitNr;
291 if (hitIt->isValid()) {
312 throw cms::Exception(
"LogicError") <<
" Error, attempting to apply selection to hit " << hitNr
313 <<
" but only cuts for " <<
matchingCuts_.size() <<
" defined";
335 if (detLayer ==
nullptr)
339 const std::vector<const DetLayer*> inLayers =
343 int nrValidLayers = 1;
344 int nrPixInLayers = 0;
345 int nrPixOutLayers = 0;
346 for (
auto layer : inLayers) {
353 for (
auto layer : outLayers) {
360 return nrValidLayers;
365 const Propagator& propToLayerFromState)
const {
371 const std::vector<GeometricSearchDet::DetWithState>& detWithState =
372 layer.
compatibleDets(hitSurState, propToLayerFromState, estimator);
373 if (detWithState.empty())
376 DetId id = detWithState.front().first->geographicalId();
396 : detId_(hit.geographicalId()),
397 hitPos_(hit.globalPosition()),
406 dPhi_ = pointPair.dPhi();
410 const std::vector<SCHitMatch>& posCharge,
411 const std::vector<SCHitMatch>& negCharge,
413 : seed_(seed), nrValidLayers_(nrValidLayers) {
414 size_t nrHitsMax =
std::max(posCharge.size(), negCharge.size());
415 for (
size_t hitNr = 0; hitNr < nrHitsMax; hitNr++) {
416 DetId detIdPos = hitNr < posCharge.size() ? posCharge[hitNr].detId() :
DetId(0);
420 DetId detIdNeg = hitNr < negCharge.size() ? negCharge[hitNr].detId() :
DetId(0);
424 if (detIdPos != detIdNeg && (detIdPos.
rawId() != 0 && detIdNeg.
rawId() != 0)) {
426 <<
" error in " << __FILE__ <<
", " << __LINE__
427 <<
" hits to be combined have different detIDs, this should not be possible and nothing good will come of it";
435 : dPhiMax_(pset.getParameter<double>(
"dPhiMax")),
436 dRZMax_(pset.getParameter<double>(
"dRZMax")),
437 dRZMaxLowEtThres_(pset.getParameter<double>(
"dRZMaxLowEtThres")),
438 dRZMaxLowEtEtaBins_(pset.getParameter<
std::vector<double> >(
"dRZMaxLowEtEtaBins")),
439 dRZMaxLowEt_(pset.getParameter<
std::vector<double> >(
"dRZMaxLowEt")) {
441 throw cms::Exception(
"InvalidConfig") <<
" dRZMaxLowEtEtaBins should be 1 less than dRZMaxLowEt when its " 461 const float absEta =
std::abs(scEta);
471 : dPhiHighEt_(pset.getParameter<
std::vector<double> >(
"dPhiMaxHighEt")),
472 dPhiHighEtThres_(pset.getParameter<
std::vector<double> >(
"dPhiMaxHighEtThres")),
473 dPhiLowEtGrad_(pset.getParameter<
std::vector<double> >(
"dPhiMaxLowEtGrad")),
474 dRZHighEt_(pset.getParameter<
std::vector<double> >(
"dRZMaxHighEt")),
475 dRZHighEtThres_(pset.getParameter<
std::vector<double> >(
"dRZMaxHighEtThres")),
476 dRZLowEtGrad_(pset.getParameter<
std::vector<double> >(
"dRZMaxLowEtGrad")),
477 etaBins_(pset.getParameter<
std::vector<double> >(
"etaBins")) {
478 auto binSizeCheck = [](
size_t sizeEtaBins,
const std::vector<double>& vec,
const std::string&
name) {
479 if (vec.size() != sizeEtaBins + 1) {
481 <<
" when constructing TrajSeedMatcher::MatchingCutsV2 " <<
name <<
" has " << vec.size()
482 <<
" bins, it should be equal to #bins of etaBins+1" << sizeEtaBins + 1;
496 if (dPhiMax >= 0 &&
std::abs(scHitMatch.
dPhi()) > dPhiMax)
499 if (dRZMax >= 0 &&
std::abs(scHitMatch.
dRZ()) > dRZMax)
508 for (
size_t etaNr = 0; etaNr <
etaBins_.size(); etaNr++) {
MatchingCutsV1(const edm::ParameterSet &pset)
const GlobalPoint & hitPos() const
T getParameter(std::string const &) const
unsigned long long cacheIdentifier() const
MeasurementDetWithData idToDet(const DetId &id) const
Previous MeasurementDetSystem interface.
void doEventSetup(const edm::EventSetup &iSetup)
bool useParamMagFieldIfDefined_
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurface > trajStateFromPointNegChargeCache_
std::pair< const_iterator, const_iterator > range
std::vector< TrajSeedMatcher::SeedWithInfo > compatibleSeeds(const TrajectorySeedCollection &seeds, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy)
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_
const TrackingRecHit * hit() const
const MagneticField & getMagField(const GlobalPoint &point) const
TrajectoryStateOnSurface makeTrajStateOnSurface(const GlobalPoint &pos, const GlobalPoint &vtx, const float energy, const int charge) const
edm::ESHandle< MagneticField > magFieldParam_
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurface > trajStateFromPointPosChargeCache_
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
Global3DPoint GlobalPoint
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_
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_
std::string paramMagFieldLabel_
Abs< T >::type abs(const T &t)
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxPosChargeCache_
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
GlobalVector momentum() const
size_t getBinNr(float eta) const
GlobalPoint position() const
std::string navSchoolLabel_
float getDRZCutValue(const float scEt, const float scEta) const
GlobalPoint position() 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)
std::vector< SCHitMatch > processSeed(const TrajectorySeed &seed, const GlobalPoint &candPos, const GlobalPoint &vprim, const float energy, const TrajectoryStateOnSurface &initialTrajState)
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
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxNegChargeCache_
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_
bool requireExactMatchCount_
std::vector< double > dRZHighEt_
float dPhiNeg(size_t hitNr) const
float getCutValue(float et, float highEt, float highEtThres, float lowEtGrad) const
const std::vector< unsigned int > minNrHits_