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());
263 float dz,
dxy, dzError, dxyError;
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;
385 std::vector<uint16_t> crossedEcalStatus;
387 crossedEcalStatus.push_back(ecalS->
find(did.rawId())->getStatusCode());
425 refToNearestLostTrack));
426 outPtrP->back().setStatus(prescaled);
428 if (saveDeDxHitInfo_) {
429 const auto& dedxRef = (*gt2dedxHitInfo)[tkref];
430 if (saveDeDxHitInfoCut_(outPtrP->back()) && dedxRef.isNonnull()) {
431 outDeDxC->push_back(*dedxRef);
432 dEdXass.push_back(outDeDxC->size() - 1);
434 dEdXass.push_back(-1);
442 for (
unsigned int ipc = 0; ipc < pc->size(); ipc++) {
448 if (pfref.
get()->trackRef().isNonnull() && pfref.
get()->trackRef().id() == gt_h.
id())
454 float dz,
dxy, dzError, dxyError;
459 if (polarP4.pt() < pT_cut_)
467 getIsolation(polarP4, pc, ipc, isolationDR03, miniIso);
470 if (polarP4.pt() < pT_cut_noIso_ && !(isolationDR03.
chargedHadronIso() < absIso_cut_ ||
488 float caloJetEm, caloJetHad;
489 getCaloJetEnergy(polarP4,
caloJets.product(), caloJetEm, caloJetHad);
491 bool pfLepOverlap = getPFLeptonOverlap(polarP4, pc);
492 float pfNeutralSum = getPFNeutralSum(polarP4, pc, ipc);
495 int refToNearestPF_idx = -1;
496 getNearestPCRef(polarP4, pc, ipc, refToNearestPF_idx);
497 if (refToNearestPF_idx != -1)
501 int refToNearestLostTrack_idx = -1;
502 getNearestPCRef(polarP4, lt, -1, refToNearestLostTrack_idx);
503 if (refToNearestLostTrack_idx != -1)
508 float dEdxPixel = -1, dEdxStrip = -1;
510 std::vector<uint16_t> ecalStatus;
511 std::vector<uint32_t> hcalStatus;
539 refToNearestLostTrack));
541 dEdXass.push_back(-1);
545 if (saveDeDxHitInfo_) {
547 auto dedxMatch = std::make_unique<reco::DeDxHitInfoAss>(dedxOH);
549 filler.insert(orphHandle, dEdXass.begin(), dEdXass.end());
560 float chiso = 0, nhiso = 0, phiso = 0, puiso = 0;
561 float chmiso = 0, nhmiso = 0, phmiso = 0, pumiso = 0;
562 float miniDR =
std::max(miniIsoParams_[0],
std::min(miniIsoParams_[1], miniIsoParams_[2] / p4.pt()));
563 for (pat::PackedCandidateCollection::const_iterator pf_it = pc->begin(); pf_it != pc->end(); pf_it++) {
564 if (
int(pf_it - pc->begin()) == pc_idx)
567 bool fromPV = (pf_it->fromPV() > 1 || fabs(pf_it->dz()) < pfIsolation_DZ_);
568 float pt = pf_it->p4().pt();
571 if (
dr < pfIsolation_DR_) {
605 bool isOverlap =
false;
606 float dr_min = pflepoverlap_DR_;
608 for (
const auto&
pf : *pc) {
617 if (
pt < pflepoverlap_pTmin_)
621 if (
dr > pflepoverlap_DR_)
630 if (dr_min < pflepoverlap_DR_ && (id_drmin == 11 || id_drmin == 13))
640 int& pc_ref_idx)
const {
641 float dr_min = pcRefNearest_DR_;
642 float dr_min_pu = pcRefNearest_DR_;
643 int pc_ref_idx_pu = -1;
644 for (pat::PackedCandidateCollection::const_iterator pf_it = pc->begin(); pf_it != pc->end(); pf_it++) {
645 if (
int(pf_it - pc->begin()) == pc_idx)
648 bool fromPV = (pf_it->fromPV() > 1 || fabs(pf_it->dz()) < pfIsolation_DZ_);
649 float pt = pf_it->p4().pt();
653 if (
pt < pcRefNearest_pTmin_)
655 if (
dr > dr_min &&
dr > dr_min_pu)
661 pc_ref_idx =
int(pf_it - pc->begin());
664 if (
dr < dr_min_pu) {
666 pc_ref_idx_pu =
int(pf_it - pc->begin());
671 if (pc_ref_idx == -1 &&
673 pc_ref_idx = pc_ref_idx_pu;
681 float nhsum = 0, phsum = 0;
682 for (pat::PackedCandidateCollection::const_iterator pf_it = pc->begin(); pf_it != pc->end(); pf_it++) {
683 if (
int(pf_it - pc->begin()) == pc_idx)
686 float pt = pf_it->p4().pt();
689 if (
dr < pfneutralsum_DR_) {
699 nsum = nhsum + phsum;
706 if (hitInfo ==
nullptr) {
710 std::vector<float> charge_vec;
711 for (
unsigned int ih = 0; ih < hitInfo->
size(); ih++) {
732 Norm = 3.61e-06 * 265;
738 int size = charge_vec.size();
743 for (
int i = 0;
i <
size;
i++) {
759 return trackAssociator_.associate(
iEvent, iSetup, trackAssocParameters_, &initialState);
765 float& caloJetHad)
const {
766 float nearestDR = 999;
768 for (
unsigned int i = 0;
i < cJets->size();
i++) {
770 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
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)
bool getData(T &iHolder) const
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_
Power< A, B >::type pow(const A &a, const B &b)
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.