CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
GenPartIsoProducer Class Reference
Inheritance diagram for GenPartIsoProducer:
edm::stream::EDProducer<>

Public Member Functions

 GenPartIsoProducer (const edm::ParameterSet &iConfig)
 
 ~GenPartIsoProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

float computeIso (TLorentzVector thisPart, edm::Handle< pat::PackedGenParticleCollection > packedGenParticles, std::set< int > gen_fsrset, bool skip_leptons)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

int additionalPdgId_
 
edm::EDGetTokenT< reco::GenParticleCollectionfinalGenParticleToken
 
std::vector< float > Lepts_RelIso
 
edm::EDGetTokenT< pat::PackedGenParticleCollectionpackedGenParticlesToken
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 31 of file GenPartIsoProducer.cc.

Constructor & Destructor Documentation

◆ GenPartIsoProducer()

GenPartIsoProducer::GenPartIsoProducer ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 33 of file GenPartIsoProducer.cc.

34  : finalGenParticleToken(consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("genPart"))),
36  consumes<pat::PackedGenParticleCollection>(iConfig.getParameter<edm::InputTag>("packedGenPart"))),
37  additionalPdgId_(iConfig.getParameter<int>("additionalPdgId")) {
38  produces<edm::ValueMap<float>>();
39  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< reco::GenParticleCollection > finalGenParticleToken
edm::EDGetTokenT< pat::PackedGenParticleCollection > packedGenParticlesToken

◆ ~GenPartIsoProducer()

GenPartIsoProducer::~GenPartIsoProducer ( )
override

Definition at line 56 of file GenPartIsoProducer.cc.

56 {}

Member Function Documentation

◆ computeIso()

float GenPartIsoProducer::computeIso ( TLorentzVector  thisPart,
edm::Handle< pat::PackedGenParticleCollection packedGenParticles,
std::set< int >  gen_fsrset,
bool  skip_leptons 
)
private

Definition at line 125 of file GenPartIsoProducer.cc.

References funct::abs(), reco::deltaR(), isotrackApplyRegressor::k, packedGenParticles_cfi::packedGenParticles, and EgammaValidation_cff::pdgId.

128  {
129  double this_GENiso = 0.0;
130  for (size_t k = 0; k < packedGenParticles->size(); k++) {
131  if ((*packedGenParticles)[k].status() != 1)
132  continue;
133  if (abs((*packedGenParticles)[k].pdgId()) == 12 || abs((*packedGenParticles)[k].pdgId()) == 14 ||
134  abs((*packedGenParticles)[k].pdgId()) == 16)
135  continue;
136  if (reco::deltaR(thisPart.Eta(), thisPart.Phi(), (*packedGenParticles)[k].eta(), (*packedGenParticles)[k].phi()) <
137  0.001)
138  continue;
139  if (skip_leptons == true) {
140  if ((abs((*packedGenParticles)[k].pdgId()) == 11 || abs((*packedGenParticles)[k].pdgId()) == 13))
141  continue;
142  if (gen_fsrset.find(k) != gen_fsrset.end())
143  continue;
144  }
145  double this_dRvL_nolep =
146  reco::deltaR(thisPart.Eta(), thisPart.Phi(), (*packedGenParticles)[k].eta(), (*packedGenParticles)[k].phi());
147  if (this_dRvL_nolep < 0.3) {
148  this_GENiso = this_GENiso + (*packedGenParticles)[k].pt();
149  }
150  }
151  this_GENiso = this_GENiso / thisPart.Pt();
152  return this_GENiso;
153 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30

◆ fillDescriptions()

void GenPartIsoProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 155 of file GenPartIsoProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

155  {
156  // Description of external inputs requered by this module
157  // genPart: collection of gen particles for which to compute Iso
158  // packedGenPart: collection of particles to be used for leptons dressing
159  // additionalPdgId: additional particle (besides leptons) for which Iso is computed
161  desc.add<edm::InputTag>("genPart")->setComment("input physics object collection");
162  desc.add<edm::InputTag>("packedGenPart")->setComment("input stable hadrons collection");
163  desc.add<int>("additionalPdgId")->setComment("additional pdgId for Iso computation");
164  descriptions.addDefault(desc);
165 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ produce()

void GenPartIsoProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 58 of file GenPartIsoProducer.cc.

References funct::abs(), reco::deltaR(), HBHEDarkening_cff::energy, PVValHelper::eta, CustomPhysics_cfi::gamma, genparticles_cff::genPart, iEvent, isotrackApplyRegressor::k, visualization-live-secondInstance_cfg::m, reco::Candidate::mother(), eostools::move(), reco::Candidate::numberOfMothers(), packedGenParticles_cfi::packedGenParticles, and DiDispStaMuonMonitor_cfi::pt.

58  {
59  using namespace edm;
60 
61  auto finalParticles = iEvent.getHandle(finalGenParticleToken);
63 
64  reco::GenParticleCollection::const_iterator genPart;
65 
66  Lepts_RelIso.clear();
67 
68  for (genPart = finalParticles->begin(); genPart != finalParticles->end(); genPart++) {
69  if (abs(genPart->pdgId()) == 11 || abs(genPart->pdgId()) == 13 || abs(genPart->pdgId()) == 15) {
70  TLorentzVector lep_dressed;
71  lep_dressed.SetPtEtaPhiE(genPart->pt(), genPart->eta(), genPart->phi(), genPart->energy());
72  std::set<int> gen_fsrset;
73  for (size_t k = 0; k < packedGenParticles->size(); k++) {
74  if ((*packedGenParticles)[k].status() != 1)
75  continue;
76  if ((*packedGenParticles)[k].pdgId() != 22)
77  continue;
78  double this_dR_lgamma = reco::deltaR(
79  genPart->eta(), genPart->phi(), (*packedGenParticles)[k].eta(), (*packedGenParticles)[k].phi());
80  bool idmatch = false;
81  if ((*packedGenParticles)[k].mother(0)->pdgId() == genPart->pdgId())
82  idmatch = true;
83  const reco::Candidate* mother = (*packedGenParticles)[k].mother(0);
84  for (size_t m = 0; m < mother->numberOfMothers(); m++) {
85  if ((*packedGenParticles)[k].mother(m)->pdgId() == genPart->pdgId())
86  idmatch = true;
87  }
88  if (!idmatch)
89  continue;
90  if (this_dR_lgamma < 0.3) {
91  gen_fsrset.insert(k);
92  TLorentzVector gamma;
93  gamma.SetPtEtaPhiE((*packedGenParticles)[k].pt(),
94  (*packedGenParticles)[k].eta(),
95  (*packedGenParticles)[k].phi(),
97  lep_dressed = lep_dressed + gamma;
98  }
99  }
100  float this_GENiso = 0.0;
101  TLorentzVector thisLep;
102  thisLep.SetPtEtaPhiM(lep_dressed.Pt(), lep_dressed.Eta(), lep_dressed.Phi(), lep_dressed.M());
103  this_GENiso = computeIso(thisLep, packedGenParticles, gen_fsrset, true);
104  Lepts_RelIso.push_back(this_GENiso);
105  } else if (abs(genPart->pdgId()) == additionalPdgId_) {
106  float this_GENiso = 0.0;
107  std::set<int> gen_fsrset_nolep;
108  TLorentzVector thisPart;
109  thisPart.SetPtEtaPhiE(genPart->pt(), genPart->eta(), genPart->phi(), genPart->energy());
110  this_GENiso = computeIso(thisPart, packedGenParticles, gen_fsrset_nolep, false);
111  Lepts_RelIso.push_back(this_GENiso);
112  } else {
113  float this_GENiso = 0.0;
114  Lepts_RelIso.push_back(this_GENiso);
115  }
116  }
117 
118  auto isoV = std::make_unique<edm::ValueMap<float>>();
119  edm::ValueMap<float>::Filler fillerIsoMap(*isoV);
120  fillerIsoMap.insert(finalParticles, Lepts_RelIso.begin(), Lepts_RelIso.end());
121  fillerIsoMap.fill();
122  iEvent.put(std::move(isoV));
123 }
float computeIso(TLorentzVector thisPart, edm::Handle< pat::PackedGenParticleCollection > packedGenParticles, std::set< int > gen_fsrset, bool skip_leptons)
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
edm::EDGetTokenT< reco::GenParticleCollection > finalGenParticleToken
edm::EDGetTokenT< pat::PackedGenParticleCollection > packedGenParticlesToken
HLT enums.
std::vector< float > Lepts_RelIso
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ additionalPdgId_

int GenPartIsoProducer::additionalPdgId_
private

Definition at line 53 of file GenPartIsoProducer.cc.

◆ finalGenParticleToken

edm::EDGetTokenT<reco::GenParticleCollection> GenPartIsoProducer::finalGenParticleToken
private

Definition at line 51 of file GenPartIsoProducer.cc.

◆ Lepts_RelIso

std::vector<float> GenPartIsoProducer::Lepts_RelIso
private

Definition at line 50 of file GenPartIsoProducer.cc.

◆ packedGenParticlesToken

edm::EDGetTokenT<pat::PackedGenParticleCollection> GenPartIsoProducer::packedGenParticlesToken
private

Definition at line 52 of file GenPartIsoProducer.cc.