68 int& pc_ref_idx)
const;
125 iConfig.getParameter<
edm::
InputTag>(
"packedPFCandidates"))),
127 iConfig.getParameter<
edm::
InputTag>(
"lostTracks"))),
129 iConfig.getParameter<
edm::
InputTag>(
"packedPFCandidates"))),
131 gt2dedxStrip_(consumes<
edm::ValueMap<
reco::DeDxData>>(iConfig.getParameter<
edm::
InputTag>(
"dEdxDataStrip"))),
132 gt2dedxPixel_(consumes<
edm::ValueMap<
reco::DeDxData>>(iConfig.getParameter<
edm::
InputTag>(
"dEdxDataPixel"))),
137 addPrescaledDeDxTracks_(iConfig.getParameter<
bool>(
"addPrescaledDeDxTracks")),
138 gt2dedxHitInfoPrescale_(addPrescaledDeDxTracks_ ? consumes<
edm::ValueMap<
int>>(
139 iConfig.getParameter<
edm::
InputTag>(
"dEdxHitInfoPrescale"))
140 :
edm::EDGetTokenT<
edm::ValueMap<
int>>()),
141 usePrecomputedDeDxStrip_(iConfig.getParameter<
bool>(
"usePrecomputedDeDxStrip")),
142 usePrecomputedDeDxPixel_(iConfig.getParameter<
bool>(
"usePrecomputedDeDxPixel")),
143 pT_cut_(iConfig.getParameter<double>(
"pT_cut")),
144 pT_cut_noIso_(iConfig.getParameter<double>(
"pT_cut_noIso")),
145 pfIsolation_DR_(iConfig.getParameter<double>(
"pfIsolation_DR")),
146 pfIsolation_DZ_(iConfig.getParameter<double>(
"pfIsolation_DZ")),
147 absIso_cut_(iConfig.getParameter<double>(
"absIso_cut")),
148 relIso_cut_(iConfig.getParameter<double>(
"relIso_cut")),
149 miniRelIso_cut_(iConfig.getParameter<double>(
"miniRelIso_cut")),
150 caloJet_DR_(iConfig.getParameter<double>(
"caloJet_DR")),
151 pflepoverlap_DR_(iConfig.getParameter<double>(
"pflepoverlap_DR")),
152 pflepoverlap_pTmin_(iConfig.getParameter<double>(
"pflepoverlap_pTmin")),
153 pcRefNearest_DR_(iConfig.getParameter<double>(
"pcRefNearest_DR")),
154 pcRefNearest_pTmin_(iConfig.getParameter<double>(
"pcRefNearest_pTmin")),
155 pfneutralsum_DR_(iConfig.getParameter<double>(
"pfneutralsum_DR")),
156 useHighPurity_(iConfig.getParameter<
bool>(
"useHighPurity")),
157 saveDeDxHitInfo_(iConfig.getParameter<
bool>(
"saveDeDxHitInfo")),
158 saveDeDxHitInfoCut_(iConfig.getParameter<
std::
string>(
"saveDeDxHitInfoCut")) {
168 throw cms::Exception(
"ParameterError") <<
"miniIsoParams must have exactly 3 elements.\n";
170 produces<pat::IsolatedTrackCollection>();
173 produces<reco::DeDxHitInfoCollection>();
174 produces<reco::DeDxHitInfoAss>();
183 iEvent.getByToken(pc_, pc_h);
193 iEvent.getByToken(gt_, gt_h);
203 iEvent.getByToken(gt2pc_, gt2pc);
207 iEvent.getByToken(gt2lt_, gt2lt);
211 iEvent.getByToken(pc2pf_, pc2pf);
218 iEvent.getByToken(gt2dedxStrip_, gt2dedxStrip);
222 iEvent.getByToken(gt2dedxPixel_, gt2dedxPixel);
226 iEvent.getByToken(gt2dedxHitInfo_, gt2dedxHitInfo);
228 if (addPrescaledDeDxTracks_) {
229 iEvent.getByToken(gt2dedxHitInfoPrescale_, gt2dedxHitInfoPrescale);
236 auto outDeDxC = std::make_unique<reco::DeDxHitInfoCollection>();
237 std::vector<int> dEdXass;
239 auto outPtrP = std::make_unique<std::vector<pat::IsolatedTrack>>();
242 for (
unsigned int igt = 0; igt <
generalTracks->size(); igt++) {
256 bool isInPackedCands = (pcref.
isNonnull() && pcref.
id() == pc_h.
id() && pfCand->
charge() != 0);
257 bool isInLostTracks = (ltref.
isNonnull() && ltref.
id() == lt_h.
id());
268 if (isInPackedCands) {
270 polarP4 = pfCand->
p4();
272 pfCandInd = pcref.
key();
274 }
else if (isInLostTracks) {
275 p4 = lostTrack->
p4();
276 polarP4 = lostTrack->
p4();
279 ltCandInd = ltref.
key();
281 double m = 0.13957018;
282 double E =
sqrt(
m *
m + gentk.
p() * gentk.
p());
283 p4.SetPxPyPzE(gentk.
px(), gentk.
py(), gentk.
pz(), E);
284 polarP4.SetCoordinates(gentk.
pt(), gentk.
eta(), gentk.
phi(),
m);
291 if (addPrescaledDeDxTracks_) {
292 const auto& dedxRef = (*gt2dedxHitInfo)[tkref];
293 if (dedxRef.isNonnull()) {
294 prescaled = (*gt2dedxHitInfoPrescale)[dedxRef];
298 if (polarP4.pt() < pT_cut_ && prescaled <= 1)
306 getIsolation(polarP4, pc, pfCandInd, isolationDR03, miniIso);
309 if (polarP4.pt() < pT_cut_noIso_ && prescaled <= 1 &&
316 if (isInPackedCands) {
324 }
else if (isInLostTracks) {
326 dz = lostTrack->
dz();
334 dz = gentk.
dz(
pv.position());
342 float caloJetEm, caloJetHad;
343 getCaloJetEnergy(polarP4,
caloJets.product(), caloJetEm, caloJetHad);
345 bool pfLepOverlap = getPFLeptonOverlap(polarP4, pc);
346 float pfNeutralSum = getPFNeutralSum(polarP4, pc, pfCandInd);
349 int refToNearestPF_idx = -1;
350 getNearestPCRef(polarP4, pc, pfCandInd, refToNearestPF_idx);
351 if (refToNearestPF_idx != -1)
355 int refToNearestLostTrack_idx = -1;
356 getNearestPCRef(polarP4, lt, ltCandInd, refToNearestLostTrack_idx);
357 if (refToNearestLostTrack_idx != -1)
361 float dEdxPixel = -1, dEdxStrip = -1;
362 if (usePrecomputedDeDxStrip_ && gt2dedxStrip.
isValid() && gt2dedxStrip->contains(tkref.
id())) {
363 dEdxStrip = (*gt2dedxStrip)[tkref].dEdx();
366 dEdxStrip = getDeDx(hitInfo,
false,
true);
368 if (usePrecomputedDeDxPixel_ && gt2dedxPixel.
isValid() && gt2dedxPixel->contains(tkref.
id())) {
369 dEdxPixel = (*gt2dedxPixel)[tkref].dEdx();
372 dEdxPixel = getDeDx(hitInfo,
true,
false);
381 std::vector<uint32_t> crossedHcalStatus;
386 std::vector<uint16_t> crossedEcalStatus;
389 crossedEcalStatus.push_back(ecalS->
find(did.rawId())->getStatusCode());
427 refToNearestLostTrack));
428 outPtrP->back().setStatus(prescaled);
430 if (saveDeDxHitInfo_) {
431 const auto& dedxRef = (*gt2dedxHitInfo)[tkref];
432 if (saveDeDxHitInfoCut_(outPtrP->back()) && dedxRef.isNonnull()) {
433 outDeDxC->push_back(*dedxRef);
434 dEdXass.push_back(outDeDxC->size() - 1);
436 dEdXass.push_back(-1);
444 for (
unsigned int ipc = 0; ipc < pc->size(); ipc++) {
450 if (pfref.
get()->trackRef().isNonnull() && pfref.
get()->trackRef().id() == gt_h.
id())
461 if (polarP4.pt() < pT_cut_)
469 getIsolation(polarP4, pc, ipc, isolationDR03, miniIso);
472 if (polarP4.pt() < pT_cut_noIso_ && !(isolationDR03.
chargedHadronIso() < absIso_cut_ ||
490 float caloJetEm, caloJetHad;
491 getCaloJetEnergy(polarP4,
caloJets.product(), caloJetEm, caloJetHad);
493 bool pfLepOverlap = getPFLeptonOverlap(polarP4, pc);
494 float pfNeutralSum = getPFNeutralSum(polarP4, pc, ipc);
497 int refToNearestPF_idx = -1;
498 getNearestPCRef(polarP4, pc, ipc, refToNearestPF_idx);
499 if (refToNearestPF_idx != -1)
503 int refToNearestLostTrack_idx = -1;
504 getNearestPCRef(polarP4, lt, -1, refToNearestLostTrack_idx);
505 if (refToNearestLostTrack_idx != -1)
510 float dEdxPixel = -1, dEdxStrip = -1;
512 std::vector<uint16_t> ecalStatus;
513 std::vector<uint32_t> hcalStatus;
541 refToNearestLostTrack));
543 dEdXass.push_back(-1);
547 if (saveDeDxHitInfo_) {
549 auto dedxMatch = std::make_unique<reco::DeDxHitInfoAss>(dedxOH);
551 filler.insert(orphHandle, dEdXass.begin(), dEdXass.end());
562 float chiso = 0, nhiso = 0, phiso = 0, puiso = 0;
563 float chmiso = 0, nhmiso = 0, phmiso = 0, pumiso = 0;
564 float miniDR =
std::max(miniIsoParams_[0],
std::min(miniIsoParams_[1], miniIsoParams_[2] / p4.pt()));
565 for (pat::PackedCandidateCollection::const_iterator pf_it = pc->begin(); pf_it != pc->end(); pf_it++) {
566 if (
int(pf_it - pc->begin()) == pc_idx)
569 bool fromPV = (pf_it->fromPV() > 1 || fabs(pf_it->dz()) < pfIsolation_DZ_);
570 float pt = pf_it->p4().pt();
571 float dr =
deltaR(p4, *pf_it);
573 if (dr < pfIsolation_DR_) {
607 bool isOverlap =
false;
608 float dr_min = pflepoverlap_DR_;
610 for (
const auto&
pf : *pc) {
619 if (
pt < pflepoverlap_pTmin_)
623 if (dr > pflepoverlap_DR_)
632 if (dr_min < pflepoverlap_DR_ && (id_drmin == 11 || id_drmin == 13))
642 int& pc_ref_idx)
const {
643 float dr_min = pcRefNearest_DR_;
644 float dr_min_pu = pcRefNearest_DR_;
645 int pc_ref_idx_pu = -1;
646 for (pat::PackedCandidateCollection::const_iterator pf_it = pc->begin(); pf_it != pc->end(); pf_it++) {
647 if (
int(pf_it - pc->begin()) == pc_idx)
650 bool fromPV = (pf_it->fromPV() > 1 || fabs(pf_it->dz()) < pfIsolation_DZ_);
651 float pt = pf_it->p4().pt();
652 float dr =
deltaR(p4, *pf_it);
655 if (
pt < pcRefNearest_pTmin_)
657 if (dr > dr_min && dr > dr_min_pu)
663 pc_ref_idx =
int(pf_it - pc->begin());
666 if (dr < dr_min_pu) {
668 pc_ref_idx_pu =
int(pf_it - pc->begin());
673 if (pc_ref_idx == -1 &&
675 pc_ref_idx = pc_ref_idx_pu;
683 float nhsum = 0, phsum = 0;
684 for (pat::PackedCandidateCollection::const_iterator pf_it = pc->begin(); pf_it != pc->end(); pf_it++) {
685 if (
int(pf_it - pc->begin()) == pc_idx)
688 float pt = pf_it->p4().pt();
689 float dr =
deltaR(p4, *pf_it);
691 if (dr < pfneutralsum_DR_) {
701 nsum = nhsum + phsum;
708 if (hitInfo ==
nullptr) {
712 std::vector<float> charge_vec;
713 for (
unsigned int ih = 0; ih < hitInfo->
size(); ih++) {
734 Norm = 3.61e-06 * 265;
740 int size = charge_vec.size();
745 for (
int i = 0;
i < size;
i++) {
761 return trackAssociator_.associate(
iEvent, iSetup, trackAssocParameters_, &initialState);
767 float& caloJetHad)
const {
768 float nearestDR = 999;
770 for (
unsigned int i = 0;
i < cJets->size();
i++) {
772 if (
dR < caloJet_DR_ &&
dR < nearestDR) {
bool quality(const TrackQuality) const
Track quality.
float pathlength(size_t i) const
PATIsolatedTrackProducer(const edm::ParameterSet &)
const edm::EDGetTokenT< reco::TrackCollection > gt_
T getParameter(std::string const &) const
const edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > gt2dedxStrip_
Jets made from CaloTowers.
const edm::EDGetTokenT< edm::ValueMap< int > > gt2dedxHitInfoPrescale_
const float pcRefNearest_pTmin_
ProductID id() const
Accessor for product ID.
float emEnergyInHF() const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
TrackDetectorAssociator trackAssociator_
int charge() const override
electric charge
bool getPFLeptonOverlap(const PolarLorentzVector &p4, const pat::PackedCandidateCollection *pc) const
float emEnergyInEE() const
double px() const
x coordinate of momentum vector
double p() const
momentum vector magnitude
std::vector< DetId > crossedEcalIds
std::vector< l1t::PFCandidate > PFCandidateCollection
float getDeDx(const reco::DeDxHitInfo *hitInfo, bool doPixel, bool doStrip) const
T const * product() const
void useDefaultPropagator()
use the default propagator
std::vector< pat::PackedCandidate > PackedCandidateCollection
void getNearestPCRef(const PolarLorentzVector &p4, const pat::PackedCandidateCollection *pc, int pc_idx, int &pc_ref_idx) const
std::vector< Track > TrackCollection
collection of Tracks
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
double py() const
y coordinate of momentum vector
bool isNonnull() const
Checks for non-null.
const PVAssoc fromPV(size_t ipv=0) const
const PolarLorentzVector & polarP4() const override
four-momentum Lorentz vector
float emEnergyInEB() const
int pdgId() const override
PDG identifier.
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > gt2pc_
std::vector< Vertex > VertexCollection
std::vector< DetId > crossedHcalIds
key_type key() const
Accessor for product key.
static const double deltaEta
const Item * getValues(DetId fId, bool throwOnFail=true) const
const edm::EDGetTokenT< reco::DeDxHitInfoAss > gt2dedxHitInfo_
const bool useHighPurity_
double pt() const
track transverse momentum
pat::IsolatedTrack::PolarLorentzVector PolarLorentzVector
int charge() const
track electric charge
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
const edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > ecalSToken_
edm::Association< DeDxHitInfoCollection > DeDxHitInfoAss
double dxyError() const
error on dxy
float getPFNeutralSum(const PolarLorentzVector &p4, const pat::PackedCandidateCollection *pc, int pc_idx) const
void getCaloJetEnergy(const PolarLorentzVector &, const reco::CaloJetCollection *, float &, float &) const
double dzError() const
error on dz
float dzError() const override
uncertainty on dz
TrackAssociatorParameters trackAssocParameters_
edm::Ref< pat::PackedCandidateCollection > PackedCandidateRef
float chargedHadronIso() const
Abs< T >::type abs(const T &t)
const SiStripCluster * stripCluster(size_t i) const
double phi() const
azimuthal angle of momentum vector
void getIsolation(const PolarLorentzVector &p4, const pat::PackedCandidateCollection *pc, int pc_idx, pat::PFIsolation &iso, pat::PFIsolation &miniiso) const
#define DEFINE_FWK_MODULE(type)
float dxyError() const override
uncertainty on dxy
const bool addPrescaledDeDxTracks_
const_iterator find(uint32_t rawId) const
const float miniRelIso_cut_
double eta() const
pseudorapidity of momentum vector
bool lt_(std::pair< double, short > a, std::pair< double, short > b)
pat::IsolatedTrack::LorentzVector LorentzVector
std::vector< double > miniIsoParams_
const edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
static TrackQuality qualityByName(const std::string &name)
StringCutObjectSelector< pat::IsolatedTrack > saveDeDxHitInfoCut_
const float pcRefNearest_DR_
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
float hadEnergyInHF() const
float hadEnergyInHE() const
const edm::EDGetTokenT< edm::Association< reco::PFCandidateCollection > > pc2pf_
const float pflepoverlap_DR_
const edm::EDGetTokenT< pat::PackedCandidateCollection > lt_
~PATIsolatedTrackProducer() override
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
double pz() const
z coordinate of momentum vector
bool contains(ProductID id) const
const float pfneutralsum_DR_
void produce(edm::Event &, const edm::EventSetup &) override
float hadEnergyInHB() const
const edm::EDGetTokenT< reco::VertexCollection > pv_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > gt2lt_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bFieldToken_
TrackDetMatchInfo getTrackDetMatchInfo(const edm::Event &, const edm::EventSetup &, const reco::Track &)
const SiPixelCluster * pixelCluster(size_t i) const
bool isPixel(HitType hitType)
T const * get() const
Returns C++ pointer to the item.
const edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > hcalQToken_
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
const JetExtendedData & getValue(const Container &, const reco::JetBaseRef &)
get value for the association. Throw exception if no association found
const bool usePrecomputedDeDxStrip_
const float pfIsolation_DZ_
virtual float dxy() const
dxy with respect to the PV ref
float charge(size_t i) const
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
const float pT_cut_noIso_
const LorentzVector & p4() const override
four-momentum Lorentz vecto r
const float pflepoverlap_pTmin_
const bool usePrecomputedDeDxPixel_
const float pfIsolation_DR_
const edm::EDGetTokenT< reco::CaloJetCollection > caloJets_
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
const bool saveDeDxHitInfo_
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
const edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > gt2dedxPixel_
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.