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 Types | Private Member Functions | Private Attributes
smproxy::DQMArchiver Class Reference

#include <DQMArchiver.h>

Public Member Functions

 DQMArchiver (StateMachine *)
 
const stor::DQMEventConsRegPtrgetRegPtr () const
 
 ~DQMArchiver ()
 

Private Types

typedef std::map< std::string,
stor::DQMTopLevelFolder::Record
Records
 

Private Member Functions

void activity ()
 
void createRegistration ()
 
void doIt ()
 
void handleDQMEvent (const stor::DQMTopLevelFolder::Record &)
 
void updateLastRecord (const stor::DQMTopLevelFolder::Record &)
 
void writeDQMEventToFile (const DQMEventMsgView &, const bool endRun) const
 

Private Attributes

const DQMArchivingParams dqmArchivingParams_
 
stor::DQMEventQueueCollectionPtr dqmEventQueueCollection_
 
Records lastUpdateForFolders_
 
stor::DQMEventConsRegPtr regPtr_
 
StateMachinestateMachine_
 
boost::scoped_ptr< boost::thread > thread_
 

Detailed Description

Archive DQM histograms

Author:
mommsen
Revision:
1.2
Date:
2011/03/07 15:41:54

Definition at line 30 of file DQMArchiver.h.

Member Typedef Documentation

typedef std::map<std::string,stor::DQMTopLevelFolder::Record> smproxy::DQMArchiver::Records
private

Definition at line 61 of file DQMArchiver.h.

Constructor & Destructor Documentation

smproxy::DQMArchiver::DQMArchiver ( StateMachine stateMachine)

Definition at line 23 of file DQMArchiver.cc.

References activity(), smproxy::DQMArchivingParams::archiveDQM_, createRegistration(), dqmArchivingParams_, and thread_.

23  :
24  stateMachine_(stateMachine),
25  dqmArchivingParams_(stateMachine->getConfiguration()->getDQMArchivingParams()),
26  dqmEventQueueCollection_(stateMachine->getDQMEventQueueCollection())
27  {
29  {
31  thread_.reset(
32  new boost::thread( boost::bind(&DQMArchiver::activity, this) )
33  );
34  }
35  }
stor::DQMEventQueueCollectionPtr dqmEventQueueCollection_
Definition: DQMArchiver.h:56
StateMachine * stateMachine_
Definition: DQMArchiver.h:54
const DQMArchivingParams dqmArchivingParams_
Definition: DQMArchiver.h:55
boost::scoped_ptr< boost::thread > thread_
Definition: DQMArchiver.h:59
smproxy::DQMArchiver::~DQMArchiver ( )

Definition at line 37 of file DQMArchiver.cc.

References thread_.

38  {
39  if (thread_) thread_->join();
40  }
boost::scoped_ptr< boost::thread > thread_
Definition: DQMArchiver.h:59

Member Function Documentation

void smproxy::DQMArchiver::activity ( )
private

Definition at line 42 of file DQMArchiver.cc.

References doIt(), alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, smproxy::StateMachine::moveToFailedState(), and stateMachine_.

Referenced by DQMArchiver().

43  {
44  try
45  {
46  doIt();
47  }
48  catch(xcept::Exception &e)
49  {
51  }
52  catch(std::exception &e)
53  {
54  XCEPT_DECLARE(exception::DQMArchival,
55  sentinelException, e.what());
56  stateMachine_->moveToFailedState(sentinelException);
57  }
58  catch(...)
59  {
60  std::string errorMsg = "Unknown exception in DQM archiving thread";
61  XCEPT_DECLARE(exception::DQMArchival,
62  sentinelException, errorMsg);
63  stateMachine_->moveToFailedState(sentinelException);
64  }
65  }
StateMachine * stateMachine_
Definition: DQMArchiver.h:54
void moveToFailedState(xcept::Exception &e)
Definition: StateMachine.h:79
void smproxy::DQMArchiver::createRegistration ( )
private

Definition at line 159 of file DQMArchiver.cc.

References edm::ParameterSet::addUntrackedParameter(), smproxy::DQMArchivingParams::archiveTopLevelFolder_, dqmArchivingParams_, dqmEventQueueCollection_, smproxy::StateMachine::getConfiguration(), smproxy::StateMachine::getRegistrationCollection(), regPtr_, and stateMachine_.

Referenced by DQMArchiver().

