CMS 3D CMS Logo

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

Public Member Functions

 JetPFConstituentVarProducer (const edm::ParameterSet &)
 
 ~JetPFConstituentVarProducer () 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

void produce (edm::Event &, const edm::EventSetup &) override
 
void PutValueMapInEvent (edm::Event &, const edm::Handle< edm::View< T >> &, const std::vector< float > &, std::string)
 

Private Attributes

const bool fallback_puppi_weight_
 
edm::EDGetTokenT< edm::View< T > > jet_token_
 
edm::EDGetTokenT< edm::ValueMap< float > > puppi_value_map_token_
 
bool use_puppi_value_map_
 

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

template<typename T>
class JetPFConstituentVarProducer< T >

Definition at line 20 of file JetPFConstituentVarProducer.cc.

Constructor & Destructor Documentation

◆ JetPFConstituentVarProducer()

template<typename T >
JetPFConstituentVarProducer< T >::JetPFConstituentVarProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 41 of file JetPFConstituentVarProducer.cc.

References edm::ParameterSet::getParameter(), JetPFConstituentVarProducer< T >::puppi_value_map_token_, and JetPFConstituentVarProducer< T >::use_puppi_value_map_.

42  : jet_token_(consumes<edm::View<T>>(iConfig.getParameter<edm::InputTag>("jets"))),
43  fallback_puppi_weight_(iConfig.getParameter<bool>("fallback_puppi_weight")),
44  use_puppi_value_map_(false) {
45  //
46  // Puppi Value Map
47  //
48  const auto& puppi_value_map_tag = iConfig.getParameter<edm::InputTag>("puppi_value_map");
49  if (!puppi_value_map_tag.label().empty()) {
50  puppi_value_map_token_ = consumes<edm::ValueMap<float>>(puppi_value_map_tag);
51  use_puppi_value_map_ = true;
52  }
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");
67 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< edm::View< T > > jet_token_
edm::EDGetTokenT< edm::ValueMap< float > > puppi_value_map_token_

◆ ~JetPFConstituentVarProducer()

template<typename T >
JetPFConstituentVarProducer< T >::~JetPFConstituentVarProducer ( )
override

Definition at line 70 of file JetPFConstituentVarProducer.cc.

70 {}

Member Function Documentation

◆ fillDescriptions()

template<typename T >
void JetPFConstituentVarProducer< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 255 of file JetPFConstituentVarProducer.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

255  {
257  desc.add<edm::InputTag>("jets", edm::InputTag("finalJetsPuppi"));
258  desc.add<edm::InputTag>("puppi_value_map", edm::InputTag("packedpuppi"));
259  desc.add<bool>("fallback_puppi_weight", false);
260  descriptions.addWithDefaultLabel(desc);
261 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

template<typename T >
void JetPFConstituentVarProducer< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 73 of file JetPFConstituentVarProducer.cc.

References funct::abs(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), Exception, iEvent, edm::errors::InvalidReference, edm::Ptr< T >::isNonnull(), edm::Ptr< T >::isNull(), metsig::jet, PDWG_EXODelayedJetMET_cff::jets, and relativeConstraints::value.

73  {
74  // Input jets
75  auto jets = iEvent.getHandle(jet_token_);
76 
77  // Get puppi value map
78  edm::Handle<edm::ValueMap<float>> puppi_value_map_;
80  iEvent.getByToken(puppi_value_map_token_, puppi_value_map_);
81  }
82 
83  std::vector<float> jet_leadConstNeHadEF(jets->size(), 0.f);
84  std::vector<float> jet_leadConstNeHadPuppiWeight(jets->size(), 0.f);
85 
86  std::vector<float> jet_leadConstChHadEF(jets->size(), 0.f);
87  std::vector<float> jet_leadConstChHadPuppiWeight(jets->size(), 0.f);
88 
89  std::vector<float> jet_leadConstPhotonEF(jets->size(), 0.f);
90  std::vector<float> jet_leadConstPhotonPuppiWeight(jets->size(), 0.f);
91 
92  std::vector<float> jet_leadConstElectronEF(jets->size(), 0.f);
93  std::vector<float> jet_leadConstElectronPuppiWeight(jets->size(), 0.f);
94 
95  std::vector<float> jet_leadConstMuonEF(jets->size(), 0.f);
96  std::vector<float> jet_leadConstMuonPuppiWeight(jets->size(), 0.f);
97 
98  std::vector<float> jet_leadConstHFHADEF(jets->size(), 0.f);
99  std::vector<float> jet_leadConstHFHADPuppiWeight(jets->size(), 0.f);
100 
101  std::vector<float> jet_leadConstHFEMEF(jets->size(), 0.f);
102  std::vector<float> jet_leadConstHFEMPuppiWeight(jets->size(), 0.f);
103 
104  // Loop over jet
105  for (std::size_t jet_idx = 0; jet_idx < jets->size(); jet_idx++) {
106  const auto& jet = (*jets)[jet_idx];
107 
108  float jet_energy_raw = jet.energy();
110  jet_energy_raw = jet.correctedJet(0).energy();
111  }
112 
113  reco::CandidatePtr leadConstNeHad;
114  reco::CandidatePtr leadConstChHad;
115  reco::CandidatePtr leadConstPhoton;
116  reco::CandidatePtr leadConstElectron;
117  reco::CandidatePtr leadConstMuon;
118  reco::CandidatePtr leadConstHFHAD;
119  reco::CandidatePtr leadConstHFEM;
120 
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;
128 
129  //
130  // Loop over jet constituents
131  //
132  for (const reco::CandidatePtr& dau : jet.daughterPtrVector()) {
133  float puppiw = 1.f;
134 
135  //
136  // Get Puppi weight from ValueMap, if provided.
137  //
138  if (use_puppi_value_map_) {
139  puppiw = (*puppi_value_map_)[dau];
140  } else if (!fallback_puppi_weight_) {
141  throw edm::Exception(edm::errors::InvalidReference, "PUPPI value map missing")
142  << "use fallback_puppi_weight option to use " << puppiw << " for cand as default";
143  }
144 
145  //
146  // Find the highest energy constituents for each PF type
147  //
148  if (abs(dau->pdgId()) == 130) {
149  if (leadConstNeHad.isNull() ||
150  (puppiw * dau->energy() > leadConstNeHadPuppiWeight * leadConstNeHad->energy())) {
151  leadConstNeHad = dau;
152  leadConstNeHadPuppiWeight = puppiw;
153  }
154  } else if (abs(dau->pdgId()) == 211) {
155  if (leadConstChHad.isNull() ||
156  (puppiw * dau->energy() > leadConstChHadPuppiWeight * leadConstChHad->energy())) {
157  leadConstChHad = dau;
158  leadConstChHadPuppiWeight = puppiw;
159  }
160  } else if (abs(dau->pdgId()) == 22) {
161  if (leadConstPhoton.isNull() ||
162  (puppiw * dau->energy() > leadConstPhotonPuppiWeight * leadConstPhoton->energy())) {
163  leadConstPhoton = dau;
164  leadConstPhotonPuppiWeight = puppiw;
165  }
166  } else if (abs(dau->pdgId()) == 11) {
167  if (leadConstElectron.isNull() ||
168  (puppiw * dau->energy() > leadConstElectronPuppiWeight * leadConstElectron->energy())) {
169  leadConstElectron = dau;
170  leadConstElectronPuppiWeight = puppiw;
171  }
172  } else if (abs(dau->pdgId()) == 13) {
173  if (leadConstMuon.isNull() || (puppiw * dau->energy() > leadConstMuonPuppiWeight * leadConstMuon->energy())) {
174  leadConstMuon = dau;
175  leadConstMuonPuppiWeight = puppiw;
176  }
177  } else if (abs(dau->pdgId()) == 1) {
178  if (leadConstHFHAD.isNull() ||
179  (puppiw * dau->energy() > leadConstHFHADPuppiWeight * leadConstHFHAD->energy())) {
180  leadConstHFHAD = dau;
181  leadConstHFHADPuppiWeight = puppiw;
182  }
183  } else if (abs(dau->pdgId()) == 2) {
184  if (leadConstHFEM.isNull() || (puppiw * dau->energy() > leadConstHFEMPuppiWeight * leadConstHFEM->energy())) {
185  leadConstHFEM = dau;
186  leadConstHFEMPuppiWeight = puppiw;
187  }
188  }
189  } // End of Jet Constituents Loop
190 
191  if (leadConstNeHad.isNonnull()) {
192  jet_leadConstNeHadEF[jet_idx] = (leadConstNeHad->energy() * leadConstNeHadPuppiWeight) / jet_energy_raw;
193  jet_leadConstNeHadPuppiWeight[jet_idx] = leadConstNeHadPuppiWeight;
194  }
195  if (leadConstChHad.isNonnull()) {
196  jet_leadConstChHadEF[jet_idx] = (leadConstChHad->energy() * leadConstChHadPuppiWeight) / jet_energy_raw;
197  jet_leadConstChHadPuppiWeight[jet_idx] = leadConstChHadPuppiWeight;
198  }
199  if (leadConstPhoton.isNonnull()) {
200  jet_leadConstPhotonEF[jet_idx] = (leadConstPhoton->energy() * leadConstPhotonPuppiWeight) / jet_energy_raw;
201  jet_leadConstPhotonPuppiWeight[jet_idx] = leadConstPhotonPuppiWeight;
202  }
203  if (leadConstElectron.isNonnull()) {
204  jet_leadConstElectronEF[jet_idx] = (leadConstElectron->energy() * leadConstElectronPuppiWeight) / jet_energy_raw;
205  jet_leadConstElectronPuppiWeight[jet_idx] = leadConstElectronPuppiWeight;
206  }
207  if (leadConstMuon.isNonnull()) {
208  jet_leadConstMuonEF[jet_idx] = (leadConstMuon->energy() * leadConstMuonPuppiWeight) / jet_energy_raw;
209  jet_leadConstMuonPuppiWeight[jet_idx] = leadConstMuonPuppiWeight;
210  }
211  if (leadConstHFHAD.isNonnull()) {
212  jet_leadConstHFHADEF[jet_idx] = (leadConstHFHAD->energy() * leadConstHFHADPuppiWeight) / jet_energy_raw;
213  jet_leadConstHFHADPuppiWeight[jet_idx] = leadConstHFHADPuppiWeight;
214  }
215  if (leadConstHFEM.isNonnull()) {
216  jet_leadConstHFEMEF[jet_idx] = (leadConstHFEM->energy() * leadConstHFEMPuppiWeight) / jet_energy_raw;
217  jet_leadConstHFEMPuppiWeight[jet_idx] = leadConstHFEMPuppiWeight;
218  }
219  }
220 
221  PutValueMapInEvent(iEvent, jets, jet_leadConstNeHadEF, "leadConstNeHadEF");
222  PutValueMapInEvent(iEvent, jets, jet_leadConstNeHadPuppiWeight, "leadConstNeHadPuppiWeight");
223 
224  PutValueMapInEvent(iEvent, jets, jet_leadConstChHadEF, "leadConstChHadEF");
225  PutValueMapInEvent(iEvent, jets, jet_leadConstChHadPuppiWeight, "leadConstChHadPuppiWeight");
226 
227  PutValueMapInEvent(iEvent, jets, jet_leadConstPhotonEF, "leadConstPhotonEF");
228  PutValueMapInEvent(iEvent, jets, jet_leadConstPhotonPuppiWeight, "leadConstPhotonPuppiWeight");
229 
230  PutValueMapInEvent(iEvent, jets, jet_leadConstElectronEF, "leadConstElectronEF");
231  PutValueMapInEvent(iEvent, jets, jet_leadConstElectronPuppiWeight, "leadConstElectronPuppiWeight");
232 
233  PutValueMapInEvent(iEvent, jets, jet_leadConstMuonEF, "leadConstMuonEF");
234  PutValueMapInEvent(iEvent, jets, jet_leadConstMuonPuppiWeight, "leadConstMuonPuppiWeight");
235 
236  PutValueMapInEvent(iEvent, jets, jet_leadConstHFHADEF, "leadConstHFHADEF");
237  PutValueMapInEvent(iEvent, jets, jet_leadConstHFHADPuppiWeight, "leadConstHFHADPuppiWeight");
238 
239  PutValueMapInEvent(iEvent, jets, jet_leadConstHFEMEF, "leadConstHFEMEF");
240  PutValueMapInEvent(iEvent, jets, jet_leadConstHFEMPuppiWeight, "leadConstHFEMPuppiWeight");
241 }
edm::EDGetTokenT< edm::View< T > > jet_token_
void PutValueMapInEvent(edm::Event &, const edm::Handle< edm::View< T >> &, const std::vector< float > &, std::string)
int iEvent
Definition: GenABIO.cc:224
bool isNull() const
Checks for null.
Definition: Ptr.h:144
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:148
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< edm::ValueMap< float > > puppi_value_map_token_

