Go to the documentation of this file.00001
00003
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 #include "DataFormats/Provenance/interface/EventAuxiliary.h"
00006 #include "EventFilter/StorageManager/interface/CurlInterface.h"
00007 #include "EventFilter/StorageManager/src/DQMHttpSource.h"
00008 #include "EventFilter/StorageManager/src/EventServerProxy.icc"
00009 #include "FWCore/ServiceRegistry/interface/Service.h"
00010 #include "FWCore/Utilities/interface/Exception.h"
00011 #include "IOPool/Streamer/interface/StreamDQMDeserializer.h"
00012
00013 #include "TClass.h"
00014
00015 #include <memory>
00016 #include <string>
00017 #include <vector>
00018
00019
00020 namespace edm
00021 {
00022 boost::mutex DQMHttpSource::mutex_;
00023
00024
00025 DQMHttpSource::DQMHttpSource
00026 (
00027 const ParameterSet& pset,
00028 const InputSourceDescription& desc
00029 ) :
00030 edm::RawInputSource(pset, desc),
00031 eventAuxiliary_(),
00032 dqmEventServerProxy_(pset),
00033 dqmStore_(0)
00034 {}
00035
00036
00037 bool DQMHttpSource::checkNextEvent() {
00038 initializeDQMStore();
00039 stor::CurlInterface::Content data;
00040
00041 dqmEventServerProxy_.getOneEvent(data);
00042 if ( data.empty() ) return false;
00043
00044 HeaderView hdrView(&data[0]);
00045 if (hdrView.code() == Header::DONE) return false;
00046
00047 const DQMEventMsgView dqmEventMsgView(&data[0]);
00048 addEventToDQMBackend(dqmStore_, dqmEventMsgView, true);
00049
00050 EventID id(dqmEventMsgView.runNumber(), dqmEventMsgView.lumiSection(), dqmEventMsgView.eventNumberAtUpdate());
00051
00052 setEventAuxiliary(std::unique_ptr<EventAuxiliary>(new EventAuxiliary(id, std::string(), dqmEventMsgView.timeStamp(), true, EventAuxiliary::PhysicsTrigger)));
00053
00054 if(!runAuxiliary() || runAuxiliary()->run() != eventAuxiliary().run()) {
00055 setRunAuxiliary(new RunAuxiliary(eventAuxiliary().run(), eventAuxiliary().time(), Timestamp::invalidTimestamp()));
00056 }
00057 if(!luminosityBlockAuxiliary() || luminosityBlockAuxiliary()->luminosityBlock() != eventAuxiliary().luminosityBlock()) {
00058 setLuminosityBlockAuxiliary(new LuminosityBlockAuxiliary(eventAuxiliary().run(), eventAuxiliary().luminosityBlock(), eventAuxiliary().time(), Timestamp::invalidTimestamp()));
00059 }
00060 setEventCached();
00061 return true;
00062 }
00063
00064 EventPrincipal* DQMHttpSource::read(EventPrincipal& eventPrincipal)
00065 {
00066
00067
00068 EventPrincipal* e = makeEvent(
00069 eventPrincipal,
00070 eventAuxiliary()
00071 );
00072
00073 return e;
00074 }
00075
00076
00077 void DQMHttpSource::addEventToDQMBackend
00078 (
00079 DQMStore* dqmStore,
00080 const DQMEventMsgView& dqmEventMsgView,
00081 const bool overwrite
00082 )
00083 {
00084 boost::mutex::scoped_lock sl(mutex_);
00085
00086 MonitorElement* me = dqmStore->get("SM_SMPS_Stats/mergeCount");
00087 if (!me){
00088 dqmStore->setCurrentFolder("SM_SMPS_Stats");
00089 me = dqmStore->bookInt("mergeCount");
00090 }
00091 me->Fill(dqmEventMsgView.mergeCount());
00092
00093 edm::StreamDQMDeserializer deserializeWorker;
00094 std::auto_ptr<DQMEvent::TObjectTable> toTablePtr =
00095 deserializeWorker.deserializeDQMEvent(dqmEventMsgView);
00096
00097 for (DQMEvent::TObjectTable::const_iterator tableIter = toTablePtr->begin(),
00098 tableIterEnd = toTablePtr->end(); tableIter != tableIterEnd; ++tableIter)
00099 {
00100 const std::string subFolderName = tableIter->first;
00101 std::vector<TObject*> toList = tableIter->second;
00102 dqmStore->setCurrentFolder(subFolderName);
00103
00104 for (std::vector<TObject*>::const_iterator objectIter = toList.begin(),
00105 objectIterEnd = toList.end(); objectIter != objectIterEnd; ++objectIter)
00106 {
00107 dqmStore->extract(*objectIter, dqmStore->pwd(), overwrite);
00108
00109 delete *objectIter;
00110 }
00111 }
00112 }
00113
00114
00115 void DQMHttpSource::initializeDQMStore()
00116 {
00117 if ( ! dqmStore_ )
00118 dqmStore_ = edm::Service<DQMStore>().operator->();
00119
00120 if ( ! dqmStore_ )
00121 throw cms::Exception("readOneEvent", "DQMHttpSource")
00122 << "Unable to lookup the DQMStore service!\n";
00123 }
00124
00125 }
00126
00127