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>> {
137 : triggerResults_(config.getParameter<edm::
InputTag>(
"triggerResults")),
138 triggerResultsToken_(consumes<edm::TriggerResults>(triggerResults_)) {}
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);
344 stream.datasets.assign(datasets, 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();
379 unsigned int run = lumi.
run();
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();
432 jsndataAdler32 =
cms::Adler32(result.c_str(), 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);
466 file << R
"""({
"data" : [
{ "name" : "Processed", "type" : "integer", "operation" : "histo"},
{ "name" : "Path-WasRun", "type" : "integer", "operation" : "histo"},
{ "name" : "Path-AfterL1Seed", "type" : "integer", "operation" : "histo"},
{ "name" : "Path-AfterPrescale", "type" : "integer", "operation" : "histo"},
{ "name" : "Path-Accepted", "type" : "integer", "operation" : "histo"},
{ "name" : "Path-Rejected", "type" : "integer", "operation" : "histo"},
{ "name" : "Path-Errors", "type" : "integer", "operation" : "histo"},
{ "name" : "Dataset-Accepted", "type" : "integer", "operation" : "histo"}
]
}
)""";
483 std::string iniFileName = fmt::sprintf(
"run%06d_ls0000_streamHLTRates_pid%05d.ini", run, getpid());
494 static constexpr const char * streamName_
std::vector< int > posL1s
void globalEndRun(edm::Run const &, edm::EventSetup const &) const override
static const std::string SOURCE
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< unsigned int > hltPre
std::vector< unsigned int > hltL1s
HLTConfigProvider hltConfig
#define DEFINE_FWK_MODULE(type)
~HLTriggerJSONMonitoring() override=default
std::vector< std::vector< unsigned int > > datasets
HLTriggerJSONMonitoring(const edm::ParameterSet &)
bool accept() const
Has at least one path accepted the event?
const std::vector< std::string > & triggerNames() const
names of trigger paths
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
Run const & getRun() const
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
virtual Json::Value toJsonValue() const
const edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
jsoncollector::HistoJ< unsigned int > hltErrors
std::vector< T > & value()
static const std::string DATA
LuminosityBlockNumber_t luminosityBlock() const
void analyze(edm::StreamID, edm::Event const &, edm::EventSetup const &) const override
unsigned int size() const
Get number of paths stored.
jsoncollector::HistoJ< unsigned int > hltPre
std::unique_ptr< HLTriggerJSONMonitoringData::stream > beginStream(edm::StreamID) const override
std::shared_ptr< HLTriggerJSONMonitoringData::lumisection > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &) const override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const HLTPathStatus & at(const unsigned int i) const
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
std::string streamDestination
static void writeJsdFile(HLTriggerJSONMonitoringData::run const &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
jsoncollector::HistoJ< unsigned int > hltWasRun
std::string write(const Value &root) override
Serialize a Value in JSON format.
std::vector< unsigned int > hltWasRun
tuple config
parse the configuration file
void streamEndLuminosityBlockSummary(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &, HLTriggerJSONMonitoringData::lumisection *) const override
jsoncollector::HistoJ< unsigned int > hltL1s
std::vector< unsigned int > datasets
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 > processed
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::shared_ptr< HLTriggerJSONMonitoringData::run > globalBeginRun(edm::Run const &, edm::EventSetup const &) const override
const std::vector< std::string > & datasetNames() const
jsoncollector::HistoJ< unsigned int > hltAccept
array value (ordered list)
std::vector< int > posPre
Run const & getRun() const