CMS 3D CMS Logo

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 28 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(), edm::ActivityRegistry::watchPreStreamBeginRun(), and ~ThroughputService().

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 ( )
default

Referenced by ThroughputService().

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 100 of file ThroughputService.cc.

References KineDebug3::count(), DEFINE_FWK_SERVICE, m_startup, m_stream_histograms, cmsPerfSuiteHarvest::now, edm::StreamContext::streamID(), cond::timestamp, and edm::StreamID::value().

Referenced by ThroughputService().

101 {
102  unsigned int sid = sc.streamID().value();
104  m_stream_histograms[sid].retired_events->Fill( std::chrono::duration_cast<std::chrono::duration<double>>(timestamp - m_startup).count() );
105 }
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 79 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().

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

Definition at line 86 of file ThroughputService.cc.

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

Referenced by ThroughputService().

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

Definition at line 40 of file ThroughputService.cc.

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

Referenced by ThroughputService().

41 {
43 
44  m_stream_histograms.resize( bounds.maxNumberOfStreams() );
45 
46  // assign a pseudo module id to the ThroughputService
48 }
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 93 of file ThroughputService.cc.

References KineDebug3::count(), m_startup, m_stream_histograms, cmsPerfSuiteHarvest::now, and cond::timestamp.

Referenced by ThroughputService().

94 {
96  m_stream_histograms[sid].sourced_events->Fill( std::chrono::duration_cast<std::chrono::duration<double>>(timestamp - m_startup).count() );
97 }
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 51 of file ThroughputService.cc.

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

Referenced by ThroughputService().

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

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

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

Definition at line 57 of file ThroughputService.h.

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

double ThroughputService::m_time_range
private

Definition at line 62 of file ThroughputService.h.

Referenced by preStreamBeginRun().

double ThroughputService::m_time_resolution
private

Definition at line 63 of file ThroughputService.h.

Referenced by preStreamBeginRun().