10 #include <fmt/printf.h> 42 unsigned int processed = 0;
48 int prescaleIndex = kPrescaleUndefined;
68 int prescaleIndex = kPrescaleUndefined;
74 edm::StreamCache<L1TriggerJSONMonitoringData::stream>,
76 edm::RunCache<L1TriggerJSONMonitoringData::run>,
78 edm::LuminosityBlockSummaryCache<L1TriggerJSONMonitoringData::lumisection> > {
95 std::unique_ptr<L1TriggerJSONMonitoringData::stream> beginStream(
edm::StreamID)
const override;
103 std::shared_ptr<L1TriggerJSONMonitoringData::run> globalBeginRun(
edm::Run const&,
112 std::shared_ptr<L1TriggerJSONMonitoringData::lumisection> globalBeginLuminosityBlockSummary(
129 static constexpr const std::array<const char*, 16> tcdsTriggerTypes_ = {{
148 static constexpr const char* streamName_ =
"streamL1Rates";
170 std::ofstream
file(initFileName);
173 <<
"Cannot create INITEMP file: " << initFileName <<
" error: " << strerror(errno);
182 descriptions.
add(
"L1TriggerJSONMonitoring",
desc);
187 return std::make_unique<L1TriggerJSONMonitoringData::stream>();
193 auto rundata = std::make_shared<L1TriggerJSONMonitoringData::run>();
198 rundata->streamMergeType =
202 rundata->streamDestination =
"";
203 rundata->streamMergeType =
"";
204 rundata->baseRunDir =
".";
210 if (menuHandle.isValid()) {
211 for (
auto const&
algo : menuHandle->getAlgorithmMap())
214 edm::LogWarning(
"L1TriggerJSONMonitoring") <<
"L1TUtmTriggerMenu not found in the EventSetup.\nThe Level 1 Trigger " 215 "rate monitoring will not include the trigger names.";
219 rundata->jsdFileName = fmt::sprintf(
"run%06d_ls0000_streamL1Rates_pid%05d.jsd",
run.run(), getpid());
234 auto&
stream = *streamCache(sid);
237 unsigned int eventType =
event.experimentType();
255 auto const& decision =
results.getAlgoDecisionFinal();
259 for (
unsigned int i = 0;
i < decision.size(); ++
i) {
267 ++
stream.l1tAcceptCalibration[
i];
279 int prescaleIndex =
results.getPreScColumn();
281 stream.prescaleIndex = prescaleIndex;
284 }
else if (
stream.prescaleIndex != prescaleIndex) {
285 edm::LogWarning(
"L1TriggerJSONMonitoring") <<
"Prescale index changed from " <<
stream.prescaleIndex <<
" to " 286 << prescaleIndex <<
" inside lumisection " <<
event.luminosityBlock();
305 lumidata->processed.update(0);
307 lumidata->l1tAccept.update(0);
309 lumidata->l1tAcceptPhysics.update(0);
311 lumidata->l1tAcceptCalibration.update(0);
313 lumidata->l1tAcceptRandom.update(0);
315 lumidata->tcdsAccept.update(0);
325 auto&
stream = *streamCache(sid);
342 auto const&
stream = *streamCache(sid);
365 unsigned int ls =
lumi.luminosityBlock();
368 bool writeFiles =
true;
379 auto const& rundata = *runCache(
lumi.getRun().index());
384 gethostname(hostname, 32);
388 std::stringstream sOutDef;
389 sOutDef << rundata.baseRunDir <<
"/" 390 <<
"output_" << getpid() <<
".jsd";
393 unsigned int jsndataSize = 0;
394 unsigned int jsndataAdler32 = 1;
418 auto jsndataFileName = fmt::sprintf(
"run%06d_ls%04d_streamL1Rates_pid%05d.jsndata",
run,
ls, getpid());
421 std::ofstream jsndataFile(rundata.baseRunDir +
"/" + jsndataFileName);
425 jsndataFileList = jsndataFileName;
426 jsndataSize =
result.size();
431 unsigned int jsnProcessed = processed;
432 unsigned int jsnAccepted = processed;
433 unsigned int jsnErrorEvents = 0;
434 unsigned int jsnRetCodeMask = 0;
436 unsigned int jsnHLTErrorEvents = 0;
453 auto jsnFileName = fmt::sprintf(
"run%06d_ls%04d_streamL1Rates_pid%05d.jsn",
run,
ls, getpid());
454 std::ofstream jsnFile(rundata.baseRunDir +
"/" + jsnFileName);
455 jsnFile <<
writer.write(jsn);
463 { "name" : "Processed", "type" : "integer", "operation" : "histo"}, 464 { "name" : "L1-AlgoAccepted", "type" : "integer", "operation" : "histo"}, 465 { "name" : "L1-AlgoAccepted-Physics", "type" : "integer", "operation" : "histo"}, 466 { "name" : "L1-AlgoAccepted-Calibration", "type" : "integer", "operation" : "histo"}, 467 { "name" : "L1-AlgoAccepted-Random", "type" : "integer", "operation" : "histo"}, 468 { "name" : "L1-Global", "type" : "integer", "operation" : "histo"}, 469 { "name" : "Prescale-Index", "type" : "integer", "operation" : "sample"} 477 std::vector<std::string>
const& l1TriggerNames) {
481 for (
auto const&
name : l1TriggerNames)
495 std::string iniFileName = fmt::sprintf(
"run%06d_ls0000_streamL1Rates_pid%05d.ini",
run, getpid());
jsoncollector::HistoJ< unsigned int > l1tAcceptRandom
static constexpr const int kPrescaleConflict
static void writeJsdFile(L1TriggerJSONMonitoringData::run const &)
const edm::InputTag level1Results_
jsoncollector::HistoJ< unsigned int > l1tAccept
static const std::string SOURCE
std::vector< unsigned int > l1tAcceptPhysics
void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, L1TriggerJSONMonitoringData::lumisection *) const override
jsoncollector::HistoJ< unsigned int > l1tAcceptCalibration
jsoncollector::HistoJ< unsigned int > processed
Log< level::Error, false > LogError
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< T > & value()
std::vector< unsigned int > tcdsAccept
static const std::string DATA
jsoncollector::HistoJ< unsigned int > tcdsAccept
static void writeIniFile(L1TriggerJSONMonitoringData::run const &, unsigned int, std::vector< std::string > const &)
static constexpr const int kPrescaleUndefined
std::string streamMergeType
std::shared_ptr< L1TriggerJSONMonitoringData::lumisection > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &) const override
Writes a Value in JSON format in a human friendly way.
std::vector< unsigned int > l1tAcceptRandom
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
array value (ordered list)
#define DEFINE_FWK_MODULE(type)
std::vector< unsigned int > l1tAccept
std::string streamDestination
jsoncollector::HistoJ< unsigned int > l1tAcceptPhysics
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
virtual Json::Value toJsonValue() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void globalEndRun(edm::Run const &, edm::EventSetup const &) const override
Value & append(const Value &value)
Append value to array at the end.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static constexpr const std::array< const char *, 16 > tcdsTriggerTypes_
const edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > l1tUtmTriggerMenuRcdToken_
void streamEndLuminosityBlockSummary(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &, L1TriggerJSONMonitoringData::lumisection *) const override
void streamBeginLuminosityBlock(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const override
void analyze(edm::StreamID, edm::Event const &, edm::EventSetup const &) const override
std::unique_ptr< L1TriggerJSONMonitoringData::stream > beginStream(edm::StreamID) const override
L1TriggerJSONMonitoring(const edm::ParameterSet &)
std::vector< unsigned int > l1tAcceptCalibration
static constexpr unsigned int maxPhysicsTriggers
std::shared_ptr< L1TriggerJSONMonitoringData::run > globalBeginRun(edm::Run const &, edm::EventSetup const &) const override
Log< level::Warning, false > LogWarning
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > level1ResultsToken_
bool shouldWriteFiles(unsigned int lumi, unsigned int *proc=nullptr)
JSON (JavaScript Object Notation).
static const std::string DEFINITION
static constexpr const char * streamName_