9 #include <fmt/printf.h>
12 #include <boost/regex.hpp>
39 struct RunBasedHistograms {
43 unsigned int index_l1_seed;
44 unsigned int index_prescale;
46 HLTIndices() : index_l1_seed((unsigned int)-1), index_prescale((unsigned int)-1) {}
50 std::vector<HLTIndices> hltIndices;
52 std::vector<std::vector<unsigned int>>
datasets;
53 std::vector<std::vector<unsigned int>> streams;
58 struct HLTRatesPlots {
68 std::vector<dqm::reco::MonitorElement *> tcds_counts;
71 std::vector<dqm::reco::MonitorElement *> l1t_counts;
74 std::vector<std::vector<HLTRatesPlots>> hlt_by_dataset_counts;
77 std::vector<dqm::reco::MonitorElement *> dataset_counts;
80 std::vector<dqm::reco::MonitorElement *> stream_counts;
94 hlt_by_dataset_counts(),
114 RunBasedHistograms &)
const override;
155 descriptions.
add(
"triggerRatesMonitor", desc);
160 m_l1tMenuToken{esConsumes<edm::Transition::BeginRun>()},
169 histograms.tcds_counts.clear();
173 histograms.l1t_counts.clear();
180 if (histograms.hltConfig.init(run, setup, labels.
process, changed)) {
181 histograms.hltIndices.resize(histograms.hltConfig.size());
183 unsigned int datasets = histograms.hltConfig.datasetNames().size();
184 histograms.hlt_by_dataset_counts.clear();
185 histograms.hlt_by_dataset_counts.resize(datasets);
187 histograms.datasets.clear();
188 histograms.datasets.resize(datasets);
190 auto const &
paths = histograms.hltConfig.datasetContent(
i);
191 histograms.hlt_by_dataset_counts[
i].resize(
paths.size());
192 histograms.datasets[
i].reserve(
paths.size());
194 histograms.datasets[
i].push_back(histograms.hltConfig.triggerIndex(
path));
197 histograms.dataset_counts.clear();
198 histograms.dataset_counts.resize(datasets);
200 unsigned int streams = histograms.hltConfig.streamNames().size();
201 histograms.streams.clear();
202 histograms.streams.resize(streams);
203 for (
unsigned int i = 0;
i < streams; ++
i) {
204 for (
auto const &
dataset : histograms.hltConfig.streamContent(
i)) {
205 for (
auto const &
path : histograms.hltConfig.datasetContent(
dataset))
206 histograms.streams[
i].push_back(histograms.hltConfig.triggerIndex(
path));
208 std::sort(histograms.streams[
i].begin(), histograms.streams[
i].end());
209 auto unique_end =
std::unique(histograms.streams[
i].begin(), histograms.streams[
i].end());
210 histograms.streams[
i].resize(unique_end - histograms.streams[
i].begin());
211 histograms.streams[
i].shrink_to_fit();
213 histograms.stream_counts.clear();
214 histograms.stream_counts.resize(streams);
218 <<
"failed to initialise HLTConfigProvider, the HLT trigger and datasets rates will not be monitored";
228 histograms.events_processed = booker.
book1D(
234 histograms.tcds_counts[
i] =
241 for (
auto const &keyval : l1tMenu.getAlgorithmMap()) {
242 unsigned int bit = keyval.second.getIndex();
244 std::string const &
name = fmt::sprintf(
"%s (bit %d)", keyval.first, bit);
246 fmt::sprintf(
"%s (bit %d)%s vs. lumisection", keyval.first, bit, (masked ?
" (masked)" :
""));
247 histograms.l1t_counts.at(bit) =
251 if (histograms.hltConfig.inited()) {
252 auto const &
datasets = histograms.hltConfig.datasetNames();
255 for (
unsigned int d = 0;
d <
datasets.size(); ++
d) {
257 for (
unsigned int i = 0; i < histograms.datasets[
d].size(); ++
i) {
258 unsigned int index = histograms.datasets[
d][
i];
260 histograms.hlt_by_dataset_counts[
d][
i].pass_l1_seed = booker.
book1D(name +
"_pass_L1_seed",
261 name +
" pass L1 seed, vs. lumisection",
265 histograms.hlt_by_dataset_counts[
d][
i].pass_prescale = booker.
book1D(name +
"_pass_prescaler",
266 name +
" pass prescaler, vs. lumisection",
270 histograms.hlt_by_dataset_counts[
d][
i].accept = booker.
book1D(name +
"_accept",
271 name +
" accept, vs. lumisection",
275 histograms.hlt_by_dataset_counts[
d][
i].reject = booker.
book1D(name +
"_reject",
276 name +
" reject, vs. lumisection",
280 histograms.hlt_by_dataset_counts[
d][
i].error = booker.
book1D(name +
"_error",
281 name +
" error, vs. lumisection",
288 for (
unsigned int i : histograms.datasets[d]) {
290 histograms.hltIndices[
i].index_l1_seed = histograms.hltConfig.size(i);
291 histograms.hltIndices[
i].index_prescale = histograms.hltConfig.size(i);
292 for (
unsigned int j = 0;
j < histograms.hltConfig.size(i); ++
j) {
295 if (type ==
"HLTL1TSeed" or type ==
"HLTLevel1GTSeed" or type ==
"HLTLevel1Activity" or
296 type ==
"HLTLevel1Pattern") {
299 histograms.hltIndices[
i].index_l1_seed =
j;
300 }
else if (type ==
"HLTPrescaler") {
302 histograms.hltIndices[
i].index_prescale =
j;
311 for (
unsigned int i = 0; i <
datasets.size(); ++
i)
312 histograms.dataset_counts[i] =
317 auto const &streams = histograms.hltConfig.streamNames();
318 for (
unsigned int i = 0; i < streams.size(); ++
i)
319 histograms.stream_counts[i] =
327 unsigned int lumisection =
event.luminosityBlock();
330 histograms.events_processed->Fill(lumisection);
332 histograms.tcds_counts[event.
experimentType()]->Fill(lumisection);
336 if (not bxvector.isEmpty(0)) {
337 auto const &
results = bxvector.at(0, 0);
339 if (
results.getAlgoDecisionFinal(
i))
340 if (histograms.l1t_counts[
i])
341 histograms.l1t_counts[
i]->Fill(lumisection);
345 if (histograms.hltConfig.inited()) {
347 if (
hltResults.size() != histograms.hltIndices.size()) {
349 <<
"This should never happen: the number of HLT paths has changed since the beginning of the run";
352 for (
unsigned int d = 0;
d < histograms.datasets.size(); ++
d) {
353 for (
unsigned int i : histograms.datasets[
d])
355 histograms.dataset_counts[
d]->Fill(lumisection);
359 for (
unsigned int i = 0;
i < histograms.datasets[
d].size(); ++
i) {
360 unsigned int index = histograms.datasets[
d][
i];
363 if (path.
index() > histograms.hltIndices[
index].index_l1_seed)
364 histograms.hlt_by_dataset_counts[d][
i].pass_l1_seed->Fill(lumisection);
365 if (path.
index() > histograms.hltIndices[
index].index_prescale)
366 histograms.hlt_by_dataset_counts[d][
i].pass_prescale->Fill(lumisection);
368 histograms.hlt_by_dataset_counts[d][
i].accept->Fill(lumisection);
369 else if (path.
error())
370 histograms.hlt_by_dataset_counts[d][
i].error->Fill(lumisection);
372 histograms.hlt_by_dataset_counts[
d][
i].reject->Fill(lumisection);
376 for (
unsigned int i = 0;
i < histograms.streams.size(); ++
i)
377 for (
unsigned int j : histograms.streams[
i])
379 histograms.stream_counts[
i]->Fill(lumisection);
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override
T getUntrackedParameter(std::string const &, T const &) const
const std::string m_dqm_path
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1t_results
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
virtual void setCurrentFolder(std::string const &fullpath)
#define DEFINE_FWK_MODULE(type)
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
bool getData(T &iHolder) const
static constexpr const char *const s_tcds_trigger_types[]
const edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > m_l1tMenuToken
bool error() const
has this path encountered an error (exception)?
dqm::legacy::MonitorElement MonitorElement
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, RunBasedHistograms const &) const override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool accept() const
has this path accepted the event?
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
tuple config
parse the configuration file
TriggerRatesMonitor(edm::ParameterSet const &)
edm::EventAuxiliary::ExperimentType experimentType() const
static constexpr unsigned int maxPhysicsTriggers
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
~TriggerRatesMonitor() override=default
unsigned int index() const