160  {
161  edm::ParameterSet pset;
162  pset.addUntrackedParameter<std::string>("DQMconsumerName", "DQMArchiver");
163  pset.addUntrackedParameter<std::string>("topLevelFolderName",
165 
167  stateMachine_->getConfiguration()->getEventServingParams(),
168  "internal")
169  );
170 
171  stor::RegistrationCollectionPtr registrationCollection =
173 
174  const stor::ConsumerID cid = registrationCollection->getConsumerId();
175  regPtr_->setConsumerId(cid);
176 
177  const stor::QueueID qid = dqmEventQueueCollection_->createQueue(regPtr_);
178  regPtr_->setQueueId(qid);
179 
180  registrationCollection->addRegistrationInfo(regPtr_);
181  }
stor::DQMEventQueueCollectionPtr dqmEventQueueCollection_
Definition: DQMArchiver.h:56
StateMachine * stateMachine_
Definition: DQMArchiver.h:54
const DQMArchivingParams dqmArchivingParams_
Definition: DQMArchiver.h:55
boost::shared_ptr< RegistrationCollection > RegistrationCollectionPtr
stor::DQMEventConsRegPtr regPtr_
Definition: DQMArchiver.h:57
ConfigurationPtr getConfiguration() const
Definition: StateMachine.h:93
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
std::string archiveTopLevelFolder_
Definition: Configuration.h:50
stor::RegistrationCollectionPtr getRegistrationCollection() const
Definition: StateMachine.h:97
void smproxy::DQMArchiver::doIt ( )
private

Definition at line 67 of file DQMArchiver.cc.

References dqmEventQueueCollection_, smproxy::StateMachine::getRegistrationCollection(), handleDQMEvent(), lastUpdateForFolders_, regPtr_, stor::utils::sleep(), stateMachine_, and writeDQMEventToFile().

Referenced by activity(), helpers.MassSearchReplaceAnyInputTagVisitor::doIt(), HiHelperTools.MassSearchReplaceAnyInputTagVisitor::doIt(), HiHelperTools.MassSearchReplaceAnyInputTagVisitor::enter(), and helpers.MassSearchReplaceAnyInputTagVisitor::enter().

68  {
69  stor::RegistrationCollectionPtr registrationCollection =
71  const stor::ConsumerID cid = regPtr_->consumerId();
72 
73  while ( registrationCollection->registrationIsAllowed(cid) )
74  {
76  dqmEventQueueCollection_->popEvent(cid);
77 
78  if ( dqmEvent.first.empty() )
79  ::sleep(1);
80  else
81  handleDQMEvent(dqmEvent.first);
82  }
83 
84  // run ended, write the last updates to file
85  BOOST_FOREACH(
86  const Records::value_type& pair,
88  )
89  {
90  writeDQMEventToFile(pair.second.getDQMEventMsgView(), true);
91  }
92  }
void writeDQMEventToFile(const DQMEventMsgView &, const bool endRun) const
Definition: DQMArchiver.cc:128
stor::DQMEventQueueCollectionPtr dqmEventQueueCollection_
Definition: DQMArchiver.h:56
StateMachine * stateMachine_
Definition: DQMArchiver.h:54
void sleep(Duration_t)
Definition: Utils.h:163
boost::shared_ptr< RegistrationCollection > RegistrationCollectionPtr
stor::DQMEventConsRegPtr regPtr_
Definition: DQMArchiver.h:57
void handleDQMEvent(const stor::DQMTopLevelFolder::Record &)
Definition: DQMArchiver.cc:94
Container::value_type value_type
ExpirableQueue< T, RejectNewest< T > >::ValueType ValueType
Records lastUpdateForFolders_
Definition: DQMArchiver.h:62
stor::RegistrationCollectionPtr getRegistrationCollection() const
Definition: StateMachine.h:97
const stor::DQMEventConsRegPtr& smproxy::DQMArchiver::getRegPtr ( ) const
inline

Return the registration pointer

Definition at line 41 of file DQMArchiver.h.

References regPtr_.

Referenced by smproxy::DataManager::doIt().

42  { return regPtr_; }
stor::DQMEventConsRegPtr regPtr_
Definition: DQMArchiver.h:57
void smproxy::DQMArchiver::handleDQMEvent ( const stor::DQMTopLevelFolder::Record record)
private

Definition at line 94 of file DQMArchiver.cc.

References smproxy::DQMArchivingParams::archiveIntervalDQM_, dqmArchivingParams_, stor::DQMTopLevelFolder::Record::getDQMEventMsgView(), updateLastRecord(), DQMEventMsgView::updateNumber(), and writeDQMEventToFile().

Referenced by doIt().

95  {
96  const DQMEventMsgView view = record.getDQMEventMsgView();
97 
98  updateLastRecord(record);
99 
100  if (
103  )
104  {
105  writeDQMEventToFile(view, false);
106  }
107  }
void writeDQMEventToFile(const DQMEventMsgView &, const bool endRun) const
Definition: DQMArchiver.cc:128
DQMEventMsgView getDQMEventMsgView() const
unsigned int archiveIntervalDQM_
Definition: Configuration.h:52
uint32 updateNumber() const
const DQMArchivingParams dqmArchivingParams_
Definition: DQMArchiver.h:55
void updateLastRecord(const stor::DQMTopLevelFolder::Record &)
Definition: DQMArchiver.cc:109
void smproxy::DQMArchiver::updateLastRecord ( const stor::DQMTopLevelFolder::Record record)
private

