4 #ifndef PhysicsTools_PatAlgos_PATUserDataHelper_h
5 #define PhysicsTools_PatAlgos_PATUserDataHelper_h
47 template <
class ObjectType>
79 template <
class ObjectType>
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")) {
90 <<
"userFunctions and userFunctionLabels do not have the same size, they must be the same\n";
96 for (; funcIt != funcEnd; ++funcIt) {
112 template <
class ObjectType>
117 userDataMerger_.add(patObject, iEvent, iSetup);
118 userFloatMerger_.add(patObject, iEvent, iSetup);
119 userIntMerger_.add(patObject, iEvent, iSetup);
120 userCandMerger_.add(patObject, iEvent, iSetup);
123 typename std::vector<function_type>::const_iterator funcBegin = functions_.begin(), funcEnd = functions_.end(),
125 if (functionLabels_.size() == functions_.size()) {
126 for (; funcIt != funcEnd; ++funcIt) {
127 double d = (*funcIt)(patObject);
128 patObject.addUserFloat(functionLabels_[funcIt - funcBegin], d);
133 template <
class ObjectType>
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);
Assists in assimilating all pat::UserData into pat objects.
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_
StringObjectFunction< ObjectType > function_type
static void fillDescription(edm::ParameterSetDescription &iDesc)
std::vector< std::string > functionLabels_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(ObjectType &patObject, edm::Event const &iEvent, edm::EventSetup const &iSetup)
std::vector< std::string > functionNames_
static void fillDescription(edm::ParameterSetDescription &iDesc)
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserInt > userIntMerger_