CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
ThroughputService Class Reference

#include <ThroughputService.h>

Classes

struct  stream_histograms
 

Public Member Functions

 ThroughputService (const edm::ParameterSet &, edm::ActivityRegistry &)
 
 ~ThroughputService ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void postEvent (edm::StreamContext const &sc)
 
void postStreamEndLumi (edm::StreamContext const &sc)
 
void postStreamEndRun (edm::StreamContext const &sc)
 
void preallocate (edm::service::SystemBounds const &bounds)
 
void preSourceEvent (edm::StreamID sid)
 
void preStreamBeginRun (edm::StreamContext const &sc)
 

Private Attributes

std::string m_dqm_path
 
unsigned int m_module_id
 
std::chrono::steady_clock::time_point m_startup
 
std::vector< stream_histogramsm_stream_histograms
 
double m_time_range
 
double m_time_resolution
 

Detailed Description

Definition at line 29 of file ThroughputService.h.

Constructor & Destructor Documentation

ThroughputService::ThroughputService ( const edm::ParameterSet config,
edm::ActivityRegistry registry 
)

Definition at line 22 of file ThroughputService.cc.

References postEvent(), postStreamEndLumi(), postStreamEndRun(), preallocate(), preSourceEvent(), preStreamBeginRun(), edm::ActivityRegistry::watchPostEvent(), edm::ActivityRegistry::watchPostStreamEndLumi(), edm::ActivityRegistry::watchPostStreamEndRun(), edm::ActivityRegistry::watchPreallocate(), edm::ActivityRegistry::watchPreSourceEvent(), and edm::ActivityRegistry::watchPreStreamBeginRun().

22  :
24  // configuration
25  m_time_range( config.getUntrackedParameter<double>("timeRange") ),
26  m_time_resolution( config.getUntrackedParameter<double>("timeResolution") ),
27  m_dqm_path( config.getUntrackedParameter<std::string>("dqmPath" ) )
28 {
34  registry.watchPostEvent( this, & ThroughputService::postEvent );
35 }
void preallocate(edm::service::SystemBounds const &bounds)
T getUntrackedParameter(std::string const &, T const &) const
void watchPreallocate(Preallocate::slot_type const &iSlot)
void preSourceEvent(edm::StreamID sid)
void watchPostEvent(PostEvent::slot_type const &iSlot)
void watchPostStreamEndLumi(PostStreamEndLumi::slot_type const &iSlot)
void postStreamEndLumi(edm::StreamContext const &sc)
void postEvent(edm::StreamContext const &sc)
std::string m_dqm_path
void preStreamBeginRun(edm::StreamContext const &sc)
void watchPostStreamEndRun(PostStreamEndRun::slot_type const &iSlot)
std::vector< stream_histograms > m_stream_histograms
void watchPreStreamBeginRun(PreStreamBeginRun::slot_type const &iSlot)
void postStreamEndRun(edm::StreamContext const &sc)
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)
ThroughputService::~ThroughputService ( )

Definition at line 37 of file ThroughputService.cc.

38 {
39 }

Member Function Documentation

void ThroughputService::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 14 of file ThroughputService.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), and AlCaHLTBitMon_QueryRunRegistry::string.

