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 >
 

Public Member Functions

 EGExtraInfoModifierFromValueMaps (const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
 
void modifyObject (pat::Electron &) const final
 
void modifyObject (pat::Photon &) const final
 
void setEvent (const edm::Event &) 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 void setEventContent (const edm::EventSetup &)
 
virtual ~ModifyObjectValueBase ()
 

Private Attributes

electron_config e_conf
 
unsigned ele_idx
 
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > ele_vmaps
 
std::vector< 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::vector< 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.

Constructor & Destructor Documentation

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

Definition at line 120 of file EGExtraInfoModifierFromValueMaps.h.

References constexpr, nano_cff::electrons, slimmedLowPtElectrons_cfi::electronSrc, edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), dataset::name, muons_cff::photons, PatBasicAnalyzer_cfi::photonSrc, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::setEvent(), AlCaHLTBitMon_QueryRunRegistry::string, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::electron_config::tok_electron_src, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::photon_config::tok_photon_src, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::electron_config::tok_valuemaps, and EGExtraInfoModifierFromValueMaps< MapType, OutputType >::photon_config::tok_valuemaps.

120  :
121  ModifyObjectValueBase(conf) {
122  constexpr char electronSrc[] = "electronSrc";
123  constexpr char photonSrc[] = "photonSrc";
124  overrideExistingValues_ = conf.exists("overrideExistingValues") ? conf.getParameter<bool>("overrideExistingValues") : false;
125  if( conf.exists("electron_config") ) {
126  const edm::ParameterSet& electrons = conf.getParameter<edm::ParameterSet>("electron_config");
127  if( electrons.exists(electronSrc) ) e_conf.tok_electron_src = cc.consumes<edm::View<pat::Electron>>(electrons.getParameter<edm::InputTag>(electronSrc));
128 
129  const std::vector<std::string> parameters = electrons.getParameterNames();
130  for( const std::string& name : parameters ) {
131  if( std::string(electronSrc) == name ) continue;
132  if( electrons.existsAs<edm::InputTag>(name) ) {
134  }
135  }
136  }
137  if( conf.exists("photon_config") ) {
138  const edm::ParameterSet& photons = conf.getParameter<edm::ParameterSet>("photon_config");
139  if( photons.exists(photonSrc) ) ph_conf.tok_photon_src = cc.consumes<edm::View<pat::Photon>>(photons.getParameter<edm::InputTag>(photonSrc));
140  const std::vector<std::string> parameters = photons.getParameterNames();
141  for( const std::string& name : parameters ) {
142  if( std::string(photonSrc) == name ) continue;
143  if( photons.existsAs<edm::InputTag>(name) ) {
145  }
146  }
147  }
148  ele_idx = pho_idx = 0;
149 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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:161
bool exists(std::string const &parameterName) const
checks if a parameter exists
const std::string & name() const
std::vector< std::string > getParameterNames() const
ModifyObjectValueBase(const edm::ParameterSet &conf)
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
edm::EDGetTokenT< edm::View< pat::Photon > > tok_photon_src
#define constexpr

Member Function Documentation

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

Reimplemented from ModifyObjectValueBase.

Definition at line 191 of file EGExtraInfoModifierFromValueMaps.h.

References EGXtraModFromVMObjFiller< OutputType >::addValuesToObject(), and pat::PATObject< ObjectType >::originalObjectRef().

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

191  {
192  // we encounter two cases here, either we are running AOD -> MINIAOD
193  // and the value maps are to the reducedEG object, can use original object ptr
194  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
197  //now we go through and modify the objects using the valuemaps we read in
200  ++ele_idx;
201 }
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::vector< edm::Ptr< reco::GsfElectron > > eles_by_oop
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > ele_vmaps
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
bool isUninitialized() const
Definition: EDGetToken.h:70
template<typename MapType , typename OutputType >
void EGExtraInfoModifierFromValueMaps< MapType, OutputType >::modifyObject ( pat::Photon pho) const
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 206 of file EGExtraInfoModifierFromValueMaps.h.

References EGXtraModFromVMObjFiller< OutputType >::addValuesToObject(), EGXtraModFromVMObjFiller< OutputType >::addValueToObject(), and pat::PATObject< ObjectType >::originalObjectRef().

206  {
207  // we encounter two cases here, either we are running AOD -> MINIAOD
208  // and the value maps are to the reducedEG object, can use original object ptr
209  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
212  //now we go through and modify the objects using the valuemaps we read in
215 
216  ++pho_idx;
217 }
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > pho_vmaps
std::vector< edm::Ptr< reco::Photon > > phos_by_oop
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:70
template<typename MapType , typename OutputType >
void EGExtraInfoModifierFromValueMaps< MapType, OutputType >::setEvent ( const edm::Event evt)
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 153 of file EGExtraInfoModifierFromValueMaps.h.

References popcon2dropbox::copy(), edm::Event::getByToken(), genParticles_cff::map, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::modifyObject(), edm::second(), and mitigatedMETSequence_cff::U.

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

153  {
154  eles_by_oop.clear();
155  phos_by_oop.clear();
156  ele_vmaps.clear();
157  pho_vmaps.clear();
158 
159  ele_idx = pho_idx = 0;
160 
164 
165  eles_by_oop.resize(eles->size());
166  std::copy(eles->ptrs().begin(), eles->ptrs().end(), eles_by_oop.begin());
167  }
168 
169  for(auto const& itr : e_conf.tok_valuemaps) evt.getByToken(itr.second,ele_vmaps[itr.second.index()]);
170 
174 
175  phos_by_oop.resize(phos->size());
176  std::copy(phos->ptrs().begin(), phos->ptrs().end(), phos_by_oop.begin());
177  }
178 
179  for(auto const& itr : ph_conf.tok_valuemaps) evt.getByToken(itr.second,pho_vmaps[itr.second.index()]);
180 }
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > pho_vmaps
def copy(args, dbName)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< edm::Ptr< reco::Photon > > phos_by_oop
std::vector< edm::Ptr< reco::GsfElectron > > eles_by_oop
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > ele_vmaps
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
edm::EDGetTokenT< edm::View< pat::Photon > > tok_photon_src
bool isUninitialized() const
Definition: EDGetToken.h:70

Member Data Documentation

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

Definition at line 107 of file EGExtraInfoModifierFromValueMaps.h.

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

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

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

Definition at line 109 of file EGExtraInfoModifierFromValueMaps.h.

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

Definition at line 114 of file EGExtraInfoModifierFromValueMaps.h.

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

Definition at line 108 of file EGExtraInfoModifierFromValueMaps.h.

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

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

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

Definition at line 111 of file EGExtraInfoModifierFromValueMaps.h.