CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_token
input_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 overridefinal
 
void modifyObject (pat::Photon &) const overridefinal
 
void setConsumes (edm::ConsumesCollector &) overridefinal
 
void setEvent (const edm::Event &) overridefinal
 
void setEventContent (const edm::EventSetup &) overridefinal
 
- Public Member Functions inherited from ModifyObjectValueBase
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, HI_PhotonSkim_cff::electrons, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), EGPfIsolationModifierFromValueMaps::photon_config::photon_inputs, EGPfIsolationModifierFromValueMaps::photon_config::photon_src, interactiveExample::photons, 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 190 of file EGPfIsolationModifier.cc.

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

190  {
191  // we encounter two cases here, either we are running AOD -> MINIAOD
192  // and the value maps are to the reducedEG object, can use original object ptr
193  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
196  auto key = eles_by_oop.find(ele_idx);
197  if( key != eles_by_oop.end() ) {
198  ptr = key->second;
199  } else {
200  throw cms::Exception("BadElectronKey")
201  << "Original object pointer with key = " << ele.originalObjectRef().key() << " not found in cache!";
202  }
203  }
204  //now we go through and modify the objects using the valuemaps we read in
205  auto pfIso = ele.pfIsolationVariables();
206 
207  const auto& e_inputs = e_conf.electron_inputs;
208 
209  assignValue(ptr,e_inputs,electron_vars[0],ele_vmaps,pfIso.sumChargedHadronPt);
210  assignValue(ptr,e_inputs,electron_vars[1],ele_vmaps,pfIso.sumNeutralHadronEt);
211  assignValue(ptr,e_inputs,electron_vars[2],ele_vmaps,pfIso.sumPhotonEt);
212  assignValue(ptr,e_inputs,electron_vars[3],ele_vmaps,pfIso.sumChargedParticlePt);
213  assignValue(ptr,e_inputs,electron_vars[4],ele_vmaps,pfIso.sumNeutralHadronEtHighThreshold);
214  assignValue(ptr,e_inputs,electron_vars[5],ele_vmaps,pfIso.sumPhotonEtHighThreshold);
215  assignValue(ptr,e_inputs,electron_vars[6],ele_vmaps,pfIso.sumPUPt);
216 
217  ele.setPfIsolationVariables(pfIso);
218  ++ele_idx;
219 }
const PflowIsolationVariables & pfIsolationVariables() const
Definition: GsfElectron.h:604
std::unordered_map< unsigned, edm::Ptr< reco::GsfElectron > > eles_by_oop
key_type key() const
Definition: Ptr.h:169
void setPfIsolationVariables(const PflowIsolationVariables &iso)
Definition: GsfElectron.h:609
const edm::Ptr< reco::Candidate > & originalObjectRef() const
reference to original object. Returns a null reference if not available
Definition: PATObject.h:484
std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > ele_vmaps
edm::EDGetTokenT< edm::View< pat::Electron > > tok_electron_src
void assignValue(const T &ptr, const U &tok, const V &map, Z &value)
bool isUninitialized() const
Definition: EDGetToken.h:71
void EGPfIsolationModifierFromValueMaps::modifyObject ( pat::Photon pho) const
finaloverridevirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 223 of file EGPfIsolationModifier.cc.

References assignValue(), edm::hlt::Exception, reco::Photon::getPflowIsolationVariables(), edm::EDGetTokenT< T >::isUninitialized(), edm::Ptr< T >::key(), relval_steps::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.

