11 #include <boost/format.hpp> 55 std::vector<std::vector<unsigned int>>
datasets;
73 edm::StreamCache<HLTriggerJSONMonitoringData::stream>,
75 edm::RunCache<HLTriggerJSONMonitoringData::run>,
77 edm::LuminosityBlockSummaryCache<HLTriggerJSONMonitoringData::lumisection>> {
94 std::unique_ptr<HLTriggerJSONMonitoringData::stream> beginStream(
edm::StreamID)
const override;
102 std::shared_ptr<HLTriggerJSONMonitoringData::run> globalBeginRun(
edm::Run const&,
111 std::shared_ptr<HLTriggerJSONMonitoringData::lumisection> globalBeginLuminosityBlockSummary(
126 static constexpr const char* streamName_ =
"streamHLTRates";
145 descriptions.
add(
"HLTriggerJSONMonitoring", desc);
150 return std::make_unique<HLTriggerJSONMonitoringData::stream>();
156 auto rundata = std::make_shared<HLTriggerJSONMonitoringData::run>();
161 rundata->streamMergeType =
165 rundata->streamDestination =
"";
166 rundata->streamMergeType =
"";
167 rundata->baseRunDir =
".";
173 edm::LogError(
"HLTriggerJSONMonitoring") <<
"HLTConfigProvider initialization failed!" << std::endl;
174 }
else if (changed) {
176 auto const&
triggerNames = rundata->hltConfig.triggerNames();
177 auto const&
datasetNames = rundata->hltConfig.datasetNames();
178 auto const&
datasets = rundata->hltConfig.datasetContents();
184 rundata->datasets.resize(datasetsSize);
185 for (
unsigned int ds = 0; ds < datasetsSize; ++ds) {
186 auto&
dataset = rundata->datasets[ds];
189 for (
unsigned int p = 0;
p <
paths;
p++) {
190 unsigned int index = rundata->hltConfig.triggerIndex(
datasets[ds][
p]);
191 if (index < triggersSize)
197 rundata->posL1s.resize(triggersSize);
198 rundata->posPre.resize(triggersSize);
199 for (
unsigned int i = 0;
i < triggersSize; ++
i) {
200 rundata->posL1s[
i] = -1;
201 rundata->posPre[
i] = -1;
202 std::vector<std::string>
const& moduleLabels = rundata->hltConfig.moduleLabels(
i);
203 for (
unsigned int j = 0;
j < moduleLabels.size(); ++
j) {
205 if (label ==
"HLTL1TSeed")
206 rundata->posL1s[
i] =
j;
207 else if (label ==
"HLTPrescaler")
208 rundata->posPre[
i] =
j;
214 rundata->jsdFileName = (
boost::format(
"run%06d_ls0000_streamHLTRates_pid%05d.jsd") % run.
run() % getpid()).
str();
229 auto& stream = *streamCache(sid);
230 auto const& rundata = *runCache(event.
getRun().
index());
235 if (not rundata.hltConfig.inited())
246 assert(results.
size() == stream.hltWasRun.size());
249 for (
unsigned int i = 0;
i < results.
size(); ++
i) {
252 ++stream.hltWasRun[
i];
256 ++stream.hltAccept[
i];
259 if (index > rundata.posL1s[
i])
261 if (index > rundata.posPre[
i])
264 ++stream.hltErrors[
i];
266 ++stream.hltReject[
i];
273 for (
unsigned int i = 0;
i < rundata.datasets.size(); ++
i)
274 if (std::any_of(rundata.datasets[
i].begin(), rundata.datasets[
i].end(), [&](
unsigned int path) {
277 ++stream.datasets[
i];
283 unsigned int triggers = 0;
285 auto const& rundata = *runCache(lumi.
getRun().
index());
286 if (rundata.hltConfig.inited()) {
287 triggers = rundata.hltConfig.triggerNames().size();
288 datasets = rundata.hltConfig.datasetNames().size();
304 lumidata->processed.update(0);
305 for (
unsigned int i = 0;
i < triggers; ++
i)
306 lumidata->hltWasRun.update(0);
307 for (
unsigned int i = 0;
i < triggers; ++
i)
308 lumidata->hltL1s.update(0);
309 for (
unsigned int i = 0;
i < triggers; ++
i)
310 lumidata->hltPre.update(0);
311 for (
unsigned int i = 0;
i < triggers; ++
i)
312 lumidata->hltAccept.update(0);
313 for (
unsigned int i = 0;
i < triggers; ++
i)
314 lumidata->hltReject.update(0);
315 for (
unsigned int i = 0;
i < triggers; ++
i)
316 lumidata->hltErrors.update(0);
318 lumidata->datasets.update(0);
327 auto& stream = *streamCache(sid);
329 unsigned int triggers = 0;
331 auto const& rundata = *runCache(lumi.
getRun().
index());
332 if (rundata.hltConfig.inited()) {
333 triggers = rundata.hltConfig.triggerNames().size();
334 datasets = rundata.hltConfig.datasetNames().size();
338 stream.processed = 0;
339 stream.hltWasRun.assign(triggers, 0);
340 stream.hltL1s.assign(triggers, 0);
341 stream.hltPre.assign(triggers, 0);
342 stream.hltAccept.assign(triggers, 0);
343 stream.hltReject.assign(triggers, 0);
344 stream.hltErrors.assign(triggers, 0);
345 stream.datasets.assign(datasets, 0);
353 auto const& stream = *streamCache(sid);
354 auto const& rundata = *runCache(lumi.
getRun().
index());
358 if (not rundata.hltConfig.inited())
361 unsigned int triggers = rundata.hltConfig.triggerNames().size();
362 for (
unsigned int i = 0;
i < triggers; ++
i) {
370 unsigned int datasets = rundata.hltConfig.datasetNames().size();
380 unsigned int run = lumi.
run();
382 bool writeFiles =
true;
393 auto const& rundata = *runCache(lumi.
getRun().
index());
398 gethostname(hostname, 32);
402 std::stringstream sOutDef;
403 sOutDef << rundata.baseRunDir <<
"/" 404 <<
"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);
469 { "name" : "Processed", "type" : "integer", "operation" : "histo"}, 470 { "name" : "Path-WasRun", "type" : "integer", "operation" : "histo"}, 471 { "name" : "Path-AfterL1Seed", "type" : "integer", "operation" : "histo"}, 472 { "name" : "Path-AfterPrescale", "type" : "integer", "operation" : "histo"}, 473 { "name" : "Path-Accepted", "type" : "integer", "operation" : "histo"}, 474 { "name" : "Path-Rejected", "type" : "integer", "operation" : "histo"}, 475 { "name" : "Path-Errors", "type" : "integer", "operation" : "histo"}, 476 { "name" : "Dataset-Accepted", "type" : "integer", "operation" : "histo"} 499 file << writer.
write(content);
std::vector< int > posL1s
static const std::string SOURCE
bool getByToken(EDGetToken token, Handle< PROD > &result) const
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
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)
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
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
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
#define DEFINE_FWK_MODULE(type)
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
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 fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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