14  {
16  desc.addUntracked<double>( "timeRange", 60000.0 );
17  desc.addUntracked<double>( "timeResolution", 10.0 );
18  desc.addUntracked<std::string>( "dqmPath", "HLT/Throughput" );
19  descriptions.add("ThroughputService", desc);
20 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void ThroughputService::postEvent ( edm::StreamContext const &  sc)
private

Definition at line 102 of file ThroughputService.cc.

References prof2calltree::count, m_startup, m_stream_histograms, fileCollector::now, edm::StreamContext::streamID(), cond::timestamp, and edm::StreamID::value().

Referenced by ThroughputService().

103 {
104  unsigned int sid = sc.streamID().value();
106  m_stream_histograms[sid].retired_events->Fill( std::chrono::duration_cast<std::chrono::duration<double>>(timestamp - m_startup).count() );
107 }
std::chrono::steady_clock::time_point m_startup
std::vector< stream_histograms > m_stream_histograms
void ThroughputService::postStreamEndLumi ( edm::StreamContext const &  sc)
private

Definition at line 81 of file ThroughputService.cc.

References edm::StreamContext::eventID(), edm::EventID::luminosityBlock(), m_module_id, edm::EventID::run(), edm::StreamContext::streamID(), and edm::StreamID::value().

Referenced by ThroughputService().

82 {
83  if (edm::Service<DQMStore>().isAvailable())
84  edm::Service<DQMStore>()->mergeAndResetMEsLuminositySummaryCache(sc.eventID().run(), sc.eventID().luminosityBlock(), sc.streamID().value(), m_module_id);
85 }
unsigned int m_module_id
void ThroughputService::postStreamEndRun ( edm::StreamContext const &  sc)
private

Definition at line 88 of file ThroughputService.cc.

References edm::StreamContext::eventID(), m_module_id, edm::EventID::run(), edm::StreamContext::streamID(), and edm::StreamID::value().

Referenced by ThroughputService().

89 {
90  if (edm::Service<DQMStore>().isAvailable())
91  edm::Service<DQMStore>()->mergeAndResetMEsRunSummaryCache(sc.eventID().run(), sc.streamID().value(), m_module_id);
92 }
unsigned int m_module_id
void ThroughputService::preallocate ( edm::service::SystemBounds const &  bounds)
private

Definition at line 42 of file ThroughputService.cc.

References edm::ModuleDescription::getUniqueID(), m_module_id, m_startup, m_stream_histograms, edm::service::SystemBounds::maxNumberOfStreams(), and fileCollector::now.

Referenced by ThroughputService().

43 {
45 
46  m_stream_histograms.resize( bounds.maxNumberOfStreams() );
47 
48  // assign a pseudo module id to the FastTimerService
50 }
static unsigned int getUniqueID()
Returns a unique id each time called. Intended to be passed to ModuleDescription&#39;s constructor&#39;s modI...
std::chrono::steady_clock::time_point m_startup
std::vector< stream_histograms > m_stream_histograms
unsigned int m_module_id
void ThroughputService::preSourceEvent ( edm::StreamID  sid)
private

Definition at line 95 of file ThroughputService.cc.

References prof2calltree::count, m_startup, m_stream_histograms, fileCollector::now, and cond::timestamp.

Referenced by ThroughputService().

96 {
98  m_stream_histograms[sid].sourced_events->Fill( std::chrono::duration_cast<std::chrono::duration<double>>(timestamp - m_startup).count() );
99 }
std::chrono::steady_clock::time_point m_startup
std::vector< stream_histograms > m_stream_histograms
void ThroughputService::preStreamBeginRun ( edm::StreamContext const &  sc)
private

Definition at line 53 of file ThroughputService.cc.

References edm::StreamContext::eventID(), cmsPerfStripChart::format, m_dqm_path, m_module_id, m_stream_histograms, m_time_range, m_time_resolution, edm::EventID::run(), edm::StreamContext::streamID(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::StreamID::value().

Referenced by ThroughputService().

54 {
55  // if the DQMStore is available, book the DQM histograms
56  if (edm::Service<DQMStore>().isAvailable()) {
57  unsigned int sid = sc.streamID().value();
58  auto & stream = m_stream_histograms[sid];
59 
60  std::string y_axis_title = (boost::format("events / %g s") % m_time_resolution).str();
61  unsigned int bins = std::round( m_time_range / m_time_resolution );
62  double range = bins * m_time_resolution;
63 
64  // define a callback that can book the histograms
65  auto bookTransactionCallback = [&, this] (DQMStore::IBooker & booker) {
66  booker.setCurrentFolder(m_dqm_path);
67  stream.sourced_events = booker.book1D("throughput_sourced", "Throughput (sourced events)", bins, 0., range)->getTH1F();
68  stream.sourced_events ->SetXTitle("time [s]");
69  stream.sourced_events ->SetYTitle(y_axis_title.c_str());
70  stream.retired_events = booker.book1D("throughput_retired", "Throughput (retired events)", bins, 0., range)->getTH1F();
71  stream.retired_events ->SetXTitle("time [s]");
72  stream.retired_events ->SetYTitle(y_axis_title.c_str());
73  };
74 
75  // book MonitorElement's for this stream
76  edm::Service<DQMStore>()->bookTransaction(bookTransactionCallback, sc.eventID().run(), sid, m_module_id);
77  }
78 }
string format
Some error handling for the usage.
std::string m_dqm_path
std::vector< stream_histograms > m_stream_histograms
unsigned int m_module_id

Member Data Documentation

std::string ThroughputService::m_dqm_path
private

Definition at line 68 of file ThroughputService.h.

Referenced by preStreamBeginRun().

unsigned int ThroughputService::m_module_id
private
std::chrono::steady_clock::time_point ThroughputService::m_startup
private

Definition at line 60 of file ThroughputService.h.

Referenced by postEvent(), preallocate(), and preSourceEvent().

std::vector<stream_histograms> ThroughputService::m_stream_histograms
private

Definition at line 58 of file ThroughputService.h.

Referenced by postEvent(), preallocate(), preSourceEvent(), and preStreamBeginRun().

double ThroughputService::m_time_range
private

Definition at line 63 of file ThroughputService.h.

Referenced by preStreamBeginRun().

double ThroughputService::m_time_resolution
private

Definition at line 64 of file ThroughputService.h.

Referenced by preStreamBeginRun().