CMS 3D CMS Logo

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

#include <DQMEventProcessor.h>

Inheritance diagram for stor::DQMEventProcessor:

Public Member Functions

 DQMEventProcessor (xdaq::Application *, SharedResourcesPtr sr)
 
bool processDQMEvents (toolbox::task::WorkLoop *)
 
void startWorkLoop (std::string workloopName)
 
 ~DQMEventProcessor ()
 

Private Member Functions

 DQMEventProcessor (DQMEventProcessor const &)
 
void endOfRun ()
 
DQMEventProcessoroperator= (DQMEventProcessor const &)
 
void processNextDQMEvent ()
 

Private Attributes

bool actionIsActive_
 
xdaq::Application * app_
 
unsigned int discardDQMUpdatesForOlderLS_
 
DQMEventStore< I2OChain,
DataSenderMonitorCollection,
AlarmHandler
dqmEventStore_
 
uint32_t latestLumiSection_
 
toolbox::task::WorkLoop * processWL_
 
SharedResourcesPtr sharedResources_
 
boost::posix_time::time_duration timeout_
 

Detailed Description

Processes the DQM event (histograms)

It retrieves the next DQM event from the DQMEventQueue, adds up the histograms belonging to one lumi-section, and puts it into the appropriate DQMConsumerQueues. Depending on the configuration, it also writes the histograms to disk every N lumi-sections.

Author:
mommsen
Revision:
1.9
Date:
2012/04/20 10:48:18

Definition at line 39 of file DQMEventProcessor.h.

Constructor & Destructor Documentation

stor::DQMEventProcessor::DQMEventProcessor ( xdaq::Application *  app,
SharedResourcesPtr  sr 
)

Definition at line 33 of file DQMEventProcessor.cc.

References stor::WorkerThreadParams::DQMEPdeqWaitTime_, sharedResources_, and timeout_.

33  :
34  app_(app),
35  sharedResources_(sr),
36  actionIsActive_(true),
40  (
41  app->getApplicationDescriptor(),
42  sr->dqmEventQueueCollection_,
43  sr->statisticsReporter_->getDQMEventMonitorCollection(),
44  &sr->statisticsReporter_->getDataSenderMonitorCollection(),
46  sr->alarmHandler_.get(),
48  sr->alarmHandler_
49  )
50  {
51  WorkerThreadParams workerParams =
52  sharedResources_->configuration_->getWorkerThreadParams();
53  timeout_ = workerParams.DQMEPdeqWaitTime_;
54  }
SharedResourcesPtr sharedResources_
DQMEventStore< I2OChain, DataSenderMonitorCollection, AlarmHandler > dqmEventStore_
virtual void moveToFailedState(xcept::Exception &)
xdaq::Application * app_
unsigned int discardDQMUpdatesForOlderLS_
boost::posix_time::time_duration timeout_
stor::DQMEventProcessor::~DQMEventProcessor ( )

Definition at line 57 of file DQMEventProcessor.cc.

References actionIsActive_, and processWL_.

58  {
59  // Stop the activity
60  actionIsActive_ = false;
61 
62  // Cancel the workloop (will wait until the action has finished)
63  processWL_->cancel();
64  }
toolbox::task::WorkLoop * processWL_
stor::DQMEventProcessor::DQMEventProcessor ( DQMEventProcessor const &  )
private

Member Function Documentation

void stor::DQMEventProcessor::endOfRun ( )
private

Purge instances and process all completed DQM records

Definition at line 190 of file DQMEventProcessor.cc.

References dqmEventStore_, and latestLumiSection_.

Referenced by processNextDQMEvent().

191  {
192  dqmEventStore_.purge();
193  latestLumiSection_ = 0;
194  }
DQMEventStore< I2OChain, DataSenderMonitorCollection, AlarmHandler > dqmEventStore_
DQMEventProcessor& stor::DQMEventProcessor::operator= ( DQMEventProcessor const &  )
private
bool stor::DQMEventProcessor::processDQMEvents ( toolbox::task::WorkLoop *  )

The workloop action taking the next DQM event from the DQMEventQueue, processes it, and puts it into the appropriate DQMConsumerQueues when the lumi-section has finished.

