CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
EGPfIsolationModifierFromValueMaps Class Reference
Inheritance diagram for EGPfIsolationModifierFromValueMaps:
ModifyObjectValueBase

Classes

struct  electron_config
 
struct  photon_config
 

Public Types

typedef std::unordered_map< std::string, tag_and_tokeninput_map
 
typedef std::tuple< edm::InputTag, edm::EDGetTokenT< edm::ValueMap< float > > > tag_and_token
 

Public Member Functions

 EGPfIsolationModifierFromValueMaps (const edm::ParameterSet &conf)
 
void modifyObject (pat::Electron &) const override final
 
void modifyObject (pat::Photon &) const override final
 
void setConsumes (edm::ConsumesCollector &) override final
 
void setEvent (const edm::Event &) override final
 
void setEventContent (const edm::EventSetup &) override final
 
- Public Member Functions inherited from ModifyObjectValueBase
virtual void modifyObject (reco::GsfElectron &) const
 
virtual void modifyObject (reco::Photon &) const
 
virtual void modifyObject (reco::Muon &) const
 
virtual void modifyObject (reco::BaseTau &) const
 
virtual void modifyObject (reco::Jet &) const
 
virtual void modifyObject (pat::Muon &) const
 
virtual void modifyObject (pat::Tau &) const
 
virtual void modifyObject (pat::Jet &) const
 
 ModifyObjectValueBase (const edm::ParameterSet &conf)
 
const std::string & name () const
 
virtual ~ModifyObjectValueBase ()
 

Private Attributes

electron_config e_conf
 
unsigned ele_idx
 
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > ele_vmaps
 
std::unordered_map< unsigned, edm::Ptr< reco::GsfElectron > > eles_by_oop
 
photon_config ph_conf
 
unsigned pho_idx
 
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > pho_vmaps
 
std::unordered_map< unsigned, edm::Ptr< reco::Photon > > phos_by_oop
 

Detailed Description

Definition at line 38 of file EGPfIsolationModifier.cc.

Member Typedef Documentation

typedef std::unordered_map<std::string,tag_and_token> EGPfIsolationModifierFromValueMaps::input_map

Definition at line 41 of file EGPfIsolationModifier.cc.

Definition at line 40 of file EGPfIsolationModifier.cc.

Constructor & Destructor Documentation

EGPfIsolationModifierFromValueMaps::EGPfIsolationModifierFromValueMaps ( const edm::ParameterSet conf)

Definition at line 79 of file EGPfIsolationModifier.cc.

References EGPfIsolationModifierFromValueMaps::electron_config::electron_inputs, EGPfIsolationModifierFromValueMaps::electron_config::electron_src, genericTrackCleaner_cfi::electrons, edm::ParameterSet::exists(), edm::Event::getByToken(), edm::ParameterSet::getParameter(), genParticles_cff::map, EGPfIsolationModifierFromValueMaps::photon_config::photon_inputs, EGPfIsolationModifierFromValueMaps::photon_config::photon_src, jetCleaner_cfi::photons, setEvent(), and AlCaHLTBitMon_QueryRunRegistry::string.

79  :
80  ModifyObjectValueBase(conf) {
81  if( conf.exists("electron_config") ) {
82  const edm::ParameterSet& electrons = conf.getParameter<edm::ParameterSet>("electron_config");
83  if( electrons.exists("electronSrc") ) e_conf.electron_src = electrons.getParameter<edm::InputTag>("electronSrc");
84  for( const std::string& varname : electron_vars ) {
85  if( electrons.exists(varname) ) {
86  std::get<0>(e_conf.electron_inputs[varname]) = electrons.getParameter<edm::InputTag>(varname);
87  }
88  }
89  }
90  if( conf.exists("photon_config") ) {
91  const edm::ParameterSet& photons = conf.getParameter<edm::ParameterSet>("photon_config");
92  if( photons.exists("photonSrc") ) ph_conf.photon_src = photons.getParameter<edm::InputTag>("photonSrc");
93  for( const std::string& varname : photon_vars ) {
94  if( photons.exists(varname) ) {
95  std::get<0>(ph_conf.photon_inputs[varname]) = photons.getParameter<edm::InputTag>(varname);
96  }
97  }
98  }
99 
100  ele_idx = pho_idx = 0;
101 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
ModifyObjectValueBase(const edm::ParameterSet &conf)

Member Function Documentation

void EGPfIsolationModifierFromValueMaps::modifyObject ( pat::Electron ele) const
finaloverridevirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 196 of file EGPfIsolationModifier.cc.

References e_conf, ele_idx, ele_vmaps, EGPfIsolationModifierFromValueMaps::electron_config::electron_inputs, eles_by_oop, Exception, edm::EDGetTokenT< T >::isUninitialized(), crabWrapper::key, edm::Ptr< T >::key(), pat::PATObject< ObjectType >::originalObjectRef(), reco::GsfElectron::pfIsolationVariables(), reco::GsfElectron::setPfIsolationVariables(), and EGPfIsolationModifierFromValueMaps::electron_config::tok_electron_src.

Referenced by setConsumes().

196  {
197  // we encounter two cases here, either we are running AOD -> MINIAOD
198  // and the value maps are to the reducedEG object, can use original object ptr
199  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
202  auto key = eles_by_oop.find(ele_idx);
203  if( key != eles_by_oop.end() ) {
204  ptr = key->second;
205  } else {
206  throw cms::Exception("BadElectronKey")
207  << "Original object pointer with key = " << ele.originalObjectRef().key() << " not found in cache!";
208  }
209  }
210  //now we go through and modify the objects using the valuemaps we read in
211  auto pfIso = ele.pfIsolationVariables();
212 
213  const auto& e_inputs = e_conf.electron_inputs;
214 
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);
222 
223  ele.setPfIsolationVariables(pfIso);
224  ++ele_idx;
225 }
const PflowIsolationVariables & pfIsolationVariables() const
Definition: GsfElectron.h:670
std::unordered_map< unsigned, edm::Ptr< reco::GsfElectron > > eles_by_oop
key_type key() const
Definition: Ptr.h:186
void setPfIsolationVariables(const PflowIsolationVariables &iso)
Definition: GsfElectron.h:675
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:500
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > ele_vmaps
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
bool isUninitialized() const
Definition: EDGetToken.h:73
void EGPfIsolationModifierFromValueMaps::modifyObject ( pat::Photon pho) const
finaloverridevirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 229 of file EGPfIsolationModifier.cc.

