17 const std::array<std::string,7> electron_vars = { {
"sumChargedHadronPt",
20 "sumChargedParticlePt",
21 "sumNeutralHadronEtHighThreshold",
22 "sumPhotonEtHighThreshold",
25 const std::array<std::string,9> photon_vars = { {
"chargedHadronIso",
26 "chargedHadronIsoWrongVtx",
30 "sumChargedParticlePt",
31 "sumNeutralHadronEtHighThreshold",
32 "sumPhotonEtHighThreshold",
36 #include <unordered_map> 40 typedef std::tuple<edm::InputTag,edm::EDGetTokenT<edm::ValueMap<float> > >
tag_and_token;
41 typedef std::unordered_map<std::string,tag_and_token>
input_map;
76 "EGPfIsolationModifierFromValueMaps");
78 EGPfIsolationModifierFromValueMaps::
81 if( conf.exists(
"electron_config") ) {
85 if( electrons.
exists(varname) ) {
90 if( conf.exists(
"photon_config") ) {
94 if( photons.
exists(varname) ) {
100 ele_idx = pho_idx = 0;
104 inline void get_product(
const edm::Event& evt,
107 if( !tok.isUninitialized() ) evt.
getByToken(tok,
map[tok.index()]);
124 for(
unsigned i = 0;
i < eles->size(); ++
i ) {
130 for(
const std::string& varname : electron_vars ) {
140 for(
unsigned i = 0;
i < phos->size(); ++
i ) {
158 template<
typename T,
typename U,
typename V>
159 inline void make_consumes(
T&
tag,
U& tok,V& sume) {
if( !(empty_tag == tag) ) tok = sume.template consumes<edm::ValueMap<float> >(
tag); }
167 for(
const std::string& varname : electron_vars ) {
170 auto& the_tuple =
inputs[varname];
171 make_consumes(std::get<0>(the_tuple),std::get<1>(the_tuple),sumes);
180 auto& the_tuple =
inputs[varname];
181 make_consumes(std::get<0>(the_tuple),std::get<1>(the_tuple),sumes);
186 template<
typename T,
typename U,
typename V>
188 auto itr = input_map.find(name);
189 if( itr == input_map.end() )
return;
190 const auto& tok = std::get<1>(itr->second);
191 if( !tok.isUninitialized() ) value = map.find(tok.index())->
second->get(ptr.id(),ptr.key());
207 <<
"Original object pointer with key = " << ele.
originalObjectRef().
key() <<
" not found in cache!";
215 assignValue(ptr,e_inputs,electron_vars[0],
ele_vmaps,pfIso.sumChargedHadronPt);
216 assignValue(ptr,e_inputs,electron_vars[1],
ele_vmaps,pfIso.sumNeutralHadronEt);
217 assignValue(ptr,e_inputs,electron_vars[2],
ele_vmaps,pfIso.sumPhotonEt);
218 assignValue(ptr,e_inputs,electron_vars[3],
ele_vmaps,pfIso.sumChargedParticlePt);
219 assignValue(ptr,e_inputs,electron_vars[4],
ele_vmaps,pfIso.sumNeutralHadronEtHighThreshold);
220 assignValue(ptr,e_inputs,electron_vars[5],
ele_vmaps,pfIso.sumPhotonEtHighThreshold);
221 assignValue(ptr,e_inputs,electron_vars[6],
ele_vmaps,pfIso.sumPUPt);
240 <<
"Original object pointer with key = " << pho.
originalObjectRef().
key() <<
" not found in cache!";
249 assignValue(ptr,ph_inputs,photon_vars[0],
pho_vmaps,pfIso.chargedHadronIso);
250 assignValue(ptr,ph_inputs,photon_vars[1],
pho_vmaps,pfIso.chargedHadronIsoWrongVtx);
251 assignValue(ptr,ph_inputs,photon_vars[2],
pho_vmaps,pfIso.neutralHadronIso);
252 assignValue(ptr,ph_inputs,photon_vars[3],
pho_vmaps,pfIso.photonIso);
253 assignValue(ptr,ph_inputs,photon_vars[4],
pho_vmaps,pfIso.modFrixione);
254 assignValue(ptr,ph_inputs,photon_vars[5],
pho_vmaps,pfIso.sumChargedParticlePt);
255 assignValue(ptr,ph_inputs,photon_vars[6],
pho_vmaps,pfIso.sumNeutralHadronEtHighThreshold);
256 assignValue(ptr,ph_inputs,photon_vars[7],
pho_vmaps,pfIso.sumPhotonEtHighThreshold);
257 assignValue(ptr,ph_inputs,photon_vars[8],
pho_vmaps,pfIso.sumPUPt);
const PflowIsolationVariables & pfIsolationVariables() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void setPflowIsolationVariables(const PflowIsolationVariables &pfisol)
Set Particle Flow Isolation variables.
T getParameter(std::string const &) const
void modifyObject(pat::Electron &) const final
Analysis-level Photon class.
std::unordered_map< unsigned, edm::Ptr< reco::GsfElectron > > eles_by_oop
void setEvent(const edm::Event &) final
std::unordered_map< unsigned, edm::Ptr< reco::Photon > > phos_by_oop
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > pho_vmaps
std::tuple< edm::InputTag, edm::EDGetTokenT< edm::ValueMap< float > > > tag_and_token
bool getByToken(EDGetToken token, Handle< PROD > &result) const
input_map electron_inputs
bool exists(std::string const ¶meterName) const
checks if a parameter exists
edm::InputTag electron_src
void setPfIsolationVariables(const PflowIsolationVariables &iso)
U second(std::pair< T, U > const &p)
const std::string & name() const
edm::EDGetTokenT< edm::View< pat::Photon > > tok_photon_src
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
std::unordered_map< std::string, tag_and_token > input_map
void setEventContent(const edm::EventSetup &) final
Analysis-level electron class.
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > ele_vmaps
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
void setConsumes(edm::ConsumesCollector &) final
bool isUninitialized() const
#define DEFINE_EDM_PLUGIN(factory, type, name)
EGPfIsolationModifierFromValueMaps(const edm::ParameterSet &conf)
const PflowIsolationVariables & getPflowIsolationVariables() const
Get Particle Flow Isolation variables block.