11 #include <boost/regex.hpp> 12 #include <boost/format.hpp> 43 struct RunBasedHistograms {
47 unsigned int index_l1_seed;
48 unsigned int index_prescale;
51 index_l1_seed( (unsigned
int) -1),
52 index_prescale( (unsigned
int) -1)
57 std::vector<HLTIndices> hltIndices;
59 std::vector<std::vector<unsigned int>>
datasets;
60 std::vector<std::vector<unsigned int>> streams;
65 struct HLTRatesPlots {
75 std::vector<ConcurrentMonitorElement> tcds_counts;
78 std::vector<ConcurrentMonitorElement> l1t_counts;
81 std::vector<std::vector<HLTRatesPlots>> hlt_by_dataset_counts;
84 std::vector<ConcurrentMonitorElement> dataset_counts;
87 std::vector<ConcurrentMonitorElement> stream_counts;
89 RunBasedHistograms() :
101 hlt_by_dataset_counts(),
126 static constexpr const char *
const s_tcds_trigger_types[] = {
163 desc.
addUntracked<uint32_t>(
"lumisectionRange", 2500 );
164 descriptions.
add(
"triggerRatesMonitor", desc);
171 m_hlt_results(consumes<
edm::TriggerResults>( config.getUntrackedParameter<
edm::InputTag>(
"hltResults" ) )),
172 m_dqm_path( config.getUntrackedParameter<
std::
string>(
"dqmPath" ) ),
173 m_lumisections_range( config.getUntrackedParameter<uint32_t>(
"lumisectionRange" ) )
179 histograms.events_processed.reset();
180 histograms.tcds_counts.clear();
184 histograms.l1t_counts.clear();
191 if (histograms.hltConfig.init(run, setup, labels.
process, changed)) {
192 histograms.hltIndices.resize(histograms.hltConfig.size());
194 unsigned int datasets = histograms.hltConfig.datasetNames().size();
195 histograms.hlt_by_dataset_counts.clear();
196 histograms.hlt_by_dataset_counts.resize(datasets);
198 histograms.datasets.clear();
199 histograms.datasets.resize(datasets);
201 auto const & paths = histograms.hltConfig.datasetContent(
i);
202 histograms.hlt_by_dataset_counts[
i].resize(paths.size());
203 histograms.datasets[
i].reserve(paths.size());
204 for (
auto const &
path: paths) {
205 histograms.datasets[
i].push_back(histograms.hltConfig.triggerIndex(
path));
208 histograms.dataset_counts.clear();
209 histograms.dataset_counts.resize(datasets);
211 unsigned int streams = histograms.hltConfig.streamNames().size();
212 histograms.streams.clear();
213 histograms.streams.resize(streams);
214 for (
unsigned int i = 0;
i < streams; ++
i) {
215 for (
auto const &
dataset : histograms.hltConfig.streamContent(
i)) {
216 for (
auto const &
path : histograms.hltConfig.datasetContent(
dataset))
217 histograms.streams[
i].push_back(histograms.hltConfig.triggerIndex(
path));
219 std::sort(histograms.streams[
i].begin(), histograms.streams[
i].end());
220 auto unique_end =
std::unique(histograms.streams[
i].begin(), histograms.streams[
i].end());
221 histograms.streams[
i].resize(unique_end - histograms.streams[
i].begin());
222 histograms.streams[
i].shrink_to_fit();
224 histograms.stream_counts.clear();
225 histograms.stream_counts.resize(streams);
228 edm::LogError(
"TriggerRatesMonitor") <<
"failed to initialise HLTConfigProvider, the HLT trigger and datasets rates will not be monitored";
246 auto const& l1tMenu = edm::get<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd>(
setup);
247 for (
auto const & keyval: l1tMenu.getAlgorithmMap()) {
248 unsigned int bit = keyval.second.getIndex();
255 if (histograms.hltConfig.inited()) {
257 auto const &
datasets = histograms.hltConfig.datasetNames();
260 for (
unsigned int d = 0;
d <
datasets.size(); ++
d) {
262 for (
unsigned int i = 0; i < histograms.datasets[
d].size(); ++
i) {
263 unsigned int index = histograms.datasets[
d][
i];
273 for (
unsigned int i: histograms.datasets[d]) {
276 histograms.hltIndices[
i].index_l1_seed = histograms.hltConfig.size(i);
277 histograms.hltIndices[
i].index_prescale = histograms.hltConfig.size(i);
278 for (
unsigned int j = 0; j < histograms.hltConfig.size(i); ++j) {
281 if (type ==
"HLTL1TSeed" or type ==
"HLTLevel1GTSeed" or type ==
"HLTLevel1Activity" or type ==
"HLTLevel1Pattern") {
284 histograms.hltIndices[
i].index_l1_seed = j;
285 }
else if (type ==
"HLTPrescaler") {
287 histograms.hltIndices[
i].index_prescale = j;
296 for (
unsigned int i = 0; i <
datasets.size(); ++
i)
301 auto const & streams = histograms.hltConfig.streamNames();
302 for (
unsigned int i = 0; i < streams.size(); ++
i)
311 unsigned int lumisection =
event.luminosityBlock();
314 histograms.events_processed.fill(lumisection);
320 if (not bxvector.isEmpty(0)) {
321 auto const &
results = bxvector.at(0, 0);
323 if (
results.getAlgoDecisionFinal(
i))
324 if (histograms.l1t_counts[
i])
325 histograms.l1t_counts[
i].fill(lumisection);
329 if (histograms.hltConfig.inited()) {
331 if (hltResults.
size() == histograms.hltIndices.size()) {
333 edm::LogWarning(
"TriggerRatesMonitor") <<
"This should never happen: the number of HLT paths has changed since the beginning of the run";
336 for (
unsigned int d = 0;
d < histograms.datasets.size(); ++
d) {
337 for (
unsigned int i: histograms.datasets[
d])
339 histograms.dataset_counts[
d].fill(lumisection);
343 for (
unsigned int i = 0;
i < histograms.datasets[
d].size(); ++
i) {
344 unsigned int index = histograms.datasets[
d][
i];
347 if (path.
index() > histograms.hltIndices[
index].index_l1_seed)
348 histograms.hlt_by_dataset_counts[d][
i].pass_l1_seed.fill(lumisection);
349 if (path.
index() > histograms.hltIndices[
index].index_prescale)
350 histograms.hlt_by_dataset_counts[d][
i].pass_prescale.fill(lumisection);
352 histograms.hlt_by_dataset_counts[d][
i].accept.fill(lumisection);
353 else if (path.
error())
354 histograms.hlt_by_dataset_counts[d][
i].error .fill(lumisection);
356 histograms.hlt_by_dataset_counts[
d][
i].reject.fill(lumisection);
360 for (
unsigned int i = 0;
i < histograms.streams.size(); ++
i)
361 for (
unsigned int j: histograms.streams[
i])
363 histograms.stream_counts[
i].fill(lumisection);
const std::string m_dqm_path
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1t_results
#define DEFINE_FWK_MODULE(type)
virtual example_global void dqmAnalyze(edm::Event const &,@example_global edm::EventSetup const &,@example_global Histograms___class__ const &) const override
const edm::EDGetTokenT< edm::TriggerResults > m_hlt_results
def setup(process, global_tag, zero_tesla=False)
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[]
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) 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)
T const & get(Event const &event, InputTag const &tag)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
ConcurrentMonitorElement book1D(Args &&...args)
format
Some error handling for the usage.
const HLTPathStatus & at(const unsigned int i) const
void bookHistograms(DQMStore::ConcurrentBooker &, edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override
bool error() const
has this path encountered an error (exception)?
void setCurrentFolder(const std::string &fullpath)
static unsigned int maxPhysicsTriggers
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