CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
pat::PATIsolatedTrackProducer Class Reference
Inheritance diagram for pat::PATIsolatedTrackProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef pat::IsolatedTrack::LorentzVector LorentzVector
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void getCaloJetEnergy (const LorentzVector &, const reco::CaloJetCollection *, float &, float &) const
 
float getDeDx (const reco::DeDxHitInfo *hitInfo, bool doPixel, bool doStrip) const
 
void getIsolation (const LorentzVector &p4, const pat::PackedCandidateCollection *pc, int pc_idx, pat::PFIsolation &iso, pat::PFIsolation &miniiso) const
 
TrackDetMatchInfo getTrackDetMatchInfo (const edm::Event &, const edm::EventSetup &, const reco::Track &)
 
 PATIsolatedTrackProducer (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
 ~PATIsolatedTrackProducer ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const float absIso_cut_
 
const float caloJet_DR_
 
const edm::EDGetTokenT< reco::CaloJetCollectioncaloJets_
 
const edm::EDGetTokenT< reco::DeDxHitInfoAssgt2dedxHitInfo_
 
const edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > gt2dedxPixel_
 
const edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > gt2dedxStrip_
 
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > gt2lt_
 
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > gt2pc_
 
const edm::EDGetTokenT< reco::TrackCollectiongt_
 
const edm::EDGetTokenT< pat::PackedCandidateCollectionlt_
 
std::vector< double > miniIsoParams_
 
const float miniRelIso_cut_
 
const edm::EDGetTokenT< edm::Association< reco::PFCandidateCollection > > pc2pf_
 
const edm::EDGetTokenT< pat::PackedCandidateCollectionpc_
 
const float pfIsolation_DR_
 
const float pfIsolation_DZ_
 
const float pT_cut_
 
const float pT_cut_noIso_
 
const edm::EDGetTokenT< reco::VertexCollectionpv_
 
const float relIso_cut_
 
TrackDetectorAssociator trackAssociator_
 
TrackAssociatorParameters trackAssocParameters_
 
const bool usePrecomputedDeDxPixel_
 
const bool usePrecomputedDeDxStrip_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 43 of file PATIsolatedTrackProducer.cc.

Member Typedef Documentation

Definition at line 45 of file PATIsolatedTrackProducer.cc.

Constructor & Destructor Documentation

pat::PATIsolatedTrackProducer::PATIsolatedTrackProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 92 of file PATIsolatedTrackProducer.cc.

References edm::EDConsumerBase::consumesCollector(), edm::ParameterSet::getParameter(), TrackAssociatorParameters::loadParameters(), miniIsoParams_, metProducer_cfi::parameters, trackAssociator_, trackAssocParameters_, and TrackDetectorAssociator::useDefaultPropagator().

92  :
93  pc_(consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
94  lt_(consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("lostTracks"))),
95  gt_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("generalTracks"))),
96  pv_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("primaryVertices"))),
100  caloJets_(consumes<reco::CaloJetCollection>(iConfig.getParameter<edm::InputTag>("caloJets"))),
103  gt2dedxHitInfo_(consumes<reco::DeDxHitInfoAss>(iConfig.getParameter<edm::InputTag>("dEdxHitInfo"))),
104  usePrecomputedDeDxStrip_(iConfig.getParameter<bool>("usePrecomputedDeDxStrip")),
105  usePrecomputedDeDxPixel_(iConfig.getParameter<bool>("usePrecomputedDeDxPixel")),
106  pT_cut_ (iConfig.getParameter<double>("pT_cut")),
107  pT_cut_noIso_ (iConfig.getParameter<double>("pT_cut_noIso")),
108  pfIsolation_DR_ (iConfig.getParameter<double>("pfIsolation_DR")),
109  pfIsolation_DZ_ (iConfig.getParameter<double>("pfIsolation_DZ")),
110  absIso_cut_ (iConfig.getParameter<double>("absIso_cut")),
111  relIso_cut_ (iConfig.getParameter<double>("relIso_cut")),
112  miniRelIso_cut_ (iConfig.getParameter<double>("miniRelIso_cut")),
113  caloJet_DR_ (iConfig.getParameter<double>("caloJet_DR"))
114 {
115  // TrackAssociator parameters
116  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
118  trackAssocParameters_.loadParameters( parameters, iC );
119 
121 
122  miniIsoParams_ = iConfig.getParameter<std::vector<double> >("miniIsoParams");
123  if(miniIsoParams_.size() != 3)
124  throw cms::Exception("ParameterError") << "miniIsoParams must have exactly 3 elements.\n";
125 
126  produces< pat::IsolatedTrackCollection > ();
127 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< reco::TrackCollection > gt_
const edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > gt2dedxStrip_
TrackDetectorAssociator trackAssociator_
void useDefaultPropagator()
use the default propagator
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > gt2pc_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< reco::DeDxHitInfoAss > gt2dedxHitInfo_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
TrackAssociatorParameters trackAssocParameters_
const edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
const edm::EDGetTokenT< edm::Association< reco::PFCandidateCollection > > pc2pf_
const edm::EDGetTokenT< pat::PackedCandidateCollection > lt_
const edm::EDGetTokenT< reco::VertexCollection > pv_
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > gt2lt_
const edm::EDGetTokenT< reco::CaloJetCollection > caloJets_
const edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > gt2dedxPixel_
pat::PATIsolatedTrackProducer::~PATIsolatedTrackProducer ( )

Definition at line 129 of file PATIsolatedTrackProducer.cc.

129 {}

Member Function Documentation

void pat::PATIsolatedTrackProducer::getCaloJetEnergy ( const LorentzVector p4,
const reco::CaloJetCollection cJets,
float &  caloJetEm,
float &  caloJetHad 
) const

Definition at line 497 of file PATIsolatedTrackProducer.cc.

References caloJet_DR_, DEFINE_FWK_MODULE, deltaR(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, reco::CaloJet::emEnergyInEB(), reco::CaloJet::emEnergyInEE(), reco::CaloJet::emEnergyInHF(), reco::CaloJet::hadEnergyInHB(), reco::CaloJet::hadEnergyInHE(), reco::CaloJet::hadEnergyInHF(), mps_fire::i, and p4.

Referenced by produce().

499 {
500  float nearestDR = 999;
501  int ind = -1;
502  for(unsigned int i=0; i<cJets->size(); i++){
503  float dR = deltaR(cJets->at(i).p4(), p4);
504  if(dR < caloJet_DR_ && dR < nearestDR){
505  nearestDR = dR;
506  ind = i;
507  }
508  }
509 
510  if(ind==-1){
511  caloJetEm = 0;
512  caloJetHad = 0;
513  }else{
514  const reco::CaloJet & cJet = cJets->at(ind);
515  caloJetEm = cJet.emEnergyInEB() + cJet.emEnergyInEE() + cJet.emEnergyInHF();
516  caloJetHad = cJet.hadEnergyInHB() + cJet.hadEnergyInHE() + cJet.hadEnergyInHF();
517  }
518 
519 }
float hadEnergyInHE() const
Definition: CaloJet.h:108
float emEnergyInEE() const
Definition: CaloJet.h:114
Jets made from CaloTowers.
Definition: CaloJet.h:29
float emEnergyInHF() const
Definition: CaloJet.h:116
double p4[4]
Definition: TauolaWrapper.h:92
float emEnergyInEB() const
Definition: CaloJet.h:112
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
float hadEnergyInHB() const
Definition: CaloJet.h:104
float hadEnergyInHF() const
Definition: CaloJet.h:110
float pat::PATIsolatedTrackProducer::getDeDx ( const reco::DeDxHitInfo hitInfo,
bool  doPixel,
bool  doStrip 
) const

Definition at line 439 of file PATIsolatedTrackProducer.cc.

References reco::DeDxHitInfo::charge(), mps_fire::i, fastTrackerRecHitType::isPixel(), NULL, reco::DeDxHitInfo::pathlength(), reco::DeDxHitInfo::pixelCluster(), funct::pow(), mps_fire::result, DeDxTools::shapeSelection(), reco::DeDxHitInfo::size(), findQualityFiles::size, and reco::DeDxHitInfo::stripCluster().

Referenced by produce().

440 {
441  if(hitInfo == NULL){
442  return -1;
443  }
444 
445  std::vector<float> charge_vec;
446  for(unsigned int ih=0; ih<hitInfo->size(); ih++){
447 
448  bool isPixel = (hitInfo->pixelCluster(ih) != nullptr);
449  bool isStrip = (hitInfo->stripCluster(ih) != nullptr);
450 
451  if(isPixel && !doPixel) continue;
452  if(isStrip && !doStrip) continue;
453 
454  // probably shouldn't happen
455  if(!isPixel && !isStrip) continue;
456 
457  // shape selection for strips
458  if(isStrip && !DeDxTools::shapeSelection(*(hitInfo->stripCluster(ih))))
459  continue;
460 
461  float Norm=0;
462  if(isPixel)
463  Norm = 3.61e-06; //compute the normalization factor to get the energy in MeV/mm
464  if(isStrip)
465  Norm = 3.61e-06 * 265;
466 
467  //save the dE/dx in MeV/mm to a vector.
468  charge_vec.push_back(Norm*hitInfo->charge(ih)/hitInfo->pathlength(ih));
469  }
470 
471  int size = charge_vec.size();
472  float result = 0.0;
473 
474  //build the harmonic 2 dE/dx estimator
475  float expo = -2;
476  for(int i=0; i<size; i++){
477  result += pow(charge_vec[i], expo);
478  }
479  result = (size>0) ? pow(result/size, 1./expo) : 0.0;
480 
481  return result;
482 }
size
Write out results.
float charge(size_t i) const
Definition: DeDxHitInfo.h:42
#define NULL
Definition: scimark2.h:8
bool shapeSelection(const SiStripCluster &ampls)
Definition: DeDxTools.cc:10
const SiPixelCluster * pixelCluster(size_t i) const
Definition: DeDxHitInfo.h:46
size_t size() const
Definition: DeDxHitInfo.h:41
float pathlength(size_t i) const
Definition: DeDxHitInfo.h:43
bool isPixel(HitType hitType)
const SiStripCluster * stripCluster(size_t i) const
Definition: DeDxHitInfo.h:63
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void pat::PATIsolatedTrackProducer::getIsolation ( const LorentzVector p4,
const pat::PackedCandidateCollection pc,
int  pc_idx,
pat::PFIsolation iso,
pat::PFIsolation miniiso 
) const

Definition at line 391 of file PATIsolatedTrackProducer.cc.

References funct::abs(), deltaR(), runTauDisplay::dr, hpstanc_transforms::max, min(), miniIsoParams_, muons2muons_cfi::PFIsolation, pfIsolation_DR_, pfIsolation_DZ_, and EnergyCorrector::pt.

Referenced by produce().

394 {
395  float chiso=0, nhiso=0, phiso=0, puiso=0; // standard isolation
396  float chmiso=0, nhmiso=0, phmiso=0, pumiso=0; // mini isolation
397  float miniDR = std::max(miniIsoParams_[0], std::min(miniIsoParams_[1], miniIsoParams_[2]/p4.pt()));
398  for(pat::PackedCandidateCollection::const_iterator pf_it = pc->begin(); pf_it != pc->end(); pf_it++){
399  if(int(pf_it - pc->begin()) == pc_idx) //don't count itself
400  continue;
401  int id = std::abs(pf_it->pdgId());
402  bool fromPV = (pf_it->fromPV()>1 || fabs(pf_it->dz()) < pfIsolation_DZ_);
403  float pt = pf_it->p4().pt();
404  float dr = deltaR(p4, pf_it->p4());
405 
406  if(dr < pfIsolation_DR_){
407  // charged cands from PV get added to trackIso
408  if(id==211 && fromPV)
409  chiso += pt;
410  // charged cands not from PV get added to pileup iso
411  else if(id==211)
412  puiso += pt;
413  // neutral hadron iso
414  if(id==130)
415  nhiso += pt;
416  // photon iso
417  if(id==22)
418  phiso += pt;
419  }
420  // same for mini isolation
421  if(dr < miniDR){
422  if(id == 211 && fromPV)
423  chmiso += pt;
424  else if(id == 211)
425  pumiso += pt;
426  if(id == 130)
427  nhmiso += pt;
428  if(id == 22)
429  phmiso += pt;
430  }
431  }
432 
433  iso = pat::PFIsolation(chiso,nhiso,phiso,puiso);
434  miniiso = pat::PFIsolation(chmiso,nhmiso,phmiso,pumiso);
435 
436 }
double p4[4]
Definition: TauolaWrapper.h:92
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
TrackDetMatchInfo pat::PATIsolatedTrackProducer::getTrackDetMatchInfo ( const edm::Event iEvent,
const edm::EventSetup iSetup,
const reco::Track track 
)

Definition at line 484 of file PATIsolatedTrackProducer.cc.

References TrackDetectorAssociator::associate(), ecalTB2006H4_GenSimDigiReco_cfg::bField, edm::EventSetup::get(), trajectoryStateTransform::initialFreeState(), trackAssociator_, and trackAssocParameters_.

Referenced by produce().

487 {
489  iSetup.get<IdealMagneticFieldRecord>().get(bField);
491 
492  // can't use the associate() using reco::Track directly, since
493  // track->extra() is non-null but segfaults when trying to use it
494  return trackAssociator_.associate(iEvent, iSetup, trackAssocParameters_, &initialState);
495 }
TrackDetectorAssociator trackAssociator_
TrackAssociatorParameters trackAssocParameters_
const T & get() const
Definition: EventSetup.h:55
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
FreeTrajectoryState initialFreeState(const reco::Track &tk, const MagneticField *field, bool withErr=true)
void pat::PATIsolatedTrackProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Definition at line 131 of file PATIsolatedTrackProducer.cc.

References absIso_cut_, isolatedTracks_cfi::caloJets, caloJets_, ALCARECOTkAlJpsiMuMu_cff::charge, reco::TrackBase::charge(), pat::PackedCandidate::charge(), pat::PFIsolation::chargedHadronIso(), edm::Association< C >::contains(), TrackDetMatchInfo::crossedEcalIds, TrackDetMatchInfo::crossedHcalIds, spr::deltaEta, hiPixelPairStep_cff::deltaPhi, PVValHelper::dxy, reco::TrackBase::dxy(), pat::PackedCandidate::dxy(), reco::TrackBase::dxyError(), pat::PackedCandidate::dxyError(), PVValHelper::dz, reco::TrackBase::dz(), pat::PackedCandidate::dz(), reco::TrackBase::dzError(), pat::PackedCandidate::dzError(), reco::TrackBase::eta(), EcalCondObjectContainer< T >::find(), pat::PackedCandidate::fromPV(), isolatedTracks_cfi::generalTracks, edm::EventSetup::get(), edm::Ref< C, T, F >::get(), edm::Event::getByToken(), getCaloJetEnergy(), getDeDx(), getIsolation(), getTrackDetMatchInfo(), reco::JetExtendedAssociation::getValue(), HcalCondObjectContainer< Item >::getValues(), gt2dedxHitInfo_, gt2dedxPixel_, gt2dedxStrip_, gt2lt_, gt2pc_, gt_, pat::PackedCandidate::hasTrackDetails(), reco::TrackBase::hitPattern(), AnalysisDataFormats_SUSYBSMObjects::hp, edm::HandleBase::id(), edm::Ref< C, T, F >::id(), createfilelist::int, edm::Ref< C, T, F >::isNonnull(), edm::HandleBase::isValid(), edm::Ref< C, T, F >::key(), lt_, funct::m, miniRelIso_cut_, eostools::move(), reco::TrackBase::p(), p4, pat::PackedCandidate::p4(), pc2pf_, pc_, cosmictrackingParticleSelector_cfi::pdgId, pat::PackedCandidate::pdgId(), reco::TrackBase::phi(), reco::Vertex::position(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), pT_cut_, pT_cut_noIso_, edm::Event::put(), MetAnalyzer::pv(), pv_, reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), reco::TrackBase::qualityMask(), relIso_cut_, mathSSE::sqrt(), photonIsolationHIProducer_cfi::trackQuality, TrackDetMatchInfo::trkGlobPosAtEcal, usePrecomputedDeDxPixel_, and usePrecomputedDeDxStrip_.

131  {
132 
133  // packedPFCandidate collection
135  iEvent.getByToken( pc_, pc_h );
136  const pat::PackedCandidateCollection *pc = pc_h.product();
137 
138  // lostTracks collection
140  iEvent.getByToken( lt_, lt_h );
141 
142  // generalTracks collection
144  iEvent.getByToken( gt_, gt_h );
146 
147  // get the primary vertex
149  iEvent.getByToken( pv_, pvs );
150  const reco::Vertex & pv = (*pvs)[0];
151 
152  // generalTracks-->packedPFCandidate association
154  iEvent.getByToken(gt2pc_, gt2pc);
155 
156  // generalTracks-->lostTracks association
158  iEvent.getByToken(gt2lt_, gt2lt);
159 
160  // packedPFCandidates-->particleFlow(reco::PFCandidate) association
162  iEvent.getByToken(pc2pf_, pc2pf);
163 
165  iEvent.getByToken(caloJets_, caloJets);
166 
167  // associate generalTracks with their DeDx data (estimator for strip dE/dx)
169  iEvent.getByToken(gt2dedxStrip_, gt2dedxStrip);
170 
171  // associate generalTracks with their DeDx data (estimator for pixel dE/dx)
173  iEvent.getByToken(gt2dedxPixel_, gt2dedxPixel);
174 
175  // associate generalTracks with their DeDx hit info (used to estimate pixel dE/dx)
176  edm::Handle<reco::DeDxHitInfoAss> gt2dedxHitInfo;
177  iEvent.getByToken(gt2dedxHitInfo_, gt2dedxHitInfo);
178 
180  iSetup.get<HcalChannelQualityRcd>().get("withTopo", hcalQ_h);
181  const HcalChannelQuality *hcalQ = hcalQ_h.product();
182 
184  iSetup.get<EcalChannelStatusRcd>().get(ecalS_h);
185  const EcalChannelStatus *ecalS = ecalS_h.product();
186 
187  auto outPtrP = std::make_unique<std::vector<pat::IsolatedTrack>>();
188 
189  //add general tracks
190  for(unsigned int igt=0; igt<generalTracks->size(); igt++){
191  const reco::Track &gentk = (*gt_h)[igt];
192  reco::TrackRef tkref = reco::TrackRef(gt_h, igt);
193  pat::PackedCandidateRef pcref = (*gt2pc)[tkref];
194  pat::PackedCandidateRef ltref = (*gt2lt)[tkref];
195  const pat::PackedCandidate & pfCand = *(pcref.get());
196  const pat::PackedCandidate & lostTrack = *(ltref.get());
197 
198  // Determine if this general track is associated with anything in packedPFCandidates or lostTracks
199  // Sometimes, a track gets associated w/ a neutral pfCand.
200  // In this case, ignore the pfCand and take from lostTracks
201  bool isInPackedCands = (pcref.isNonnull() && pcref.id()==pc_h.id() && pfCand.charge()!=0);
202  bool isInLostTracks = (ltref.isNonnull() && ltref.id()==lt_h.id());
203 
205  pat::PackedCandidateRef refToCand;
206  int pdgId, charge, fromPV;
207  float dz, dxy, dzError, dxyError;
208  int pfCandInd; //to avoid counting packedPFCands in their own isolation
209 
210  // get the four-momentum and charge
211  if(isInPackedCands){
212  p4 = pfCand.p4();
213  charge = pfCand.charge();
214  pfCandInd = pcref.key();
215  }else if(isInLostTracks){
216  p4 = lostTrack.p4();
217  charge = lostTrack.charge();
218  pfCandInd = -1;
219  }else{
220  double m = 0.13957018; //assume pion mass
221  double E = sqrt(m*m + gentk.p()*gentk.p());
222  p4.SetPxPyPzE(gentk.px(), gentk.py(), gentk.pz(), E);
223  charge = gentk.charge();
224  pfCandInd = -1;
225  }
226 
227  if(p4.pt() < pT_cut_)
228  continue;
229  if(charge == 0)
230  continue;
231 
232  // get the isolation of the track
233  pat::PFIsolation isolationDR03;
234  pat::PFIsolation miniIso;
235  getIsolation(p4, pc, pfCandInd, isolationDR03, miniIso);
236 
237  // isolation cut
238  if( p4.pt() < pT_cut_noIso_ &&
239  !(isolationDR03.chargedHadronIso() < absIso_cut_ ||
240  isolationDR03.chargedHadronIso()/p4.pt() < relIso_cut_ ||
241  miniIso.chargedHadronIso()/p4.pt() < miniRelIso_cut_))
242  continue;
243 
244  // get the rest after the pt/iso cuts. Saves some runtime
245  if(isInPackedCands){
246  pdgId = pfCand.pdgId();
247  dz = pfCand.dz();
248  dxy = pfCand.dxy();
249  dzError = pfCand.dzError();
250  dxyError = pfCand.dxyError();
251  fromPV = pfCand.fromPV();
252  refToCand = pcref;
253  }else if(isInLostTracks){
254  pdgId = lostTrack.pdgId();
255  dz = lostTrack.dz();
256  dxy = lostTrack.dxy();
257  dzError = lostTrack.dzError();
258  dxyError = lostTrack.dxyError();
259  fromPV = lostTrack.fromPV();
260  refToCand = ltref;
261  }else{
262  pdgId = 0;
263  dz = gentk.dz(pv.position());
264  dxy = gentk.dxy(pv.position());
265  dzError = gentk.dzError();
266  dxyError = gentk.dxyError();
267  fromPV = -1;
268  refToCand = pat::PackedCandidateRef(); //NULL reference
269  }
270 
271  float caloJetEm, caloJetHad;
272  getCaloJetEnergy(p4, caloJets.product(), caloJetEm, caloJetHad);
273 
274  // if no dEdx info exists, just store -1
275  float dEdxPixel=-1, dEdxStrip=-1;
276  if(usePrecomputedDeDxStrip_ && gt2dedxStrip.isValid() && gt2dedxStrip->contains(tkref.id())){
277  dEdxStrip = (*gt2dedxStrip)[tkref].dEdx();
278  }else if(gt2dedxHitInfo.isValid() && gt2dedxHitInfo->contains(tkref.id())){
279  const reco::DeDxHitInfo* hitInfo = (*gt2dedxHitInfo)[tkref].get();
280  dEdxStrip = getDeDx(hitInfo, false, true);
281  }
282  if(usePrecomputedDeDxPixel_ && gt2dedxPixel.isValid() && gt2dedxPixel->contains(tkref.id())){
283  dEdxPixel = (*gt2dedxPixel)[tkref].dEdx();
284  }else if(gt2dedxHitInfo.isValid() && gt2dedxHitInfo->contains(tkref.id())){
285  const reco::DeDxHitInfo* hitInfo = (*gt2dedxHitInfo)[tkref].get();
286  dEdxPixel = getDeDx(hitInfo, true, false);
287  }
288 
289  int trackQuality = gentk.qualityMask();
290 
291  // get the associated ecal/hcal detectors
292  TrackDetMatchInfo trackDetInfo = getTrackDetMatchInfo(iEvent, iSetup, gentk);
293 
294  // fill ecal/hcal status vectors
295  std::vector<uint32_t> crossedHcalStatus;
296  for(auto const & did : trackDetInfo.crossedHcalIds){
297  crossedHcalStatus.push_back(hcalQ->getValues(did.rawId())->getValue());
298  }
299  std::vector<uint16_t> crossedEcalStatus;
300  for(auto const & did : trackDetInfo.crossedEcalIds){
301  crossedEcalStatus.push_back(ecalS->find(did.rawId())->getStatusCode());
302  }
303 
304  int deltaEta = int((trackDetInfo.trkGlobPosAtEcal.eta() - gentk.eta())/0.5 * 250);
305  int deltaPhi = int((trackDetInfo.trkGlobPosAtEcal.phi() - gentk.phi())/0.5 * 250);
306  if(deltaEta < -250) deltaEta = -250;
307  if(deltaEta > 250) deltaEta = 250;
308  if(deltaPhi < -250) deltaPhi = -250;
309  if(deltaPhi > 250) deltaPhi = 250;
310 
311  outPtrP->push_back(pat::IsolatedTrack(isolationDR03, miniIso, caloJetEm, caloJetHad, p4,
312  charge, pdgId, dz, dxy, dzError, dxyError,
313  gentk.hitPattern(), dEdxStrip, dEdxPixel, fromPV, trackQuality,
314  crossedEcalStatus, crossedHcalStatus,
315  deltaEta, deltaPhi, refToCand));
316 
317  }
318 
319  // there are some number of pfcandidates with no associated track
320  // (mostly electrons, with a handful of muons)
321  // here we find these and store. Track-specific variables get some default values
322  for(unsigned int ipc=0; ipc<pc->size(); ipc++){
323  const pat::PackedCandidate& pfCand = pc->at(ipc);
325  reco::PFCandidateRef pfref = (*pc2pf)[pcref];
326 
327  // already counted if it has a track reference in the generalTracks collection
328  if(pfref.get()->trackRef().isNonnull() && pfref.get()->trackRef().id() == gt_h.id())
329  continue;
330 
332  pat::PackedCandidateRef refToCand;
333  int pdgId, charge, fromPV;
334  float dz, dxy, dzError, dxyError;
335 
336  p4 = pfCand.p4();
337  charge = pfCand.charge();
338 
339  if(p4.pt() < pT_cut_)
340  continue;
341  if(charge == 0)
342  continue;
343 
344  // get the isolation of the track
345  pat::PFIsolation isolationDR03;
346  pat::PFIsolation miniIso;
347  getIsolation(p4, pc, ipc, isolationDR03, miniIso);
348 
349  // isolation cut
350  if( p4.pt() < pT_cut_noIso_ &&
351  !(isolationDR03.chargedHadronIso() < absIso_cut_ ||
352  isolationDR03.chargedHadronIso()/p4.pt() < relIso_cut_ ||
353  miniIso.chargedHadronIso()/p4.pt() < miniRelIso_cut_))
354  continue;
355 
356  pdgId = pfCand.pdgId();
357  dz = pfCand.dz();
358  dxy = pfCand.dxy();
359  if (pfCand.hasTrackDetails()){
360  dzError = pfCand.dzError();
361  dxyError = pfCand.dxyError();
362  } else {
363  dzError = 0;
364  dxyError = 0;
365  }
366  fromPV = pfCand.fromPV();
367  refToCand = pcref;
368 
369  float caloJetEm, caloJetHad;
370  getCaloJetEnergy(p4, caloJets.product(), caloJetEm, caloJetHad);
371 
372  // fill with default values
374  float dEdxPixel=-1, dEdxStrip=-1;
375  int trackQuality=0;
376  std::vector<uint16_t> ecalStatus;
377  std::vector<uint32_t> hcalStatus;
378  int deltaEta=0;
379  int deltaPhi=0;
380 
381  outPtrP->push_back(pat::IsolatedTrack(isolationDR03, miniIso, caloJetEm, caloJetHad, p4,
382  charge, pdgId, dz, dxy, dzError, dxyError,
383  hp, dEdxStrip, dEdxPixel, fromPV, trackQuality,
384  ecalStatus, hcalStatus, deltaEta, deltaPhi, refToCand));
385  }
386 
387  iEvent.put(std::move(outPtrP));
388 }
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
double p() const
momentum vector magnitude
Definition: TrackBase.h:615
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.
Definition: Event.h:122
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
virtual float dzError() const
uncertainty on dz
ProductID id() const
Definition: HandleBase.cc:15
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
double dxyError() const
error on dxy
Definition: TrackBase.h:796
std::vector< DetId > crossedEcalIds
std::vector< pat::PackedCandidate > PackedCandidateCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:645
const Item * getValues(DetId fId, bool throwOnFail=true) const
key_type key() const
Accessor for product key.
Definition: Ref.h:265
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:627
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > gt2pc_
std::vector< DetId > crossedHcalIds
const Point & position() const
position
Definition: Vertex.h:109
ProductID id() const
Accessor for product ID.
Definition: Ref.h:259
static const double deltaEta
Definition: CaloConstants.h:8
const edm::EDGetTokenT< reco::DeDxHitInfoAss > gt2dedxHitInfo_
void getCaloJetEnergy(const LorentzVector &, const reco::CaloJetCollection *, float &, float &) const
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:651
const PVAssoc fromPV(size_t ipv=0) const
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
T sqrt(T t)
Definition: SSEVec.h:18
double p4[4]
Definition: TauolaWrapper.h:92
edm::Ref< pat::PackedCandidateCollection > PackedCandidateRef
int qualityMask() const
Definition: TrackBase.h:862
def pv(vc)
Definition: MetAnalyzer.py:6
virtual int charge() const
electric charge
math::XYZTLorentzVector LorentzVector
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:245
bool isValid() const
Definition: HandleBase.h:74
bool contains(ProductID id) const
Definition: Association.h:62
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:639
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
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...
Definition: TrackBase.h:609
double dzError() const
error on dz
Definition: TrackBase.h:814
const edm::EDGetTokenT< pat::PackedCandidateCollection > pc_
T const * product() const
Definition: Handle.h:81
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:446
const edm::EDGetTokenT< edm::Association< reco::PFCandidateCollection > > pc2pf_
const edm::EDGetTokenT< pat::PackedCandidateCollection > lt_
const T & get() const
Definition: EventSetup.h:55
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
const edm::EDGetTokenT< reco::VertexCollection > pv_
void getIsolation(const LorentzVector &p4, const pat::PackedCandidateCollection *pc, int pc_idx, pat::PFIsolation &iso, pat::PFIsolation &miniiso) const
const edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > gt2lt_
TrackDetMatchInfo getTrackDetMatchInfo(const edm::Event &, const edm::EventSetup &, const reco::Track &)
const_iterator find(uint32_t rawId) const
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
virtual const LorentzVector & p4() const
four-momentum Lorentz vecto r
int charge() const
track electric charge
Definition: TrackBase.h:567
virtual float dxy() const
dxy with respect to the PV ref
float chargedHadronIso() const
Definition: PFIsolation.h:33
virtual int pdgId() const
PDG identifier.
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:591
T const * product() const
Definition: ESHandle.h:86
virtual float dxyError() const
uncertainty on dxy
def move(src, dest)
Definition: eostools.py:510
const edm::EDGetTokenT< reco::CaloJetCollection > caloJets_
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:633
const edm::EDGetTokenT< edm::ValueMap< reco::DeDxData > > gt2dedxPixel_
float getDeDx(const reco::DeDxHitInfo *hitInfo, bool doPixel, bool doStrip) const

Member Data Documentation

const float pat::PATIsolatedTrackProducer::absIso_cut_
private

Definition at line 80 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const float pat::PATIsolatedTrackProducer::caloJet_DR_
private

Definition at line 83 of file PATIsolatedTrackProducer.cc.

Referenced by getCaloJetEnergy().

const edm::EDGetTokenT<reco::CaloJetCollection> pat::PATIsolatedTrackProducer::caloJets_
private

Definition at line 70 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::DeDxHitInfoAss> pat::PATIsolatedTrackProducer::gt2dedxHitInfo_
private

Definition at line 73 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::ValueMap<reco::DeDxData> > pat::PATIsolatedTrackProducer::gt2dedxPixel_
private

Definition at line 72 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::ValueMap<reco::DeDxData> > pat::PATIsolatedTrackProducer::gt2dedxStrip_
private

Definition at line 71 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > pat::PATIsolatedTrackProducer::gt2lt_
private

Definition at line 68 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > pat::PATIsolatedTrackProducer::gt2pc_
private

Definition at line 67 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::TrackCollection> pat::PATIsolatedTrackProducer::gt_
private

Definition at line 65 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<pat::PackedCandidateCollection> pat::PATIsolatedTrackProducer::lt_
private

Definition at line 64 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

std::vector<double> pat::PATIsolatedTrackProducer::miniIsoParams_
private

Definition at line 85 of file PATIsolatedTrackProducer.cc.

Referenced by getIsolation(), and PATIsolatedTrackProducer().

const float pat::PATIsolatedTrackProducer::miniRelIso_cut_
private

Definition at line 82 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::Association<reco::PFCandidateCollection> > pat::PATIsolatedTrackProducer::pc2pf_
private

Definition at line 69 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<pat::PackedCandidateCollection> pat::PATIsolatedTrackProducer::pc_
private

Definition at line 63 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const float pat::PATIsolatedTrackProducer::pfIsolation_DR_
private

Definition at line 78 of file PATIsolatedTrackProducer.cc.

Referenced by getIsolation().

const float pat::PATIsolatedTrackProducer::pfIsolation_DZ_
private

Definition at line 79 of file PATIsolatedTrackProducer.cc.

Referenced by getIsolation().

const float pat::PATIsolatedTrackProducer::pT_cut_
private

Definition at line 76 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const float pat::PATIsolatedTrackProducer::pT_cut_noIso_
private

Definition at line 77 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<reco::VertexCollection> pat::PATIsolatedTrackProducer::pv_
private

Definition at line 66 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const float pat::PATIsolatedTrackProducer::relIso_cut_
private

Definition at line 81 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

TrackDetectorAssociator pat::PATIsolatedTrackProducer::trackAssociator_
private

Definition at line 87 of file PATIsolatedTrackProducer.cc.

Referenced by getTrackDetMatchInfo(), and PATIsolatedTrackProducer().

TrackAssociatorParameters pat::PATIsolatedTrackProducer::trackAssocParameters_
private

Definition at line 88 of file PATIsolatedTrackProducer.cc.

Referenced by getTrackDetMatchInfo(), and PATIsolatedTrackProducer().

const bool pat::PATIsolatedTrackProducer::usePrecomputedDeDxPixel_
private

Definition at line 75 of file PATIsolatedTrackProducer.cc.

Referenced by produce().

const bool pat::PATIsolatedTrackProducer::usePrecomputedDeDxStrip_
private

Definition at line 74 of file PATIsolatedTrackProducer.cc.

Referenced by produce().