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

Member Typedef Documentation

◆ ValMapToken

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

Definition at line 83 of file EGExtraInfoModifierFromValueMaps.h.

◆ ValueMaps

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

Definition at line 84 of file EGExtraInfoModifierFromValueMaps.h.

Constructor & Destructor Documentation

◆ EGExtraInfoModifierFromValueMaps()

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

Definition at line 115 of file EGExtraInfoModifierFromValueMaps.h.

References gpuPixelDoublets::cc, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::e_conf, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::ele_idx, pwdgSkimBPark_cfi::electrons, B2GDQM_cfi::electronSrc, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), ModifyObjectValueBase::name(), EGExtraInfoModifierFromValueMaps< MapType, OutputType >::overrideExistingValues_, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::ph_conf, EGExtraInfoModifierFromValueMaps< MapType, OutputType >::pho_idx, BPHMonitor_cfi::photons, PatBasicAnalyzer_cfi::photonSrc, 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.

117  : ModifyObjectValueBase(conf) {
118  constexpr char electronSrc[] = "electronSrc";
119  constexpr char photonSrc[] = "photonSrc";
121  conf.exists("overrideExistingValues") ? conf.getParameter<bool>("overrideExistingValues") : false;
122  if (conf.exists("electron_config")) {
123  const edm::ParameterSet& electrons = conf.getParameter<edm::ParameterSet>("electron_config");
124  if (electrons.exists(electronSrc))
127 
128  const std::vector<std::string> parameters = electrons.getParameterNames();
129  for (const std::string& name : parameters) {
130  if (std::string(electronSrc) == name)
131  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))
141  const std::vector<std::string> parameters = photons.getParameterNames();
142  for (const std::string& name : parameters) {
143  if (std::string(photonSrc) == name)
144  continue;
145  if (photons.existsAs<edm::InputTag>(name)) {
147  }
148  }
149  }
150  ele_idx = pho_idx = 0;
151 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< edm::View< reco::GsfElectron > > tok_electron_src
ModifyObjectValueBase(const edm::ParameterSet &conf)
const std::string & name() const
edm::EDGetTokenT< edm::View< reco::Photon > > tok_photon_src

Member Function Documentation

◆ modifyObject() [1/2]

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

Reimplemented from ModifyObjectValueBase.

Definition at line 194 of file EGExtraInfoModifierFromValueMaps.h.

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

194  {
195  // we encounter two cases here, either we are running AOD -> MINIAOD
196  // and the value maps are to the reducedEG object, can use original object ptr
197  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
200  ptr = eles_by_oop.at(ele_idx);
201  //now we go through and modify the objects using the valuemaps we read in
204  ++ele_idx;
205 }
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > ele_vmaps
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:104
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)
edm::EDGetTokenT< edm::View< reco::GsfElectron > > tok_electron_src
std::vector< edm::Ptr< reco::GsfElectron > > eles_by_oop
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:537

◆ modifyObject() [2/2]

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

Reimplemented from ModifyObjectValueBase.

Definition at line 208 of file EGExtraInfoModifierFromValueMaps.h.

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

208  {
209  // we encounter two cases here, either we are running AOD -> MINIAOD
210  // and the value maps are to the reducedEG object, can use original object ptr
211  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
214  ptr = phos_by_oop.at(pho_idx);
215  //now we go through and modify the objects using the valuemaps we read in
218 
219  ++pho_idx;
220 }
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:104
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > pho_vmaps
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)
std::vector< edm::Ptr< reco::Photon > > phos_by_oop
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:537
edm::EDGetTokenT< edm::View< reco::Photon > > tok_photon_src

◆ setEvent()

template<typename MapType , typename OutputType >
void EGExtraInfoModifierFromValueMaps< MapType, OutputType >::setEvent ( const edm::Event evt)
finalvirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 154 of file EGExtraInfoModifierFromValueMaps.h.

References filterCSVwithJSON::copy, hltEgammaEleL1TrkIsoL1Seeded_cfi::eles, and edm::Event::getHandle().

154  {
155  eles_by_oop.clear();
156  phos_by_oop.clear();
157  ele_vmaps.clear();
158  pho_vmaps.clear();
159 
160  ele_idx = pho_idx = 0;
161 
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) {
170  ele_vmaps[itr.second.index()] = evt.getHandle(itr.second);
171  }
172 
174  auto phos = evt.getHandle(ph_conf.tok_photon_src);
175 
176  phos_by_oop.resize(phos->size());
177  std::copy(phos->ptrs().begin(), phos->ptrs().end(), phos_by_oop.begin());
178  }
179 
180  for (auto const& itr : ph_conf.tok_valuemaps) {
181  pho_vmaps[itr.second.index()] = evt.getHandle(itr.second);
182  }
183 }
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > ele_vmaps
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:104
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< MapType > > > pho_vmaps
edm::EDGetTokenT< edm::View< reco::GsfElectron > > tok_electron_src
std::vector< edm::Ptr< reco::Photon > > phos_by_oop
std::vector< edm::Ptr< reco::GsfElectron > > eles_by_oop
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:552
edm::EDGetTokenT< edm::View< reco::Photon > > tok_photon_src

Member Data Documentation

◆ e_conf

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

◆ ele_idx

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

◆ ele_vmaps

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

Definition at line 106 of file EGExtraInfoModifierFromValueMaps.h.

◆ eles_by_oop

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

Definition at line 105 of file EGExtraInfoModifierFromValueMaps.h.

◆ overrideExistingValues_

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

◆ ph_conf

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

◆ pho_idx

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

◆ pho_vmaps

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

Definition at line 108 of file EGExtraInfoModifierFromValueMaps.h.

◆ phos_by_oop

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

Definition at line 107 of file EGExtraInfoModifierFromValueMaps.h.