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;
150 desc.addUntracked<uint32_t>(
"lumisectionRange", 2500);
151 descriptions.
add(
"triggerRatesMonitor",
desc);
156 m_l1tMenu_token{esConsumes<edm::Transition::BeginRun>()},
158 m_l1t_results_token{consumes(m_l1t_results_inputTag)},
161 m_lumisections_range{
config.getUntrackedParameter<uint32_t>(
"lumisectionRange")} {}
179 auto const nTriggers =
histograms.hltConfig.size();
182 unsigned int const nDatasets =
histograms.hltConfig.datasetNames().size();
184 histograms.hlt_by_dataset_counts.resize(nDatasets);
188 for (
unsigned int i = 0;
i < nDatasets; ++
i) {
194 if (triggerIdx < nTriggers)
198 <<
"The rates of the HLT path \"" <<
path <<
"\" (dataset: \"" <<
histograms.hltConfig.datasetName(
i)
199 <<
"\") will not be monitored for this run.\nThis HLT path is not available in the process \"" 200 <<
labels.process <<
"\", but it is listed in its \"datasets\" PSet.";
206 unsigned int const nStreams =
histograms.hltConfig.streamNames().size();
209 for (
unsigned int i = 0;
i < nStreams; ++
i) {
213 if (triggerIdx < nTriggers)
217 <<
"The rates of the HLT path \"" <<
path <<
"\" (stream: \"" <<
histograms.hltConfig.streamName(
i)
218 <<
"\", dataset: \"" <<
dataset <<
"\") will not be monitored for this run.\n" 219 <<
"This HLT path is not available in the process \"" <<
labels.process
220 <<
"\", but it is listed in its \"datasets\" PSet.";
232 edm::LogError(
"TriggerRatesMonitor") <<
"Failed to initialise HLTConfigProvider: the rates of HLT triggers, " 233 "datasets and streams will not be monitored for this run.";
246 unsigned int const sizeof_tcds_trigger_types =
sizeof(
s_tcds_trigger_types) /
sizeof(
const char *);
247 if (sizeof_tcds_trigger_types ==
histograms.tcds_counts.size()) {
248 for (
unsigned int i = 0;
i < sizeof_tcds_trigger_types; ++
i)
256 <<
"This should never happen: size of \"s_tcds_trigger_types\" array (" << sizeof_tcds_trigger_types
257 <<
") differs from size of \"histograms.tcds_counts\" vector (size=" <<
histograms.tcds_counts.size()
258 <<
").\nRate histograms of TCDS trigger types will not be booked for this run.";
263 for (
auto const &keyval : l1tMenu.getAlgorithmMap()) {
264 unsigned int const bit = keyval.second.getIndex();
267 <<
"This should never happen: bit of L1T algorithm (bit=" <<
bit <<
", name=\"" << keyval.first
268 <<
"\") is not smaller than size of \"histograms.l1t_counts\" vector (size=" <<
histograms.l1t_counts.size()
269 <<
").\nRate histogram of this L1T algorithm will not be booked for this run.";
275 fmt::sprintf(
"%s (bit %d)%s vs. lumisection", keyval.first,
bit, (masked ?
" (masked)" :
""));
285 for (
unsigned int i = 0;
i <
histograms.datasets[
d].size(); ++
i) {
289 name +
" pass L1 seed, vs. lumisection",
294 name +
" pass prescaler, vs. lumisection",
299 name +
" accept, vs. lumisection",
304 name +
" reject, vs. lumisection",
309 name +
" error, vs. lumisection",
322 if (
type ==
"HLTL1TSeed" or type ==
"HLTLevel1GTSeed" or type ==
"HLTLevel1Activity" or 323 type ==
"HLTLevel1Pattern") {
327 }
else if (
type ==
"HLTPrescaler") {
344 auto const &streamNames =
histograms.hltConfig.streamNames();
345 for (
unsigned int i = 0;
i < streamNames.size(); ++
i)
354 unsigned int lumisection =
event.luminosityBlock();
357 histograms.events_processed->Fill(lumisection);
363 if (not algBlkBxVecHandle.isValid()) {
366 <<
"] not present or invalid. MonitorElements of L1T results not filled for this event.";
367 }
else if (algBlkBxVecHandle->isEmpty(0)) {
370 <<
"] empty for BX=0. MonitorElements of L1T results not filled for this event.";
372 auto const &
results = algBlkBxVecHandle->at(0, 0);
374 if (
results.getAlgoDecisionFinal(
i))
384 <<
"This should never happen: the number of HLT paths has changed since the beginning of the run" 386 <<
"Histograms for rates of HLT paths, datasets and streams will not be filled for this event.";
390 for (
unsigned int d = 0;
d <
histograms.datasets.size(); ++
d) {
397 for (
unsigned int i = 0;
i <
histograms.datasets[
d].size(); ++
i) {
402 histograms.hlt_by_dataset_counts[
d][
i].pass_l1_seed->Fill(lumisection);
404 histograms.hlt_by_dataset_counts[
d][
i].pass_prescale->Fill(lumisection);
406 histograms.hlt_by_dataset_counts[
d][
i].accept->Fill(lumisection);
407 else if (
path.error())
408 histograms.hlt_by_dataset_counts[
d][
i].error->Fill(lumisection);
410 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
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