CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions
EGXtraModFromVMObjFiller< OutputType > Class Template Reference

#include <EGExtraInfoModifierFromValueMaps.h>

Public Member Functions

template<>
void addValuesToObject (pat::Electron &obj, const edm::Ptr< reco::Candidate > &ptr, const std::unordered_map< std::string, edm::EDGetTokenT< edm::ValueMap< float > > > &vmaps_token, const std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > &vmaps, bool overrideExistingValues)
 
template<>
void addValuesToObject (pat::Photon &obj, const edm::Ptr< reco::Candidate > &ptr, const std::unordered_map< std::string, edm::EDGetTokenT< edm::ValueMap< float > > > &vmaps_token, const std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > &vmaps, bool overrideExistingValues)
 
template<>
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, bool overrideExistingValues)
 
template<>
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, bool overrideExistingValues)
 
 EGXtraModFromVMObjFiller ()=delete
 
 ~EGXtraModFromVMObjFiller ()=delete
 

Static Public Member Functions

template<typename ObjType , typename MapType >
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)
 
template<typename ObjType , typename MapType >
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, bool overrideExistingValues)
 

Detailed Description

template<typename OutputType>
class EGXtraModFromVMObjFiller< OutputType >

Definition at line 55 of file EGExtraInfoModifierFromValueMaps.h.

Constructor & Destructor Documentation

template<typename OutputType >
EGXtraModFromVMObjFiller< OutputType >::EGXtraModFromVMObjFiller ( )
delete
template<typename OutputType >
EGXtraModFromVMObjFiller< OutputType >::~EGXtraModFromVMObjFiller ( )
delete

Member Function Documentation

template<typename OutputType >
template<typename ObjType , typename MapType >
static void EGXtraModFromVMObjFiller< OutputType >::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 
)
inlinestatic

Definition at line 71 of file EGExtraInfoModifierFromValueMaps.h.

Referenced by EGXtraModFromVMObjFiller< OutputType >::addValuesToObject(), EGXtraModFromVMObjFiller< OutputType >::addValueToObject(), and EGExtraInfoModifierFromValueMaps< MapType, OutputType >::modifyObject().

75  {
76  for( auto itr = vmaps_token.begin(); itr != vmaps_token.end(); ++itr ) {
77  addValueToObject(obj,ptr,vmaps,*itr,overrideExistingValues);
78  }
79  }
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, bool overrideExistingValues)
template<>
void EGXtraModFromVMObjFiller< egmodifier::EGID >::addValuesToObject ( pat::Electron obj,
const edm::Ptr< reco::Candidate > &  ptr,
const std::unordered_map< std::string, edm::EDGetTokenT< edm::ValueMap< float > > > &  vmaps_token,
const std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > &  vmaps,
bool  overrideExistingValues 
)

Definition at line 355 of file EGExtraInfoModifierFromValueMaps.h.

References EGXtraModFromVMObjFiller< OutputType >::addValuesToObject(), photons_cff::ids, and pat::Electron::setElectronIDs().

360 {
361  std::vector<std::pair<std::string,float >> ids;
362  for( auto itr = vmaps_token.begin(); itr != vmaps_token.end(); ++itr ) {
363  float idVal(0);
364  assignValue(ptr,itr->second,vmaps,idVal);
365  ids.push_back({itr->first,idVal});
366  }
367  std::sort(ids.begin(),ids.end(),[](auto& lhs,auto& rhs){return lhs.first<rhs.first;});
368  obj.setElectronIDs(ids);
369 }
void setElectronIDs(const std::vector< IdPair > &ids)
Store multiple electron ID values, discarding existing ones. The first one in the list becomes the &#39;d...
Definition: Electron.h:146
template<>
void EGXtraModFromVMObjFiller< egmodifier::EGID >::addValuesToObject ( pat::Photon obj,
const edm::Ptr< reco::Candidate > &  ptr,
const std::unordered_map< std::string, edm::EDGetTokenT< edm::ValueMap< float > > > &  vmaps_token,
const std::unordered_map< unsigned, edm::Handle< edm::ValueMap< float > > > &  vmaps,
bool  overrideExistingValues 
)

Definition at line 374 of file EGExtraInfoModifierFromValueMaps.h.

References photons_cff::ids, and pat::Photon::setPhotonIDs().

379 {
380  //we do a float->bool conversion here to make things easier to be consistent with electrons
381  std::vector<std::pair<std::string,bool> > ids;
382  for( auto itr = vmaps_token.begin(); itr != vmaps_token.end(); ++itr ) {
383  float idVal(0);
384  assignValue(ptr,itr->second,vmaps,idVal);
385  ids.push_back({itr->first,idVal});
386  }
387  std::sort(ids.begin(),ids.end(),[](auto& lhs,auto& rhs){return lhs.first<rhs.first;});
388  obj.setPhotonIDs(ids);
389 }
void setPhotonIDs(const std::vector< IdPair > &ids)
Definition: Photon.h:110
template<typename OutputType >
template<typename ObjType , typename MapType >
void EGXtraModFromVMObjFiller< OutputType >::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,
bool  overrideExistingValues 
)
static

Definition at line 295 of file EGExtraInfoModifierFromValueMaps.h.

References Exception.

Referenced by EGXtraModFromVMObjFiller< OutputType >::addValueToObject(), and EGExtraInfoModifierFromValueMaps< MapType, OutputType >::modifyObject().

300 {
301  MapType value{};
302  assignValue(ptr,val_map.second,vmaps,value);
303  if( overrideExistingValues || !obj.hasUserData(val_map.first) ) {
304  obj.addUserData(val_map.first,value,true);
305  } else {
306  throw cms::Exception("ValueNameAlreadyExists")
307  << "Trying to add new UserData = " << val_map.first
308  << " failed because it already exists and you didnt specify to override it (set in the config overrideExistingValues=cms.bool(True) )";
309  }
310 }
Definition: value.py:1
template<>
void EGXtraModFromVMObjFiller< float >::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,
bool  overrideExistingValues 
)

Definition at line 315 of file EGExtraInfoModifierFromValueMaps.h.

References EGXtraModFromVMObjFiller< OutputType >::addValueToObject(), Exception, and relativeConstraints::value.

320 {
321  float value(0.0);
322  assignValue(ptr,val_map.second,vmaps,value);
323  if( overrideExistingValues || !obj.hasUserFloat(val_map.first) ) {
324  obj.addUserFloat(val_map.first,value,true);
325  } else {
326  throw cms::Exception("ValueNameAlreadyExists")
327  << "Trying to add new UserFloat = " << val_map.first
328  << " failed because it already exists and you didnt specify to override it (set in the config overrideExistingValues=cms.bool(True) )";
329  }
330 }
Definition: value.py:1
template<>
void EGXtraModFromVMObjFiller< int >::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,
bool  overrideExistingValues 
)

Definition at line 335 of file EGExtraInfoModifierFromValueMaps.h.

References EGXtraModFromVMObjFiller< OutputType >::addValuesToObject(), Exception, and relativeConstraints::value.

340 {
341  int value(0);
342  assignValue(ptr,val_map.second,vmaps,value);
343  if( overrideExistingValues || !obj.hasUserInt(val_map.first) ) {
344  obj.addUserInt(val_map.first,value,true);
345  } else {
346  throw cms::Exception("ValueNameAlreadyExists")
347  << "Trying to add new UserInt = " << val_map.first
348  << " failed because it already exists and you didnt specify to override it (set in the config overrideExistingValues=cms.bool(True) )";
349  }
350 }
Definition: value.py:1