10 #include <fmt/printf.h>
54 std::vector<std::vector<unsigned int>>
datasets;
72 edm::StreamCache<HLTriggerJSONMonitoringData::stream>,
74 edm::RunCache<HLTriggerJSONMonitoringData::run>,
76 edm::LuminosityBlockSummaryCache<HLTriggerJSONMonitoringData::lumisection>> {
144 descriptions.
add(
"HLTriggerJSONMonitoring",
desc);
149 return std::make_unique<HLTriggerJSONMonitoringData::stream>();
155 auto rundata = std::make_shared<HLTriggerJSONMonitoringData::run>();
160 rundata->streamMergeType =
164 rundata->streamDestination =
"";
165 rundata->streamMergeType =
"";
166 rundata->baseRunDir =
".";
172 edm::LogError(
"HLTriggerJSONMonitoring") <<
"HLTConfigProvider initialization failed!" << std::endl;
173 }
else if (changed) {
175 auto const&
triggerNames = rundata->hltConfig.triggerNames();
176 auto const&
datasetNames = rundata->hltConfig.datasetNames();
177 auto const&
datasets = rundata->hltConfig.datasetContents();
183 rundata->datasets.resize(datasetsSize);
184 for (
unsigned int ds = 0; ds < datasetsSize; ++ds) {
185 auto&
dataset = rundata->datasets[ds];
188 for (
unsigned int p = 0;
p <
paths;
p++) {
189 unsigned int index = rundata->hltConfig.triggerIndex(
datasets[ds][
p]);
190 if (
index < triggersSize)
196 rundata->posL1s.resize(triggersSize);
197 rundata->posPre.resize(triggersSize);
198 for (
unsigned int i = 0;
i < triggersSize; ++
i) {
199 rundata->posL1s[
i] = -1;
200 rundata->posPre[
i] = -1;
201 std::vector<std::string>
const& moduleLabels = rundata->hltConfig.moduleLabels(
i);
202 for (
unsigned int j = 0;
j < moduleLabels.size(); ++
j) {
204 if (
label ==
"HLTL1TSeed")
205 rundata->posL1s[
i] =
j;
206 else if (
label ==
"HLTPrescaler")
207 rundata->posPre[
i] =
j;
213 rundata->jsdFileName = fmt::sprintf(
"run%06d_ls0000_streamHLTRates_pid%05d.jsd",
run.run(), getpid());
228 auto&
stream = *streamCache(sid);
229 auto const& rundata = *runCache(
event.getRun().index());
234 if (not rundata.hltConfig.inited())
248 for (
unsigned int i = 0;
i <
results.size(); ++
i) {
258 if (
index > rundata.posL1s[
i])
260 if (
index > rundata.posPre[
i])
272 for (
unsigned int i = 0;
i < rundata.datasets.size(); ++
i)
273 if (std::any_of(rundata.datasets[
i].begin(), rundata.datasets[
i].end(), [&](
unsigned int path) {
282 unsigned int triggers = 0;
284 auto const& rundata = *runCache(
lumi.getRun().index());
285 if (rundata.hltConfig.inited()) {
286 triggers = rundata.hltConfig.triggerNames().size();
287 datasets = rundata.hltConfig.datasetNames().size();
303 lumidata->processed.update(0);
304 for (
unsigned int i = 0;
i < triggers; ++
i)
305 lumidata->hltWasRun.update(0);
306 for (
unsigned int i = 0;
i < triggers; ++
i)
307 lumidata->hltL1s.update(0);
308 for (
unsigned int i = 0;
i < triggers; ++
i)
309 lumidata->hltPre.update(0);
310 for (
unsigned int i = 0;
i < triggers; ++
i)
311 lumidata->hltAccept.update(0);
312 for (
unsigned int i = 0;
i < triggers; ++
i)
313 lumidata->hltReject.update(0);
314 for (
unsigned int i = 0;
i < triggers; ++
i)
315 lumidata->hltErrors.update(0);
317 lumidata->datasets.update(0);
326 auto&
stream = *streamCache(sid);
328 unsigned int triggers = 0;
330 auto const& rundata = *runCache(
lumi.getRun().index());
331 if (rundata.hltConfig.inited()) {
332 triggers = rundata.hltConfig.triggerNames().size();
333 datasets = rundata.hltConfig.datasetNames().size();
338 stream.hltWasRun.assign(triggers, 0);
339 stream.hltL1s.assign(triggers, 0);
340 stream.hltPre.assign(triggers, 0);
341 stream.hltAccept.assign(triggers, 0);
342 stream.hltReject.assign(triggers, 0);
343 stream.hltErrors.assign(triggers, 0);
352 auto const&
stream = *streamCache(sid);
353 auto const& rundata = *runCache(
lumi.getRun().index());
357 if (not rundata.hltConfig.inited())
360 unsigned int triggers = rundata.hltConfig.triggerNames().size();
361 for (
unsigned int i = 0;
i < triggers; ++
i) {
369 unsigned int datasets = rundata.hltConfig.datasetNames().size();
378 unsigned int ls =
lumi.luminosityBlock();
381 bool writeFiles =
true;
392 auto const& rundata = *runCache(
lumi.getRun().index());
397 gethostname(hostname, 32);
401 std::stringstream sOutDef;
402 sOutDef << rundata.baseRunDir <<
"/"
403 <<
"output_" << getpid() <<
".jsd";
406 unsigned int jsndataSize = 0;
407 unsigned int jsndataAdler32 = 1;
423 auto jsndataFileName = fmt::sprintf(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsndata",
run,
ls, getpid());
426 std::ofstream jsndataFile(rundata.baseRunDir +
"/" + jsndataFileName);
430 jsndataFileList = jsndataFileName;
431 jsndataSize =
result.size();
436 unsigned int jsnProcessed = processed;
437 unsigned int jsnAccepted = processed;
438 unsigned int jsnErrorEvents = 0;
439 unsigned int jsnRetCodeMask = 0;
441 unsigned int jsnHLTErrorEvents = 0;
458 auto jsnFileName = fmt::sprintf(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsn",
run,
ls, getpid());
459 std::ofstream jsnFile(rundata.baseRunDir +
"/" + jsnFileName);
460 jsnFile <<
writer.write(jsn);
468 { "name" : "Processed", "type" : "integer", "operation" : "histo"},
469 { "name" : "Path-WasRun", "type" : "integer", "operation" : "histo"},
470 { "name" : "Path-AfterL1Seed", "type" : "integer", "operation" : "histo"},
471 { "name" : "Path-AfterPrescale", "type" : "integer", "operation" : "histo"},
472 { "name" : "Path-Accepted", "type" : "integer", "operation" : "histo"},
473 { "name" : "Path-Rejected", "type" : "integer", "operation" : "histo"},
474 { "name" : "Path-Errors", "type" : "integer", "operation" : "histo"},
475 { "name" : "Dataset-Accepted", "type" : "integer", "operation" : "histo"}
495 std::string iniFileName = fmt::sprintf(
"run%06d_ls0000_streamHLTRates_pid%05d.ini",
run, getpid());