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>> {
157 descriptions.
add(
"HLTriggerJSONMonitoring",
desc);
162 return std::make_unique<HLTriggerJSONMonitoringData::stream>();
168 auto rundata = std::make_shared<HLTriggerJSONMonitoringData::run>();
173 rundata->streamMergeType =
177 rundata->streamDestination =
"";
178 rundata->streamMergeType =
"";
179 rundata->baseRunDir =
".";
185 edm::LogError(
"HLTriggerJSONMonitoring") <<
"HLTConfigProvider initialization failed!";
186 }
else if (changed) {
188 auto const&
triggerNames = rundata->hltConfig.triggerNames();
192 rundata->indicesOfTriggerPaths.clear();
193 rundata->indicesOfTriggerPaths.reserve(triggerNamesSize);
194 for (
auto triggerNameIdx = 0u; triggerNameIdx < triggerNamesSize; ++triggerNameIdx) {
197 rundata->indicesOfTriggerPaths.emplace_back(triggerNameIdx);
200 auto const triggersSize = rundata->indicesOfTriggerPaths.size();
203 auto const&
datasets = rundata->hltConfig.datasetContents();
204 auto const&
datasetNames = rundata->hltConfig.datasetNames();
206 rundata->datasets.resize(datasetsSize);
207 for (
auto ds = 0u; ds < datasetsSize; ++ds) {
208 auto&
dataset = rundata->datasets[ds];
213 auto const datasetPathExists =
215 if (datasetPathExists) {
220 auto const index = rundata->hltConfig.triggerIndex(datasetPathName);
221 if (
index < triggerNamesSize)
227 auto const index = rundata->hltConfig.triggerIndex(
datasets[ds][
p]);
228 if (
index < triggerNamesSize)
235 rundata->posPre.resize(triggersSize);
236 for (
auto i = 0u;
i < triggersSize; ++
i) {
237 rundata->posPre[
i] = -1;
238 auto const trigNameIndx = rundata->indicesOfTriggerPaths[
i];
239 auto const& moduleLabels = rundata->hltConfig.moduleLabels(trigNameIndx);
240 for (
auto j = 0u;
j < moduleLabels.size(); ++
j) {
241 auto const& moduleType = rundata->hltConfig.moduleType(moduleLabels[
j]);
242 if (moduleType ==
"HLTPrescaler") {
243 rundata->posPre[
i] =
j;
251 rundata->jsdFileName = fmt::sprintf(
"run%06d_ls0000_streamHLTRates_pid%05d.jsd",
run.run(), getpid());
266 auto&
stream = *streamCache(sid);
267 auto const& rundata = *runCache(
event.getRun().index());
272 if (not rundata.hltConfig.inited())
283 assert(
results.size() == rundata.hltConfig.triggerNames().size());
286 for (
auto idx = 0u;
idx < rundata.indicesOfTriggerPaths.size(); ++
idx) {
287 auto const triggerPathIdx = rundata.indicesOfTriggerPaths[
idx];
311 for (
auto i = 0u;
i < rundata.datasets.size(); ++
i)
312 if (std::any_of(rundata.datasets[
i].begin(), rundata.datasets[
i].end(), [&](
unsigned int path) {
321 unsigned int triggers = 0;
323 auto const& rundata = *runCache(
lumi.getRun().index());
324 if (rundata.hltConfig.inited()) {
325 triggers = rundata.indicesOfTriggerPaths.size();
326 datasets = rundata.hltConfig.datasetNames().size();
342 lumidata->processed.update(0);
343 for (
unsigned int i = 0;
i < triggers; ++
i)
344 lumidata->hltWasRun.update(0);
345 for (
unsigned int i = 0;
i < triggers; ++
i)
346 lumidata->hltPrePS.update(0);
347 for (
unsigned int i = 0;
i < triggers; ++
i)
348 lumidata->hltPostPS.update(0);
349 for (
unsigned int i = 0;
i < triggers; ++
i)
350 lumidata->hltAccept.update(0);
351 for (
unsigned int i = 0;
i < triggers; ++
i)
352 lumidata->hltReject.update(0);
353 for (
unsigned int i = 0;
i < triggers; ++
i)
354 lumidata->hltErrors.update(0);
356 lumidata->datasets.update(0);
365 auto&
stream = *streamCache(sid);
367 unsigned int triggers = 0;
369 auto const& rundata = *runCache(
lumi.getRun().index());
370 if (rundata.hltConfig.inited()) {
371 triggers = rundata.indicesOfTriggerPaths.size();
372 datasets = rundata.hltConfig.datasetNames().size();
377 stream.hltWasRun.assign(triggers, 0);
378 stream.hltPrePS.assign(triggers, 0);
379 stream.hltPostPS.assign(triggers, 0);
380 stream.hltAccept.assign(triggers, 0);
381 stream.hltReject.assign(triggers, 0);
382 stream.hltErrors.assign(triggers, 0);
391 auto const&
stream = *streamCache(sid);
392 auto const& rundata = *runCache(
lumi.getRun().index());
396 if (not rundata.hltConfig.inited())
399 auto const triggers = rundata.indicesOfTriggerPaths.size();
400 for (
auto i = 0u;
i < triggers; ++
i) {
408 auto const datasets = rundata.hltConfig.datasetNames().size();
417 unsigned int ls =
lumi.luminosityBlock();
420 bool writeFiles =
true;
431 auto const& rundata = *runCache(
lumi.getRun().index());
436 gethostname(hostname, 32);
440 std::stringstream sOutDef;
441 sOutDef << rundata.baseRunDir <<
"/" 442 <<
"output_" << getpid() <<
".jsd";
445 unsigned int jsndataSize = 0;
446 unsigned int jsndataAdler32 = 1;
462 auto jsndataFileName = fmt::sprintf(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsndata",
run,
ls, getpid());
465 std::ofstream jsndataFile(rundata.baseRunDir +
"/" + jsndataFileName);
469 jsndataFileList = jsndataFileName;
470 jsndataSize =
result.size();
475 unsigned int jsnProcessed = processed;
476 unsigned int jsnAccepted = processed;
477 unsigned int jsnErrorEvents = 0;
478 unsigned int jsnRetCodeMask = 0;
480 unsigned int jsnHLTErrorEvents = 0;
497 auto jsnFileName = fmt::sprintf(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsn",
run,
ls, getpid());
498 std::ofstream jsnFile(rundata.baseRunDir +
"/" + jsnFileName);
499 jsnFile <<
writer.write(jsn);
507 { "name" : "Processed", "type" : "integer", "operation" : "histo"}, 508 { "name" : "Path-WasRun", "type" : "integer", "operation" : "histo"}, 509 { "name" : "Path-AfterL1Seed", "type" : "integer", "operation" : "histo"}, 510 { "name" : "Path-AfterPrescale", "type" : "integer", "operation" : "histo"}, 511 { "name" : "Path-Accepted", "type" : "integer", "operation" : "histo"}, 512 { "name" : "Path-Rejected", "type" : "integer", "operation" : "histo"}, 513 { "name" : "Path-Errors", "type" : "integer", "operation" : "histo"}, 514 { "name" : "Dataset-Accepted", "type" : "integer", "operation" : "histo"} 534 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
#define DEFINE_FWK_MODULE(type)
~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
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