Definition at line 94 of file DQMEventProcessor.cc.

References actionIsActive_, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, processNextDQMEvent(), and sharedResources_.

Referenced by startWorkLoop().

95  {
96  std::string errorMsg = "Failed to process a DQM event: ";
97 
98  try
99  {
101  }
102  catch(xcept::Exception &e)
103  {
104  XCEPT_DECLARE_NESTED( stor::exception::DQMEventProcessing,
105  sentinelException, errorMsg, e );
106  sharedResources_->alarmHandler_->moveToFailedState(sentinelException);
107  }
108  catch(std::exception &e)
109  {
110  errorMsg += e.what();
111  XCEPT_DECLARE( stor::exception::DQMEventProcessing,
112  sentinelException, errorMsg );
113  sharedResources_->alarmHandler_->moveToFailedState(sentinelException);
114  }
115  catch(...)
116  {
117  errorMsg += "Unknown exception";
118  XCEPT_DECLARE( stor::exception::DQMEventProcessing,
119  sentinelException, errorMsg );
120  sharedResources_->alarmHandler_->moveToFailedState(sentinelException);
121  }
122 
123  return actionIsActive_;
124  }
SharedResourcesPtr sharedResources_
void stor::DQMEventProcessor::processNextDQMEvent ( )
private

Pops the next DQM event from the DQMEventQueue and adds it to the DQMStore

Definition at line 127 of file DQMEventProcessor.cc.

References stor::DQMEventProcessorResources::Requests::configuration, stor::DQMProcessingParams::discardDQMUpdatesForOlderLS_, discardDQMUpdatesForOlderLS_, dqmEventStore_, stor::DQMEventProcessorResources::Requests::endOfRun, endOfRun(), Vispa.Plugins.EdmBrowser.EdmDataAccessor::eq(), stor::utils::getCurrentTime(), latestLumiSection_, max(), sharedResources_, stor::DQMEventProcessorResources::Requests::storeDestruction, and timeout_.

Referenced by processDQMEvents().

128  {
129  DQMEventQueue::ValueType dqmEvent;
130  DQMEventQueuePtr eq = sharedResources_->dqmEventQueue_;
132  if (eq->deqTimedWait(dqmEvent, timeout_))
133  {
134  utils::Duration_t elapsedTime = utils::getCurrentTime() - startTime;
135  sharedResources_->statisticsReporter_->getThroughputMonitorCollection().
136  addDQMEventProcessorIdleSample(elapsedTime);
137 
138  if (
140  (dqmEvent.first.lumiSection() + discardDQMUpdatesForOlderLS_ < latestLumiSection_)
141  )
142  // subtracting unsigned quantities might not yield the right result!
143  {
144  // discard very old LS
145  sharedResources_->statisticsReporter_->getDQMEventMonitorCollection().
146  getDroppedDQMEventCountsMQ().addSample(dqmEvent.second + 1);
147  }
148  else
149  {
150  sharedResources_->statisticsReporter_->getThroughputMonitorCollection().
151  addPoppedDQMEventSample(dqmEvent.first.memoryUsed());
152  sharedResources_->statisticsReporter_->getDQMEventMonitorCollection().
153  getDroppedDQMEventCountsMQ().addSample(dqmEvent.second);
154 
155  latestLumiSection_ = std::max(latestLumiSection_, dqmEvent.first.lumiSection());
156  dqmEventStore_.addDQMEvent(dqmEvent.first);
157  }
158  }
159  else
160  {
161  utils::Duration_t elapsedTime = utils::getCurrentTime() - startTime;
162  sharedResources_->statisticsReporter_->getThroughputMonitorCollection().
163  addDQMEventProcessorIdleSample(elapsedTime);
164  }
165 
166  DQMEventProcessorResources::Requests requests;
167  DQMProcessingParams dqmParams;
168  boost::posix_time::time_duration newTimeoutValue;
169  if (sharedResources_->dqmEventProcessorResources_->
170  getRequests(requests, dqmParams, newTimeoutValue))
171  {
172  if (requests.configuration)
173  {
174  timeout_ = newTimeoutValue;
175  dqmEventStore_.setParameters(dqmParams);
176  discardDQMUpdatesForOlderLS_ = dqmParams.discardDQMUpdatesForOlderLS_;
177  }
178  if (requests.endOfRun)
179  {
180  endOfRun();
181  }
182  if (requests.storeDestruction)
183  {
184  dqmEventStore_.clear();
185  }
186  sharedResources_->dqmEventProcessorResources_->requestsDone();
187  }
188  }
TimePoint_t getCurrentTime()
Definition: Utils.h:158
boost::shared_ptr< DQMEventQueue > DQMEventQueuePtr
Definition: DQMEventQueue.h:23
SharedResourcesPtr sharedResources_
EnqPolicy::ValueType ValueType
boost::posix_time::time_duration Duration_t
Definition: Utils.h:41
const T & max(const T &a, const T &b)
boost::posix_time::ptime TimePoint_t
Definition: Utils.h:35
DQMEventStore< I2OChain, DataSenderMonitorCollection, AlarmHandler > dqmEventStore_
unsigned int discardDQMUpdatesForOlderLS_
boost::posix_time::time_duration timeout_
void stor::DQMEventProcessor::startWorkLoop ( std::string  workloopName)

