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_ = {{
148 static constexpr const char* streamName_ =
"streamL1Rates";
164 level1Results_(config.getParameter<
edm::InputTag>(
"L1Results")),
175 descriptions.
add(
"L1TriggerJSONMonitoring", desc);
179 std::unique_ptr<L1TriggerJSONMonitoringData::stream>
182 return std::make_unique<L1TriggerJSONMonitoringData::stream>();
186 std::shared_ptr<L1TriggerJSONMonitoringData::run>
189 auto rundata = std::make_shared<L1TriggerJSONMonitoringData::run>();
197 rundata->streamDestination =
"";
208 triggerNames[
algo.second.getIndex()] =
algo.first;
210 edm::LogWarning(
"L1TriggerJSONMonitoring") <<
"L1TUtmTriggerMenu not found in the EventSetup.\nThe Level 1 Trigger rate monitoring will not include the rigger names.";
234 auto & stream = * streamCache(sid);
237 unsigned int eventType =
event.experimentType();
239 ++stream.tcdsAccept[eventType];
241 edm::LogWarning(
"L1TriggerJSONMonitoring") <<
"Unexpected event type " << eventType;
254 auto const& decision =
results.getAlgoDecisionFinal();
258 for (
unsigned int i = 0;
i < decision.size(); ++
i) {
260 ++stream.l1tAccept[
i];
263 ++stream.l1tAcceptPhysics[
i];
266 ++stream.l1tAcceptCalibration[
i];
269 ++stream.l1tAcceptRandom[
i];
278 int prescaleIndex =
results.getPreScColumn();
280 stream.prescaleIndex = prescaleIndex;
283 }
else if (stream.prescaleIndex != prescaleIndex) {
285 "Prescale index changed from " << stream.prescaleIndex <<
" to " << prescaleIndex <<
" inside lumisection " <<
event.luminosityBlock();
292 std::shared_ptr<L1TriggerJSONMonitoringData::lumisection>
321 auto & stream = * streamCache(sid);
324 stream.processed = 0;
337 auto const& stream = * streamCache(sid);
361 unsigned int run = lumi.
run();
363 bool writeFiles =
true;
378 gethostname(hostname, 32);
382 std::stringstream sOutDef;
383 sOutDef <<
rundata.baseRunDir <<
"/" <<
"output_" << getpid() <<
".jsd";
386 unsigned int jsndataSize = 0;
387 unsigned int jsndataAdler32 = 1;
411 auto jsndataFileName =
boost::format(
"run%06d_ls%04d_streamL1Rates_pid%05d.jsndata") % run % ls % getpid();
414 std::ofstream jsndataFile(
rundata.baseRunDir +
"/" + jsndataFileName.str());
418 jsndataFileList = jsndataFileName.str();
419 jsndataSize = result.size();
420 jsndataAdler32 =
cms::Adler32(result.c_str(), result.size());
424 unsigned int jsnProcessed = processed;
425 unsigned int jsnAccepted = processed;
426 unsigned int jsnErrorEvents = 0;
427 unsigned int jsnRetCodeMask = 0;
429 unsigned int jsnHLTErrorEvents = 0;
446 auto jsnFileName =
boost::format(
"run%06d_ls%04d_streamL1Rates_pid%05d.jsn") % run % ls % getpid();
447 std::ofstream jsnFile(
rundata.baseRunDir +
"/" + jsnFileName.str() );
448 jsnFile << writer.write(jsn);
458 { "name" : "Processed", "type" : "integer", "operation" : "histo"}, 459 { "name" : "L1-AlgoAccepted", "type" : "integer", "operation" : "histo"}, 460 { "name" : "L1-AlgoAccepted-Physics", "type" : "integer", "operation" : "histo"}, 461 { "name" : "L1-AlgoAccepted-Calibration", "type" : "integer", "operation" : "histo"}, 462 { "name" : "L1-AlgoAccepted-Random", "type" : "integer", "operation" : "histo"}, 463 { "name" : "L1-Global", "type" : "integer", "operation" : "histo"}, 464 { "name" : "Prescale-Index", "type" : "integer", "operation" : "sample"} 476 for (
auto const&
name: l1TriggerNames)
478 content[
"L1-Algo-Names"] = triggerNames;
488 content[
"Event-Type"] = eventTypes;
493 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
def analyze(function, filename, filter=None)
#define DEFINE_FWK_MODULE(type)
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
static const unsigned int maxPhysicsTriggers
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 &)
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.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual std::string write(const Value &root)
Serialize a Value in JSON format.
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 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_
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