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

Constructor & Destructor Documentation

◆ EGXtraModFromVMObjFiller()

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

◆ ~EGXtraModFromVMObjFiller()

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

Member Function Documentation

◆ addValuesToObject() [1/3]

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

References EGXtraModFromVMObjFiller< OutputType >::addValueToObject(), and getGTfromDQMFile::obj.

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

73  {
74  for (auto itr = vmaps_token.begin(); itr != vmaps_token.end(); ++itr) {
75  addValueToObject(obj, ptr, vmaps, *itr, overrideExistingValues);
76  }
77  }
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)

◆ addValuesToObject() [2/3]

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 
)
inline

Definition at line 284 of file EGExtraInfoModifierFromValueMaps.h.

References getGTfromDQMFile::obj, and jetsAK4_CHS_cff::sort.

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

◆ addValuesToObject() [3/3]

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 
)
inline

Definition at line 302 of file EGExtraInfoModifierFromValueMaps.h.

References getGTfromDQMFile::obj, and jetsAK4_CHS_cff::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 }

◆ addValueToObject() [1/3]

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

References Exception, and getGTfromDQMFile::obj.

Referenced by EGXtraModFromVMObjFiller< OutputType >::addValuesToObject().

229  {
230  MapType value{};
231  assignValue(ptr, val_map.second, vmaps, value);
232  if (overrideExistingValues || !obj.hasUserData(val_map.first)) {
233  obj.addUserData(val_map.first, value, true);
234  } else {
235  throw cms::Exception("ValueNameAlreadyExists")
236  << "Trying to add new UserData = " << val_map.first
237  << " failed because it already exists and you didnt specify to override it (set in the config "
238  "overrideExistingValues=cms.bool(True) )";
239  }
240 }
Definition: value.py:1

◆ addValueToObject() [2/3]

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

References Exception, getGTfromDQMFile::obj, and relativeConstraints::value.

249  {
250  float value(0.0);
251  assignValue(ptr, val_map.second, vmaps, value);
252  if (overrideExistingValues || !obj.hasUserFloat(val_map.first)) {
253  obj.addUserFloat(val_map.first, value, true);
254  } else {
255  throw cms::Exception("ValueNameAlreadyExists")
256  << "Trying to add new UserFloat = " << val_map.first
257  << " failed because it already exists and you didnt specify to override it (set in the config "
258  "overrideExistingValues=cms.bool(True) )";
259  }
260 }
Definition: value.py:1

◆ addValueToObject() [3/3]

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

References Exception, getGTfromDQMFile::obj, and relativeConstraints::value.

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