29 bool passesQuality(
const reco::Track& trk,
const std::vector<reco::TrackBase::TrackQuality>& allowedQuals) {
30 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")),
91 minPtToStoreProps_(iConfig.getParameter<double>(
"minPtToStoreProps")),
92 covarianceVersion_(iConfig.getParameter<
int>(
"covarianceVersion")),
93 covarianceSchema_(iConfig.getParameter<
int>(
"covarianceSchema")),
95 passThroughCut_(iConfig.getParameter<
std::
string>(
"passThroughCut")) {
96 std::vector<std::string> trkQuals(iConfig.
getParameter<std::vector<std::string>>(
"qualsToAutoAccept"));
102 std::ostringstream
msg;
103 msg <<
" PATLostTracks has a quality requirement which resolves to undefQuality. This usually means a typo and is "
104 "therefore treated a config error\nquality requirements:\n ";
105 for (
const auto& trkQual : trkQuals)
106 msg << trkQual <<
" ";
110 produces<std::vector<reco::Track>>();
111 produces<std::vector<pat::PackedCandidate>>();
112 produces<std::vector<pat::PackedCandidate>>(
"eleTracks");
113 produces<edm::Association<pat::PackedCandidateCollection>>();
123 iEvent.getByToken(map_, pf2pc);
147 iEvent.getByToken(pvOrigs_, pvOrigs);
150 auto outPtrTrks = std::make_unique<std::vector<reco::Track>>();
151 auto outPtrTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>();
152 auto outPtrEleTrksAsCands = std::make_unique<std::vector<pat::PackedCandidate>>();
154 std::vector<TrkStatus> trkStatus(
tracks->size(), TrkStatus::NOTUSED);
159 for (
unsigned int ic = 0, nc =
cands->size(); ic < nc; ++ic) {
162 if (
cand.charge() &&
cand.trackRef().isNonnull() &&
cand.trackRef().id() ==
tracks.id()) {
163 if (
cand.pdgId() == 11)
164 trkStatus[
cand.trackRef().key()] = TrkStatus::PFELECTRON;
165 else if (
cand.pdgId() == -11)
166 trkStatus[
cand.trackRef().key()] = TrkStatus::PFPOSITRON;
167 else if ((*pf2pc)[
r]->numberOfHits() > 0)
168 trkStatus[
cand.trackRef().key()] = TrkStatus::PFCAND;
170 trkStatus[
cand.trackRef().key()] = TrkStatus::PFCANDNOTRKPROPS;
175 for (
const auto& secVert : *
vertices) {
176 for (
auto trkIt = secVert.tracks_begin(); trkIt != secVert.tracks_end(); trkIt++) {
177 if (trkStatus[trkIt->key()] == TrkStatus::NOTUSED)
178 trkStatus[trkIt->key()] = TrkStatus::VTX;
182 for (
size_t dIdx = 0; dIdx <
v0.numberOfDaughters(); dIdx++) {
183 size_t key = (dynamic_cast<const reco::RecoChargedCandidate*>(
v0.daughter(dIdx)))->track().key();
184 if (trkStatus[
key] == TrkStatus::NOTUSED)
185 trkStatus[
key] = TrkStatus::VTX;
189 for (
size_t dIdx = 0; dIdx <
v0.numberOfDaughters(); dIdx++) {
190 size_t key = (dynamic_cast<const reco::RecoChargedCandidate*>(
v0.daughter(dIdx)))->track().key();
191 if (trkStatus[
key] == TrkStatus::NOTUSED)
192 trkStatus[
key] = TrkStatus::VTX;
197 for (
unsigned int trkIndx = 0; trkIndx <
tracks->size(); trkIndx++) {
199 if (trkStatus[trkIndx] == TrkStatus::VTX || (trkStatus[trkIndx] == TrkStatus::NOTUSED && passTrkCuts(*trk))) {
200 outPtrTrks->emplace_back(*trk);
201 addPackedCandidate(*outPtrTrksAsCands, trk,
pv, pvRefProd, pvOrig, trkStatus[trkIndx],
muons);
205 mapping[trkIndx] = lostTrkIndx;
207 }
else if ((trkStatus[trkIndx] == TrkStatus::PFELECTRON || trkStatus[trkIndx] == TrkStatus::PFPOSITRON) &&
209 addPackedCandidate(*outPtrEleTrksAsCands, trk,
pv, pvRefProd, pvOrig, trkStatus[trkIndx],
muons);
216 auto tk2pc = std::make_unique<edm::Association<pat::PackedCandidateCollection>>(oh);
226 const bool passTrkQual = passesQuality(tr, qualsToAutoAccept_);
228 return passTrkHits || passTrkQual || passThroughCut_(tr);
238 const float mass = 0.13957018;
240 int id = 211 * trk->charge();
241 if (trkStatus == TrkStatus::PFELECTRON)
243 else if (trkStatus == TrkStatus::PFPOSITRON)
249 id = -13 * trk->charge();
269 cands.back().setTrackHighPurity(
true);
271 cands.back().setTrackHighPurity(
false);
274 if (trk->pt() > minPtToStoreProps_ || trkStatus == TrkStatus::VTX)
275 cands.back().setTrackProperties(*trk, covarianceSchema_, covarianceVersion_);