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

References EGXtraModFromVMObjFiller< OutputType >::addValuesToObject(), pat::Electron::setElectronIDs(), and jetUpdater_cfi::sort.

288 {
289  std::vector<std::pair<std::string,float >> ids;
290  for( auto itr = vmaps_token.begin(); itr != vmaps_token.end(); ++itr ) {
291  float idVal(0);
292  assignValue(ptr,itr->second,vmaps,idVal);
293  ids.push_back({itr->first,idVal});
294  }
295  std::sort(ids.begin(),ids.end(),[](auto& lhs,auto& rhs){return lhs.first<rhs.first;});
296  obj.setElectronIDs(ids);
297 }
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 302 of file EGExtraInfoModifierFromValueMaps.h.

References pat::Photon::setPhotonIDs(), and jetUpdater_cfi::sort.

307 {
308  //we do a float->bool conversion here to make things easier to be consistent with electrons
309  std::vector<std::pair<std::string,bool> > ids;
310  for( auto itr = vmaps_token.begin(); itr != vmaps_token.end(); ++itr ) {
311  float idVal(0);
312  assignValue(ptr,itr->second,vmaps,idVal);
313  ids.push_back({itr->first,idVal});
314  }
315  std::sort(ids.begin(),ids.end(),[](auto& lhs,auto& rhs){return lhs.first<rhs.first;});
316  obj.setPhotonIDs(ids);
317 }
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 223 of file EGExtraInfoModifierFromValueMaps.h.

References Exception.

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

228 {
229  MapType value{};
230  assignValue(ptr,val_map.second,vmaps,value);
231  if( overrideExistingValues || !obj.hasUserData(val_map.first) ) {
232  obj.addUserData(val_map.first,value,true);
233  } else {
234  throw cms::Exception("ValueNameAlreadyExists")
235  << "Trying to add new UserData = " << val_map.first
236  << " failed because it already exists and you didnt specify to override it (set in the config overrideExistingValues=cms.bool(True) )";
237  }
238 }
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 243 of file EGExtraInfoModifierFromValueMaps.h.

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

248 {
249  float value(0.0);
250  assignValue(ptr,val_map.second,vmaps,value);
251  if( overrideExistingValues || !obj.hasUserFloat(val_map.first) ) {
252  obj.addUserFloat(val_map.first,value,true);
253  } else {
254  throw cms::Exception("ValueNameAlreadyExists")
255  << "Trying to add new UserFloat = " << val_map.first
256  << " failed because it already exists and you didnt specify to override it (set in the config overrideExistingValues=cms.bool(True) )";
257  }
258 }
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 263 of file EGExtraInfoModifierFromValueMaps.h.

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

268 {
269  int value(0);
270  assignValue(ptr,val_map.second,vmaps,value);
271  if( overrideExistingValues || !obj.hasUserInt(val_map.first) ) {
272  obj.addUserInt(val_map.first,value,true);
273  } else {
274  throw cms::Exception("ValueNameAlreadyExists")
275  << "Trying to add new UserInt = " << val_map.first
276  << " failed because it already exists and you didnt specify to override it (set in the config overrideExistingValues=cms.bool(True) )";
277  }
278 }
Definition: value.py:1