References Exception, reco::Photon::getPflowIsolationVariables(), edm::EDGetTokenT< T >::isUninitialized(), crabWrapper::key, edm::Ptr< T >::key(), pat::PATObject< ObjectType >::originalObjectRef(), ph_conf, pho_idx, pho_vmaps, phos_by_oop, EGPfIsolationModifierFromValueMaps::photon_config::photon_inputs, reco::Photon::setPflowIsolationVariables(), and EGPfIsolationModifierFromValueMaps::photon_config::tok_photon_src.

229  {
230  // we encounter two cases here, either we are running AOD -> MINIAOD
231  // and the value maps are to the reducedEG object, can use original object ptr
232  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
235  auto key = phos_by_oop.find(pho_idx);
236  if( key != phos_by_oop.end() ) {
237  ptr = key->second;
238  } else {
239  throw cms::Exception("BadPhotonKey")
240  << "Original object pointer with key = " << pho.originalObjectRef().key() << " not found in cache!";
241  }
242  }
243 
244  //now we go through and modify the objects using the valuemaps we read in
245  auto pfIso = pho.getPflowIsolationVariables();
246 
247  const auto& ph_inputs = ph_conf.photon_inputs;
248 
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);
258 
259  pho.setPflowIsolationVariables(pfIso);
260  ++pho_idx;
261 }
void setPflowIsolationVariables(const PflowIsolationVariables &pfisol)
Set Particle Flow Isolation variables.
Definition: Photon.h:497
std::unordered_map< unsigned, edm::Ptr< reco::Photon > > phos_by_oop
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > pho_vmaps
key_type key() const
Definition: Ptr.h:186
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
Definition: PATObject.h:500
bool isUninitialized() const
Definition: EDGetToken.h:73
const PflowIsolationVariables & getPflowIsolationVariables() const
Get Particle Flow Isolation variables block.
Definition: Photon.h:494
void EGPfIsolationModifierFromValueMaps::setConsumes ( edm::ConsumesCollector sumes)
finaloverridevirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 163 of file EGPfIsolationModifier.cc.

References edm::ConsumesCollector::consumes(), e_conf, EGPfIsolationModifierFromValueMaps::electron_config::electron_inputs, EGPfIsolationModifierFromValueMaps::electron_config::electron_src, PatBasicFWLiteJetAnalyzer_Selector_cfg::inputs, genParticles_cff::map, modifyObject(), ModifyObjectValueBase::name(), ph_conf, EGPfIsolationModifierFromValueMaps::photon_config::photon_inputs, EGPfIsolationModifierFromValueMaps::photon_config::photon_src, edm::second(), AlCaHLTBitMon_QueryRunRegistry::string, EGPfIsolationModifierFromValueMaps::electron_config::tok_electron_src, EGPfIsolationModifierFromValueMaps::photon_config::tok_photon_src, and mitigatedMETSequence_cff::U.

Referenced by setEventContent().

