CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
EGExtraInfoModifierFromValueMaps< MapType, OutputType > Class Template Reference

#include <EGExtraInfoModifierFromValueMaps.h>

Inheritance diagram for EGExtraInfoModifierFromValueMaps< MapType, OutputType >:
ModifyObjectValueBase

Classes

struct  electron_config
 
struct  photon_config
 

Public Types

using ValMapToken = edm::EDGetTokenT< edm::ValueMap< MapType > >
 
using ValueMaps = std::unordered_map< std::string, ValMapToken >
 
using ValueMapsTags = std::unordered_map< std::string, edm::InputTag >
 

Public Member Functions

 EGExtraInfoModifierFromValueMaps (const edm::ParameterSet &conf)
 
void modifyObject (pat::Electron &) const final
 
void modifyObject (pat::Photon &) const final
 
void setConsumes (edm::ConsumesCollector &) final
 
void setEvent (const edm::Event &) final
 
void setEventContent (const edm::EventSetup &) 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< MapType > > > ele_vmaps
 
std::unordered_map< unsigned, edm::Ptr< reco::GsfElectron > > eles_by_oop
 
bool overrideExistingValues_
 
photon_config ph_conf
 
unsigned pho_idx
 
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > pho_vmaps
 
std::unordered_map< unsigned, edm::Ptr< reco::Photon > > phos_by_oop
 

Detailed Description

template<typename MapType, typename OutputType = MapType>
class EGExtraInfoModifierFromValueMaps< MapType, OutputType >

Definition at line 84 of file EGExtraInfoModifierFromValueMaps.h.

Member Typedef Documentation

template<typename MapType , typename OutputType = MapType>
using EGExtraInfoModifierFromValueMaps< MapType, OutputType >::ValMapToken = edm::EDGetTokenT<edm::ValueMap<MapType> >

Definition at line 86 of file EGExtraInfoModifierFromValueMaps.h.

template<typename MapType , typename OutputType = MapType>
using EGExtraInfoModifierFromValueMaps< MapType, OutputType >::ValueMaps = std::unordered_map<std::string,ValMapToken>

Definition at line 87 of file EGExtraInfoModifierFromValueMaps.h.

template<typename MapType , typename OutputType = MapType>
using EGExtraInfoModifierFromValueMaps< MapType, OutputType >::ValueMapsTags = std::unordered_map<std::string,edm::InputTag>

Definition at line 88 of file EGExtraInfoModifierFromValueMaps.h.

Constructor & Destructor Documentation

template<typename MapType , typename OutputType >
EGExtraInfoModifierFromValueMaps< MapType, OutputType >::EGExtraInfoModifierFromValueMaps ( const edm::ParameterSet conf)

Definition at line 127 of file EGExtraInfoModifierFromValueMaps.h.

References constexpr, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::electron_config::electron_src, electrons_cff::electrons, PatBasicAnalyzer_cfi::electronSrc, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), edm::Event::getByToken(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), genParticles_cff::map, dataset::name, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::photon_config::photon_src, nano_cff::photons, PatBasicAnalyzer_cfi::photonSrc, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::setEvent(), AlCaHLTBitMon_QueryRunRegistry::string, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::electron_config::valuemaps, and EGExtraInfoModifierFromValueMaps< MapType, OutputType >::photon_config::valuemaps.

