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
 
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 61 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 63 of file EGExtraInfoModifierFromValueMaps.h.

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

Definition at line 64 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 65 of file EGExtraInfoModifierFromValueMaps.h.

Constructor & Destructor Documentation

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

Definition at line 103 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.

103  :
104  ModifyObjectValueBase(conf) {
105  constexpr char electronSrc[] = "electronSrc";
106  constexpr char photonSrc[] = "photonSrc";
107 
108  if( conf.exists("electron_config") ) {
109  const edm::ParameterSet& electrons = conf.getParameter<edm::ParameterSet>("electron_config");
110  if( electrons.exists(electronSrc) ) e_conf.electron_src = electrons.getParameter<edm::InputTag>(electronSrc);
111  const std::vector<std::string> parameters = electrons.getParameterNames();
112  for( const std::string& name : parameters ) {
113  if( std::string(electronSrc) == name ) continue;
114  if( electrons.existsAs<edm::InputTag>(name) ) {
116  }
117  }
118  }
119  if( conf.exists("photon_config") ) {
120  const edm::ParameterSet& photons = conf.getParameter<edm::ParameterSet>("photon_config");
121  if( photons.exists(photonSrc) ) ph_conf.photon_src = photons.getParameter<edm::InputTag>(photonSrc);
122  const std::vector<std::string> parameters = photons.getParameterNames();
123  for( const std::string& name : parameters ) {
124  if( std::string(photonSrc) == name ) continue;
125  if( photons.existsAs<edm::InputTag>(name) ) {
127  }
128  }
129  }
130  ele_idx = pho_idx = 0;
131 }
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:186
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 221 of file EGExtraInfoModifierFromValueMaps.h.

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

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

221  {
222  // we encounter two cases here, either we are running AOD -> MINIAOD
223  // and the value maps are to the reducedEG object, can use original object ptr
224  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
227  auto key = eles_by_oop.find(ele_idx);
228  if( key != eles_by_oop.end() ) {
229  ptr = key->second;
230  } else {
231  throw cms::Exception("BadElectronKey")
232  << "Original object pointer with key = " << ele.originalObjectRef().key()
233  << " not found in cache!";
234  }
235  }
236  //now we go through and modify the objects using the valuemaps we read in
237  for( auto itr = e_conf.tok_valuemaps.begin(); itr != e_conf.tok_valuemaps.end(); ++itr ) {
239  }
240  ++ele_idx;
241 }
key_type key() const
Definition: Ptr.h:185
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
static void addValueToObject(ObjType &obj, const edm::Ptr< reco::Candidate > &ptr, const std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > &vmaps, const std::pair< const std::string, edm::EDGetTokenT< edm::ValueMap< MapType > > > &val_map)
template<typename MapType , typename OutputType >
void EGExtraInfoModifierFromValueMaps< MapType, OutputType >::modifyObject ( pat::Photon pho) const
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 245 of file EGExtraInfoModifierFromValueMaps.h.

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

245  {
246  // we encounter two cases here, either we are running AOD -> MINIAOD
247  // and the value maps are to the reducedEG object, can use original object ptr
248  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
251  auto key = phos_by_oop.find(pho_idx);
252  if( key != phos_by_oop.end() ) {
253  ptr = key->second;
254  } else {
255  throw cms::Exception("BadPhotonKey")
256  << "Original object pointer with key = " << pho.originalObjectRef().key() << " not found in cache!";
257  }
258  }
259  //now we go through and modify the objects using the valuemaps we read in
260  for( auto itr = ph_conf.tok_valuemaps.begin(); itr != ph_conf.tok_valuemaps.end(); ++itr ) {
262  }
263  ++pho_idx;
264 }
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > pho_vmaps
key_type key() const
Definition: Ptr.h:185
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
static void addValueToObject(ObjType &obj, const edm::Ptr< reco::Candidate > &ptr, const std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > &vmaps, const std::pair< const std::string, edm::EDGetTokenT< edm::ValueMap< MapType > > > &val_map)
template<typename MapType , typename OutputType >
void EGExtraInfoModifierFromValueMaps< MapType, OutputType >::setConsumes ( edm::ConsumesCollector sumes)
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 196 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().

196  {
197  //setup electrons
199 
200  for( auto itr = e_conf.valuemaps.begin(); itr != e_conf.valuemaps.end(); ++itr ) {
201  make_consumes(itr->second,e_conf.tok_valuemaps[itr->first],sumes);
202  }
203 
204  // setup photons
206 
207  for( auto itr = ph_conf.valuemaps.begin(); itr != ph_conf.valuemaps.end(); ++itr ) {
208  make_consumes(itr->second,ph_conf.tok_valuemaps[itr->first],sumes);
209  }
210 }
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 144 of file EGExtraInfoModifierFromValueMaps.h.

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

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

144  {
145  eles_by_oop.clear();
146  phos_by_oop.clear();
147  ele_vmaps.clear();
148  pho_vmaps.clear();
149 
150  ele_idx = pho_idx = 0;
151 
155 
156  for( unsigned i = 0; i < eles->size(); ++i ) {
157  edm::Ptr<pat::Electron> ptr = eles->ptrAt(i);
158  eles_by_oop[i] = ptr;
159  }
160  }
161 
162  for( auto itr = e_conf.tok_valuemaps.begin(); itr != e_conf.tok_valuemaps.end(); ++itr ) {
163  get_product(evt,itr->second,ele_vmaps);
164  }
165 
169 
170  for( unsigned i = 0; i < phos->size(); ++i ) {
171  edm::Ptr<pat::Photon> ptr = phos->ptrAt(i);
172  phos_by_oop[i] = ptr;
173  }
174  }
175 
176  for( auto itr = ph_conf.tok_valuemaps.begin(); itr != ph_conf.tok_valuemaps.end(); ++itr ) {
177  get_product(evt,itr->second,pho_vmaps);
178  }
179 }
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > pho_vmaps
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
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 91 of file EGExtraInfoModifierFromValueMaps.h.

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

Definition at line 97 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 94 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 93 of file EGExtraInfoModifierFromValueMaps.h.

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

Definition at line 92 of file EGExtraInfoModifierFromValueMaps.h.

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

Definition at line 97 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 96 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 95 of file EGExtraInfoModifierFromValueMaps.h.