10 #include <fmt/printf.h> 13 #include <boost/regex.hpp> 35 struct RunBasedHistograms {
38 unsigned int index_trigger;
39 unsigned int index_l1_seed;
40 unsigned int index_prescale;
43 : index_trigger((unsigned
int)-1), index_l1_seed((unsigned
int)-1), index_prescale((unsigned
int)-1) {}
47 std::vector<HLTIndices> hltIndices;
49 std::vector<std::vector<unsigned int>>
datasets;
50 std::vector<std::vector<unsigned int>>
streams;
55 struct HLTRatesPlots {
65 std::vector<MonitorElement *> tcds_counts;
68 std::vector<MonitorElement *> l1t_counts;
71 std::vector<HLTRatesPlots> hlt_counts;
74 std::vector<MonitorElement *> dataset_counts;
77 std::vector<MonitorElement *> stream_counts;
111 RunBasedHistograms &)
const override;
152 desc.addUntracked<uint32_t>(
"lumisectionRange", 2500);
153 descriptions.
add(
"triggerRatesMonitor",
desc);
158 m_l1tMenu_token{esConsumes<edm::Transition::BeginRun>()},
160 m_l1t_results_token{consumes(m_l1t_results_inputTag)},
163 m_lumisections_range{
config.getUntrackedParameter<uint32_t>(
"lumisectionRange")} {}
181 auto const nTriggers =
histograms.hltConfig.size();
187 unsigned int const nDatasets =
histograms.hltConfig.datasetNames().size();
190 for (
unsigned int i = 0;
i < nDatasets; ++
i) {
195 if (triggerIdx < nTriggers)
199 <<
"The rates of the HLT path \"" <<
path <<
"\" (dataset: \"" <<
histograms.hltConfig.datasetName(
i)
200 <<
"\") will not be monitored for this run.\nThis HLT path is not available in the process \"" 201 <<
labels.process <<
"\", but it is listed in its \"datasets\" PSet.";
207 unsigned int const nStreams =
histograms.hltConfig.streamNames().size();
210 for (
unsigned int i = 0;
i < nStreams; ++
i) {
214 if (triggerIdx < nTriggers)
218 <<
"The rates of the HLT path \"" <<
path <<
"\" (stream: \"" <<
histograms.hltConfig.streamName(
i)
219 <<
"\", dataset: \"" <<
dataset <<
"\") will not be monitored for this run.\n" 220 <<
"This HLT path is not available in the process \"" <<
labels.process
221 <<
"\", but it is listed in its \"datasets\" PSet.";
233 edm::LogError(
"TriggerRatesMonitor") <<
"Failed to initialise HLTConfigProvider: the rates of HLT triggers, " 234 "datasets and streams will not be monitored for this run.";
247 unsigned int const sizeof_tcds_trigger_types =
sizeof(
s_tcds_trigger_types) /
sizeof(
const char *);
248 if (sizeof_tcds_trigger_types ==
histograms.tcds_counts.size()) {
249 for (
unsigned int i = 0;
i < sizeof_tcds_trigger_types; ++
i)
257 <<
"This should never happen: size of \"s_tcds_trigger_types\" array (" << sizeof_tcds_trigger_types
258 <<
") differs from size of \"histograms.tcds_counts\" vector (size=" <<
histograms.tcds_counts.size()
259 <<
").\nRate histograms of TCDS trigger types will not be booked for this run.";
264 for (
auto const &keyval : l1tMenu.getAlgorithmMap()) {
265 unsigned int const bit = keyval.second.getIndex();
268 <<
"This should never happen: bit of L1T algorithm (bit=" <<
bit <<
", name=\"" << keyval.first
269 <<
"\") is not smaller than size of \"histograms.l1t_counts\" vector (size=" <<
histograms.l1t_counts.size()
270 <<
").\nRate histogram of this L1T algorithm will not be booked for this run.";
276 fmt::sprintf(
"%s (bit %d)%s vs. lumisection", keyval.first,
bit, (masked ?
" (masked)" :
""));
288 name +
" pass L1 seed, vs. lumisection",
293 name +
" pass prescaler, vs. lumisection",
298 name +
" accept, vs. lumisection",
303 name +
" reject, vs. lumisection",
317 if (
type ==
"HLTL1TSeed" or type ==
"HLTLevel1GTSeed" or type ==
"HLTLevel1Activity" or 318 type ==
"HLTLevel1Pattern") {
322 }
else if (
type ==
"HLTPrescaler") {
339 auto const &streamNames =
histograms.hltConfig.streamNames();
340 for (
unsigned int i = 0;
i < streamNames.size(); ++
i)
349 unsigned int lumisection =
event.luminosityBlock();
352 histograms.events_processed->Fill(lumisection);
358 if (not algBlkBxVecHandle.isValid()) {
361 <<
"] not present or invalid. MonitorElements of L1T results not filled for this event.";
362 }
else if (algBlkBxVecHandle->isEmpty(0)) {
365 <<
"] empty for BX=0. MonitorElements of L1T results not filled for this event.";
367 auto const &
results = algBlkBxVecHandle->at(0, 0);
369 if (
results.getAlgoDecisionFinal(
i))
379 <<
"This should never happen: the number of HLT paths has changed since the beginning of the run" 381 <<
"Histograms for rates of HLT paths, datasets and streams will not be filled for this event.";
385 for (
unsigned int i = 0;
i <
histograms.hltIndices.size(); ++
i) {
390 histograms.hlt_counts[
i].pass_l1_seed->Fill(lumisection);
392 histograms.hlt_counts[
i].pass_prescale->Fill(lumisection);
394 histograms.hlt_counts[
i].accept->Fill(lumisection);
395 else if (
path.error())
398 histograms.hlt_counts[
i].reject->Fill(lumisection);
401 for (
unsigned int d = 0;
d <
histograms.datasets.size(); ++
d) {
411 for (
unsigned int i = 0;
i <
histograms.streams.size(); ++
i) {
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override
const std::string m_dqm_path
dqm::impl::MonitorElement MonitorElement
virtual void setCurrentFolder(std::string const &fullpath)
const edm::EDGetTokenT< edm::TriggerResults > m_hlt_results_token
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Log< level::Error, false > LogError
const uint32_t m_lumisections_range
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override
static constexpr const char *const s_tcds_trigger_types[]
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
def unique(seq, keepstr=True)
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1t_results_token
#define DEFINE_FWK_MODULE(type)
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, RunBasedHistograms const &) const override
const edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > m_l1tMenu_token
void add(std::string const &label, ParameterSetDescription const &psetDescription)
TriggerRatesMonitor(edm::ParameterSet const &)
static constexpr unsigned int maxPhysicsTriggers
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
~TriggerRatesMonitor() override=default
const edm::InputTag m_l1t_results_inputTag
void labelsForToken(EDGetToken iToken, Labels &oLabels) const