File indexing completed on 2025-02-13 02:58:09
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 #include "Validation/HLTrigger/interface/HLTGenValObject.h"
0037
0038 namespace hltdqm {
0039
0040 template <typename ObjType>
0041 float scEtaFunc(const ObjType& obj) {
0042 return obj.superCluster()->eta();
0043 }
0044
0045
0046 template <typename ObjType>
0047 std::function<float(const ObjType&)> getUnaryFuncExtraFloat(const std::string& varName) {
0048 std::function<float(const ObjType&)> varFunc;
0049 return varFunc;
0050 }
0051
0052
0053 template <typename ObjType>
0054 std::function<float(const ObjType&)> getUnaryFuncFloat(const std::string& varName) {
0055 std::function<float(const ObjType&)> varFunc;
0056 if (varName == "et")
0057 varFunc = &ObjType::et;
0058 else if (varName == "pt")
0059 varFunc = &ObjType::pt;
0060 else if (varName == "eta")
0061 varFunc = &ObjType::eta;
0062 else if (varName == "phi")
0063 varFunc = &ObjType::phi;
0064 else if (varName == "mass")
0065 varFunc = &ObjType::mass;
0066 else
0067 varFunc = getUnaryFuncExtraFloat<ObjType>(varName);
0068
0069 if (!varFunc && !varName.empty()) {
0070 throw cms::Exception("ConfigError")
0071 << "var " << varName << " not recognised " << __FILE__ << "," << __LINE__ << std::endl;
0072 }
0073 return varFunc;
0074 }
0075
0076 template <>
0077 std::function<float(const reco::GsfElectron&)> getUnaryFuncExtraFloat<reco::GsfElectron>(const std::string& varName);
0078 template <>
0079 std::function<float(const reco::Photon&)> getUnaryFuncExtraFloat<reco::Photon>(const std::string& varName);
0080 template <>
0081 std::function<float(const HLTGenValObject&)> getUnaryFuncExtraFloat<HLTGenValObject>(const std::string& varName);
0082
0083 }
0084
0085 #endif