4 #ifndef PhysicsTools_PatAlgos_PATUserDataHelper_h
5 #define PhysicsTools_PatAlgos_PATUserDataHelper_h
52 template<
class ObjectType>
89 template<
class ObjectType>
91 userDataMerger_ (iConfig.getParameter<edm::
ParameterSet>(
"userClasses"), iC),
92 userFloatMerger_ (iConfig.getParameter<edm::
ParameterSet>(
"userFloats"), iC),
93 userIntMerger_ (iConfig.getParameter<edm::
ParameterSet>(
"userInts"), iC),
94 userCandMerger_ (iConfig.getParameter<edm::
ParameterSet>(
"userCands"), iC),
95 functionNames_ (iConfig.getParameter<std::vector<std::
string> >(
"userFunctions")),
96 functionLabels_ (iConfig.getParameter<std::vector<std::
string> >(
"userFunctionLabels"))
101 throw cms::Exception(
"Size mismatch") <<
"userFunctions and userFunctionLabels do not have the same size, they must be the same\n";
105 std::vector<std::string>::const_iterator funcBegin =
functionNames_.begin(),
108 for ( ; funcIt != funcEnd; ++funcIt) {
125 template<
class ObjectType>
132 userDataMerger_.add( patObject, iEvent, iSetup );
133 userFloatMerger_.add( patObject, iEvent, iSetup );
134 userIntMerger_.add( patObject, iEvent, iSetup );
135 userCandMerger_.add( patObject, iEvent, iSetup );
138 typename std::vector<function_type>::const_iterator funcBegin = functions_.begin(),
139 funcEnd = functions_.end(),
141 if ( functionLabels_.size() == functions_.size() ) {
142 for ( ; funcIt != funcEnd; ++funcIt) {
143 double d = (*funcIt)( patObject );
144 patObject.addUserFloat( functionLabels_[funcIt - funcBegin], d );
152 template<
class ObjectType>
157 iDesc.
add(
"userClasses", dataMergerPSet);
158 iDesc.
add(
"userFloats", dataMergerPSet);
159 iDesc.
add(
"userInts", dataMergerPSet);
160 iDesc.
add(
"userCands", dataMergerPSet);
161 std::vector<std::string> emptyVectorOfStrings;
162 iDesc.
add<std::vector<std::string> >(
"userFunctions",emptyVectorOfStrings);
163 iDesc.
add<std::vector<std::string> >(
"userFunctionLabels",emptyVectorOfStrings);
Assists in assimilating all pat::UserData into pat objects.
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserFloat > userFloatMerger_
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_
std::vector< function_type > functions_
static void fillDescription(edm::ParameterSetDescription &iDesc)
pat::PATUserDataMerger< ObjectType, pat::helper::AddUserInt > userIntMerger_