27 #include <TLorentzVector.h> 35 packedGenParticlesToken(
37 additionalPdgId_(iConfig.getParameter<
int>(
"additionalPdgId")) {
38 produces<edm::ValueMap<float>>();
46 float computeIso(TLorentzVector thisPart,
48 std::set<int> gen_fsrset,
61 auto finalParticles =
iEvent.getHandle(finalGenParticleToken);
64 reco::GenParticleCollection::const_iterator
genPart;
70 TLorentzVector lep_dressed;
72 std::set<int> gen_fsrset;
79 genPart->eta(),
genPart->phi(), (*packedGenParticles)[
k].eta(), (*packedGenParticles)[
k].phi());
90 if (this_dR_lgamma < 0.3) {
97 lep_dressed = lep_dressed +
gamma;
100 float this_GENiso = 0.0;
101 TLorentzVector thisLep;
102 thisLep.SetPtEtaPhiM(lep_dressed.Pt(), lep_dressed.Eta(), lep_dressed.Phi(), lep_dressed.M());
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;
111 Lepts_RelIso.push_back(this_GENiso);
113 float this_GENiso = 0.0;
114 Lepts_RelIso.push_back(this_GENiso);
118 auto isoV = std::make_unique<edm::ValueMap<float>>();
120 fillerIsoMap.insert(finalParticles, Lepts_RelIso.begin(), Lepts_RelIso.end());
127 std::set<int> gen_fsrset,
129 double this_GENiso = 0.0;
136 if (
reco::deltaR(thisPart.Eta(), thisPart.Phi(), (*packedGenParticles)[
k].eta(), (*packedGenParticles)[
k].phi()) <
139 if (skip_leptons ==
true) {
142 if (gen_fsrset.find(
k) != gen_fsrset.end())
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();
151 this_GENiso = this_GENiso / thisPart.Pt();
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");
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
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)
void addDefault(ParameterSetDescription const &psetDescription)
void produce(edm::Event &, const edm::EventSetup &) override
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
GenPartIsoProducer(const edm::ParameterSet &iConfig)
~GenPartIsoProducer() override
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< reco::GenParticleCollection > finalGenParticleToken
std::vector< pat::PackedGenParticle > PackedGenParticleCollection
edm::EDGetTokenT< pat::PackedGenParticleCollection > packedGenParticlesToken
std::vector< float > Lepts_RelIso