CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMHttpSource.cc
Go to the documentation of this file.
1 // $Id: DQMHttpSource.cc,v 1.28 2011/07/05 12:06:04 mommsen Exp $
3 
7 #include "EventFilter/StorageManager/src/EventServerProxy.icc"
11 
12 #include "TClass.h"
13 
14 #include <string>
15 #include <vector>
16 
17 
18 namespace edm
19 {
21 
22 
24  (
25  const ParameterSet& pset,
26  const InputSourceDescription& desc
27  ) :
28  edm::RawInputSource(pset, desc),
29  dqmEventServerProxy_(pset),
30  dqmStore_(0)
31  {}
32 
33 
34  std::auto_ptr<Event> DQMHttpSource::readOneEvent()
35  {
38 
40  if ( data.empty() ) return std::auto_ptr<edm::Event>();
41 
42  HeaderView hdrView(&data[0]);
43  if (hdrView.code() == Header::DONE)
44  return std::auto_ptr<edm::Event>();
45 
46  const DQMEventMsgView dqmEventMsgView(&data[0]);
47  addEventToDQMBackend(dqmStore_, dqmEventMsgView, true);
48 
49  // make a fake event containing no data but the evId and runId from DQMEvent
50  // and the time stamp from the event at update
51  std::auto_ptr<Event> e = makeEvent(
52  dqmEventMsgView.runNumber(),
53  dqmEventMsgView.lumiSection(),
54  dqmEventMsgView.eventNumberAtUpdate(),
55  dqmEventMsgView.timeStamp()
56  );
57 
58  return e;
59  }
60 
61 
63  (
64  DQMStore* dqmStore,
65  const DQMEventMsgView& dqmEventMsgView,
66  const bool overwrite
67  )
68  {
69  boost::mutex::scoped_lock sl(mutex_);
70 
71  MonitorElement* me = dqmStore->get("SM_SMPS_Stats/mergeCount");
72  if (!me){
73  dqmStore->setCurrentFolder("SM_SMPS_Stats");
74  me = dqmStore->bookInt("mergeCount");
75  }
76  me->Fill(dqmEventMsgView.mergeCount());
77 
78  edm::StreamDQMDeserializer deserializeWorker;
79  std::auto_ptr<DQMEvent::TObjectTable> toTablePtr =
80  deserializeWorker.deserializeDQMEvent(dqmEventMsgView);
81 
82  for (DQMEvent::TObjectTable::const_iterator tableIter = toTablePtr->begin(),
83  tableIterEnd = toTablePtr->end(); tableIter != tableIterEnd; ++tableIter)
84  {
85  const std::string subFolderName = tableIter->first;
86  std::vector<TObject*> toList = tableIter->second;
87  dqmStore->setCurrentFolder(subFolderName); // creates dir if needed
88 
89  for (std::vector<TObject*>::const_iterator objectIter = toList.begin(),
90  objectIterEnd = toList.end(); objectIter != objectIterEnd; ++objectIter)
91  {
92  dqmStore->extract(*objectIter, dqmStore->pwd(), overwrite);
93  // TObject cloned into DQMStore. Thus, delete it here.
94  delete *objectIter;
95  }
96  }
97  }
98 
99 
101  {
102  if ( ! dqmStore_ )
104 
105  if ( ! dqmStore_ )
106  throw cms::Exception("readOneEvent", "DQMHttpSource")
107  << "Unable to lookup the DQMStore service!\n";
108  }
109 
110 } // namespace edm
111 
112 
static void addEventToDQMBackend(DQMStore *, const DQMEventMsgView &, const bool overwrite)
static boost::mutex mutex
Definition: LHEProxy.cc:11
DQMHttpSource(const edm::ParameterSet &, const edm::InputSourceDescription &)
std::auto_ptr< Event > makeEvent(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, Timestamp const &tstamp)
uint32 eventNumberAtUpdate() const
uint32 code() const
Definition: MsgHeader.h:34
void Fill(long long x)
static boost::mutex mutex_
Definition: DQMHttpSource.h:57
bool extract(TObject *obj, const std::string &dir, bool overwrite)
Definition: DQMStore.cc:1771
std::auto_ptr< DQMEvent::TObjectTable > deserializeDQMEvent(DQMEventMsgView const &dqmEventView)
stor::EventServerProxy< stor::DQMEventConsumerRegistrationInfo > dqmEventServerProxy_
Definition: DQMHttpSource.h:54
virtual std::auto_ptr< edm::Event > readOneEvent()
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
uint32 lumiSection() const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void getOneEvent(CurlInterface::Content &data)
DQMStore * dqmStore_
Definition: DQMHttpSource.h:55
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:624
uint32 runNumber() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
edm::Timestamp timeStamp() const
uint32 mergeCount() const
const std::string & pwd(void) const
Definition: DQMStore.cc:401
std::vector< char > Content
Definition: CurlInterface.h:31