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;
125 static constexpr const char* streamName_ =
"streamHLTRates";
139 triggerResults_(config.getParameter<
edm::InputTag>(
"triggerResults")),
140 triggerResultsToken_(consumes<
edm::TriggerResults>(triggerResults_))
150 descriptions.
add(
"HLTriggerJSONMonitoring", desc);
154 std::unique_ptr<HLTriggerJSONMonitoringData::stream>
157 return std::make_unique<HLTriggerJSONMonitoringData::stream>();
161 std::shared_ptr<HLTriggerJSONMonitoringData::run>
164 auto rundata = std::make_shared<HLTriggerJSONMonitoringData::run>();
172 rundata->streamDestination =
"";
180 edm::LogError(
"HLTriggerJSONMonitoring") <<
"HLTConfigProvider initialization failed!" << std::endl;
183 auto const & triggerNames =
rundata->hltConfig.triggerNames();
187 const unsigned int triggersSize = triggerNames.size();
191 rundata->datasets.resize(datasetsSize);
192 for (
unsigned int ds = 0; ds < datasetsSize; ++ds) {
194 unsigned int paths =
datasets[ds].size();
196 for (
unsigned int p = 0;
p < paths;
p++) {
198 if (index < triggersSize)
204 rundata->posL1s.resize(triggersSize);
205 rundata->posPre.resize(triggersSize);
206 for (
unsigned int i = 0;
i < triggersSize; ++
i) {
209 std::vector<std::string>
const& moduleLabels =
rundata->hltConfig.moduleLabels(
i);
210 for (
unsigned int j = 0; j < moduleLabels.size(); ++j) {
212 if (label ==
"HLTL1TSeed")
214 else if (label ==
"HLTPrescaler")
241 auto & stream = * streamCache(sid);
247 if (not
rundata.hltConfig.inited())
257 assert(results.
size() == stream.hltWasRun.size());
260 for (
unsigned int i = 0;
i < results.
size(); ++
i) {
263 ++stream.hltWasRun[
i];
267 ++stream.hltAccept[
i];
270 if (index >
rundata.posL1s[
i]) ++stream.hltL1s[
i];
271 if (index >
rundata.posPre[
i]) ++stream.hltPre[
i];
273 ++stream.hltErrors[
i];
275 ++stream.hltReject[
i];
282 for (
unsigned int i = 0;
i <
rundata.datasets.size(); ++
i)
284 ++stream.datasets[
i];
290 std::shared_ptr<HLTriggerJSONMonitoringData::lumisection>
293 unsigned int triggers = 0;
296 if (
rundata.hltConfig.inited()) {
297 triggers =
rundata.hltConfig.triggerNames().size();
298 datasets =
rundata.hltConfig.datasetNames().size();
315 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltWasRun.update(0);
316 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltL1s.update(0);
317 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltPre.update(0);
318 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltAccept.update(0);
319 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltReject.update(0);
320 for (
unsigned int i = 0;
i < triggers; ++
i)
lumidata->hltErrors.update(0);
330 auto & stream = * streamCache(sid);
332 unsigned int triggers = 0;
335 if (
rundata.hltConfig.inited()) {
336 triggers =
rundata.hltConfig.triggerNames().size();
337 datasets =
rundata.hltConfig.datasetNames().size();
341 stream.processed = 0;
342 stream.hltWasRun.assign(triggers, 0);
343 stream.hltL1s.assign(triggers, 0);
344 stream.hltPre.assign(triggers, 0);
345 stream.hltAccept.assign(triggers, 0);
346 stream.hltReject.assign(triggers, 0);
347 stream.hltErrors.assign(triggers, 0);
348 stream.datasets.assign(datasets, 0);
355 auto const& stream = * streamCache(sid);
360 if (not
rundata.hltConfig.inited())
363 unsigned int triggers =
rundata.hltConfig.triggerNames().size();
364 for (
unsigned int i = 0;
i < triggers; ++
i) {
382 unsigned int run = lumi.
run();
384 bool writeFiles =
true;
399 gethostname(hostname, 32);
403 std::stringstream sOutDef;
404 sOutDef <<
rundata.baseRunDir <<
"/" <<
"output_" << getpid() <<
".jsd";
407 unsigned int jsndataSize = 0;
408 unsigned int jsndataAdler32 = 1;
424 auto jsndataFileName =
boost::format(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsndata") % run % ls % getpid();
427 std::ofstream jsndataFile(
rundata.baseRunDir +
"/" + jsndataFileName.str());
431 jsndataFileList = jsndataFileName.str();
432 jsndataSize = result.size();
433 jsndataAdler32 =
cms::Adler32(result.c_str(), result.size());
437 unsigned int jsnProcessed = processed;
438 unsigned int jsnAccepted = processed;
439 unsigned int jsnErrorEvents = 0;
440 unsigned int jsnRetCodeMask = 0;
442 unsigned int jsnHLTErrorEvents = 0;
459 auto jsnFileName =
boost::format(
"run%06d_ls%04d_streamHLTRates_pid%05d.jsn") % run % ls % getpid();
460 std::ofstream jsnFile(
rundata.baseRunDir +
"/" + jsnFileName.str() );
461 jsnFile << writer.write(jsn);
472 { "name" : "Processed", "type" : "integer", "operation" : "histo"}, 473 { "name" : "Path-WasRun", "type" : "integer", "operation" : "histo"}, 474 { "name" : "Path-AfterL1Seed", "type" : "integer", "operation" : "histo"}, 475 { "name" : "Path-AfterPrescale", "type" : "integer", "operation" : "histo"}, 476 { "name" : "Path-Accepted", "type" : "integer", "operation" : "histo"}, 477 { "name" : "Path-Rejected", "type" : "integer", "operation" : "histo"}, 478 { "name" : "Path-Errors", "type" : "integer", "operation" : "histo"}, 479 { "name" : "Dataset-Accepted", "type" : "integer", "operation" : "histo"} 494 content[
"Path-Names"] = triggerNames;
504 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
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 const char * streamName_
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.
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