CMS 3D CMS Logo

PATPuppiJetSpecificsProducer.cc
Go to the documentation of this file.
1 /*
2  * PATPuppiJetSpecificProducer
3  *
4  * Author: Andreas Hinzmann
5  *
6  * Compute weighted constituent multiplicites for PUPPI PAT jets
7  *
8  */
9 
16 
19 
23 
25 public:
28  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
29  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
30 
31 private:
32  // input collection
35 };
36 
38  srcjets_ = cfg.getParameter<edm::InputTag>("src");
39  jets_token = consumes<edm::View<pat::Jet> >(srcjets_);
40 
41  produces<edm::ValueMap<float> >("puppiMultiplicity");
42  produces<edm::ValueMap<float> >("neutralPuppiMultiplicity");
43  produces<edm::ValueMap<float> >("neutralHadronPuppiMultiplicity");
44  produces<edm::ValueMap<float> >("photonPuppiMultiplicity");
45  produces<edm::ValueMap<float> >("HFHadronPuppiMultiplicity");
46  produces<edm::ValueMap<float> >("HFEMPuppiMultiplicity");
47 }
48 
52 
53  std::vector<float> puppiMultiplicities;
54  std::vector<float> neutralPuppiMultiplicities;
55  std::vector<float> neutralHadronPuppiMultiplicities;
56  std::vector<float> photonPuppiMultiplicities;
57  std::vector<float> HFHadronPuppiMultiplicities;
58  std::vector<float> HFEMPuppiMultiplicities;
59 
60  for (auto const& c : *jets) {
61  float puppiMultiplicity = 0;
62  float neutralPuppiMultiplicity = 0;
63  float neutralHadronPuppiMultiplicity = 0;
64  float photonPuppiMultiplicity = 0;
65  float HFHadronPuppiMultiplicity = 0;
66  float HFEMPuppiMultiplicity = 0;
67 
68  for (unsigned i = 0; i < c.numberOfDaughters(); i++) {
69  const pat::PackedCandidate& dau = static_cast<const pat::PackedCandidate&>(*c.daughter(i));
70  auto weight = dau.puppiWeight();
71  puppiMultiplicity += weight;
72  // This logic is taken from RecoJets/JetProducers/src/JetSpecific.cc
73  switch (std::abs(dau.pdgId())) {
74  case 130: //PFCandidate::h0 : // neutral hadron
75  neutralHadronPuppiMultiplicity += weight;
76  neutralPuppiMultiplicity += weight;
77  break;
78  case 22: //PFCandidate::gamma: // photon
79  photonPuppiMultiplicity += weight;
80  neutralPuppiMultiplicity += weight;
81  break;
82  case 1: // PFCandidate::h_HF : // hadron in HF
83  HFHadronPuppiMultiplicity += weight;
84  neutralPuppiMultiplicity += weight;
85  break;
86  case 2: //PFCandidate::egamma_HF : // electromagnetic in HF
87  HFEMPuppiMultiplicity += weight;
88  neutralPuppiMultiplicity += weight;
89  break;
90  }
91  }
92 
93  puppiMultiplicities.push_back(puppiMultiplicity);
94  neutralPuppiMultiplicities.push_back(neutralPuppiMultiplicity);
95  neutralHadronPuppiMultiplicities.push_back(neutralHadronPuppiMultiplicity);
96  photonPuppiMultiplicities.push_back(photonPuppiMultiplicity);
97  HFHadronPuppiMultiplicities.push_back(HFHadronPuppiMultiplicity);
98  HFEMPuppiMultiplicities.push_back(HFEMPuppiMultiplicity);
99  }
100 
101  std::unique_ptr<edm::ValueMap<float> > puppiMultiplicities_out(new edm::ValueMap<float>());
102  edm::ValueMap<float>::Filler puppiMultiplicities_filler(*puppiMultiplicities_out);
103  puppiMultiplicities_filler.insert(jets, puppiMultiplicities.begin(), puppiMultiplicities.end());
104  puppiMultiplicities_filler.fill();
105  evt.put(std::move(puppiMultiplicities_out), "puppiMultiplicity");
106 
107  std::unique_ptr<edm::ValueMap<float> > neutralPuppiMultiplicities_out(new edm::ValueMap<float>());
108  edm::ValueMap<float>::Filler neutralPuppiMultiplicities_filler(*neutralPuppiMultiplicities_out);
109  neutralPuppiMultiplicities_filler.insert(jets, neutralPuppiMultiplicities.begin(), neutralPuppiMultiplicities.end());
110  neutralPuppiMultiplicities_filler.fill();
111  evt.put(std::move(neutralPuppiMultiplicities_out), "neutralPuppiMultiplicity");
112 
113  std::unique_ptr<edm::ValueMap<float> > neutralHadronPuppiMultiplicities_out(new edm::ValueMap<float>());
114  edm::ValueMap<float>::Filler neutralHadronPuppiMultiplicities_filler(*neutralHadronPuppiMultiplicities_out);
115  neutralHadronPuppiMultiplicities_filler.insert(
116  jets, neutralHadronPuppiMultiplicities.begin(), neutralHadronPuppiMultiplicities.end());
117  neutralHadronPuppiMultiplicities_filler.fill();
118  evt.put(std::move(neutralHadronPuppiMultiplicities_out), "neutralHadronPuppiMultiplicity");
119 
120  std::unique_ptr<edm::ValueMap<float> > photonPuppiMultiplicities_out(new edm::ValueMap<float>());
121  edm::ValueMap<float>::Filler photonPuppiMultiplicities_filler(*photonPuppiMultiplicities_out);
122  photonPuppiMultiplicities_filler.insert(jets, photonPuppiMultiplicities.begin(), photonPuppiMultiplicities.end());
123  photonPuppiMultiplicities_filler.fill();
124  evt.put(std::move(photonPuppiMultiplicities_out), "photonPuppiMultiplicity");
125 
126  std::unique_ptr<edm::ValueMap<float> > HFHadronPuppiMultiplicities_out(new edm::ValueMap<float>());
127  edm::ValueMap<float>::Filler HFHadronPuppiMultiplicities_filler(*HFHadronPuppiMultiplicities_out);
128  HFHadronPuppiMultiplicities_filler.insert(
129  jets, HFHadronPuppiMultiplicities.begin(), HFHadronPuppiMultiplicities.end());
130  HFHadronPuppiMultiplicities_filler.fill();
131  evt.put(std::move(HFHadronPuppiMultiplicities_out), "HFHadronPuppiMultiplicity");
132 
133  std::unique_ptr<edm::ValueMap<float> > HFEMPuppiMultiplicities_out(new edm::ValueMap<float>());
134  edm::ValueMap<float>::Filler HFEMPuppiMultiplicities_filler(*HFEMPuppiMultiplicities_out);
135  HFEMPuppiMultiplicities_filler.insert(jets, HFEMPuppiMultiplicities.begin(), HFEMPuppiMultiplicities.end());
136  HFEMPuppiMultiplicities_filler.fill();
137  evt.put(std::move(HFEMPuppiMultiplicities_out), "HFEMPuppiMultiplicity");
138 }
139 
142  desc.add<edm::InputTag>("src", edm::InputTag("slimmedJets"));
143  descriptions.add("patPuppiJetSpecificProducer", desc);
144 }
145 
147 
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
edm::helper::Filler::insert
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
MessageLogger.h
PATPuppiJetSpecificProducer
Definition: PATPuppiJetSpecificsProducer.cc:24
pat::PackedCandidate::pdgId
int pdgId() const override
PDG identifier.
Definition: PackedCandidate.h:832
edm::EDGetTokenT
Definition: EDGetToken.h:33
mps_merge.weight
weight
Definition: mps_merge.py:88
edm::helper::Filler::fill
void fill()
Definition: ValueMap.h:65
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
edm::Handle
Definition: AssociativeIterator.h:50
PATPuppiJetSpecificProducer::PATPuppiJetSpecificProducer
PATPuppiJetSpecificProducer(const edm::ParameterSet &cfg)
Definition: PATPuppiJetSpecificsProducer.cc:37
MakerMacros.h
PATPuppiJetSpecificProducer::~PATPuppiJetSpecificProducer
~PATPuppiJetSpecificProducer() override
Definition: PATPuppiJetSpecificsProducer.cc:27
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
ParameterSetDescription.h
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
PATPuppiJetSpecificProducer::jets_token
edm::EDGetTokenT< edm::View< pat::Jet > > jets_token
Definition: PATPuppiJetSpecificsProducer.cc:34
PATPuppiJetSpecificProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: PATPuppiJetSpecificsProducer.cc:49
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
pat::PackedCandidate::puppiWeight
float puppiWeight() const
Definition: PackedCandidate.cc:380
Event.h
pat::PackedCandidate
Definition: PackedCandidate.h:22
PackedCandidate.h
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
Jet.h
looper.cfg
cfg
Definition: looper.py:297
ValueMap.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
PATPuppiJetSpecificProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PATPuppiJetSpecificsProducer.cc:140
edm::ValueMap< float >
EventSetup.h
Exception.h
edm::helper::Filler
Definition: ValueMap.h:22
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
EDProducer.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
weight
Definition: weight.py:1
PATPuppiJetSpecificProducer::srcjets_
edm::InputTag srcjets_
Definition: PATPuppiJetSpecificsProducer.cc:33