10 #include <boost/regex.hpp> 11 #include <boost/format.hpp> 41 struct RunBasedHistograms {
45 unsigned int index_l1_seed;
46 unsigned int index_prescale;
48 HLTIndices() : index_l1_seed((unsigned
int)-1), index_prescale((unsigned
int)-1) {}
52 std::vector<HLTIndices> hltIndices;
54 std::vector<std::vector<unsigned int>>
datasets;
55 std::vector<std::vector<unsigned int>>
streams;
60 struct HLTRatesPlots {
70 std::vector<dqm::reco::MonitorElement *> tcds_counts;
73 std::vector<dqm::reco::MonitorElement *> l1t_counts;
76 std::vector<std::vector<HLTRatesPlots>> hlt_by_dataset_counts;
79 std::vector<dqm::reco::MonitorElement *> dataset_counts;
82 std::vector<dqm::reco::MonitorElement *> stream_counts;
96 hlt_by_dataset_counts(),
116 RunBasedHistograms &)
const override;
121 static constexpr const char *
const s_tcds_trigger_types[] = {
156 descriptions.
add(
"triggerRatesMonitor", desc);
163 m_dqm_path(config.getUntrackedParameter<
std::
string>(
"dqmPath")),
164 m_lumisections_range(config.getUntrackedParameter<uint32_t>(
"lumisectionRange")) {}
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);
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] =
240 auto const &l1tMenu = edm::get<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd>(
setup);
241 for (
auto const &keyval : l1tMenu.getAlgorithmMap()) {
242 unsigned int bit = keyval.second.getIndex();
246 (
boost::format(
"%s (bit %d)%s vs. lumisection") % keyval.first % bit % (masked ?
" (masked)" :
"")).str();
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()) {
350 <<
"This should never happen: the number of HLT paths has changed since the beginning of the run";
353 for (
unsigned int d = 0;
d < histograms.datasets.size(); ++
d) {
354 for (
unsigned int i : histograms.datasets[
d])
356 histograms.dataset_counts[
d]->Fill(lumisection);
360 for (
unsigned int i = 0;
i < histograms.datasets[
d].size(); ++
i) {
361 unsigned int index = histograms.datasets[
d][
i];
364 if (path.
index() > histograms.hltIndices[
index].index_l1_seed)
365 histograms.hlt_by_dataset_counts[d][
i].pass_l1_seed->Fill(lumisection);
366 if (path.
index() > histograms.hltIndices[
index].index_prescale)
367 histograms.hlt_by_dataset_counts[d][
i].pass_prescale->Fill(lumisection);
369 histograms.hlt_by_dataset_counts[d][
i].accept->Fill(lumisection);
370 else if (path.
error())
371 histograms.hlt_by_dataset_counts[d][
i].error->Fill(lumisection);
373 histograms.hlt_by_dataset_counts[
d][
i].reject->Fill(lumisection);
377 for (
unsigned int i = 0;
i < histograms.streams.size(); ++
i)
378 for (
unsigned int j : histograms.streams[
i])
380 histograms.stream_counts[
i]->Fill(lumisection);
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
const std::string m_dqm_path
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1t_results
void setCurrentFolder(std::string const &fullpath)
const edm::EDGetTokenT< edm::TriggerResults > m_hlt_results
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const uint32_t m_lumisections_range
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
static const char *const s_tcds_trigger_types[]
#define DEFINE_FWK_MODULE(type)
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override
example_global void dqmAnalyze(edm::Event const &,@example_global edm::EventSetup const &,@example_global Histograms___class__ const &) const override
unsigned int size() const
Get number of paths stored.
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 HLTPathStatus & at(const unsigned int i) const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override
bool error() const
has this path encountered an error (exception)?
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static unsigned int maxPhysicsTriggers
dqm::legacy::MonitorElement MonitorElement
T const & get(Event const &event, InputTag const &tag)(false)
example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup 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
TriggerRatesMonitor(edm::ParameterSet const &)
edm::EventAuxiliary::ExperimentType experimentType() const
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, RunBasedHistograms const &) const override
unsigned int index() const