23 auto makeMatchingCuts(std::vector<edm::ParameterSet>
const&
cutsPSets) {
24 std::vector<std::unique_ptr<TrajSeedMatcher::MatchingCuts> > matchingCuts;
26 for (
const auto& cutPSet : cutsPSets) {
27 int version = cutPSet.getParameter<
int>(
"version");
30 matchingCuts.emplace_back(std::make_unique<TrajSeedMatcher::MatchingCutsV1>(cutPSet));
33 matchingCuts.emplace_back(std::make_unique<TrajSeedMatcher::MatchingCutsV2>(cutPSet));
36 throw cms::Exception(
"InvalidConfig") <<
" Error TrajSeedMatcher::TrajSeedMatcher pixel match cuts version "
37 << version <<
" not recognised" << std::endl;
57 const std::vector<TrajSeedMatcher::MatchInfo> makeMatchInfoVector(
58 std::vector<TrajSeedMatcher::SCHitMatch>
const& posCharge,
59 std::vector<TrajSeedMatcher::SCHitMatch>
const& negCharge) {
60 std::vector<TrajSeedMatcher::MatchInfo> matchInfos;
61 size_t nrHitsMax =
std::max(posCharge.size(), negCharge.size());
62 for (
size_t hitNr = 0; hitNr < nrHitsMax; hitNr++) {
63 DetId detIdPos = hitNr < posCharge.size() ? posCharge[hitNr].detId :
DetId(0);
67 DetId detIdNeg = hitNr < negCharge.size() ? negCharge[hitNr].detId :
DetId(0);
71 if (detIdPos != detIdNeg && (detIdPos.
rawId() != 0 && detIdNeg.
rawId() != 0)) {
72 cms::Exception(
"LogicError") <<
" error in " << __FILE__ <<
", " << __LINE__
73 <<
" hits to be combined have different detIDs, this should not be possible and "
74 "nothing good will come of it";
76 DetId detId = detIdPos.
rawId() != 0 ? detIdPos : detIdNeg;
77 matchInfos.push_back({detId, dRZPos, dRZNeg, dPhiPos, dPhiNeg});
84 : magFieldToken{cc.esConsumes()},
88 useRecoVertex{
pset.getParameter<
bool>(
"useRecoVertex")},
89 enableHitSkipping{
pset.getParameter<
bool>(
"enableHitSkipping")},
90 requireExactMatchCount{
pset.getParameter<
bool>(
"requireExactMatchCount")},
91 useParamMagFieldIfDefined{
pset.getParameter<
bool>(
"useParamMagFieldIfDefined")},
92 minNrHits{
pset.getParameter<std::vector<unsigned int> >(
"minNrHits")},
93 minNrHitsValidLayerBins{
pset.getParameter<std::vector<int> >(
"minNrHitsValidLayerBins")},
94 matchingCuts{makeMatchingCuts(
pset.getParameter<std::vector<edm::ParameterSet> >(
"matchingCuts"))} {
95 if (minNrHitsValidLayerBins.size() + 1 != minNrHits.size()) {
97 <<
" TrajSeedMatcher::TrajSeedMatcher minNrHitsValidLayerBins should be 1 less than minNrHits when its "
98 << minNrHitsValidLayerBins.size() <<
" vs " << minNrHits.size();
108 vprim_(vprim.x(), vprim.y(), vprim.z()),
110 magField_{iSetup.getData(cfg_.magFieldToken)},
111 magFieldParam_{iSetup.getData(cfg_.paramMagFieldToken)},
113 navSchool_{iSetup.getData(cfg_.navSchoolToken)},
114 detLayerGeom_{iSetup.getData(cfg_.detLayerGeomToken)},
115 forwardPropagator_(
alongMomentum, kElectronMass_, &magField_),
120 desc.
add<
bool>(
"useRecoVertex",
false);
121 desc.
add<
bool>(
"enableHitSkipping",
false);
122 desc.
add<
bool>(
"requireExactMatchCount",
true);
123 desc.
add<
bool>(
"useParamMagFieldIfDefined",
true);
127 desc.
add<std::vector<int> >(
"minNrHitsValidLayerBins", {4});
128 desc.
add<std::vector<unsigned int> >(
"minNrHits", {2, 3});
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});
159 std::vector<SeedWithInfo> matchedSeeds;
166 std::vector<SCHitMatch> matchedHitsNeg =
processSeed(
seed, candPos, energy, scTrajStateOnSurfNeg);
167 std::vector<SCHitMatch> matchedHitsPos =
processSeed(
seed, candPos, energy, scTrajStateOnSurfPos);
169 int nrValidLayersPos = 0;
170 int nrValidLayersNeg = 0;
171 if (matchedHitsNeg.size() >= 2) {
174 if (matchedHitsPos.size() >= 2) {
178 int nrValidLayers =
std::max(nrValidLayersNeg, nrValidLayersPos);
180 bool matchCountPasses;
184 matchCountPasses = matchedHitsNeg.size() == nrHitsRequired || matchedHitsPos.size() == nrHitsRequired;
186 matchCountPasses = matchedHitsNeg.size() >= nrHitsRequired || matchedHitsPos.size() >= nrHitsRequired;
188 if (matchCountPasses) {
189 matchedSeeds.push_back({
seed, makeMatchInfoVector(matchedHitsPos, matchedHitsNeg), nrValidLayers});
200 const float candEta = candPos.
eta();
202 const int charge = initialTrajState.
charge();
204 std::vector<SCHitMatch> matches;
209 for (
size_t iHit = 0;
214 if (!recHit.isValid()) {
218 const bool doFirstMatch = matches.empty();
220 auto const& trajState = doFirstMatch
227 auto const& vtxForMatchObject = doFirstMatch ?
vprim_ : vertex;
228 auto match = makeSCHitMatch(vtxForMatchObject, trajState, recHit, candEt, candEta, candPos.
phi(),
charge, 1);
231 matches.push_back(
match);
238 prevHitPos =
match.hitPos;
248 auto sq = [](
float x) {
return x *
x; };
252 const double r1Diff = calRDiff(primeVtxPos, hitPos);
253 const double r2Diff = calRDiff(hitPos, candPos);
254 return hitPos.
z() - r1Diff * (candPos.
z() - hitPos.
z()) / r2Diff;
260 auto& trajStateFromVtxCache =
264 auto res = trajStateFromVtxCache.find(
key);
265 if (res != trajStateFromVtxCache.end())
270 return val.first->second;
278 auto& trajStateFromPointCache =
282 auto res = trajStateFromPointCache.find(
key);
283 if (res != trajStateFromPointCache.end())
288 return val.first->second;
294 const int charge)
const {
318 if (detLayer ==
nullptr)
325 int nrValidLayers = 1;
326 int nrPixInLayers = 0;
327 int nrPixOutLayers = 0;
328 for (
auto layer : inLayers) {
335 for (
auto layer : outLayers) {
342 return nrValidLayers;
347 const Propagator& propToLayerFromState)
const {
353 const std::vector<GeometricSearchDet::DetWithState>& detWithState =
354 layer.
compatibleDets(hitSurState, propToLayerFromState, estimator);
355 if (detWithState.empty())
358 DetId id = detWithState.front().first->geographicalId();
376 : dPhiMax_(pset.getParameter<double>(
"dPhiMax")),
377 dRZMax_(pset.getParameter<double>(
"dRZMax")),
378 dRZMaxLowEtThres_(pset.getParameter<double>(
"dRZMaxLowEtThres")),
379 dRZMaxLowEtEtaBins_(pset.getParameter<std::
vector<double> >(
"dRZMaxLowEtEtaBins")),
380 dRZMaxLowEt_(pset.getParameter<std::
vector<double> >(
"dRZMaxLowEt")) {
382 throw cms::Exception(
"InvalidConfig") <<
" dRZMaxLowEtEtaBins should be 1 less than dRZMaxLowEt when its "
388 if (dPhiMax_ >= 0 &&
std::abs(scHitMatch.
dPhi) > dPhiMax_)
391 const float dRZMax = getDRZCutValue(scHitMatch.
et, scHitMatch.
eta);
392 if (dRZMax_ >= 0 &&
std::abs(scHitMatch.
dRZ) > dRZMax)
399 if (scEt >= dRZMaxLowEtThres_)
402 const float absEta =
std::abs(scEta);
403 for (
size_t etaNr = 0; etaNr < dRZMaxLowEtEtaBins_.size(); etaNr++) {
404 if (absEta < dRZMaxLowEtEtaBins_[etaNr])
405 return dRZMaxLowEt_[etaNr];
407 return dRZMaxLowEt_.back();
412 : dPhiHighEt_(pset.getParameter<std::
vector<double> >(
"dPhiMaxHighEt")),
413 dPhiHighEtThres_(pset.getParameter<std::
vector<double> >(
"dPhiMaxHighEtThres")),
414 dPhiLowEtGrad_(pset.getParameter<std::
vector<double> >(
"dPhiMaxLowEtGrad")),
415 dRZHighEt_(pset.getParameter<std::
vector<double> >(
"dRZMaxHighEt")),
416 dRZHighEtThres_(pset.getParameter<std::
vector<double> >(
"dRZMaxHighEtThres")),
417 dRZLowEtGrad_(pset.getParameter<std::
vector<double> >(
"dRZMaxLowEtGrad")),
418 etaBins_(pset.getParameter<std::
vector<double> >(
"etaBins")) {
419 auto binSizeCheck = [](
size_t sizeEtaBins,
const std::vector<double>& vec,
const std::string&
name) {
420 if (vec.size() != sizeEtaBins + 1) {
422 <<
" when constructing TrajSeedMatcher::MatchingCutsV2 " <<
name <<
" has " << vec.size()
423 <<
" bins, it should be equal to #bins of etaBins+1" << sizeEtaBins + 1;
435 size_t binNr = getBinNr(scHitMatch.
eta);
436 float dPhiMax = getCutValue(scHitMatch.
et, dPhiHighEt_[binNr], dPhiHighEtThres_[binNr], dPhiLowEtGrad_[binNr]);
437 if (dPhiMax >= 0 &&
std::abs(scHitMatch.
dPhi) > dPhiMax)
439 float dRZMax = getCutValue(scHitMatch.
et, dRZHighEt_[binNr], dRZHighEtThres_[binNr], dRZLowEtGrad_[binNr]);
440 if (dRZMax >= 0 &&
std::abs(scHitMatch.
dRZ) > dRZMax)
449 for (
size_t etaNr = 0; etaNr < etaBins_.size(); etaNr++) {
450 if (absEta < etaBins_[etaNr])
453 return etaBins_.size();
std::vector< SCHitMatch > processSeed(const TrajectorySeed &seed, const GlobalPoint &candPos, const float energy, const TrajectoryStateOnSurface &initialTrajState)
MatchingCutsV1(const edm::ParameterSet &pset)
MeasurementDetWithData idToDet(const DetId &id) const
Previous MeasurementDetSystem interface.
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurface > trajStateFromPointNegChargeCache_
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
MatchingCutsV2(const edm::ParameterSet &pset)
std::vector< double > dRZLowEtGrad_
const bool requireExactMatchCount
TrackCharge charge() const
const TrajectoryStateOnSurface & getTrajStateFromVtx(const TrackingRecHit &hit, const TrajectoryStateOnSurface &initialState, const PropagatorWithMaterial &propagator)
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Configuration(const edm::ParameterSet &pset, edm::ConsumesCollector &&cc)
std::vector< double > dPhiLowEtGrad_
IntGlobalPointPairUnorderedMap< TrajectoryStateOnSurface > trajStateFromPointPosChargeCache_
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
Global3DPoint GlobalPoint
constexpr uint32_t rawId() const
get the raw id
TrajectoryStateOnSurface makeTrajStateOnSurface(const GlobalPoint &pos, const float energy, const int charge) const
TrackCharge charge() const
const std::vector< double > dRZMaxLowEt_
virtual GlobalPoint globalPosition() const
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)
constexpr std::array< uint8_t, layerIndexSize > layer
const std::vector< std::unique_ptr< MatchingCuts > > matchingCuts
Geom::Theta< T > theta() const
std::vector< TrajSeedMatcher::SeedWithInfo > operator()(const GlobalPoint &candPos, const float energy)
std::vector< double > etaBins_
const bool enableHitSkipping
TrajectorySeedCollection const & seeds_
PropagatorWithMaterial forwardPropagator_
Configuration const & cfg_
static edm::ParameterSetDescription makePSetDescription()
bool operator()(const SCHitMatch &scHitMatch) const override
const std::vector< int > minNrHitsValidLayerBins
std::vector< TrajectorySeed > TrajectorySeedCollection
const GeomDet * det() const
FreeTrajectoryState const * freeState(bool withErrors=true) const
void addParameter(std::string const &name, T const &value)
NavigationSchool const & navSchool_
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) ...
tuple key
prepare the HTCondor submission files and eventually submit them
Abs< T >::type abs(const T &t)
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxPosChargeCache_
int getNrValidLayersAlongTraj(const SCHitMatch &hit1, const SCHitMatch &hit2, const GlobalPoint &candPos, const float energy, const int charge)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< double > dPhiHighEt_
DetLayerGeometry const & detLayerGeom_
size_t getNrHitsRequired(const int nrValidLayers) const
size_t getBinNr(float eta) const
bool operator()(const SCHitMatch &scHitMatch) const override
GlobalPoint position() const
const TrackingRecHit & hit
float getDRZCutValue(const float scEt, const float scEta) const
TrajSeedMatcher(TrajectorySeedCollection const &seeds, math::XYZPoint const &vprim, Configuration const &cfg, edm::EventSetup const &iSetup, MeasurementTrackerEvent const &measTkEvt)
RecHitRange recHits() const
const std::vector< double > dRZMaxLowEtEtaBins_
const GlobalTrajectoryParameters & globalParameters() const
XYZPointD XYZPoint
point in space with cartesian internal representation
MeasurementTrackerEvent const & measTkEvt_
auto ftsFromVertexToPoint(GlobalPoint const &point, GlobalPoint const &vertex, float energy, int charge) const
std::vector< double > dPhiHighEtThres_
PropagatorWithMaterial backwardPropagator_
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
unsigned int nHits() const
static constexpr float kElectronMass_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
DetId geographicalId() const
std::unordered_map< int, TrajectoryStateOnSurface > trajStateFromVtxNegChargeCache_
virtual const DetLayer * idToLayer(const DetId &detId) const
bool layerHasValidHits(const DetLayer &layer, const TrajectoryStateOnSurface &hitSurState, const Propagator &propToLayerFromState) const
const std::vector< unsigned int > minNrHits
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_