Definition at line 109 of file DQMArchiver.cc.

References stor::DQMTopLevelFolder::Record::getDQMEventMsgView(), lastUpdateForFolders_, pos, record, and DQMEventMsgView::topFolderName().

Referenced by handleDQMEvent().

110  {
111  const DQMEventMsgView view = record.getDQMEventMsgView();
112  const std::string topFolderName = view.topFolderName();
113  Records::iterator pos = lastUpdateForFolders_.lower_bound(topFolderName);
114 
115  if (pos != lastUpdateForFolders_.end() &&
116  !(lastUpdateForFolders_.key_comp()(topFolderName, pos->first)))
117  {
118  // key already exists
119  pos->second = record;
120  }
121  else
122  {
123  lastUpdateForFolders_.insert(pos, Records::value_type(topFolderName, record));
124  }
125  }
DQMEventMsgView getDQMEventMsgView() const
JetCorrectorParameters::Record record
Definition: classes.h:11
std::string topFolderName() const
Container::value_type value_type
Records lastUpdateForFolders_
Definition: DQMArchiver.h:62
void smproxy::DQMArchiver::writeDQMEventToFile ( const DQMEventMsgView view,
const bool  endRun 
) const
private

Definition at line 128 of file DQMArchiver.cc.

References edm::DQMHttpSource::addEventToDQMBackend(), stor::MonitoredQuantity::addSample(), edm::ParameterSet::addUntrackedParameter(), convertXMLtoSQLite_cfg::fileName, stor::DQMEventMonitorCollection::getNumberOfWrittenTopLevelFoldersMQ(), stor::DQMEventMonitorCollection::getWrittenDQMEventSizeMQ(), DQMEventMsgView::lumiSection(), DQMEventMsgView::runNumber(), DQMEventMsgView::size(), and DQMStore::StripRunDirs.

Referenced by doIt(), and handleDQMEvent().

132  {
133  edm::ParameterSet dqmStorePSet;
134  dqmStorePSet.addUntrackedParameter<bool>("collateHistograms", true);
135  DQMStore dqmStore(dqmStorePSet);
136 
137  std::ostringstream fileName;
139  << "/DQM_R"
140  << std::setfill('0') << std::setw(9) << view.runNumber();
141  if ( ! endRun ) fileName << "_L" << std::setw(6) << view.lumiSection();
142  fileName << ".root";
143 
144  // don't require that the file exists
145  dqmStore.load(fileName.str(), DQMStore::StripRunDirs, false);
146 
147  edm::DQMHttpSource::addEventToDQMBackend(&dqmStore, view, false);
148 
149  dqmStore.save(fileName.str());
150 
152  stateMachine_->getStatisticsReporter()->getDQMEventMonitorCollection();
154  static_cast<double>(view.size()) / 0x100000
155  );
157  }
static void addEventToDQMBackend(DQMStore *, const DQMEventMsgView &, const bool overwrite)
StateMachine * stateMachine_
Definition: DQMArchiver.h:54
void addSample(const double &value=1)
const DQMArchivingParams dqmArchivingParams_
Definition: DQMArchiver.h:55
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
const MonitoredQuantity & getWrittenDQMEventSizeMQ() const
uint32 lumiSection() const
const MonitoredQuantity & getNumberOfWrittenTopLevelFoldersMQ() const
uint32 size() const
StatisticsReporterPtr getStatisticsReporter() const
Definition: StateMachine.h:107
uint32 runNumber() const

Member Data Documentation

const DQMArchivingParams smproxy::DQMArchiver::dqmArchivingParams_
private

Definition at line 55 of file DQMArchiver.h.

Referenced by createRegistration(), DQMArchiver(), and handleDQMEvent().

stor::DQMEventQueueCollectionPtr smproxy::DQMArchiver::dqmEventQueueCollection_
private

Definition at line 56 of file DQMArchiver.h.

Referenced by createRegistration(), and doIt().

Records smproxy::DQMArchiver::lastUpdateForFolders_
private

Definition at line 62 of file DQMArchiver.h.

Referenced by doIt(), and updateLastRecord().

stor::DQMEventConsRegPtr smproxy::DQMArchiver::regPtr_
private

Definition at line 57 of file DQMArchiver.h.

Referenced by createRegistration(), doIt(), and getRegPtr().

StateMachine* smproxy::DQMArchiver::stateMachine_
private

Definition at line 54 of file DQMArchiver.h.

Referenced by activity(), createRegistration(), and doIt().

boost::scoped_ptr<boost::thread> smproxy::DQMArchiver::thread_
private

Definition at line 59 of file DQMArchiver.h.

Referenced by DQMArchiver(), and ~DQMArchiver().