10 #include <fmt/printf.h> 13 #include <boost/regex.hpp> 35 struct RunBasedHistograms {
38 unsigned int index_l1_seed;
39 unsigned int index_prescale;
41 HLTIndices() : index_l1_seed((unsigned
int)-1), index_prescale((unsigned
int)-1) {}
45 std::vector<HLTIndices> hltIndices;
47 std::vector<std::vector<unsigned int>>
datasets;
48 std::vector<std::vector<unsigned int>>
streams;
53 struct HLTRatesPlots {
63 std::vector<MonitorElement *> tcds_counts;
66 std::vector<MonitorElement *> l1t_counts;
69 std::vector<std::vector<HLTRatesPlots>> hlt_by_dataset_counts;
72 std::vector<MonitorElement *> dataset_counts;
75 std::vector<MonitorElement *> stream_counts;
89 hlt_by_dataset_counts(),
109 RunBasedHistograms &)
const override;
149 desc.addUntracked<uint32_t>(
"lumisectionRange", 2500);
150 descriptions.
add(
"triggerRatesMonitor",
desc);
155 m_l1tMenuToken{esConsumes<edm::Transition::BeginRun>()},
156 m_l1t_results(consumes<GlobalAlgBlkBxCollection>(
config.getUntrackedParameter<
edm::InputTag>(
"l1tResults"))),
157 m_hlt_results(consumes<edm::TriggerResults>(
config.getUntrackedParameter<
edm::InputTag>(
"hltResults"))),
159 m_lumisections_range(
config.getUntrackedParameter<uint32_t>(
"lumisectionRange")) {}
177 auto const nTriggers =
histograms.hltConfig.size();
180 unsigned int const nDatasets =
histograms.hltConfig.datasetNames().size();
182 histograms.hlt_by_dataset_counts.resize(nDatasets);
186 for (
unsigned int i = 0;
i < nDatasets; ++
i) {
192 if (triggerIdx < nTriggers)
196 <<
"The rates of the HLT path \"" <<
path <<
"\" (dataset: \"" <<
histograms.hltConfig.datasetName(
i)
197 <<
"\") will not be monitored for this run.\nThis HLT path is not available in the process \"" 198 <<
labels.process <<
"\", but it is listed in its \"datasets\" PSet.";
204 unsigned int const nStreams =
histograms.hltConfig.streamNames().size();
207 for (
unsigned int i = 0;
i < nStreams; ++
i) {
211 if (triggerIdx < nTriggers)
215 <<
"The rates of the HLT path \"" <<
path <<
"\" (stream: \"" <<
histograms.hltConfig.streamName(
i)
216 <<
"\", dataset: \"" <<
dataset <<
"\") will not be monitored for this run.\n" 217 <<
"This HLT path is not available in the process \"" <<
labels.process
218 <<
"\", but it is listed in its \"datasets\" PSet.";
230 edm::LogError(
"TriggerRatesMonitor") <<
"Failed to initialise HLTConfigProvider: the rates of HLT triggers, " 231 "datasets and streams will not be monitored for this run.";
244 unsigned int const sizeof_tcds_trigger_types =
sizeof(
s_tcds_trigger_types) /
sizeof(
const char *);
245 if (sizeof_tcds_trigger_types ==
histograms.tcds_counts.size()) {
246 for (
unsigned int i = 0;
i < sizeof_tcds_trigger_types; ++
i)
254 <<
"This should never happen: size of \"s_tcds_trigger_types\" array (" << sizeof_tcds_trigger_types
255 <<
") differs from size of \"histograms.tcds_counts\" vector (size=" <<
histograms.tcds_counts.size()
256 <<
").\nRate histograms of TCDS trigger types will not be booked for this run.";
261 for (
auto const &keyval : l1tMenu.getAlgorithmMap()) {
262 unsigned int const bit = keyval.second.getIndex();
265 <<
"This should never happen: bit of L1T algorithm (bit=" <<
bit <<
", name=\"" << keyval.first
266 <<
"\") is not smaller than size of \"histograms.l1t_counts\" vector (size=" <<
histograms.l1t_counts.size()
267 <<
").\nRate histogram of this L1T algorithm will not be booked for this run.";
273 fmt::sprintf(
"%s (bit %d)%s vs. lumisection", keyval.first,
bit, (masked ?
" (masked)" :
""));
283 for (
unsigned int i = 0;
i <
histograms.datasets[
d].size(); ++
i) {
287 name +
" pass L1 seed, vs. lumisection",
292 name +
" pass prescaler, vs. lumisection",
297 name +
" accept, vs. lumisection",
302 name +
" reject, vs. lumisection",
307 name +
" error, vs. lumisection",
320 if (
type ==
"HLTL1TSeed" or type ==
"HLTLevel1GTSeed" or type ==
"HLTLevel1Activity" or 321 type ==
"HLTLevel1Pattern") {
325 }
else if (
type ==
"HLTPrescaler") {
342 auto const &streamNames =
histograms.hltConfig.streamNames();
343 for (
unsigned int i = 0;
i < streamNames.size(); ++
i)
352 unsigned int lumisection =
event.luminosityBlock();
355 histograms.events_processed->Fill(lumisection);
361 if (not bxvector.isEmpty(0)) {
362 auto const &
results = bxvector.at(0, 0);
364 if (
results.getAlgoDecisionFinal(
i))
374 <<
"This should never happen: the number of HLT paths has changed since the beginning of the run" 376 <<
"Histograms for rates of HLT paths, datasets and streams will not be filled for this event.";
380 for (
unsigned int d = 0;
d <
histograms.datasets.size(); ++
d) {
387 for (
unsigned int i = 0;
i <
histograms.datasets[
d].size(); ++
i) {
392 histograms.hlt_by_dataset_counts[
d][
i].pass_l1_seed->Fill(lumisection);
394 histograms.hlt_by_dataset_counts[
d][
i].pass_prescale->Fill(lumisection);
396 histograms.hlt_by_dataset_counts[
d][
i].accept->Fill(lumisection);
397 else if (
path.error())
398 histograms.hlt_by_dataset_counts[
d][
i].error->Fill(lumisection);
400 histograms.hlt_by_dataset_counts[
d][
i].reject->Fill(lumisection);
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override
const std::string m_dqm_path
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1t_results
dqm::impl::MonitorElement MonitorElement
virtual void setCurrentFolder(std::string const &fullpath)
const edm::EDGetTokenT< edm::TriggerResults > m_hlt_results
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::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > m_l1tMenuToken
#define DEFINE_FWK_MODULE(type)
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, RunBasedHistograms const &) const override
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
void labelsForToken(EDGetToken iToken, Labels &oLabels) const