223  {
224  // we encounter two cases here, either we are running AOD -> MINIAOD
225  // and the value maps are to the reducedEG object, can use original object ptr
226  // or we are running MINIAOD->MINIAOD and we need to fetch the pat objects to reference
229  auto key = phos_by_oop.find(pho_idx);
230  if( key != phos_by_oop.end() ) {
231  ptr = key->second;
232  } else {
233  throw cms::Exception("BadPhotonKey")
234  << "Original object pointer with key = " << pho.originalObjectRef().key() << " not found in cache!";
235  }
236  }
237 
238  //now we go through and modify the objects using the valuemaps we read in
239  auto pfIso = pho.getPflowIsolationVariables();
240 
241  const auto& ph_inputs = ph_conf.photon_inputs;
242 
243  assignValue(ptr,ph_inputs,photon_vars[0],pho_vmaps,pfIso.chargedHadronIso);
244  assignValue(ptr,ph_inputs,photon_vars[1],pho_vmaps,pfIso.chargedHadronIsoWrongVtx);
245  assignValue(ptr,ph_inputs,photon_vars[2],pho_vmaps,pfIso.neutralHadronIso);
246  assignValue(ptr,ph_inputs,photon_vars[3],pho_vmaps,pfIso.photonIso);
247  assignValue(ptr,ph_inputs,photon_vars[4],pho_vmaps,pfIso.modFrixione);
248  assignValue(ptr,ph_inputs,photon_vars[5],pho_vmaps,pfIso.sumChargedParticlePt);
249  assignValue(ptr,ph_inputs,photon_vars[6],pho_vmaps,pfIso.sumNeutralHadronEtHighThreshold);
250  assignValue(ptr,ph_inputs,photon_vars[7],pho_vmaps,pfIso.sumPhotonEtHighThreshold);
251  assignValue(ptr,ph_inputs,photon_vars[8],pho_vmaps,pfIso.sumPUPt);
252 
253  pho.setPflowIsolationVariables(pfIso);
254  ++pho_idx;
255 }
void setPflowIsolationVariables(const PflowIsolationVariables &pfisol)
Set Particle Flow Isolation variables.
Definition: Photon.h:450
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:169
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:484
void assignValue(const T &ptr, const U &tok, const V &map, Z &value)
bool isUninitialized() const
Definition: EDGetToken.h:71
const PflowIsolationVariables & getPflowIsolationVariables() const
Get Particle Flow Isolation variables block.
Definition: Photon.h:447
void EGPfIsolationModifierFromValueMaps::setConsumes ( edm::ConsumesCollector sumes)
finaloverridevirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 159 of file EGPfIsolationModifier.cc.

References edm::ConsumesCollector::consumes(), e_conf, EGPfIsolationModifierFromValueMaps::electron_config::electron_inputs, EGPfIsolationModifierFromValueMaps::electron_config::electron_src, SiPixelRawToDigiRegional_cfi::inputs, make_consumes(), ph_conf, EGPfIsolationModifierFromValueMaps::photon_config::photon_inputs, EGPfIsolationModifierFromValueMaps::photon_config::photon_src, AlCaHLTBitMon_QueryRunRegistry::string, EGPfIsolationModifierFromValueMaps::electron_config::tok_electron_src, and EGPfIsolationModifierFromValueMaps::photon_config::tok_photon_src.

159  {
160  //setup electrons
162 
163  for( const std::string& varname : electron_vars ) {
164  auto& inputs = e_conf.electron_inputs;
165  if( inputs.find(varname) == inputs.end() ) continue;
166  auto& the_tuple = inputs[varname];
167  make_consumes(std::get<0>(the_tuple),std::get<1>(the_tuple),sumes);
168  }
169 
170  // setup photons
172 
173  for( const std::string& varname : photon_vars ) {
174  auto& inputs = ph_conf.photon_inputs;
175  if( inputs.find(varname) == inputs.end() ) continue;
176  auto& the_tuple = inputs[varname];
177  make_consumes(std::get<0>(the_tuple),std::get<1>(the_tuple),sumes);
178  }
179 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void make_consumes(T &tag, U &tok, V &sume)
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 110 of file EGPfIsolationModifier.cc.

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

110  {
111  eles_by_oop.clear();
112  phos_by_oop.clear();
113  ele_vmaps.clear();
114  pho_vmaps.clear();
115 
116  ele_idx = pho_idx = 0;
117 
121 
122  for( unsigned i = 0; i < eles->size(); ++i ) {
123  edm::Ptr<pat::Electron> ptr = eles->ptrAt(i);
124  eles_by_oop[i] = ptr;
125  }
126  }
127 
128  for( const std::string& varname : electron_vars ) {
129  auto& inputs = e_conf.electron_inputs;
130  if( inputs.find(varname) == inputs.end() ) continue;
131  get_product(evt,std::get<1>(inputs[varname]),ele_vmaps);
132  }
133 
137 
138  for( unsigned i = 0; i < phos->size(); ++i ) {
139  edm::Ptr<pat::Photon> ptr = phos->ptrAt(i);
140  phos_by_oop[i] = ptr;
141  }
142  }
143 
144  for( const std::string& varname : photon_vars ) {
145  auto& inputs = ph_conf.photon_inputs;
146  if( inputs.find(varname) == inputs.end() ) continue;
147  get_product(evt,std::get<1>(inputs[varname]),pho_vmaps);
148  }
149 }
int i
Definition: DBlmapReader.cc:9
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:449
void get_product(const edm::Event &evt, const edm::EDGetTokenT< edm::ValueMap< T > > &tok, std::unordered_map< unsigned, edm::Handle< edm::ValueMap< T > > > &map)
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:71
void EGPfIsolationModifierFromValueMaps::setEventContent ( const edm::EventSetup evs)
finaloverridevirtual

Reimplemented from ModifyObjectValueBase.

Definition at line 152 of file EGPfIsolationModifier.cc.

152  {
153 }

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().