127  :
128  ModifyObjectValueBase(conf) {
129  constexpr char electronSrc[] = "electronSrc";
130  constexpr char photonSrc[] = "photonSrc";
131  overrideExistingValues_ = conf.exists("overrideExistingValues") ? conf.getParameter<bool>("overrideExistingValues") : false;
132  if( conf.exists("electron_config") ) {
133  const edm::ParameterSet& electrons = conf.getParameter<edm::ParameterSet>("electron_config");
134  if( electrons.exists(electronSrc) ) e_conf.electron_src = electrons.getParameter<edm::InputTag>(electronSrc);
135 
136  const std::vector<std::string> parameters = electrons.getParameterNames();
137  for( const std::string& name : parameters ) {
138  if( std::string(electronSrc) == name ) continue;
139  if( electrons.existsAs<edm::InputTag>(name) ) {
141  }
142  }
143  }
144  if( conf.exists("photon_config") ) {
145  const edm::ParameterSet& photons = conf.getParameter<edm::ParameterSet>("photon_config");
146  if( photons.exists(photonSrc) ) ph_conf.photon_src = photons.getParameter<edm::InputTag>(photonSrc);
147  const std::vector<std::string> parameters = photons.getParameterNames();
148  for( const std::string& name : parameters ) {
149  if( std::string(photonSrc) == name ) continue;
150  if( photons.existsAs<edm::InputTag>(name) ) {
152  }
153  }
154  }
155  ele_idx = pho_idx = 0;
156 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:185
bool exists(std::string const &parameterName) const
checks if a parameter exists
#define constexpr
const std::string & name() const
std::vector< std::string > getParameterNames() const
ModifyObjectValueBase(const edm::ParameterSet &conf)

Member Function Documentation

template<typename MapType , typename OutputType >
void EGExtraInfoModifierFromValueMaps< MapType, OutputType >::modifyObject ( pat::Electron ele) const
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 246 of file EGExtraInfoModifierFromValueMaps.h.

References EGXtraModFromVMObjFiller< OutputType >::addValuesToObject(), Exception, crabWrapper::key, edm::Ptr< T >::key(), and pat::PATObject< ObjectType >::originalObjectRef().

Referenced by EGExtraInfoModifierFromValueMaps< MapType, OutputType >::setConsumes().

246  {
247  // we encounter two cases here, either we are running AOD -> MINIAOD
248  // and the value maps are to the reducedEG object, can use original object ptr
249  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
252  auto key = eles_by_oop.find(ele_idx);
253  if( key != eles_by_oop.end() ) {
254  ptr = key->second;
255  } else {
256  throw cms::Exception("BadElectronKey")
257  << "Original object pointer with key = " << ele.originalObjectRef().key()
258  << " not found in cache!";
259  }
260  }
261  //now we go through and modify the objects using the valuemaps we read in
264  ++ele_idx;
265 }
key_type key() const
Definition: Ptr.h:185
static void addValuesToObject(ObjType &obj, const edm::Ptr< reco::Candidate > &ptr, const std::unordered_map< std::string, edm::EDGetTokenT< edm::ValueMap< MapType > > > &vmaps_token, const std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > &vmaps, bool overrideExistingValues)
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< MapType > > > ele_vmaps
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
std::unordered_map< unsigned, edm::Ptr< reco::GsfElectron > > eles_by_oop
bool isUninitialized() const
Definition: EDGetToken.h:73
template<typename MapType , typename OutputType >
void EGExtraInfoModifierFromValueMaps< MapType, OutputType >::modifyObject ( pat::Photon pho) const
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 270 of file EGExtraInfoModifierFromValueMaps.h.

References EGXtraModFromVMObjFiller< OutputType >::addValuesToObject(), EGXtraModFromVMObjFiller< OutputType >::addValueToObject(), Exception, crabWrapper::key, edm::Ptr< T >::key(), and pat::PATObject< ObjectType >::originalObjectRef().

270  {
271  // we encounter two cases here, either we are running AOD -> MINIAOD
272  // and the value maps are to the reducedEG object, can use original object ptr
273  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
276  auto key = phos_by_oop.find(pho_idx);
277  if( key != phos_by_oop.end() ) {
278  ptr = key->second;
279  } else {
280  throw cms::Exception("BadPhotonKey")
281  << "Original object pointer with key = " << pho.originalObjectRef().key() << " not found in cache!";
282  }
283  }
284  //now we go through and modify the objects using the valuemaps we read in
287 
288  ++pho_idx;
289 }
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > pho_vmaps
key_type key() const
Definition: Ptr.h:185
static void addValuesToObject(ObjType &obj, const edm::Ptr< reco::Candidate > &ptr, const std::unordered_map< std::string, edm::EDGetTokenT< edm::ValueMap< MapType > > > &vmaps_token, const std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > &vmaps, bool overrideExistingValues)
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:500
edm::EDGetTokenT< edm::View< pat::Photon > > tok_photon_src
bool isUninitialized() const
Definition: EDGetToken.h:73
std::unordered_map< unsigned, edm::Ptr< reco::Photon > > phos_by_oop
template<typename MapType , typename OutputType >
void EGExtraInfoModifierFromValueMaps< MapType, OutputType >::setConsumes ( edm::ConsumesCollector sumes)
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 221 of file EGExtraInfoModifierFromValueMaps.h.

References edm::ConsumesCollector::consumes(), genParticles_cff::map, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::modifyObject(), edm::second(), and mitigatedMETSequence_cff::U.

Referenced by EGExtraInfoModifierFromValueMaps< MapType, OutputType >::setEventContent().

