10 #include <boost/format.hpp> 73 edm::StreamCache<L1TriggerJSONMonitoringData::stream>,
75 edm::RunCache<L1TriggerJSONMonitoringData::run>,
77 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&,
edm::EventSetup const&)
const override;
124 static constexpr const std::array<const char *, 16> tcdsTriggerTypes_ = {{
147 static constexpr const char* streamName_ =
"streamL1Rates";
163 level1Results_(config.getParameter<
edm::InputTag>(
"L1Results")),
174 descriptions.
add(
"L1TriggerJSONMonitoring", desc);
178 std::unique_ptr<L1TriggerJSONMonitoringData::stream>
181 return std::make_unique<L1TriggerJSONMonitoringData::stream>();
185 std::shared_ptr<L1TriggerJSONMonitoringData::run>
188 auto rundata = std::make_shared<L1TriggerJSONMonitoringData::run>();
196 rundata->streamDestination =
"";
207 triggerNames[
algo.second.getIndex()] =
algo.first;
209 edm::LogWarning(
"L1TriggerJSONMonitoring") <<
"L1TUtmTriggerMenu not found in the EventSetup.\nThe Level 1 Trigger rate monitoring will not include the trigger names.";
233 auto & stream = * streamCache(sid);
236 unsigned int eventType =
event.experimentType();
238 ++stream.tcdsAccept[eventType];
240 edm::LogWarning(
"L1TriggerJSONMonitoring") <<
"Unexpected event type " << eventType;
253 auto const& decision =
results.getAlgoDecisionFinal();
257 for (
unsigned int i = 0;
i < decision.size(); ++
i) {
259 ++stream.l1tAccept[
i];
262 ++stream.l1tAcceptPhysics[
i];
265 ++stream.l1tAcceptCalibration[
i];
268 ++stream.l1tAcceptRandom[
i];
277 int prescaleIndex =
results.getPreScColumn();
279 stream.prescaleIndex = prescaleIndex;
282 }
else if (stream.prescaleIndex != prescaleIndex) {
284 "Prescale index changed from " << stream.prescaleIndex <<
" to " << prescaleIndex <<
" inside lumisection " <<
event.luminosityBlock();
291 std::shared_ptr<L1TriggerJSONMonitoringData::lumisection>
320 auto & stream = * streamCache(sid);
323 stream.processed = 0;
336 auto const& stream = * streamCache(sid);
360 unsigned int run = lumi.
run();
362 bool writeFiles =
true;
377 gethostname(hostname, 32);
381 std::stringstream sOutDef;
382 sOutDef <<
rundata.baseRunDir <<
"/" <<
"output_" << getpid() <<
".jsd";
385 unsigned int jsndataSize = 0;
386 unsigned int jsndataAdler32 = 1;
410 auto jsndataFileName =
boost::format(
"run%06d_ls%04d_streamL1Rates_pid%05d.jsndata") % run % ls % getpid();
413 std::ofstream jsndataFile(
rundata.baseRunDir +
"/" + jsndataFileName.str());
417 jsndataFileList = jsndataFileName.str();
418 jsndataSize = result.size();
419 jsndataAdler32 =
cms::Adler32(result.c_str(), result.size());
423 unsigned int jsnProcessed = processed;
424 unsigned int jsnAccepted = processed;
425 unsigned int jsnErrorEvents = 0;
426 unsigned int jsnRetCodeMask = 0;
428 unsigned int jsnHLTErrorEvents = 0;
445 auto jsnFileName =
boost::format(
"run%06d_ls%04d_streamL1Rates_pid%05d.jsn") % run % ls % getpid();
446 std::ofstream jsnFile(
rundata.baseRunDir +
"/" + jsnFileName.str() );
447 jsnFile << writer.write(jsn);
457 { "name" : "Processed", "type" : "integer", "operation" : "histo"}, 458 { "name" : "L1-AlgoAccepted", "type" : "integer", "operation" : "histo"}, 459 { "name" : "L1-AlgoAccepted-Physics", "type" : "integer", "operation" : "histo"}, 460 { "name" : "L1-AlgoAccepted-Calibration", "type" : "integer", "operation" : "histo"}, 461 { "name" : "L1-AlgoAccepted-Random", "type" : "integer", "operation" : "histo"}, 462 { "name" : "L1-Global", "type" : "integer", "operation" : "histo"}, 463 { "name" : "Prescale-Index", "type" : "integer", "operation" : "sample"} 475 for (
auto const&
name: l1TriggerNames)
477 content[
"L1-Algo-Names"] = triggerNames;
487 content[
"Event-Type"] = eventTypes;
492 file << writer.
write(content);
jsoncollector::HistoJ< unsigned int > l1tAcceptRandom
static void writeJsdFile(L1TriggerJSONMonitoringData::run const &)
std::shared_ptr< L1TriggerJSONMonitoringData::lumisection > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &) const override
const edm::InputTag level1Results_
jsoncollector::HistoJ< unsigned int > l1tAccept
static const std::string SOURCE
std::vector< unsigned int > l1tAcceptPhysics
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool shouldWriteFiles(unsigned int lumi, unsigned int *proc=0)
def setup(process, global_tag, zero_tesla=False)
Value & append(const Value &value)
Append value to array at the end.
void streamEndLuminosityBlockSummary(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &, L1TriggerJSONMonitoringData::lumisection *) const override
jsoncollector::HistoJ< unsigned int > l1tAcceptCalibration
static const int kPrescaleConflict
jsoncollector::HistoJ< unsigned int > processed
virtual Json::Value toJsonValue() const
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
LuminosityBlockNumber_t luminosityBlock() const
jsoncollector::HistoJ< unsigned int > tcdsAccept
static void writeIniFile(L1TriggerJSONMonitoringData::run const &, unsigned int, std::vector< std::string > const &)
#define DEFINE_FWK_MODULE(type)
std::shared_ptr< L1TriggerJSONMonitoringData::run > globalBeginRun(edm::Run const &, edm::EventSetup const &) const override
std::string streamMergeType
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
std::vector< unsigned int > l1tAccept
format
Some error handling for the usage.
static const char * streamName_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::string streamDestination
jsoncollector::HistoJ< unsigned int > l1tAcceptPhysics
void streamBeginLuminosityBlock(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const override
void Adler32(char const *data, size_t len, uint32_t &a, uint32_t &b)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static unsigned int maxPhysicsTriggers
static const int kPrescaleUndefined
void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, L1TriggerJSONMonitoringData::lumisection *) const override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static const std::array< const char *, 16 > tcdsTriggerTypes_
std::string write(const Value &root) override
Serialize a Value in JSON format.
void globalEndRun(edm::Run const &, edm::EventSetup const &) const override
L1TriggerJSONMonitoring(const edm::ParameterSet &)
std::vector< unsigned int > l1tAcceptCalibration
void analyze(edm::StreamID, edm::Event const &, edm::EventSetup const &) const override
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > level1ResultsToken_
Writes a Value in JSON format in a human friendly way.
static const std::string DEFINITION
std::unique_ptr< L1TriggerJSONMonitoringData::stream > beginStream(edm::StreamID) const override
array value (ordered list)
const T & at(int bx, unsigned i) const
Run const & getRun() const