11 #include <boost/format.hpp> 57 std::vector<std::vector<unsigned int>>
datasets;
77 edm::StreamCache<HLTriggerJSONMonitoringData::stream>,
79 edm::RunCache<HLTriggerJSONMonitoringData::run>,
81 edm::LuminosityBlockSummaryCache<HLTriggerJSONMonitoringData::lumisection>
99 std::unique_ptr<HLTriggerJSONMonitoringData::stream> beginStream(
edm::StreamID)
const override;
107 std::shared_ptr<HLTriggerJSONMonitoringData::run> globalBeginRun(
edm::Run const&,
edm::EventSetup const&)
const override;
126 static constexpr const char* streamName_ =
"streamHLTRates";
140 triggerResults_(config.getParameter<
edm::InputTag>(
"triggerResults")),
141 triggerResultsToken_(consumes<
edm::TriggerResults>(triggerResults_))
151 descriptions.
add(
"HLTriggerJSONMonitoring", desc);
155 std::unique_ptr<HLTriggerJSONMonitoringData::stream>
158 return std::make_unique<HLTriggerJSONMonitoringData::stream>();
162 std::shared_ptr<HLTriggerJSONMonitoringData::run>
165 auto rundata = std::make_shared<HLTriggerJSONMonitoringData::run>();
173 rundata->streamDestination =
"";
181 edm::LogError(
"HLTriggerJSONMonitoring") <<
"HLTConfigProvider initialization failed!" << std::endl;
184 auto const & triggerNames =
rundata->hltConfig.triggerNames();
188 const unsigned int triggersSize = triggerNames.size();
192 rundata->datasets.resize(datasetsSize);
193 for (
unsigned int ds = 0; ds < datasetsSize; ++ds) {
195 unsigned int paths =
datasets[ds].size();
197 for (
unsigned int p = 0;
p < paths;
p++) {
199 if (index < triggersSize)
205 rundata->posL1s.resize(triggersSize);
206 rundata->posPre.resize(triggersSize);
207 for (
unsigned int i = 0;
i < triggersSize; ++
i) {
210 std::vector<std::string>
const& moduleLabels =
rundata->hltConfig.moduleLabels(
i);
211 for (
unsigned int j = 0; j < moduleLabels.size(); ++j) {
213 if (label ==
"HLTL1TSeed")
215 else if (label ==
"HLTPrescaler")
242 auto & stream = * streamCache(sid);
248 if (not
rundata.hltConfig.inited())
258 assert(results.
size() == stream.hltWasRun.size());
261 for (
unsigned int i = 0;
i < results.
size(); ++
i) {
264 ++stream.hltWasRun[
i];
268 ++stream.hltAccept[
i];
271 if (index >
rundata.posL1s[
i]) ++stream.hltL1s[
i];
272 if (index >
rundata.posPre[
i]) ++stream.hltPre[
i];
274 ++stream.hltErrors[
i];
276 ++stream.hltReject[
i];
283 for (
unsigned int i = 0;
i <
rundata.datasets.size(); ++
i)
285 ++stream.datasets[
i];
291 std::shared_ptr<HLTriggerJSONMonitoringData::lumisection>
294 unsigned int triggers = 0;
297 if (
rundata.hltConfig.inited()) {
298 triggers =
rundata.hltConfig.triggerNames().size();
299 datasets =
rundata.hltConfig.datasetNames().size();
316 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltWasRun.update(0);
317 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltL1s.update(0);
318 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltPre.update(0);
319 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltAccept.update(0);
320 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltReject.update(0);
321 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltErrors.update(0);
331 auto & stream = * streamCache(sid);
333 unsigned int triggers = 0;
336 if (
rundata.hltConfig.inited()) {
337 triggers =
rundata.hltConfig.triggerNames().size();
338 datasets =
rundata.hltConfig.datasetNames().size();
342 stream.processed = 0;
343 stream.hltWasRun.assign(triggers, 0);
344 stream.hltL1s.assign(triggers, 0);
345 stream.hltPre.assign(triggers, 0);
346 stream.hltAccept.assign(triggers, 0);
347 stream.hltReject.assign(triggers, 0);
348 stream.hltErrors.assign(triggers, 0);
349 stream.datasets.assign(datasets, 0);
356 auto const& stream = * streamCache(sid);
361 if (not
rundata.hltConfig.inited())
364 unsigned int triggers =
rundata.hltConfig.triggerNames().size();
365 for (
unsigned int i = 0;
i < triggers; ++
i) {
383 unsigned int run = lumi.
run();
385 bool writeFiles =
true;
400 gethostname(hostname, 32);
404 std::stringstream sOutDef;
405 sOutDef <<
rundata.baseRunDir <<
"/" <<
"output_" << getpid() <<
".jsd";
408 unsigned int jsndataSize = 0;
409 unsigned int jsndataAdler32 = 1;
425 auto jsndataFileName =
boost::format(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsndata") % run % ls % getpid();
428 std::ofstream jsndataFile(
rundata.baseRunDir +
"/" + jsndataFileName.str());
432 jsndataFileList = jsndataFileName.str();
433 jsndataSize = result.size();
434 jsndataAdler32 =
cms::Adler32(result.c_str(), result.size());
438 unsigned int jsnProcessed = processed;
439 unsigned int jsnAccepted = processed;
440 unsigned int jsnErrorEvents = 0;
441 unsigned int jsnRetCodeMask = 0;
443 unsigned int jsnHLTErrorEvents = 0;
460 auto jsnFileName =
boost::format(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsn") % run % ls % getpid();
461 std::ofstream jsnFile(
rundata.baseRunDir +
"/" + jsnFileName.str() );
462 jsnFile << writer.write(jsn);
473 { "name" : "Processed", "type" : "integer", "operation" : "histo"}, 474 { "name" : "Path-WasRun", "type" : "integer", "operation" : "histo"}, 475 { "name" : "Path-AfterL1Seed", "type" : "integer", "operation" : "histo"}, 476 { "name" : "Path-AfterPrescale", "type" : "integer", "operation" : "histo"}, 477 { "name" : "Path-Accepted", "type" : "integer", "operation" : "histo"}, 478 { "name" : "Path-Rejected", "type" : "integer", "operation" : "histo"}, 479 { "name" : "Path-Errors", "type" : "integer", "operation" : "histo"}, 480 { "name" : "Dataset-Accepted", "type" : "integer", "operation" : "histo"} 495 content[
"Path-Names"] = triggerNames;
505 file << writer.
write(content);
std::vector< int > posL1s
static const std::string SOURCE
bool getByToken(EDGetToken token, Handle< PROD > &result) const
def analyze(function, filename, filter=None)
std::vector< unsigned int > hltPre
std::vector< unsigned int > hltL1s
HLTConfigProvider hltConfig
std::shared_ptr< HLTriggerJSONMonitoringData::run > globalBeginRun(edm::Run const &, edm::EventSetup const &) const override
#define DEFINE_FWK_MODULE(type)
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
bool shouldWriteFiles(unsigned int lumi, unsigned int *proc=0)
static void writeIniFile(HLTriggerJSONMonitoringData::run const &, unsigned int)
def setup(process, global_tag, zero_tesla=False)
Value & append(const Value &value)
Append value to array at the end.
std::vector< unsigned int > hltErrors
Run const & getRun() const
void analyze(edm::StreamID, edm::Event const &, edm::EventSetup const &) const override
jsoncollector::HistoJ< unsigned int > hltReject
std::string streamMergeType
void globalEndLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &, HLTriggerJSONMonitoringData::lumisection *) const override
std::shared_ptr< HLTriggerJSONMonitoringData::lumisection > globalBeginLuminosityBlockSummary(edm::LuminosityBlock const &, edm::EventSetup const &) const override
void streamEndLuminosityBlockSummary(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &, HLTriggerJSONMonitoringData::lumisection *) const override
virtual Json::Value toJsonValue() const
void streamBeginLuminosityBlock(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const override
const edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
jsoncollector::HistoJ< unsigned int > hltErrors
std::vector< T > & value()
static const std::string DATA
LuminosityBlockNumber_t luminosityBlock() const
unsigned int size() const
Get number of paths stored.
jsoncollector::HistoJ< unsigned int > hltPre
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
format
Some error handling for the usage.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::unique_ptr< HLTriggerJSONMonitoringData::stream > beginStream(edm::StreamID) const override
virtual std::string write(const Value &root)
Serialize a Value in JSON format.
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
void globalEndRun(edm::Run const &, edm::EventSetup const &) const override
std::vector< unsigned int > hltWasRun
jsoncollector::HistoJ< unsigned int > hltL1s
std::vector< unsigned int > datasets
const edm::InputTag triggerResults_
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.
static const std::string DEFINITION
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
jsoncollector::HistoJ< unsigned int > datasets
const std::vector< std::string > & datasetNames() const
jsoncollector::HistoJ< unsigned int > hltAccept
array value (ordered list)
std::vector< int > posPre
Run const & getRun() const