File indexing completed on 2024-11-14 04:15:40
0001 #ifndef HLTrigger_HLTcore_HLTConfigData_h
0002 #define HLTrigger_HLTcore_HLTConfigData_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 #include "DataFormats/HLTReco/interface/HLTPrescaleTable.h"
0016 #include "HLTrigger/HLTcore/interface/FractionalPrescale.h"
0017
0018 #include <map>
0019 #include <string>
0020 #include <vector>
0021 #include <type_traits>
0022 #include <oneapi/tbb/concurrent_unordered_map.h>
0023
0024
0025
0026
0027
0028 class HLTConfigData {
0029 public:
0030 HLTConfigData();
0031 HLTConfigData(const edm::ParameterSet* iID);
0032
0033 private:
0034
0035 void extract();
0036
0037 public:
0038
0039 void dump(const std::string& what) const;
0040
0041
0042
0043
0044 const std::string& processName() const;
0045
0046
0047 const std::string& globalTag() const;
0048
0049
0050 const std::string& tableName() const;
0051
0052
0053 unsigned int size() const;
0054
0055 unsigned int size(unsigned int trigger) const;
0056 unsigned int size(const std::string& trigger) const;
0057
0058
0059 const std::vector<std::string>& triggerNames() const;
0060 const std::string& triggerName(unsigned int triggerIndex) const;
0061
0062
0063 unsigned int triggerIndex(const std::string& triggerName) const;
0064
0065
0066 const std::vector<std::string>& moduleLabels(unsigned int trigger) const;
0067 const std::vector<std::string>& moduleLabels(const std::string& trigger) const;
0068 const std::vector<std::string>& saveTagsModules(unsigned int trigger) const;
0069 const std::vector<std::string>& saveTagsModules(const std::string& trigger) const;
0070 const std::string& moduleLabel(unsigned int trigger, unsigned int module) const;
0071 const std::string& moduleLabel(const std::string& trigger, unsigned int module) const;
0072
0073
0074 unsigned int moduleIndex(unsigned int trigger, const std::string& module) const;
0075 unsigned int moduleIndex(const std::string& trigger, const std::string& module) const;
0076
0077
0078 const std::string& moduleType(const std::string& module) const;
0079
0080
0081 const std::string& moduleEDMType(const std::string& module) const;
0082
0083
0084 const edm::ParameterSet& processPSet() const;
0085
0086
0087 const edm::ParameterSet& modulePSet(const std::string& module) const;
0088
0089
0090 bool saveTags(const std::string& module) const;
0091
0092
0093 unsigned int l1tType() const;
0094
0095
0096
0097 const std::vector<std::vector<std::pair<bool, std::string>>>& hltL1GTSeeds() const;
0098
0099 const std::vector<std::pair<bool, std::string>>& hltL1GTSeeds(const std::string& trigger) const;
0100
0101 const std::vector<std::pair<bool, std::string>>& hltL1GTSeeds(unsigned int trigger) const;
0102
0103
0104
0105 const std::vector<std::vector<std::string>>& hltL1TSeeds() const;
0106
0107 const std::vector<std::string>& hltL1TSeeds(const std::string& trigger) const;
0108
0109 const std::vector<std::string>& hltL1TSeeds(unsigned int trigger) const;
0110
0111
0112
0113 const std::vector<std::string>& streamNames() const;
0114
0115 const std::string& streamName(unsigned int stream) const;
0116
0117 unsigned int streamIndex(const std::string& stream) const;
0118
0119 const std::vector<std::vector<std::string>>& streamContents() const;
0120
0121 const std::vector<std::string>& streamContent(unsigned int stream) const;
0122
0123 const std::vector<std::string>& streamContent(const std::string& stream) const;
0124
0125
0126
0127 const std::vector<std::string>& datasetNames() const;
0128
0129 const std::string& datasetName(unsigned int dataset) const;
0130
0131 unsigned int datasetIndex(const std::string& dataset) const;
0132
0133 const std::vector<std::vector<std::string>>& datasetContents() const;
0134
0135 const std::vector<std::string>& datasetContent(unsigned int dataset) const;
0136
0137 const std::vector<std::string>& datasetContent(const std::string& dataset) const;
0138
0139
0140
0141 unsigned int prescaleSize() const;
0142
0143 template <typename T = unsigned int>
0144 T prescaleValue(unsigned int set, const std::string& trigger) const;
0145
0146 const std::vector<std::string>& prescaleLabels() const;
0147
0148 template <typename T = unsigned int>
0149 std::map<std::string, std::vector<T>> const& prescaleTable() const;
0150
0151
0152 edm::ParameterSetID id() const;
0153
0154 private:
0155 inline std::string canonicalModuleName(const std::string& module) const {
0156 return module.front() != '-' ? module : module.substr(1);
0157 }
0158
0159 const edm::ParameterSet* processPSet_;
0160
0161 std::string processName_;
0162 std::string globalTag_;
0163 std::string tableName_;
0164 std::vector<std::string> triggerNames_;
0165 std::vector<std::vector<std::string>> moduleLabels_;
0166 std::vector<std::vector<std::string>> saveTagsModules_;
0167
0168 std::map<std::string, unsigned int> triggerIndex_;
0169 std::vector<std::map<std::string, unsigned int>> moduleIndex_;
0170
0171 unsigned int l1tType_;
0172 std::vector<std::vector<std::pair<bool, std::string>>> hltL1GTSeeds_;
0173 std::vector<std::vector<std::string>> hltL1TSeeds_;
0174
0175 std::vector<std::string> streamNames_;
0176 std::map<std::string, unsigned int> streamIndex_;
0177 std::vector<std::vector<std::string>> streamContents_;
0178
0179 std::vector<std::string> datasetNames_;
0180 std::map<std::string, unsigned int> datasetIndex_;
0181 std::vector<std::vector<std::string>> datasetContents_;
0182
0183 trigger::HLTPrescaleTable hltPrescaleTable_;
0184 std::map<std::string, std::vector<double>> hltPrescaleTableValuesDouble_;
0185 std::map<std::string, std::vector<FractionalPrescale>> hltPrescaleTableValuesFractional_;
0186 struct ModuleInfo {
0187 ModuleInfo(edm::ParameterSet const* iPSet, const std::string& iClass, const std::string& iType)
0188 : pset_(iPSet), class_(iClass), edmType_(iType) {}
0189
0190 edm::ParameterSet const* pset_ = nullptr;
0191 std::string class_;
0192 std::string edmType_;
0193 };
0194
0195 const ModuleInfo& moduleInfoFor(const std::string& iModule) const;
0196 mutable oneapi::tbb::concurrent_unordered_map<std::string, ModuleInfo> modulesInfo_;
0197 };
0198
0199 template <typename T>
0200 T HLTConfigData::prescaleValue(unsigned int set, const std::string& trigger) const {
0201 static_assert(std::is_same_v<T, double> or std::is_same_v<T, FractionalPrescale>,
0202 "\n\tPlease use prescaleValue<double> or prescaleValue<FractionalPrescale>"
0203 "\n\t(other types for HLT prescales are not supported anymore by HLTConfigData)");
0204 return hltPrescaleTable_.prescale(set, trigger);
0205 }
0206
0207 template <typename T>
0208 std::map<std::string, std::vector<T>> const& HLTConfigData::prescaleTable() const {
0209 static_assert(std::is_same_v<T, double> or std::is_same_v<T, FractionalPrescale>,
0210 "\n\tPlease use prescaleTable<double> or prescaleTable<FractionalPrescale>"
0211 "\n\t(other types for HLT prescales are not supported anymore by HLTConfigData)");
0212 return hltPrescaleTable_.table();
0213 }
0214
0215 template <>
0216 std::map<std::string, std::vector<double>> const& HLTConfigData::prescaleTable() const;
0217
0218 template <>
0219 std::map<std::string, std::vector<FractionalPrescale>> const& HLTConfigData::prescaleTable() const;
0220
0221 #endif