CMS 3D CMS Logo

FWHLTTriggerTableView.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWHLTTriggerTableView
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author:
10 // Created: Tue Jan 25 16:02:03 CET 2011
11 //
12 #include <boost/regex.hpp>
13 
16 
24 
26  : FWTriggerTableView(iParent, FWViewType::kTableHLT), m_event(nullptr) {
27  m_columns[0].title = "Filter Name";
28  m_columns.push_back(Column("Accept"));
29  m_columns.push_back(Column("Average Accept"));
30  dataChanged();
31 }
32 
34  if (event != m_event) {
35  m_event = event;
37  }
39  edm::TriggerNames const* triggerNames(nullptr);
40  try {
41  hTriggerResults.getByLabel(*event, "TriggerResults", "", m_process.value().c_str());
42  triggerNames = &event->triggerNames(*hTriggerResults);
43  } catch (cms::Exception&) {
44  fwLog(fwlog::kWarning) << " no trigger results with process name HLT is available" << std::endl;
46  return;
47  }
48  boost::regex filter(m_regex.value());
49  for (unsigned int i = 0; i < triggerNames->size(); ++i) {
50  if (!boost::regex_search(triggerNames->triggerName(i), filter))
51  continue;
52  m_columns.at(0).values.push_back(triggerNames->triggerName(i));
53  m_columns.at(1).values.push_back(Form("%d", hTriggerResults->accept(i)));
54  m_columns.at(2).values.push_back(Form("%6.1f%%", m_averageAccept[triggerNames->triggerName(i)] * 100));
55  }
56 }
57 
59  edm::EventID currentEvent = m_event->id();
60  // better to keep the keys and just set to zero the values
61  for (acceptmap_t::iterator it = m_averageAccept.begin(), ed = m_averageAccept.end(); it != ed; ++it) {
62  it->second = 0;
63  }
64 
65  // loop over events
67  for (m_event->toBegin(); !m_event->atEnd(); ++(*m_event)) {
68  hTriggerResults.getByLabel(*m_event, "TriggerResults", "", "HLT");
69  edm::TriggerNames const* triggerNames(nullptr);
70  try {
71  triggerNames = &m_event->triggerNames(*hTriggerResults);
72  } catch (cms::Exception&) {
73  fwLog(fwlog::kError) << " exception caught while trying to get trigger info" << std::endl;
74  break;
75  }
76 
77  for (unsigned int i = 0; i < triggerNames->size(); ++i) {
78  if (hTriggerResults->accept(i)) {
79  m_averageAccept[triggerNames->triggerName(i)]++;
80  }
81  }
82  }
83  m_event->to(currentEvent);
84 
85  double denominator = 1.0 / m_event->size();
86  for (acceptmap_t::iterator it = m_averageAccept.begin(), ed = m_averageAccept.end(); it != ed; ++it) {
87  it->second *= denominator;
88  }
89 }
bool accept() const
Has at least one path accepted the event?
std::vector< Column > m_columns
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:402
FWStringParameter m_regex
void fillTable(fwlite::Event *event) override
FWHLTTriggerTableView(TEveWindowSlot *)
bool to(Long64_t iIndex)
Go to the event at index iIndex.
Definition: Event.cc:208
edm::EventID id() const
Definition: EventBase.h:59
bool atEnd() const override
Definition: Event.cc:267
Event const & toBegin() override
Go to the very first Event.
Definition: Event.cc:230
#define fwLog(_level_)
Definition: fwLog.h:45
FWStringParameter m_process
void getByLabel(const P &iP, const char *iModuleLabel, const char *iProductInstanceLabel=nullptr, const char *iProcessLabel=nullptr)
Definition: Handle.h:100
FWTriggerTableViewTableManager * m_tableManager
Long64_t size() const
Returns number of events in the file.
Definition: Event.cc:258
Definition: event.py:1