File indexing completed on 2023-03-17 10:58:28
0001 #ifndef DQMOffline_Trigger_FunctionDefs_h
0002 #define DQMOffline_Trigger_FunctionDefs_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "FWCore/Utilities/interface/Exception.h"
0030
0031 #include <vector>
0032 #include <functional>
0033
0034 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
0035 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0036
0037 namespace hltdqm {
0038
0039 template <typename ObjType>
0040 float scEtaFunc(const ObjType& obj) {
0041 return obj.superCluster()->eta();
0042 }
0043
0044
0045 template <typename ObjType>
0046 std::function<float(const ObjType&)> getUnaryFuncExtraFloat(const std::string& varName) {
0047 std::function<float(const ObjType&)> varFunc;
0048 return varFunc;
0049 }
0050
0051
0052 template <typename ObjType>
0053 std::function<float(const ObjType&)> getUnaryFuncFloat(const std::string& varName) {
0054 std::function<float(const ObjType&)> varFunc;
0055 if (varName == "et")
0056 varFunc = &ObjType::et;
0057 else if (varName == "pt")
0058 varFunc = &ObjType::pt;
0059 else if (varName == "eta")
0060 varFunc = &ObjType::eta;
0061 else if (varName == "phi")
0062 varFunc = &ObjType::phi;
0063 else
0064 varFunc = getUnaryFuncExtraFloat<ObjType>(varName);
0065
0066 if (!varFunc && !varName.empty()) {
0067 throw cms::Exception("ConfigError")
0068 << "var " << varName << " not recognised " << __FILE__ << "," << __LINE__ << std::endl;
0069 }
0070 return varFunc;
0071 }
0072
0073 template <>
0074 std::function<float(const reco::GsfElectron&)> getUnaryFuncExtraFloat<reco::GsfElectron>(const std::string& varName);
0075 template <>
0076 std::function<float(const reco::Photon&)> getUnaryFuncExtraFloat<reco::Photon>(const std::string& varName);
0077
0078 }
0079
0080 #endif