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>();
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());
262 int pdgId,
charge, fromPV;
263 float dz,
dxy, dzError, dxyError;
268 if (isInPackedCands) {
270 polarP4 = pfCand->
p4();
271 charge = pfCand->
charge();
272 pfCandInd = pcref.
key();
274 }
else if (isInLostTracks) {
275 p4 = lostTrack->
p4();
276 polarP4 = lostTrack->
p4();
277 charge = lostTrack->
charge();
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) {
317 pdgId = pfCand->
pdgId();
322 fromPV = pfCand->
fromPV();
324 }
else if (isInLostTracks) {
325 pdgId = lostTrack->
pdgId();
326 dz = lostTrack->
dz();
327 dxy = lostTrack->
dxy();
330 fromPV = lostTrack->
fromPV();
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();
364 }
else if (gt2dedxHitInfo.
isValid() && gt2dedxHitInfo->contains(tkref.
id())) {
366 dEdxStrip = getDeDx(hitInfo,
false,
true);
368 if (usePrecomputedDeDxPixel_ && gt2dedxPixel.
isValid() && gt2dedxPixel->contains(tkref.
id())) {
369 dEdxPixel = (*gt2dedxPixel)[tkref].dEdx();
370 }
else if (gt2dedxHitInfo.
isValid() && gt2dedxHitInfo->contains(tkref.
id())) {
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())
453 int pdgId,
charge, fromPV;
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_ ||
475 pdgId = pfCand.
pdgId();
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_) {
573 if (
id == 211 && fromPV)
587 if (
id == 211 && fromPV)
605 bool isOverlap =
false;
606 float dr_min = pflepoverlap_DR_;
608 for (
const auto& pf : *pc) {
611 bool fromPV = (pf.fromPV() > 1 ||
std::abs(pf.dz()) < pfIsolation_DZ_);
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++) {
715 if (isPixel && !doPixel)
717 if (isStrip && !doStrip)
721 if (!isPixel && !isStrip)
732 Norm = 3.61e-06 * 265;
738 int size = charge_vec.size();
743 for (
int i = 0;
i <
size;
i++) {
744 result +=
pow(charge_vec[
i], expo);
746 result = (size > 0) ?
pow(result / size, 1. / expo) : 0.0;
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++) {
769 float dR =
deltaR(cJets->at(
i), p4);
770 if (dR < caloJet_DR_ && dR < nearestDR) {
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
float hadEnergyInHE() const
double p() const
momentum vector magnitude
float emEnergyInEE() const
PATIsolatedTrackProducer(const edm::ParameterSet &)
const edm::EDGetTokenT< reco::TrackCollection > gt_
const edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > gt2dedxStrip_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
Jets made from CaloTowers.
const edm::EDGetTokenT< edm::ValueMap< int > > gt2dedxHitInfoPrescale_
const float pcRefNearest_pTmin_
TrackDetectorAssociator trackAssociator_
uint16_t *__restrict__ id
int charge() const override
electric charge
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double dxyError() const
error on dxy
float getPFNeutralSum(const PolarLorentzVector &p4, const pat::PackedCandidateCollection *pc, int pc_idx) const
#define DEFINE_FWK_MODULE(type)
float charge(size_t i) const
std::vector< DetId > crossedEcalIds
std::vector< l1t::PFCandidate > PFCandidateCollection
void useDefaultPropagator()
use the default propagator
std::vector< pat::PackedCandidate > PackedCandidateCollection
std::vector< Track > TrackCollection
collection of Tracks
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
float emEnergyInHF() const
double phi() const
azimuthal angle of momentum vector
const PolarLorentzVector & polarP4() const override
four-momentum Lorentz vector
const Item * getValues(DetId fId, bool throwOnFail=true) const
key_type key() const
Accessor for product key.
double px() const
x coordinate of momentum vector
int pdgId() const override
PDG identifier.
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > gt2pc_
std::vector< Vertex > VertexCollection
std::vector< DetId > crossedHcalIds
const Point & position() const
position
ProductID id() const
Accessor for product ID.
static const double deltaEta
const edm::EDGetTokenT< reco::DeDxHitInfoAss > gt2dedxHitInfo_
const bool useHighPurity_
bool getData(T &iHolder) const
pat::IsolatedTrack::PolarLorentzVector PolarLorentzVector
void getIsolation(const PolarLorentzVector &p4, const pat::PackedCandidateCollection *pc, int pc_idx, pat::PFIsolation &iso, pat::PFIsolation &miniiso) const
double eta() const
pseudorapidity of momentum vector
const edm::ESGetToken< EcalChannelStatus, EcalChannelStatusRcd > ecalSToken_
edm::Association< DeDxHitInfoCollection > DeDxHitInfoAss
void getNearestPCRef(const PolarLorentzVector &p4, const pat::PackedCandidateCollection *pc, int pc_idx, int &pc_ref_idx) const
const PVAssoc fromPV(size_t ipv=0) const
float dzError() const override
uncertainty on dz
double pt() const
track transverse momentum
TrackAssociatorParameters trackAssocParameters_
float emEnergyInEB() const
edm::Ref< pat::PackedCandidateCollection > PackedCandidateRef
Abs< T >::type abs(const T &t)
const SiPixelCluster * pixelCluster(size_t i) const
T const * get() const
Returns C++ pointer to the item.
float dxyError() const override
uncertainty on dxy
const bool addPrescaledDeDxTracks_
double pz() const
z coordinate of momentum vector
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
const float miniRelIso_cut_
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...
double dzError() const
error on dz
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_
T const * product() const
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
void getCaloJetEnergy(const PolarLorentzVector &, const reco::CaloJetCollection *, float &, float &) 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
T getParameter(std::string const &) const
const float pfneutralsum_DR_
void produce(edm::Event &, const edm::EventSetup &) override
const edm::EDGetTokenT< reco::VertexCollection > pv_
bool quality(const TrackQuality) const
Track quality.
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 &)
< trclass="colgroup">< tdclass="colgroup"colspan=5 > DT local reconstruction</td ></tr >< tr >< td >< ahref="classDTRecHit1DPair.html"> DTRecHit1DPair</a ></td >< td >< ahref="DataFormats_DTRecHit.html"> edm::RangeMap & lt
float pathlength(size_t i) const
float hadEnergyInHB() const
bool getPFLeptonOverlap(const PolarLorentzVector &p4, const pat::PackedCandidateCollection *pc) const
bool isPixel(HitType hitType)
const_iterator find(uint32_t rawId) const
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_
int charge() const
track electric charge
const float pT_cut_noIso_
virtual float dxy() const
dxy with respect to the PV ref
float hadEnergyInHF() const
float chargedHadronIso() const
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 LorentzVector & p4() const override
four-momentum Lorentz vecto r
const float pflepoverlap_pTmin_
const bool usePrecomputedDeDxPixel_
const SiStripCluster * stripCluster(size_t i) const
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
const float pfIsolation_DR_
const edm::EDGetTokenT< reco::CaloJetCollection > caloJets_
double py() const
y coordinate of momentum vector
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
const bool saveDeDxHitInfo_
const edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > gt2dedxPixel_
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
float getDeDx(const reco::DeDxHitInfo *hitInfo, bool doPixel, bool doStrip) const