15 #include <fmt/printf.h> 64 std::vector<std::vector<unsigned int>>
datasets;
83 edm::StreamCache<HLTriggerJSONMonitoringData::stream>,
85 edm::RunCache<HLTriggerJSONMonitoringData::run>,
87 edm::LuminosityBlockSummaryCache<HLTriggerJSONMonitoringData::lumisection>> {
155 std::ofstream
file(initFileName);
158 <<
"Cannot create INITEMP file: " << initFileName <<
" error: " << strerror(errno);
167 descriptions.
add(
"HLTriggerJSONMonitoring",
desc);
172 return std::make_unique<HLTriggerJSONMonitoringData::stream>();
178 auto rundata = std::make_shared<HLTriggerJSONMonitoringData::run>();
183 rundata->streamMergeType =
187 rundata->streamDestination =
"";
188 rundata->streamMergeType =
"";
189 rundata->baseRunDir =
".";
195 edm::LogError(
"HLTriggerJSONMonitoring") <<
"HLTConfigProvider initialization failed!";
196 }
else if (changed) {
198 auto const&
triggerNames = rundata->hltConfig.triggerNames();
202 rundata->indicesOfTriggerPaths.clear();
203 rundata->indicesOfTriggerPaths.reserve(triggerNamesSize);
204 for (
auto triggerNameIdx = 0u; triggerNameIdx < triggerNamesSize; ++triggerNameIdx) {
207 rundata->indicesOfTriggerPaths.emplace_back(triggerNameIdx);
210 auto const triggersSize = rundata->indicesOfTriggerPaths.size();
213 auto const&
datasets = rundata->hltConfig.datasetContents();
214 auto const&
datasetNames = rundata->hltConfig.datasetNames();
216 rundata->datasets.resize(datasetsSize);
217 for (
auto ds = 0u; ds < datasetsSize; ++ds) {
218 auto&
dataset = rundata->datasets[ds];
223 auto const datasetPathExists =
225 if (datasetPathExists) {
230 auto const index = rundata->hltConfig.triggerIndex(datasetPathName);
231 if (
index < triggerNamesSize)
237 auto const index = rundata->hltConfig.triggerIndex(
datasets[ds][
p]);
238 if (
index < triggerNamesSize)
245 rundata->posPre.resize(triggersSize);
246 for (
auto i = 0u;
i < triggersSize; ++
i) {
247 rundata->posPre[
i] = -1;
248 auto const trigNameIndx = rundata->indicesOfTriggerPaths[
i];
249 auto const& moduleLabels = rundata->hltConfig.moduleLabels(trigNameIndx);
250 for (
auto j = 0u;
j < moduleLabels.size(); ++
j) {
251 auto const& moduleType = rundata->hltConfig.moduleType(moduleLabels[
j]);
252 if (moduleType ==
"HLTPrescaler") {
253 rundata->posPre[
i] =
j;
261 rundata->jsdFileName = fmt::sprintf(
"run%06d_ls0000_streamHLTRates_pid%05d.jsd",
run.run(), getpid());
276 auto&
stream = *streamCache(sid);
277 auto const& rundata = *runCache(
event.getRun().index());
282 if (not rundata.hltConfig.inited())
293 assert(
results.size() == rundata.hltConfig.triggerNames().size());
296 for (
auto idx = 0u;
idx < rundata.indicesOfTriggerPaths.size(); ++
idx) {
297 auto const triggerPathIdx = rundata.indicesOfTriggerPaths[
idx];
321 for (
auto i = 0u;
i < rundata.datasets.size(); ++
i)
322 if (std::any_of(rundata.datasets[
i].begin(), rundata.datasets[
i].end(), [&](
unsigned int path) {
331 unsigned int triggers = 0;
333 auto const& rundata = *runCache(
lumi.getRun().index());
334 if (rundata.hltConfig.inited()) {
335 triggers = rundata.indicesOfTriggerPaths.size();
336 datasets = rundata.hltConfig.datasetNames().size();
352 lumidata->processed.update(0);
353 for (
unsigned int i = 0;
i < triggers; ++
i)
354 lumidata->hltWasRun.update(0);
355 for (
unsigned int i = 0;
i < triggers; ++
i)
356 lumidata->hltPrePS.update(0);
357 for (
unsigned int i = 0;
i < triggers; ++
i)
358 lumidata->hltPostPS.update(0);
359 for (
unsigned int i = 0;
i < triggers; ++
i)
360 lumidata->hltAccept.update(0);
361 for (
unsigned int i = 0;
i < triggers; ++
i)
362 lumidata->hltReject.update(0);
363 for (
unsigned int i = 0;
i < triggers; ++
i)
364 lumidata->hltErrors.update(0);
366 lumidata->datasets.update(0);
375 auto&
stream = *streamCache(sid);
377 unsigned int triggers = 0;
379 auto const& rundata = *runCache(
lumi.getRun().index());
380 if (rundata.hltConfig.inited()) {
381 triggers = rundata.indicesOfTriggerPaths.size();
382 datasets = rundata.hltConfig.datasetNames().size();
387 stream.hltWasRun.assign(triggers, 0);
388 stream.hltPrePS.assign(triggers, 0);
389 stream.hltPostPS.assign(triggers, 0);
390 stream.hltAccept.assign(triggers, 0);
391 stream.hltReject.assign(triggers, 0);
392 stream.hltErrors.assign(triggers, 0);
401 auto const&
stream = *streamCache(sid);
402 auto const& rundata = *runCache(
lumi.getRun().index());
406 if (not rundata.hltConfig.inited())
409 auto const triggers = rundata.indicesOfTriggerPaths.size();
410 for (
auto i = 0u;
i < triggers; ++
i) {
418 auto const datasets = rundata.hltConfig.datasetNames().size();
427 unsigned int ls =
lumi.luminosityBlock();
430 bool writeFiles =
true;
441 auto const& rundata = *runCache(
lumi.getRun().index());
446 gethostname(hostname, 32);
450 std::stringstream sOutDef;
451 sOutDef << rundata.baseRunDir <<
"/" 452 <<
"output_" << getpid() <<
".jsd";
455 unsigned int jsndataSize = 0;
456 unsigned int jsndataAdler32 = 1;
472 auto jsndataFileName = fmt::sprintf(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsndata",
run,
ls, getpid());
475 std::ofstream jsndataFile(rundata.baseRunDir +
"/" + jsndataFileName);
479 jsndataFileList = jsndataFileName;
480 jsndataSize =
result.size();
485 unsigned int jsnProcessed = processed;
486 unsigned int jsnAccepted = processed;
487 unsigned int jsnErrorEvents = 0;
488 unsigned int jsnRetCodeMask = 0;
490 unsigned int jsnHLTErrorEvents = 0;
507 auto jsnFileName = fmt::sprintf(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsn",
run,
ls, getpid());
508 std::ofstream jsnFile(rundata.baseRunDir +
"/" + jsnFileName);
509 jsnFile <<
writer.write(jsn);
517 { "name" : "Processed", "type" : "integer", "operation" : "histo"}, 518 { "name" : "Path-WasRun", "type" : "integer", "operation" : "histo"}, 519 { "name" : "Path-AfterL1Seed", "type" : "integer", "operation" : "histo"}, 520 { "name" : "Path-AfterPrescale", "type" : "integer", "operation" : "histo"}, 521 { "name" : "Path-Accepted", "type" : "integer", "operation" : "histo"}, 522 { "name" : "Path-Rejected", "type" : "integer", "operation" : "histo"}, 523 { "name" : "Path-Errors", "type" : "integer", "operation" : "histo"}, 524 { "name" : "Dataset-Accepted", "type" : "integer", "operation" : "histo"} 544 std::string iniFileName = fmt::sprintf(
"run%06d_ls0000_streamHLTRates_pid%05d.ini",
run, getpid());
static constexpr const char * streamName_
void globalEndRun(edm::Run const &, edm::EventSetup const &) const override
static constexpr const char * datasetPathNamePrefix_
static const std::string SOURCE
HLTConfigProvider hltConfig
~HLTriggerJSONMonitoring() override=default
std::vector< std::vector< unsigned int > > datasets
HLTriggerJSONMonitoring(const edm::ParameterSet &)
void streamBeginLuminosityBlock(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const override
static void writeIniFile(HLTriggerJSONMonitoringData::run const &, unsigned int)
Value & append(const Value &value)
Append value to array at the end.
std::vector< unsigned int > hltErrors
jsoncollector::HistoJ< unsigned int > hltReject
std::string streamMergeType
Log< level::Error, false > LogError
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
jsoncollector::HistoJ< unsigned int > hltErrors
std::vector< T > & value()
static const std::string DATA
void analyze(edm::StreamID, edm::Event const &, edm::EventSetup const &) const override
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
std::unique_ptr< HLTriggerJSONMonitoringData::stream > beginStream(edm::StreamID) const override
std::shared_ptr< HLTriggerJSONMonitoringData::lumisection > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &) const override
#define DEFINE_FWK_MODULE(type)
std::vector< unsigned int > hltPrePS
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
std::string streamDestination
virtual Json::Value toJsonValue() const
static void writeJsdFile(HLTriggerJSONMonitoringData::run const &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
jsoncollector::HistoJ< unsigned int > hltWasRun
const std::vector< std::string > & triggerNames() const
names of trigger paths
std::vector< unsigned int > hltWasRun
void streamEndLuminosityBlockSummary(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &, HLTriggerJSONMonitoringData::lumisection *) const override
std::vector< unsigned int > datasets
std::vector< unsigned int > hltPostPS
const edm::InputTag triggerResults_
void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, HLTriggerJSONMonitoringData::lumisection *) const override
std::vector< unsigned int > hltAccept
jsoncollector::HistoJ< unsigned int > hltPrePS
jsoncollector::HistoJ< unsigned int > processed
const std::vector< std::string > & datasetNames() const
std::vector< unsigned int > hltReject
Writes a Value in JSON format in a human friendly way.
bool shouldWriteFiles(unsigned int lumi, unsigned int *proc=nullptr)
static const std::string DEFINITION
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
jsoncollector::HistoJ< unsigned int > datasets
std::vector< unsigned int > indicesOfTriggerPaths
std::shared_ptr< HLTriggerJSONMonitoringData::run > globalBeginRun(edm::Run const &, edm::EventSetup const &) const override
jsoncollector::HistoJ< unsigned int > hltAccept
jsoncollector::HistoJ< unsigned int > hltPostPS
array value (ordered list)
std::vector< int > posPre