16 bool passesQuality(
const reco::Track& trk,
const std::vector<reco::TrackBase::TrackQuality>& allowedQuals) {
17 for (
const auto& qual : allowedQuals) {
81 iConfig.getParameter<
edm::InputTag>(
"packedPFCandidates"))),
88 minPt_(iConfig.getParameter<double>(
"minPt")),
89 minHits_(iConfig.getParameter<uint32_t>(
"minHits")),
90 minPixelHits_(iConfig.getParameter<uint32_t>(
"minPixelHits")),
99 iConfig.getParameter<
edm::
ParameterSet>(
"pvAssignment").getParameter<double>(
"maxDzForPrimaryAssignment")),
101 iConfig.getParameter<
edm::
ParameterSet>(
"pvAssignment").getParameter<double>(
"maxDzSigForPrimaryAssignment")),
103 .getParameter<double>(
"maxDzErrorForPrimaryAssignment")),
105 .getParameter<double>(
"maxDxyForNotReconstructedPrimary")),
107 .getParameter<double>(
"maxDxySigForNotReconstructedPrimary")),
111 xiMassCut_(iConfig.getParameter<double>(
"xiMassCut")) {
112 std::vector<std::string> trkQuals(iConfig.
getParameter<std::vector<std::string>>(
"qualsToAutoAccept"));
118 std::ostringstream
msg;
119 msg <<
" PATLostTracks has a quality requirement which resolves to undefQuality. This usually means a typo and is " 120 "therefore treated a config error\nquality requirements:\n ";
121 for (
const auto& trkQual : trkQuals)
122 msg << trkQual <<
" ";
126 produces<std::vector<reco::Track>>();
127 produces<std::vector<pat::PackedCandidate>>();
128 produces<std::vector<pat::PackedCandidate>>(
"eleTracks");
129 produces<edm::Association<pat::PackedCandidateCollection>>();
162 auto outPtrTrks = std::make_unique<std::vector<reco::Track>>();
163 auto outPtrTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>();
164 auto outPtrEleTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>();
171 for (
unsigned int ic = 0, nc = cands->size(); ic < nc; ++ic) {
175 if (cand.
pdgId() == 11)
177 else if (cand.
pdgId() == -11)
179 else if ((*pf2pc)[r]->numberOfHits() > 0)
187 for (
const auto& secVert : *vertices) {
188 for (
auto trkIt = secVert.tracks_begin(); trkIt != secVert.tracks_end(); trkIt++) {
193 for (
const auto& v0 : *kshorts) {
194 for (
size_t dIdx = 0; dIdx < v0.numberOfDaughters(); dIdx++) {
200 for (
const auto& v0 : *lambdas) {
201 double protonCharge = 0;
202 for (
size_t dIdx = 0; dIdx < v0.numberOfDaughters(); dIdx++) {
206 protonCharge += v0.daughter(dIdx)->charge() * v0.daughter(dIdx)->momentum().mag2();
212 for (
unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) {
218 trk->px(), trk->py(), trk->pz(),
sqrt(trk->momentum().mag2() + 0.01947995518));
224 std::vector<int>
mapping(tracks->size(), -1);
226 for (
unsigned int trkIndx = 0; trkIndx < tracks->size(); trkIndx++) {
229 outPtrTrks->emplace_back(*trk);
231 std::pair<int, pat::PackedCandidate::PVAssociationQuality> pvAsso =
associateTrkToVtx(*pvOrigs, trk);
235 }
else if (!pvs->empty()) {
238 addPackedCandidate(*outPtrTrksAsCands, trk,
pv, pvRefProd, trkStatus[trkIndx], pvAsso.second, muons);
242 mapping[trkIndx] = lostTrkIndx;
247 std::pair<int, pat::PackedCandidate::PVAssociationQuality> pvAsso =
associateTrkToVtx(*pvOrigs, trk);
251 }
else if (!pvs->empty()) {
254 addPackedCandidate(*outPtrEleTrksAsCands, trk,
pv, pvRefProd, trkStatus[trkIndx], pvAsso.second, muons);
259 iEvent.
put(
std::move(outPtrEleTrksAsCands),
"eleTracks");
261 auto tk2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
283 const float mass = 0.13957018;
285 int id = 211 * trk->charge();
293 for (
auto&
mu : *muons) {
295 id = -13 * trk->charge();
315 cands.back().setLostInnerHits(lostHits);
324 if (trk->hitPattern().numberOfValidPixelHits() > 0) {
325 cands.back().setTrackProperties(
328 cands.back().setTrackProperties(
333 if (trk->hitPattern().numberOfValidPixelHits() > 0) {
334 cands.back().setTrackProperties(
337 cands.back().setTrackProperties(
341 cands.back().setAssociationQuality(pvAssocQuality);
350 float w = vertices[0].trackWeight(trk);
354 return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(0,
357 return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(-1,
365 int iVtxMaxWeight = -1;
366 int iVtxMinDzDist = -1;
371 for (
auto const&
vtx : vertices) {
372 float w =
vtx.trackWeight(trk);
374 double dzSig = dz / trk->dzError();
379 if (dzSig < minDzSig) {
387 if (iVtxMaxWeight >= 0) {
388 if (maxWeight > 0.5) {
389 return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMaxWeight,
392 return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMaxWeight,
398 const double add_cov = vertices[iVtxMinDzDist].covariance(2, 2);
399 const double dzErr =
sqrt(trk->dzError() * trk->dzError() + add_cov);
401 return std::pair<int, pat::PackedCandidate::PVAssociationQuality>(iVtxMinDzDist,
409 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
const double minPtToStoreLowQualityProps_
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
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
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_
LostInnerHits
Enumerator specifying the.
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 bool fillLostInnerHits_
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.