◆ PutValueMapInEvent()

template<typename T >
void JetPFConstituentVarProducer< T >::PutValueMapInEvent ( edm::Event iEvent,
const edm::Handle< edm::View< T >> &  coll,
const std::vector< float > &  vec_var,
std::string  VMName 
)
private

Definition at line 243 of file JetPFConstituentVarProducer.cc.

References edm::helper::Filler< Map >::fill(), iEvent, edm::helper::Filler< Map >::insert(), and eostools::move().

246  {
247  std::unique_ptr<edm::ValueMap<float>> VM(new edm::ValueMap<float>());
248  edm::ValueMap<float>::Filler fillerVM(*VM);
249  fillerVM.insert(coll, vec_var.begin(), vec_var.end());
250  fillerVM.fill();
251  iEvent.put(std::move(VM), VMName);
252 }
int iEvent
Definition: GenABIO.cc:224
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ fallback_puppi_weight_

template<typename T >
const bool JetPFConstituentVarProducer< T >::fallback_puppi_weight_
private

Definition at line 33 of file JetPFConstituentVarProducer.cc.

◆ jet_token_

template<typename T >
edm::EDGetTokenT<edm::View<T> > JetPFConstituentVarProducer< T >::jet_token_
private

Definition at line 30 of file JetPFConstituentVarProducer.cc.

◆ puppi_value_map_token_

template<typename T >
edm::EDGetTokenT<edm::ValueMap<float> > JetPFConstituentVarProducer< T >::puppi_value_map_token_
private

◆ use_puppi_value_map_

template<typename T >
bool JetPFConstituentVarProducer< T >::use_puppi_value_map_
private