58 desc.
setComment(
"Plugin to write payloads of type AlCaRecoTriggerBits");
59 desc.
add<
unsigned int>(
"firstRunIOV", 1);
60 desc.
add<
int>(
"lastRunIOV", -1);
61 desc.
add<
bool>(
"startEmpty",
true);
62 desc.
add<std::vector<std::string>>(
"listNamesRemove", {});
66 desc_triggeListsToAdd.add<std::vector<std::string>>(
"hltPaths");
67 std::vector<edm::ParameterSet> default_triggerListsToAdd;
68 desc.
addVPSet(
"triggerListsAdd", desc_triggeListsToAdd, default_triggerListsToAdd);
73 std::vector<edm::ParameterSet> default_alcarecoToReplace;
74 desc.
addVPSet(
"alcarecoToReplace", desc_alcarecoToReplace, default_alcarecoToReplace);
83 firstRunIOV_(cfg.getParameter<unsigned int>(
"firstRunIOV")),
84 lastRunIOV_(cfg.getParameter<int>(
"lastRunIOV")),
85 startEmpty_(cfg.getParameter<bool>(
"startEmpty")),
86 listNamesRemove_(cfg.getParameter<std::
vector<std::
string>>(
"listNamesRemove")),
88 alcarecoReplace_(cfg.getParameter<std::
vector<edm::
ParameterSet>>(
"alcarecoToReplace")) {}
94 <<
"Writing to DB to be done only once, set\n"
95 <<
"'process.maxEvents = cms.untracked.PSet(input = cms.untracked.int32(1))'\n"
96 <<
" next time. But your writing is fine.)";
101 std::unique_ptr<AlCaRecoTriggerBits> bitsToWrite;
103 bitsToWrite = std::make_unique<AlCaRecoTriggerBits>();
124 for (std::vector<std::string>::const_iterator iKey = keys.begin(), endKey = keys.end(); iKey != endKey; ++iKey) {
125 if (triggerMap.find(*iKey) != triggerMap.end()) {
130 triggerMap.erase(*iKey);
132 throw cms::Exception(
"BadConfig") <<
"[AlCaRecoTriggerBitsRcdUpdate::removeKeysFromMap] "
133 <<
"Cannot remove key '" << *iKey <<
"' since not in "
134 <<
"list - typo in configuration?\n";
144 std::vector<std::pair<std::string, std::string>> keyPairs;
145 keyPairs.reserve(alcarecoReplace.size());
147 for (
auto &iSet : alcarecoReplace) {
150 keyPairs.push_back(std::make_pair(oldKey, newKey));
153 for (
auto &iKey : keyPairs) {
154 if (triggerMap.find(iKey.first) != triggerMap.end()) {
155 std::string bitsToReplace = triggerMap[iKey.first];
156 triggerMap.erase(iKey.first);
157 triggerMap[iKey.second] = bitsToReplace;
160 <<
"[AlCaRecoTriggerBitsRcdUpdate::replaceKeysFromMap] "
161 <<
"Cannot replace key '" << iKey.first <<
"with " << iKey.second <<
" since not in "
162 <<
"list - typo in configuration?\n";
175 for (std::vector<edm::ParameterSet>::const_iterator iSet = triggerListsAdd.begin(); iSet != triggerListsAdd.end();
177 const std::vector<std::string>
paths(iSet->getParameter<std::vector<std::string>>(
"hltPaths"));
183 if (triggerMap.find(filter) != triggerMap.end()) {
184 throw cms::Exception(
"BadConfig") <<
"List name '" << filter <<
"' already in map, either "
185 <<
"remove from 'triggerListsAdd' or "
186 <<
" add to 'listNamesRemove'.\n";
188 triggerMap[
filter] = mergedPaths;
200 throw cms::Exception(
"NotAvailable") <<
"PoolDBOutputService not available.\n";
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const edm::ESGetToken< AlCaRecoTriggerBits, AlCaRecoTriggerBitsRcd > triggerBitsToken_
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
std::map< std::string, std::string > m_alcarecoToTrig
#define DEFINE_FWK_MODULE(type)
bool addTriggerLists(const std::vector< edm::ParameterSet > &triggerListsAdd, AlCaRecoTriggerBits &bits) const
unsigned int nEventCalls_
std::map< std::string, std::string > TriggerMap
const std::vector< edm::ParameterSet > triggerListsAdd_
bool getData(T &iHolder) const
void setComment(std::string const &value)
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
const std::vector< edm::ParameterSet > alcarecoReplace_
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
const unsigned int firstRunIOV_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void writeBitsToDB(const AlCaRecoTriggerBits &bitsToWrite) const
~AlCaRecoTriggerBitsRcdUpdate() override=default
Log< level::Info, false > LogInfo
std::string compose(const std::vector< std::string > &paths) const
Compose several paths into one string :
bool removeKeysFromMap(const std::vector< std::string > &keys, TriggerMap &triggerMap) const
AlCaRecoTriggerBitsRcdUpdate(const edm::ParameterSet &cfg)
const std::vector< std::string > listNamesRemove_
Log< level::Warning, false > LogWarning
bool replaceKeysFromMap(const std::vector< edm::ParameterSet > &alcarecoReplace, TriggerMap &triggerMap) const