43 fallback_puppi_weight_(iConfig.getParameter<
bool>(
"fallback_puppi_weight")),
44 use_puppi_value_map_(
false) {
49 if (!puppi_value_map_tag.label().empty()) {
53 produces<edm::ValueMap<float>>(
"leadConstNeHadEF");
54 produces<edm::ValueMap<float>>(
"leadConstChHadEF");
55 produces<edm::ValueMap<float>>(
"leadConstPhotonEF");
56 produces<edm::ValueMap<float>>(
"leadConstElectronEF");
57 produces<edm::ValueMap<float>>(
"leadConstMuonEF");
58 produces<edm::ValueMap<float>>(
"leadConstHFHADEF");
59 produces<edm::ValueMap<float>>(
"leadConstHFEMEF");
60 produces<edm::ValueMap<float>>(
"leadConstNeHadPuppiWeight");
61 produces<edm::ValueMap<float>>(
"leadConstChHadPuppiWeight");
62 produces<edm::ValueMap<float>>(
"leadConstPhotonPuppiWeight");
63 produces<edm::ValueMap<float>>(
"leadConstElectronPuppiWeight");
64 produces<edm::ValueMap<float>>(
"leadConstMuonPuppiWeight");
65 produces<edm::ValueMap<float>>(
"leadConstHFHADPuppiWeight");
66 produces<edm::ValueMap<float>>(
"leadConstHFEMPuppiWeight");
79 if (use_puppi_value_map_) {
80 iEvent.getByToken(puppi_value_map_token_, puppi_value_map_);
83 std::vector<float> jet_leadConstNeHadEF(
jets->size(), 0.f);
84 std::vector<float> jet_leadConstNeHadPuppiWeight(
jets->size(), 0.f);
86 std::vector<float> jet_leadConstChHadEF(
jets->size(), 0.f);
87 std::vector<float> jet_leadConstChHadPuppiWeight(
jets->size(), 0.f);
89 std::vector<float> jet_leadConstPhotonEF(
jets->size(), 0.f);
90 std::vector<float> jet_leadConstPhotonPuppiWeight(
jets->size(), 0.f);
92 std::vector<float> jet_leadConstElectronEF(
jets->size(), 0.f);
93 std::vector<float> jet_leadConstElectronPuppiWeight(
jets->size(), 0.f);
95 std::vector<float> jet_leadConstMuonEF(
jets->size(), 0.f);
96 std::vector<float> jet_leadConstMuonPuppiWeight(
jets->size(), 0.f);
98 std::vector<float> jet_leadConstHFHADEF(
jets->size(), 0.f);
99 std::vector<float> jet_leadConstHFHADPuppiWeight(
jets->size(), 0.f);
101 std::vector<float> jet_leadConstHFEMEF(
jets->size(), 0.f);
102 std::vector<float> jet_leadConstHFEMPuppiWeight(
jets->size(), 0.f);
105 for (std::size_t jet_idx = 0; jet_idx <
jets->size(); jet_idx++) {
106 const auto&
jet = (*jets)[jet_idx];
108 float jet_energy_raw =
jet.energy();
110 jet_energy_raw =
jet.correctedJet(0).energy();
121 float leadConstNeHadPuppiWeight = 1.f;
122 float leadConstChHadPuppiWeight = 1.f;
123 float leadConstPhotonPuppiWeight = 1.f;
124 float leadConstElectronPuppiWeight = 1.f;
125 float leadConstMuonPuppiWeight = 1.f;
126 float leadConstHFHADPuppiWeight = 1.f;
127 float leadConstHFEMPuppiWeight = 1.f;
138 if (use_puppi_value_map_) {
139 puppiw = (*puppi_value_map_)[dau];
140 }
else if (!fallback_puppi_weight_) {
142 <<
"use fallback_puppi_weight option to use " << puppiw <<
" for cand as default";
148 if (
abs(dau->pdgId()) == 130) {
149 if (leadConstNeHad.
isNull() ||
150 (puppiw * dau->energy() > leadConstNeHadPuppiWeight * leadConstNeHad->energy())) {
151 leadConstNeHad = dau;
152 leadConstNeHadPuppiWeight = puppiw;
154 }
else if (
abs(dau->pdgId()) == 211) {
155 if (leadConstChHad.
isNull() ||
156 (puppiw * dau->energy() > leadConstChHadPuppiWeight * leadConstChHad->energy())) {
157 leadConstChHad = dau;
158 leadConstChHadPuppiWeight = puppiw;
160 }
else if (
abs(dau->pdgId()) == 22) {
161 if (leadConstPhoton.
isNull() ||
162 (puppiw * dau->energy() > leadConstPhotonPuppiWeight * leadConstPhoton->energy())) {
163 leadConstPhoton = dau;
164 leadConstPhotonPuppiWeight = puppiw;
166 }
else if (
abs(dau->pdgId()) == 11) {
167 if (leadConstElectron.
isNull() ||
168 (puppiw * dau->energy() > leadConstElectronPuppiWeight * leadConstElectron->energy())) {
169 leadConstElectron = dau;
170 leadConstElectronPuppiWeight = puppiw;
172 }
else if (
abs(dau->pdgId()) == 13) {
173 if (leadConstMuon.
isNull() || (puppiw * dau->energy() > leadConstMuonPuppiWeight * leadConstMuon->energy())) {
175 leadConstMuonPuppiWeight = puppiw;
177 }
else if (
abs(dau->pdgId()) == 1) {
178 if (leadConstHFHAD.
isNull() ||
179 (puppiw * dau->energy() > leadConstHFHADPuppiWeight * leadConstHFHAD->energy())) {
180 leadConstHFHAD = dau;
181 leadConstHFHADPuppiWeight = puppiw;
183 }
else if (
abs(dau->pdgId()) == 2) {
184 if (leadConstHFEM.
isNull() || (puppiw * dau->energy() > leadConstHFEMPuppiWeight * leadConstHFEM->energy())) {
186 leadConstHFEMPuppiWeight = puppiw;
192 jet_leadConstNeHadEF[jet_idx] = (leadConstNeHad->energy() * leadConstNeHadPuppiWeight) / jet_energy_raw;
193 jet_leadConstNeHadPuppiWeight[jet_idx] = leadConstNeHadPuppiWeight;
196 jet_leadConstChHadEF[jet_idx] = (leadConstChHad->energy() * leadConstChHadPuppiWeight) / jet_energy_raw;
197 jet_leadConstChHadPuppiWeight[jet_idx] = leadConstChHadPuppiWeight;
200 jet_leadConstPhotonEF[jet_idx] = (leadConstPhoton->energy() * leadConstPhotonPuppiWeight) / jet_energy_raw;
201 jet_leadConstPhotonPuppiWeight[jet_idx] = leadConstPhotonPuppiWeight;
204 jet_leadConstElectronEF[jet_idx] = (leadConstElectron->energy() * leadConstElectronPuppiWeight) / jet_energy_raw;
205 jet_leadConstElectronPuppiWeight[jet_idx] = leadConstElectronPuppiWeight;
208 jet_leadConstMuonEF[jet_idx] = (leadConstMuon->energy() * leadConstMuonPuppiWeight) / jet_energy_raw;
209 jet_leadConstMuonPuppiWeight[jet_idx] = leadConstMuonPuppiWeight;
212 jet_leadConstHFHADEF[jet_idx] = (leadConstHFHAD->energy() * leadConstHFHADPuppiWeight) / jet_energy_raw;
213 jet_leadConstHFHADPuppiWeight[jet_idx] = leadConstHFHADPuppiWeight;
216 jet_leadConstHFEMEF[jet_idx] = (leadConstHFEM->energy() * leadConstHFEMPuppiWeight) / jet_energy_raw;
217 jet_leadConstHFEMPuppiWeight[jet_idx] = leadConstHFEMPuppiWeight;
221 PutValueMapInEvent(
iEvent,
jets, jet_leadConstNeHadEF,
"leadConstNeHadEF");
222 PutValueMapInEvent(
iEvent,
jets, jet_leadConstNeHadPuppiWeight,
"leadConstNeHadPuppiWeight");
224 PutValueMapInEvent(
iEvent,
jets, jet_leadConstChHadEF,
"leadConstChHadEF");
225 PutValueMapInEvent(
iEvent,
jets, jet_leadConstChHadPuppiWeight,
"leadConstChHadPuppiWeight");
227 PutValueMapInEvent(
iEvent,
jets, jet_leadConstPhotonEF,
"leadConstPhotonEF");
228 PutValueMapInEvent(
iEvent,
jets, jet_leadConstPhotonPuppiWeight,
"leadConstPhotonPuppiWeight");
230 PutValueMapInEvent(
iEvent,
jets, jet_leadConstElectronEF,
"leadConstElectronEF");
231 PutValueMapInEvent(
iEvent,
jets, jet_leadConstElectronPuppiWeight,
"leadConstElectronPuppiWeight");
233 PutValueMapInEvent(
iEvent,
jets, jet_leadConstMuonEF,
"leadConstMuonEF");
234 PutValueMapInEvent(
iEvent,
jets, jet_leadConstMuonPuppiWeight,
"leadConstMuonPuppiWeight");
236 PutValueMapInEvent(
iEvent,
jets, jet_leadConstHFHADEF,
"leadConstHFHADEF");
237 PutValueMapInEvent(
iEvent,
jets, jet_leadConstHFHADPuppiWeight,
"leadConstHFHADPuppiWeight");
239 PutValueMapInEvent(
iEvent,
jets, jet_leadConstHFEMEF,
"leadConstHFEMEF");
240 PutValueMapInEvent(
iEvent,
jets, jet_leadConstHFEMPuppiWeight,
"leadConstHFEMPuppiWeight");
242 template <
typename T>
245 const std::vector<float>& vec_var,
249 fillerVM.
insert(coll, vec_var.begin(), vec_var.end());
254 template <
typename T>
259 desc.add<
bool>(
"fallback_puppi_weight",
false);
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< T > > jet_token_
void PutValueMapInEvent(edm::Event &, const edm::Handle< edm::View< T >> &, const std::vector< float > &, std::string)
const bool fallback_puppi_weight_
void insert(const H &h, I begin, I end)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
JetPFConstituentVarProducer< pat::Jet > PatJetPFConstituentVarProducer
bool isNull() const
Checks for null.
JetPFConstituentVarProducer(const edm::ParameterSet &)
bool isNonnull() const
Checks for non-null.
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< edm::ValueMap< float > > puppi_value_map_token_
bool use_puppi_value_map_
void produce(edm::Event &, const edm::EventSetup &) override
~JetPFConstituentVarProducer() override