CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
pat::PATUserDataHelper< ObjectType > Class Template Reference

Assists in assimilating all pat::UserData into pat objects. More...

#include "PhysicsTools/PatAlgos/interface/PATUserDataHelper.h"

Public Types

typedef StringObjectFunction< ObjectType > function_type
 

Public Member Functions

void add (ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
 
 PATUserDataHelper ()
 
 PATUserDataHelper (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
 ~PATUserDataHelper ()
 

Static Public Member Functions

static void fillDescription (edm::ParameterSetDescription &iDesc)
 

Private Attributes

std::vector< std::string > functionLabels_
 
std::vector< std::string > functionNames_
 
std::vector< function_typefunctions_
 
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserCanduserCandMerger_
 
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserPtruserDataMerger_
 
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserFloatuserFloatMerger_
 
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserIntuserIntMerger_
 

Detailed Description

template<class ObjectType>
class pat::PATUserDataHelper< ObjectType >

Assists in assimilating all pat::UserData into pat objects.

This will pull the following from the event stream (if they exist) and put them into the object in question, all indexed by the reco objects that make up the pat objects in question:

ValueMap<double> ValueMap<int> ValueMap<Ptr<UserData> > ValueMap<CandidatePtr>

This is accomplished by using PATUserDataMergers.

This also can add "in situ" string-parser-based methods directly.

Author
Salvatore Rappoccio
Version
Id
PATUserDataHelper.h,v 1.8 2010/02/20 21:00:13 wmtan Exp

Definition at line 48 of file PATUserDataHelper.h.

Member Typedef Documentation

◆ function_type

template<class ObjectType>
typedef StringObjectFunction<ObjectType> pat::PATUserDataHelper< ObjectType >::function_type

Definition at line 50 of file PATUserDataHelper.h.

Constructor & Destructor Documentation

◆ PATUserDataHelper() [1/2]

template<class ObjectType>
pat::PATUserDataHelper< ObjectType >::PATUserDataHelper ( )
inline

Definition at line 52 of file PATUserDataHelper.h.

52 {}

◆ PATUserDataHelper() [2/2]

template<class ObjectType >
pat::PATUserDataHelper< ObjectType >::PATUserDataHelper ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)

Definition at line 80 of file PATUserDataHelper.h.

81  : userDataMerger_(iConfig.getParameter<edm::ParameterSet>("userClasses"), iC),
82  userFloatMerger_(iConfig.getParameter<edm::ParameterSet>("userFloats"), iC),
83  userIntMerger_(iConfig.getParameter<edm::ParameterSet>("userInts"), iC),
84  userCandMerger_(iConfig.getParameter<edm::ParameterSet>("userCands"), iC),
85  functionNames_(iConfig.getParameter<std::vector<std::string> >("userFunctions")),
86  functionLabels_(iConfig.getParameter<std::vector<std::string> >("userFunctionLabels")) {
87  // Make sure the sizes match
88  if (functionNames_.size() != functionLabels_.size()) {
89  throw cms::Exception("Size mismatch")
90  << "userFunctions and userFunctionLabels do not have the same size, they must be the same\n";
91  }
92  // Loop over the function names, create a new string-parser function object
93  // with all of them. This operates on ObjectType
94  std::vector<std::string>::const_iterator funcBegin = functionNames_.begin(), funcEnd = functionNames_.end(),
95  funcIt = funcBegin;
96  for (; funcIt != funcEnd; ++funcIt) {
97  functions_.push_back(StringObjectFunction<ObjectType>(*funcIt));
98  }
99  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserFloat > userFloatMerger_
std::vector< function_type > functions_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserPtr > userDataMerger_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserCand > userCandMerger_
std::vector< std::string > functionLabels_
std::vector< std::string > functionNames_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserInt > userIntMerger_

◆ ~PATUserDataHelper()

template<class ObjectType>
pat::PATUserDataHelper< ObjectType >::~PATUserDataHelper ( )
inline

Definition at line 54 of file PATUserDataHelper.h.

54 {}

Member Function Documentation

◆ add()

template<class ObjectType>
void pat::PATUserDataHelper< ObjectType >::add ( ObjectType &  patObject,
edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)

Definition at line 113 of file PATUserDataHelper.h.

Referenced by pat::PATCompositeCandidateProducer::produce(), pat::PATGenericParticleProducer::produce(), pat::PATMETProducer::produce(), pat::PATJetUpdater::produce(), pat::PATPFParticleProducer::produce(), pat::PATPhotonProducer::produce(), pat::PATTauProducer::produce(), pat::PATJetProducer::produce(), pat::PATElectronProducer::produce(), pat::PATMuonProducer::produce(), and counter.Counter::register().

115  {
116  // Add "complex" user data to the PAT object
117  userDataMerger_.add(patObject, iEvent, iSetup);
118  userFloatMerger_.add(patObject, iEvent, iSetup);
119  userIntMerger_.add(patObject, iEvent, iSetup);
120  userCandMerger_.add(patObject, iEvent, iSetup);
121 
122  // Add "inline" user-selected functions to the PAT object
123  typename std::vector<function_type>::const_iterator funcBegin = functions_.begin(), funcEnd = functions_.end(),
124  funcIt = funcBegin;
125  if (functionLabels_.size() == functions_.size()) {
126  for (; funcIt != funcEnd; ++funcIt) {
127  double d = (*funcIt)(patObject);
128  patObject.addUserFloat(functionLabels_[funcIt - funcBegin], d);
129  }
130  }
131  }
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserFloat > userFloatMerger_
std::vector< function_type > functions_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserPtr > userDataMerger_
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserCand > userCandMerger_
std::vector< std::string > functionLabels_
int iEvent
Definition: GenABIO.cc:224
d
Definition: ztail.py:151
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserInt > userIntMerger_

◆ fillDescription()

template<class ObjectType >
void pat::PATUserDataHelper< ObjectType >::fillDescription ( edm::ParameterSetDescription iDesc)
static

Definition at line 134 of file PATUserDataHelper.h.

Referenced by pat::PATMETProducer::fillDescriptions(), pat::PATJetUpdater::fillDescriptions(), pat::PATPhotonProducer::fillDescriptions(), pat::PATTauProducer::fillDescriptions(), pat::PATJetProducer::fillDescriptions(), pat::PATElectronProducer::fillDescriptions(), and pat::PATMuonProducer::fillDescriptions().

134  {
135  edm::ParameterSetDescription dataMergerPSet;
137  iDesc.add("userClasses", dataMergerPSet);
138  iDesc.add("userFloats", dataMergerPSet);
139  iDesc.add("userInts", dataMergerPSet);
140  iDesc.add("userCands", dataMergerPSet);
141  std::vector<std::string> emptyVectorOfStrings;
142  iDesc.add<std::vector<std::string> >("userFunctions", emptyVectorOfStrings);
143  iDesc.add<std::vector<std::string> >("userFunctionLabels", emptyVectorOfStrings);
144  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescription(edm::ParameterSetDescription &iDesc)

Member Data Documentation

◆ functionLabels_

template<class ObjectType>
std::vector<std::string> pat::PATUserDataHelper< ObjectType >::functionLabels_
private

Definition at line 74 of file PATUserDataHelper.h.

◆ functionNames_

template<class ObjectType>
std::vector<std::string> pat::PATUserDataHelper< ObjectType >::functionNames_
private

Definition at line 73 of file PATUserDataHelper.h.

◆ functions_

template<class ObjectType>
std::vector<function_type> pat::PATUserDataHelper< ObjectType >::functions_
private

Definition at line 75 of file PATUserDataHelper.h.

◆ userCandMerger_

template<class ObjectType>
pat::PATUserDataMerger<ObjectType, pat::helper::AddUserCand> pat::PATUserDataHelper< ObjectType >::userCandMerger_
private

Definition at line 70 of file PATUserDataHelper.h.

◆ userDataMerger_

template<class ObjectType>
pat::PATUserDataMerger<ObjectType, pat::helper::AddUserPtr> pat::PATUserDataHelper< ObjectType >::userDataMerger_
private

Definition at line 64 of file PATUserDataHelper.h.

◆ userFloatMerger_

template<class ObjectType>
pat::PATUserDataMerger<ObjectType, pat::helper::AddUserFloat> pat::PATUserDataHelper< ObjectType >::userFloatMerger_
private

Definition at line 66 of file PATUserDataHelper.h.

◆ userIntMerger_

template<class ObjectType>
pat::PATUserDataMerger<ObjectType, pat::helper::AddUserInt> pat::PATUserDataHelper< ObjectType >::userIntMerger_
private

Definition at line 68 of file PATUserDataHelper.h.