15 #include <fmt/printf.h> 66 std::vector<std::vector<unsigned int>>
datasets;
85 edm::StreamCache<HLTriggerJSONMonitoringData::stream>,
87 edm::RunCache<HLTriggerJSONMonitoringData::run>,
89 edm::LuminosityBlockSummaryCache<HLTriggerJSONMonitoringData::lumisection>> {
106 std::unique_ptr<HLTriggerJSONMonitoringData::stream> beginStream(
edm::StreamID)
const override;
114 std::shared_ptr<HLTriggerJSONMonitoringData::run> globalBeginRun(
edm::Run const&,
123 std::shared_ptr<HLTriggerJSONMonitoringData::lumisection> globalBeginLuminosityBlockSummary(
138 static constexpr const char* streamName_ =
"streamHLTRates";
140 static constexpr const char* datasetPathNamePrefix_ =
"Dataset_";
157 std::ofstream
file(initFileName);
160 <<
"Cannot create INITEMP file: " << initFileName <<
" error: " << strerror(errno);
169 descriptions.
add(
"HLTriggerJSONMonitoring",
desc);
174 return std::make_unique<HLTriggerJSONMonitoringData::stream>();
180 auto rundata = std::make_shared<HLTriggerJSONMonitoringData::run>();
185 rundata->streamMergeType =
189 rundata->streamDestination =
"";
190 rundata->streamMergeType =
"";
191 rundata->baseRunDir =
".";
197 edm::LogError(
"HLTriggerJSONMonitoring") <<
"HLTConfigProvider initialization failed!";
198 }
else if (changed) {
200 auto const&
triggerNames = rundata->hltConfig.triggerNames();
204 rundata->indicesOfTriggerPaths.clear();
205 rundata->indicesOfTriggerPaths.reserve(triggerNamesSize);
206 for (
auto triggerNameIdx = 0u; triggerNameIdx < triggerNamesSize; ++triggerNameIdx) {
209 rundata->indicesOfTriggerPaths.emplace_back(triggerNameIdx);
212 auto const triggersSize = rundata->indicesOfTriggerPaths.size();
215 auto const&
datasets = rundata->hltConfig.datasetContents();
216 auto const&
datasetNames = rundata->hltConfig.datasetNames();
218 rundata->datasets.resize(datasetsSize);
219 for (
auto ds = 0u; ds < datasetsSize; ++ds) {
220 auto&
dataset = rundata->datasets[ds];
225 auto const datasetPathExists =
227 if (datasetPathExists) {
232 auto const index = rundata->hltConfig.triggerIndex(datasetPathName);
233 if (
index < triggerNamesSize)
239 auto const index = rundata->hltConfig.triggerIndex(
datasets[ds][
p]);
240 if (
index < triggerNamesSize)
247 rundata->posPre.resize(triggersSize);
248 for (
auto i = 0u;
i < triggersSize; ++
i) {
249 rundata->posPre[
i] = -1;
250 auto const trigNameIndx = rundata->indicesOfTriggerPaths[
i];
251 auto const& moduleLabels = rundata->hltConfig.moduleLabels(trigNameIndx);
252 for (
auto j = 0u;
j < moduleLabels.size(); ++
j) {
253 auto const& moduleType = rundata->hltConfig.moduleType(moduleLabels[
j]);
254 if (moduleType ==
"HLTPrescaler") {
255 rundata->posPre[
i] =
j;
263 rundata->jsdFileName = fmt::sprintf(
"run%06d_ls0000_streamHLTRates_pid%05d.jsd",
run.run(), getpid());
278 auto&
stream = *streamCache(sid);
279 auto const& rundata = *runCache(
event.getRun().index());
284 if (not rundata.hltConfig.inited())
295 assert(
results.size() == rundata.hltConfig.triggerNames().size());
298 for (
auto idx = 0u;
idx < rundata.indicesOfTriggerPaths.size(); ++
idx) {
299 auto const triggerPathIdx = rundata.indicesOfTriggerPaths[
idx];
323 for (
auto i = 0u;
i < rundata.datasets.size(); ++
i)
324 if (std::any_of(rundata.datasets[
i].begin(), rundata.datasets[
i].end(), [&](
unsigned int path) {
335 auto const& rundata = *runCache(
lumi.getRun().index());
336 if (rundata.hltConfig.inited()) {
337 triggers = rundata.indicesOfTriggerPaths.size();
338 datasets = rundata.hltConfig.datasetNames().size();
354 lumidata->processed.update(0);
356 lumidata->hltWasRun.update(0);
358 lumidata->hltPrePS.update(0);
360 lumidata->hltPostPS.update(0);
362 lumidata->hltAccept.update(0);
364 lumidata->hltReject.update(0);
366 lumidata->hltErrors.update(0);
368 lumidata->datasets.update(0);
377 auto&
stream = *streamCache(sid);
381 auto const& rundata = *runCache(
lumi.getRun().index());
382 if (rundata.hltConfig.inited()) {
383 triggers = rundata.indicesOfTriggerPaths.size();
384 datasets = rundata.hltConfig.datasetNames().size();
403 auto const&
stream = *streamCache(sid);
404 auto const& rundata = *runCache(
lumi.getRun().index());
408 if (not rundata.hltConfig.inited())
411 auto const triggers = rundata.indicesOfTriggerPaths.size();
420 auto const datasets = rundata.hltConfig.datasetNames().size();
429 unsigned int ls =
lumi.luminosityBlock();
432 bool writeFiles =
true;
443 auto const& rundata = *runCache(
lumi.getRun().index());
448 gethostname(hostname, 32);
452 std::stringstream sOutDef;
453 sOutDef << rundata.baseRunDir <<
"/" 454 <<
"output_" << getpid() <<
".jsd";
457 unsigned int jsndataSize = 0;
458 unsigned int jsndataAdler32 = 1;
474 auto jsndataFileName = fmt::sprintf(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsndata",
run,
ls, getpid());
477 std::ofstream jsndataFile(rundata.baseRunDir +
"/" + jsndataFileName);
481 jsndataFileList = jsndataFileName;
482 jsndataSize =
result.size();
487 unsigned int jsnProcessed = processed;
488 unsigned int jsnAccepted = processed;
489 unsigned int jsnErrorEvents = 0;
490 unsigned int jsnRetCodeMask = 0;
492 unsigned int jsnHLTErrorEvents = 0;
509 auto jsnFileName = fmt::sprintf(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsn",
run,
ls, getpid());
510 std::ofstream jsnFile(rundata.baseRunDir +
"/" + jsnFileName);
511 jsnFile <<
writer.write(jsn);
519 { "name" : "Processed", "type" : "integer", "operation" : "histo"}, 520 { "name" : "Path-WasRun", "type" : "integer", "operation" : "histo"}, 521 { "name" : "Path-AfterL1Seed", "type" : "integer", "operation" : "histo"}, 522 { "name" : "Path-AfterPrescale", "type" : "integer", "operation" : "histo"}, 523 { "name" : "Path-Accepted", "type" : "integer", "operation" : "histo"}, 524 { "name" : "Path-Rejected", "type" : "integer", "operation" : "histo"}, 525 { "name" : "Path-Errors", "type" : "integer", "operation" : "histo"}, 526 { "name" : "Dataset-Accepted", "type" : "integer", "operation" : "histo"} 546 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
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)
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)
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
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
Writes a Value in JSON format in a human friendly way.
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
array value (ordered list)
#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 fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void writeJsdFile(HLTriggerJSONMonitoringData::run const &)
Value & append(const Value &value)
Append value to array at the end.
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
bool shouldWriteFiles(unsigned int lumi, unsigned int *proc=nullptr)
JSON (JavaScript Object Notation).
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
std::vector< int > posPre