16 bool passesQuality(
const reco::Track& trk,
const std::vector<reco::TrackBase::TrackQuality>& allowedQuals) {
17 for (
const auto& qual : allowedQuals) {
77 iConfig.getParameter<
edm::InputTag>(
"packedPFCandidates"))),
84 minPt_(iConfig.getParameter<double>(
"minPt")),
85 minHits_(iConfig.getParameter<uint32_t>(
"minHits")),
86 minPixelHits_(iConfig.getParameter<uint32_t>(
"minPixelHits")),
94 iConfig.getParameter<
edm::
ParameterSet>(
"pvAssignment").getParameter<double>(
"maxDzForPrimaryAssignment")),
96 iConfig.getParameter<
edm::
ParameterSet>(
"pvAssignment").getParameter<double>(
"maxDzSigForPrimaryAssignment")),
98 .getParameter<double>(
"maxDzErrorForPrimaryAssignment")),
100 .getParameter<double>(
"maxDxyForNotReconstructedPrimary")),
102 .getParameter<double>(
"maxDxySigForNotReconstructedPrimary")),
104 std::vector<std::string> trkQuals(iConfig.
getParameter<std::vector<std::string>>(
"qualsToAutoAccept"));
110 std::ostringstream
msg;
111 msg <<
" PATLostTracks has a quality requirement which resolves to undefQuality. This usually means a typo and is " 112 "therefore treated a config error\nquality requirements:\n ";
113 for (
const auto& trkQual : trkQuals)
114 msg << trkQual <<
" ";
118 produces<std::vector<reco::Track>>();
119 produces<std::vector<pat::PackedCandidate>>();
120 produces<std::vector<pat::PackedCandidate>>(
"eleTracks");
121 produces<edm::Association<pat::PackedCandidateCollection>>();
154 auto outPtrTrks = std::make_unique<std::vector<reco::Track>>();
155 auto outPtrTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>();
156 auto outPtrEleTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>();
163 for (
unsigned int ic = 0, nc = cands->size(); ic < nc; ++ic) {
167 if (cand.
pdgId() == 11)
169 else if (cand.
pdgId() == -11)
171 else if ((*pf2pc)[r]->numberOfHits() > 0)
179 for (
const auto& secVert : *vertices) {
180 for (
auto trkIt = secVert.tracks_begin(); trkIt != secVert.tracks_end(); trkIt++) {
185 for (
const auto& v0 : *kshorts) {
186 for (
size_t dIdx = 0; dIdx < v0.numberOfDaughters(); dIdx++) {
192 for (
const auto& v0 : *lambdas) {
193 for (
size_t dIdx = 0; dIdx < v0.numberOfDaughters(); dIdx++) {
199 std::vector<int>
mapping(tracks->size(), -1);
201 for (
unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) {
204 outPtrTrks->emplace_back(*trk);
206 std::pair<int, pat::PackedCandidate::PVAssociationQuality> pvAsso =
associateTrkToVtx(*pvOrigs, trk);
210 }
else if (!pvs->empty()) {
213 addPackedCandidate(*outPtrTrksAsCands, trk,
pv, pvRefProd, trkStatus[trkIndx], pvAsso.second, muons);
217 mapping[trkIndx] = lostTrkIndx;
222 std::pair<int, pat::PackedCandidate::PVAssociationQuality> pvAsso =
associateTrkToVtx(*pvOrigs, trk);
226 }
else if (!pvs->empty()) {
229 addPackedCandidate(*outPtrEleTrksAsCands, trk,
pv, pvRefProd, trkStatus[trkIndx], pvAsso.second, muons);
234 iEvent.
put(
std::move(outPtrEleTrksAsCands),
"eleTracks");
236 auto tk2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
258 const float mass = 0.13957018;
260 int id = 211 * trk->charge();
268 for (
auto&
mu : *muons) {
270 id = -13 * trk->charge();
286 if (trk->hitPattern().numberOfValidPixelHits() > 0) {
287 cands.back().setTrackProperties(
290 cands.back().setTrackProperties(
295 if (trk->hitPattern().numberOfValidPixelHits() > 0) {
296 cands.back().setTrackProperties(
299 cands.back().setTrackProperties(
303 cands.back().setAssociationQuality(pvAssocQuality);
312 float w = vertices[0].trackWeight(trk);
316 return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(0,
319 return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(-1,
327 int iVtxMaxWeight = -1;
328 int iVtxMinDzDist = -1;
333 for (
auto const&
vtx : vertices) {
334 float w =
vtx.trackWeight(trk);
336 double dzSig = dz / trk->dzError();
341 if (dzSig < minDzSig) {
349 if (iVtxMaxWeight >= 0) {
350 if (maxWeight > 0.5) {
351 return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMaxWeight,
354 return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMaxWeight,
360 const double add_cov = vertices[iVtxMinDzDist].covariance(2, 2);
361 const double dzErr =
sqrt(trk->dzError() * trk->dzError() + add_cov);
363 return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMinDzDist,
371 return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMinDzDist,
T getParameter(std::string const &) const
int pdgId() const final
PDG identifier.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
bool isNonnull() const
Checks for non-null.
const double minPtToStoreProps_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
~PATLostTracks() override
std::vector< pat::PackedCandidate > PackedCandidateCollection
const double maxDzSigForPrimaryAssignment_
std::vector< Track > TrackCollection
collection of Tracks
std::vector< Vertex > VertexCollection
collection of Vertex objects
int charge() const final
electric charge
key_type key() const
Accessor for product key.
PATLostTracks(const edm::ParameterSet &)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const double maxDxyForNotReconstructedPrimary_
const int covarianceVersion_
ProductID id() const
Accessor for product ID.
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
reco::TrackRef trackRef() const
const edm::EDGetTokenT< reco::PFCandidateCollection > cands_
#define DEFINE_FWK_MODULE(type)
const double maxDzErrorForPrimaryAssignment_
const edm::EDGetTokenT< reco::MuonCollection > muons_
const bool useLegacySetup_
double pt() const
track transverse momentum
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > lambdas_
Abs< T >::type abs(const T &t)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
unsigned short numberOfValidHits() const
number of valid hits found
edm::Ref< VertexCollection > VertexRef
persistent reference to a Vertex
std::pair< int, pat::PackedCandidate::PVAssociationQuality > associateTrkToVtx(const reco::VertexCollection &vertices, const reco::TrackRef &trk) const
const double maxDzForPrimaryAssignment_
const double maxDxySigForNotReconstructedPrimary_
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
static TrackQuality qualityByName(const std::string &name)
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > map_
void addPackedCandidate(std::vector< pat::PackedCandidate > &cands, const reco::TrackRef &trk, const reco::VertexRef &pvSlimmed, const reco::VertexRefProd &pvSlimmedColl, const TrkStatus &trkStatus, const pat::PackedCandidate::PVAssociationQuality &pvAssocQuality, edm::Handle< reco::MuonCollection > muons) const
bool passTrkCuts(const reco::Track &tr) const
const edm::EDGetTokenT< reco::TrackCollection > tracks_
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
const edm::EDGetTokenT< reco::VertexCollection > vertices_
const std::vector< int > covariancePackingSchemas_
bool quality(const TrackQuality) const
Track quality.
const edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > kshorts_
std::vector< Muon > MuonCollection
std::vector< reco::TrackBase::TrackQuality > qualsToAutoAccept_
StringCutObjectSelector< reco::Track, false > passThroughCut_
Particle reconstructed by the particle flow algorithm.
int numberOfValidPixelHits() const
const double minPixelHits_
const edm::EDGetTokenT< reco::VertexCollection > pv_
const edm::EDGetTokenT< reco::VertexCollection > pvOrigs_
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.