4 #ifndef PhysicsTools_PatAlgos_PATUserDataHelper_h
5 #define PhysicsTools_PatAlgos_PATUserDataHelper_h
48 template <
class ObjectType>
80 template <
class ObjectType>
82 : userDataMerger_(iConfig.getParameter<
edm::
ParameterSet>(
"userClasses"), iC),
83 userFloatMerger_(iConfig.getParameter<
edm::
ParameterSet>(
"userFloats"), iC),
84 userIntMerger_(iConfig.getParameter<
edm::
ParameterSet>(
"userInts"), iC),
85 userCandMerger_(iConfig.getParameter<
edm::
ParameterSet>(
"userCands"), iC),
86 functionNames_(iConfig.getParameter<
std::vector<
std::
string> >(
"userFunctions")),
87 functionLabels_(iConfig.getParameter<
std::vector<
std::
string> >(
"userFunctionLabels")) {
89 if (functionNames_.size() != functionLabels_.size()) {
91 <<
"userFunctions and userFunctionLabels do not have the same size, they must be the same\n";
95 std::vector<std::string>::const_iterator funcBegin = functionNames_.begin(), funcEnd = functionNames_.end(),
97 for (; funcIt != funcEnd; ++funcIt) {
113 template <
class ObjectType>
118 userDataMerger_.add(patObject,
iEvent, iSetup);
119 userFloatMerger_.add(patObject,
iEvent, iSetup);
120 userIntMerger_.add(patObject,
iEvent, iSetup);
121 userCandMerger_.add(patObject,
iEvent, iSetup);
124 typename std::vector<function_type>::const_iterator funcBegin = functions_.begin(), funcEnd = functions_.end(),
126 if (functionLabels_.size() == functions_.size()) {
127 for (; funcIt != funcEnd; ++funcIt) {
128 double d = (*funcIt)(patObject);
129 patObject.addUserFloat(functionLabels_[funcIt - funcBegin],
d);
134 template <
class ObjectType>
138 iDesc.
add(
"userClasses", dataMergerPSet);
139 iDesc.
add(
"userFloats", dataMergerPSet);
140 iDesc.
add(
"userInts", dataMergerPSet);
141 iDesc.
add(
"userCands", dataMergerPSet);
142 std::vector<std::string> emptyVectorOfStrings;
143 iDesc.
add<std::vector<std::string> >(
"userFunctions", emptyVectorOfStrings);
144 iDesc.
add<std::vector<std::string> >(
"userFunctionLabels", emptyVectorOfStrings);