Creates and starts the DQM event processing workloop

Definition at line 67 of file DQMEventProcessor.cc.

References app_, alignCSCRings::e, edm::hlt::Exception, stor::utils::getIdentifier(), lumiQueryAPI::msg, processDQMEvents(), and processWL_.

68  {
69  try
70  {
71  std::string identifier = utils::getIdentifier(app_->getApplicationDescriptor());
72 
73  processWL_ = toolbox::task::getWorkLoopFactory()->
74  getWorkLoop( identifier + workloopName, "waiting" );
75 
76  if ( ! processWL_->isActive() )
77  {
78  toolbox::task::ActionSignature* processAction =
79  toolbox::task::bind(this, &DQMEventProcessor::processDQMEvents,
80  identifier + "ProcessNextDQMEvent");
81  processWL_->submit(processAction);
82 
83  processWL_->activate();
84  }
85  }
86  catch (xcept::Exception& e)
87  {
88  std::string msg = "Failed to start workloop 'DQMEventProcessor' with 'processNextDQMEvent'.";
89  XCEPT_RETHROW(stor::exception::DQMEventProcessing, msg, e);
90  }
91  }
toolbox::task::WorkLoop * processWL_
bool processDQMEvents(toolbox::task::WorkLoop *)
std::string getIdentifier(xdaq::ApplicationDescriptor *)
Definition: Utils.cc:72
xdaq::Application * app_

Member Data Documentation

bool stor::DQMEventProcessor::actionIsActive_
private

Definition at line 83 of file DQMEventProcessor.h.

Referenced by processDQMEvents(), and ~DQMEventProcessor().

xdaq::Application* stor::DQMEventProcessor::app_
private

Definition at line 79 of file DQMEventProcessor.h.

Referenced by startWorkLoop().

unsigned int stor::DQMEventProcessor::discardDQMUpdatesForOlderLS_
private

Definition at line 85 of file DQMEventProcessor.h.

Referenced by processNextDQMEvent().

DQMEventStore<I2OChain,DataSenderMonitorCollection,AlarmHandler> stor::DQMEventProcessor::dqmEventStore_
private

Definition at line 89 of file DQMEventProcessor.h.

Referenced by endOfRun(), and processNextDQMEvent().

uint32_t stor::DQMEventProcessor::latestLumiSection_
private

Definition at line 84 of file DQMEventProcessor.h.

Referenced by endOfRun(), and processNextDQMEvent().

toolbox::task::WorkLoop* stor::DQMEventProcessor::processWL_
private

Definition at line 87 of file DQMEventProcessor.h.

Referenced by startWorkLoop(), and ~DQMEventProcessor().

SharedResourcesPtr stor::DQMEventProcessor::sharedResources_
private

Definition at line 80 of file DQMEventProcessor.h.

Referenced by DQMEventProcessor(), processDQMEvents(), and processNextDQMEvent().

boost::posix_time::time_duration stor::DQMEventProcessor::timeout_
private

Definition at line 82 of file DQMEventProcessor.h.

Referenced by DQMEventProcessor(), and processNextDQMEvent().