221  {
222  //setup electrons
224 
225  for( auto itr = e_conf.valuemaps.begin(); itr != e_conf.valuemaps.end(); ++itr ) {
226  make_consumes(itr->second,e_conf.tok_valuemaps[itr->first],sumes);
227  }
228 
229  // setup photons
231 
232  for( auto itr = ph_conf.valuemaps.begin(); itr != ph_conf.valuemaps.end(); ++itr ) {
233  make_consumes(itr->second,ph_conf.tok_valuemaps[itr->first],sumes);
234  }
235 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
edm::EDGetTokenT< edm::View< pat::Photon > > tok_photon_src
template<typename MapType , typename OutputType >
void EGExtraInfoModifierFromValueMaps< MapType, OutputType >::setEvent ( const edm::Event evt)
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 169 of file EGExtraInfoModifierFromValueMaps.h.

References edm::Event::getByToken(), mps_fire::i, and EGExtraInfoModifierFromValueMaps< MapType, OutputType >::setEventContent().

Referenced by EGExtraInfoModifierFromValueMaps< MapType, OutputType >::EGExtraInfoModifierFromValueMaps().

169  {
170  eles_by_oop.clear();
171  phos_by_oop.clear();
172  ele_vmaps.clear();
173  pho_vmaps.clear();
174 
175  ele_idx = pho_idx = 0;
176 
180 
181  for( unsigned i = 0; i < eles->size(); ++i ) {
182  edm::Ptr<pat::Electron> ptr = eles->ptrAt(i);
183  eles_by_oop[i] = ptr;
184  }
185  }
186 
187  for( auto itr = e_conf.tok_valuemaps.begin(); itr != e_conf.tok_valuemaps.end(); ++itr ) {
188  get_product(evt,itr->second,ele_vmaps);
189  }
190 
194 
195  for( unsigned i = 0; i < phos->size(); ++i ) {
196  edm::Ptr<pat::Photon> ptr = phos->ptrAt(i);
197  phos_by_oop[i] = ptr;
198  }
199  }
200 
201  for( auto itr = ph_conf.tok_valuemaps.begin(); itr != ph_conf.tok_valuemaps.end(); ++itr ) {
202  get_product(evt,itr->second,pho_vmaps);
203  }
204 }
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > pho_vmaps
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > ele_vmaps
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
std::unordered_map< unsigned, edm::Ptr< reco::GsfElectron > > eles_by_oop
edm::EDGetTokenT< edm::View< pat::Photon > > tok_photon_src
bool isUninitialized() const
Definition: EDGetToken.h:73
std::unordered_map< unsigned, edm::Ptr< reco::Photon > > phos_by_oop
template<typename MapType , typename OutputType >
void EGExtraInfoModifierFromValueMaps< MapType, OutputType >::setEventContent ( const edm::EventSetup evs)
finalvirtual

Member Data Documentation

template<typename MapType , typename OutputType = MapType>
electron_config EGExtraInfoModifierFromValueMaps< MapType, OutputType >::e_conf
private

Definition at line 114 of file EGExtraInfoModifierFromValueMaps.h.

template<typename MapType , typename OutputType = MapType>
unsigned EGExtraInfoModifierFromValueMaps< MapType, OutputType >::ele_idx
mutableprivate

Definition at line 120 of file EGExtraInfoModifierFromValueMaps.h.

template<typename MapType , typename OutputType = MapType>
std::unordered_map<unsigned,edm::Handle<edm::ValueMap<MapType> > > EGExtraInfoModifierFromValueMaps< MapType, OutputType >::ele_vmaps
private

Definition at line 117 of file EGExtraInfoModifierFromValueMaps.h.

template<typename MapType , typename OutputType = MapType>
std::unordered_map<unsigned,edm::Ptr<reco::GsfElectron> > EGExtraInfoModifierFromValueMaps< MapType, OutputType >::eles_by_oop
private

Definition at line 116 of file EGExtraInfoModifierFromValueMaps.h.

template<typename MapType , typename OutputType = MapType>
bool EGExtraInfoModifierFromValueMaps< MapType, OutputType >::overrideExistingValues_
private

Definition at line 121 of file EGExtraInfoModifierFromValueMaps.h.

template<typename MapType , typename OutputType = MapType>
photon_config EGExtraInfoModifierFromValueMaps< MapType, OutputType >::ph_conf
private

Definition at line 115 of file EGExtraInfoModifierFromValueMaps.h.

template<typename MapType , typename OutputType = MapType>
unsigned EGExtraInfoModifierFromValueMaps< MapType, OutputType >::pho_idx
mutableprivate

Definition at line 120 of file EGExtraInfoModifierFromValueMaps.h.

template<typename MapType , typename OutputType = MapType>
std::unordered_map<unsigned,edm::Handle<edm::ValueMap<MapType> > > EGExtraInfoModifierFromValueMaps< MapType, OutputType >::pho_vmaps
private

Definition at line 119 of file EGExtraInfoModifierFromValueMaps.h.

template<typename MapType , typename OutputType = MapType>
std::unordered_map<unsigned,edm::Ptr<reco::Photon> > EGExtraInfoModifierFromValueMaps< MapType, OutputType >::phos_by_oop
private

Definition at line 118 of file EGExtraInfoModifierFromValueMaps.h.