63 #include <Math/DistFunc.h> 101 produces<edm::ValueMap<float>>(
"MVAVals");
103 produces<MVACollection>(
"MVAValues");
106 if (
cfg.exists(
"useAnyMVA"))
116 copyExtras_ =
cfg.getUntrackedParameter<
bool>(
"copyExtras",
false);
128 res_par_.push_back(
cfg.getParameter<std::vector<double>>(
"res_par"));
131 d0_par1_.push_back(
cfg.getParameter<std::vector<double>>(
"d0_par1"));
132 dz_par1_.push_back(
cfg.getParameter<std::vector<double>>(
"dz_par1"));
133 d0_par2_.push_back(
cfg.getParameter<std::vector<double>>(
"d0_par2"));
134 dz_par2_.push_back(
cfg.getParameter<std::vector<double>>(
"dz_par2"));
139 max_d0_.push_back(
cfg.getParameter<
double>(
"max_d0"));
140 max_z0_.push_back(
cfg.getParameter<
double>(
"max_z0"));
141 nSigmaZ_.push_back(
cfg.getParameter<
double>(
"nSigmaZ"));
143 min_layers_.push_back(
cfg.getParameter<uint32_t>(
"minNumberLayers"));
148 min_nhits_.push_back(
cfg.getParameter<uint32_t>(
"min_nhits"));
150 cfg.existsAs<int32_t>(
"max_minMissHitOutOrIn") ?
cfg.getParameter<int32_t>(
"max_minMissHitOutOrIn") : 99);
152 cfg.existsAs<
double>(
"max_lostHitFraction") ?
cfg.getParameter<
double>(
"max_lostHitFraction") : 1.0);
153 min_eta_.push_back(
cfg.getParameter<
double>(
"min_eta"));
154 max_eta_.push_back(
cfg.getParameter<
double>(
"max_eta"));
158 keepAllTracks_.push_back(
cfg.exists(
"keepAllTracks") ?
cfg.getParameter<
bool>(
"keepAllTracks") :
false);
164 edm::LogError(
"MisConfiguration") <<
"vector of size less then 2";
168 if (
cfg.exists(
"qualityBit")) {
170 if (!qualityStr.empty()) {
178 <<
"If you set 'keepAllTracks' to true, you must specify which qualityBit to set.\n";
181 <<
"You can't set the quality bit " <<
cfg.getParameter<
std::string>(
"qualityBit")
182 <<
" as it is 'undefQuality' or unknown.\n";
192 bool thisMVA =
false;
193 if (
cfg.exists(
"useMVA"))
194 thisMVA =
cfg.getParameter<
bool>(
"useMVA");
198 if (
cfg.exists(
"minMVA"))
199 minVal =
cfg.getParameter<
double>(
"minMVA");
203 :
"MVASelectorIter0");
204 useMVAonly_.push_back(
cfg.exists(
"useMVAonly") ?
cfg.getParameter<
bool>(
"useMVAonly") :
false);
221 produces<reco::TrackExtraCollection>().setBranchAlias(
alias +
"TrackExtras");
222 produces<TrackingRecHitCollection>().setBranchAlias(
alias +
"RecHits");
225 produces<std::vector<Trajectory>>().setBranchAlias(
alias +
"Trajectories");
226 produces<TrajTrackAssociationCollection>().setBranchAlias(
alias +
"TrajectoryTrackAssociations");
231 produces<reco::TrackCollection>().setBranchAlias(
alias +
"Tracks");
238 std::unique_ptr<reco::TrackCollection> selTracks_;
239 std::unique_ptr<reco::TrackExtraCollection> selTrackExtras_;
240 std::unique_ptr<TrackingRecHitCollection> selHits_;
241 std::unique_ptr<std::vector<Trajectory>> selTrajs_;
242 std::unique_ptr<std::vector<const Trajectory*>> selTrajPtrs_;
243 std::unique_ptr<TrajTrackAssociationCollection> selTTAss_;
248 std::vector<reco::TrackRef> trackRefs_;
252 using namespace reco;
263 vertexBeamSpot = *hBsp;
268 std::vector<Point>
points;
269 std::vector<float> vterr, vzerr;
274 LogDebug(
"SelectVertex") <<
points.size() <<
" good pixel vertices";
284 selTracks_ = std::make_unique<TrackCollection>();
287 selTrackExtras_ = std::make_unique<TrackExtraCollection>();
288 selHits_ = std::make_unique<TrackingRecHitCollection>();
294 trackRefs_.resize(hSrcTrack->size());
296 std::vector<float> mvaVals_(hSrcTrack->size(), -99.f);
297 processMVA(evt, es, vertexBeamSpot, *vtxPtr, 0, mvaVals_,
true);
301 for (TrackCollection::const_iterator
it = hSrcTrack->begin(), ed = hSrcTrack->end();
it != ed; ++
it, ++current) {
305 LogTrace(
"TrackSelection") <<
"ready to check track with pt=" << trk.
pt();
309 mvaVal = mvaVals_[current];
310 bool ok =
select(0, vertexBeamSpot, srcHits, trk,
points, vterr, vzerr, mvaVal);
312 LogTrace(
"TrackSelection") <<
"track with pt=" << trk.
pt() <<
" NOT selected";
319 LogTrace(
"TrackSelection") <<
"track with pt=" << trk.
pt() <<
" selected";
320 selTracks_->push_back(
Track(trk));
327 selTracks_->back().setQuality(TrackBase::tight);
331 selTracks_->back().setQuality(TrackBase::looseSetWithPV);
333 selTracks_->back().setQuality(TrackBase::looseSetWithPV);
334 selTracks_->back().setQuality(TrackBase::highPuritySetWithPV);
352 selTracks_->back().setExtra(
TrackExtraRef(rTrackExtras_, selTrackExtras_->size() - 1));
356 auto const firstHitIndex = selHits_->size();
358 selHits_->push_back((*hit)->clone());
360 tx.
setHits(rHits_, firstHitIndex, selHits_->
size() - firstHitIndex);
364 trackRefs_[current] =
TrackRef(rTracks_, selTracks_->size() - 1);
372 selTrajs_ = std::make_unique<std::vector<Trajectory>>();
374 selTTAss_ = std::make_unique<TrajTrackAssociationCollection>(rTrajectories_, rTracks_);
375 for (
size_t i = 0,
n = hTraj->size();
i <
n; ++
i) {
380 short oldKey =
static_cast<short>(trkRef.
key());
381 if (trackRefs_[oldKey].isNonnull()) {
383 selTTAss_->insert(
Ref<vector<Trajectory>>(rTrajectories_, selTrajs_->size() - 1), trackRefs_[oldKey]);
std::vector< uint32_t > min_nhits_
std::vector< double > max_d0NoPV_
std::vector< double > max_z0_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< uint32_t > min_layers_
Cuts on numbers of layers with hits/3D hits/lost hits.
std::vector< double > max_z0NoPV_
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
bool get(ProductID const &oid, Handle< PROD > &result) const
edm::EDGetTokenT< TrajTrackAssociationCollection > srcTass_
const math::XYZPoint & outerPosition() const
position of the outermost hit
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
std::vector< bool > useMVA_
Quality qualityByName(std::string const &name)
friend struct const_iterator
std::vector< bool > keepAllTracks_
std::vector< uint32_t > min_hits_bypass_
bool copyTrajectories_
copy also trajectories and trajectory->track associations
double minEta_
eta restrictions
std::vector< Track > TrackCollection
collection of Tracks
std::vector< bool > applyAdaptedPVCuts_
std::vector< Vertex > VertexCollection
collection of Vertex objects
std::vector< double > chi2n_no1Dmod_par_
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< double > nSigmaZ_
const edm::RefToBase< TrajectorySeed > & seedRef() const
std::vector< std::string > mvaType_
std::vector< unsigned int > preFilter_
Log< level::Error, false > LogError
const TrackResiduals & residuals() const
get the residuals
edm::EDGetTokenT< TrackingRecHitCollection > hSrc_
edm::EDGetTokenT< std::vector< Trajectory > > srcTraj_
edm::EDGetTokenT< reco::VertexCollection > vertices_
key_type key() const
Accessor for product key.
const_iterator find(const key_type &k) const
find element with specified reference key
std::vector< uint32_t > min_3Dlayers_
const_iterator end() const
last iterator over the map (read only)
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
double pt() const
track transverse momentum
std::vector< uint32_t > max_lostLayers_
std::vector< GBRForest * > forest_
std::vector< int32_t > max_lostHitFraction_
edm::EDGetTokenT< reco::BeamSpot > beamspot_
std::vector< double > min_eta_
std::vector< bool > setQualityBit_
do I have to set a quality bit?
std::vector< std::vector< double > > dz_par1_
void processMVA(edm::Event &evt, const edm::EventSetup &es, const reco::BeamSpot &beamspot, const reco::VertexCollection &vertices, int selIndex, std::vector< float > &mvaVals_, bool writeIt=false) const
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
~AnalyticalTrackSelector() override
destructor
#define DEFINE_FWK_MODULE(type)
std::vector< std::vector< double > > d0_par1_
void selectVertices(unsigned int tsNum, const reco::VertexCollection &vtxs, std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr) const
bool select(unsigned tsNum, const reco::BeamSpot &vertexBeamSpot, const TrackingRecHitCollection &recHits, const reco::Track &tk, const std::vector< Point > &points, std::vector< float > &vterr, std::vector< float > &vzerr, double mvaVal) const
return class, or -1 if rejected
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
std::vector< double > max_relpterr_
RefProd< PROD > getRefBeforePut()
AnalyticalTrackSelector(const edm::ParameterSet &cfg)
constructor
bool innerOk() const
return true if the innermost hit is valid
void run(edm::Event &evt, const edm::EventSetup &es) const override
process one event
const PropagationDirection & seedDirection() const
direction of how the hits were sorted in the original seed
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
std::vector< int32_t > vtxNumber_
vertex cuts
std::vector< reco::TrackBase::TrackQuality > qualityToSet_
XYZPointD XYZPoint
point in space with cartesian internal representation
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
std::vector< std::string > forestLabel_
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
std::vector< StringCutObjectSelector< reco::Vertex > > vertexCut_
std::vector< std::vector< double > > dz_par2_
std::vector< bool > applyAbsCutsIfNoPV_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
std::vector< int32_t > max_minMissHitOutOrIn_
std::vector< double > min_MVA_
edm::EDGetTokenT< reco::TrackCollection > src_
source collection label
std::vector< double > max_d0_
Impact parameter absolute cuts.
const math::XYZPoint & innerPosition() const
position of the innermost hit
std::vector< bool > useMVAonly_
std::vector< std::vector< double > > res_par_
std::vector< double > max_eta_
bool outerOk() const
return true if the outermost hit is valid
std::vector< double > chi2n_par_
const TrackExtraRef & extra() const
reference to "extra" object
std::vector< std::vector< double > > d0_par2_