CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/EventFilter/StorageManager/src/EventStreamHttpReader.cc

Go to the documentation of this file.
00001 // $Id: EventStreamHttpReader.cc,v 1.54 2012/10/31 17:09:27 wmtan Exp $
00003 
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 #include "EventFilter/StorageManager/interface/CurlInterface.h"
00006 #include "EventFilter/StorageManager/src/EventServerProxy.icc"
00007 #include "EventFilter/StorageManager/src/EventStreamHttpReader.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include "FWCore/ServiceRegistry/interface/Service.h"
00010 #include "FWCore/Utilities/interface/Exception.h"
00011 
00012 #include <string>
00013 
00014 
00015 namespace edm
00016 {  
00017   EventStreamHttpReader::EventStreamHttpReader
00018   (
00019     ParameterSet const& pset,
00020     InputSourceDescription const& desc
00021   ):
00022   StreamerInputSource(pset, desc),
00023   eventServerProxy_(pset),
00024   dqmStore_(0),
00025   dqmStoreAvailabiltyChecked_(false),
00026   dropOldLumisectionEvents_(pset.getUntrackedParameter<bool>("dropOldLumisectionEvents", false)),
00027   consumerName_(pset.getUntrackedParameter<std::string>("consumerName")),
00028   totalDroppedEvents_(0),
00029   lastLS_(0)
00030   {
00031     // Default in StreamerInputSource is 'false'
00032     bool inputFileTransitionsEachEvent = pset.getUntrackedParameter<bool>("inputFileTransitionsEachEvent", true);
00033     if(inputFileTransitionsEachEvent) {
00034       setInputFileTransitionsEachEvent();
00035     }
00036 
00037     readHeader();
00038   }
00039   
00040   bool EventStreamHttpReader::checkNextEvent()
00041   {
00042     initializeDQMStore();
00043 
00044     stor::CurlInterface::Content data;
00045     unsigned int currentLS(0);
00046     unsigned int droppedEvents(0);
00047     
00048     do
00049     {
00050       eventServerProxy_.getOneEvent(data);
00051       if ( data.empty() ) return false;
00052       
00053       HeaderView hdrView(&data[0]);
00054       if (hdrView.code() == Header::DONE)
00055       {
00056         return false;
00057       }
00058       
00059       EventMsgView eventView(&data[0]);
00060       currentLS = eventView.lumi();
00061       droppedEvents += eventView.droppedEventsCount();
00062     }
00063     while (
00064       dropOldLumisectionEvents_ &&
00065       lastLS_ > currentLS
00066     );
00067     
00068     lastLS_ = currentLS;
00069 
00070     if (dqmStore_)
00071     {
00072       MonitorElement* me = dqmStore_->get("SM_SMPS_Stats/droppedEventsCount_" + consumerName_ );
00073       if (!me){
00074         dqmStore_->setCurrentFolder("SM_SMPS_Stats");
00075         me = dqmStore_->bookInt("droppedEventsCount_" + consumerName_ );
00076       }
00077       totalDroppedEvents_ += droppedEvents;
00078       me->Fill(totalDroppedEvents_);
00079     }
00080 
00081     deserializeEvent(EventMsgView(&data[0]));
00082     return true;
00083   }
00084   
00085   
00086   void EventStreamHttpReader::readHeader()
00087   {
00088     stor::CurlInterface::Content data;
00089     
00090     eventServerProxy_.getInitMsg(data);
00091     InitMsgView initView(&data[0]);
00092     deserializeAndMergeWithRegistry(initView);
00093   }
00094   
00095   
00096   void EventStreamHttpReader::initializeDQMStore()
00097   {
00098     if ( ! dqmStoreAvailabiltyChecked_ )
00099     {   
00100       try
00101       {
00102         dqmStore_ = edm::Service<DQMStore>().operator->();
00103       }
00104       catch (cms::Exception& e)
00105       {
00106         edm::LogInfo("EventStreamHttpReader")
00107           << "Service DQMStore not defined. Will not record the number of dropped events.";
00108       }
00109       dqmStoreAvailabiltyChecked_ = true;
00110     }
00111   }
00112 
00113 
00114 } //namespace edm
00115 
00116