163  {
164  //setup electrons
166 
167  for( const std::string& varname : electron_vars ) {
168  auto& inputs = e_conf.electron_inputs;
169  if( inputs.find(varname) == inputs.end() ) continue;
170  auto& the_tuple = inputs[varname];
171  make_consumes(std::get<0>(the_tuple),std::get<1>(the_tuple),sumes);
172  }
173 
174  // setup photons
176 
177  for( const std::string& varname : photon_vars ) {
178  auto& inputs = ph_conf.photon_inputs;
179  if( inputs.find(varname) == inputs.end() ) continue;
180  auto& the_tuple = inputs[varname];
181  make_consumes(std::get<0>(the_tuple),std::get<1>(the_tuple),sumes);
182  }
183 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< pat::Photon > > tok_photon_src
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
void EGPfIsolationModifierFromValueMaps::setEvent ( const edm::Event evt)
finaloverridevirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 112 of file EGPfIsolationModifier.cc.

References e_conf, ele_idx, ele_vmaps, EGPfIsolationModifierFromValueMaps::electron_config::electron_inputs, eles_by_oop, edm::Event::getByToken(), mps_fire::i, PatBasicFWLiteJetAnalyzer_Selector_cfg::inputs, edm::EDGetTokenT< T >::isUninitialized(), ph_conf, pho_idx, pho_vmaps, phos_by_oop, EGPfIsolationModifierFromValueMaps::photon_config::photon_inputs, setEventContent(), AlCaHLTBitMon_QueryRunRegistry::string, EGPfIsolationModifierFromValueMaps::electron_config::tok_electron_src, and EGPfIsolationModifierFromValueMaps::photon_config::tok_photon_src.

Referenced by EGPfIsolationModifierFromValueMaps().

112  {
113  eles_by_oop.clear();
114  phos_by_oop.clear();
115  ele_vmaps.clear();
116  pho_vmaps.clear();
117 
118  ele_idx = pho_idx = 0;
119 
123 
124  for( unsigned i = 0; i < eles->size(); ++i ) {
125  edm::Ptr<pat::Electron> ptr = eles->ptrAt(i);
126  eles_by_oop[i] = ptr;
127  }
128  }
129 
130  for( const std::string& varname : electron_vars ) {
131  auto& inputs = e_conf.electron_inputs;
132  if( inputs.find(varname) == inputs.end() ) continue;
133  get_product(evt,std::get<1>(inputs[varname]),ele_vmaps);
134  }
135 
139 
140  for( unsigned i = 0; i < phos->size(); ++i ) {
141  edm::Ptr<pat::Photon> ptr = phos->ptrAt(i);
142  phos_by_oop[i] = ptr;
143  }
144  }
145 
146  for( const std::string& varname : photon_vars ) {
147  auto& inputs = ph_conf.photon_inputs;
148  if( inputs.find(varname) == inputs.end() ) continue;
149  get_product(evt,std::get<1>(inputs[varname]),pho_vmaps);
150  }
151 }
std::unordered_map< unsigned, edm::Ptr< reco::GsfElectron > > eles_by_oop
std::unordered_map< unsigned, edm::Ptr< reco::Photon > > phos_by_oop
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > pho_vmaps
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
edm::EDGetTokenT< edm::View< pat::Photon > > tok_photon_src
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > ele_vmaps
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
bool isUninitialized() const
Definition: EDGetToken.h:73
void EGPfIsolationModifierFromValueMaps::setEventContent ( const edm::EventSetup evs)
finaloverridevirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 154 of file EGPfIsolationModifier.cc.

References setConsumes(), GlobalPosition_Frontier_DevDB_cff::tag, and mitigatedMETSequence_cff::U.

Referenced by setEvent().

154  {
155 }

Member Data Documentation

electron_config EGPfIsolationModifierFromValueMaps::e_conf
private

Definition at line 65 of file EGPfIsolationModifier.cc.

Referenced by modifyObject(), setConsumes(), and setEvent().

unsigned EGPfIsolationModifierFromValueMaps::ele_idx
mutableprivate

Definition at line 71 of file EGPfIsolationModifier.cc.

Referenced by modifyObject(), and setEvent().

std::unordered_map<unsigned,edm::Handle<edm::ValueMap<float> > > EGPfIsolationModifierFromValueMaps::ele_vmaps
private

Definition at line 68 of file EGPfIsolationModifier.cc.

Referenced by modifyObject(), and setEvent().

std::unordered_map<unsigned,edm::Ptr<reco::GsfElectron> > EGPfIsolationModifierFromValueMaps::eles_by_oop
private

Definition at line 67 of file EGPfIsolationModifier.cc.

Referenced by modifyObject(), and setEvent().

photon_config EGPfIsolationModifierFromValueMaps::ph_conf
private

Definition at line 66 of file EGPfIsolationModifier.cc.

Referenced by modifyObject(), setConsumes(), and setEvent().

unsigned EGPfIsolationModifierFromValueMaps::pho_idx
mutableprivate

Definition at line 71 of file EGPfIsolationModifier.cc.

Referenced by modifyObject(), and setEvent().

std::unordered_map<unsigned,edm::Handle<edm::ValueMap<float> > > EGPfIsolationModifierFromValueMaps::pho_vmaps
private

Definition at line 70 of file EGPfIsolationModifier.cc.

Referenced by modifyObject(), and setEvent().

std::unordered_map<unsigned,edm::Ptr<reco::Photon> > EGPfIsolationModifierFromValueMaps::phos_by_oop
private

Definition at line 69 of file EGPfIsolationModifier.cc.

Referenced by modifyObject(), and setEvent().