CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/EventFilter/StorageManager/src/EventStreamHttpReader.cc

Go to the documentation of this file.
00001 // $Id: EventStreamHttpReader.cc,v 1.51 2011/07/05 12:06:04 mommsen 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   lastLS_(0)
00029   {
00030     // Default in StreamerInputSource is 'false'
00031     inputFileTransitionsEachEvent_ =
00032       pset.getUntrackedParameter<bool>("inputFileTransitionsEachEvent", true);
00033 
00034     readHeader();
00035   }
00036   
00037   
00038   EventPrincipal* EventStreamHttpReader::read()
00039   {
00040     initializeDQMStore();
00041 
00042     stor::CurlInterface::Content data;
00043     unsigned int currentLS(0);
00044     unsigned int droppedEvents(0);
00045     
00046     do
00047     {
00048       eventServerProxy_.getOneEvent(data);
00049       if ( data.empty() ) return 0;
00050       
00051       HeaderView hdrView(&data[0]);
00052       if (hdrView.code() == Header::DONE)
00053       {
00054         setEndRun();
00055         return 0;
00056       }
00057       
00058       EventMsgView eventView(&data[0]);
00059       currentLS = eventView.lumi();
00060       droppedEvents += eventView.droppedEventsCount();
00061     }
00062     while (
00063       dropOldLumisectionEvents_ &&
00064       lastLS_ > currentLS
00065     );
00066     
00067     lastLS_ = currentLS;
00068 
00069     if (dqmStore_)
00070     {
00071       MonitorElement* me = dqmStore_->get("SM_SMPS_Stats/droppedEventsCount_" + consumerName_ );
00072       if (!me){
00073         dqmStore_->setCurrentFolder("SM_SMPS_Stats");
00074         me = dqmStore_->bookInt("droppedEventsCount_" + consumerName_ );
00075       }
00076       me->Fill(droppedEvents);
00077     }
00078 
00079     return deserializeEvent(EventMsgView(&data[0]));
00080   }
00081   
00082   
00083   void EventStreamHttpReader::readHeader()
00084   {
00085     stor::CurlInterface::Content data;
00086     
00087     eventServerProxy_.getInitMsg(data);
00088     InitMsgView initView(&data[0]);
00089     deserializeAndMergeWithRegistry(initView);
00090   }
00091   
00092   
00093   void EventStreamHttpReader::initializeDQMStore()
00094   {
00095     if ( ! dqmStoreAvailabiltyChecked_ )
00096     {   
00097       try
00098       {
00099         dqmStore_ = edm::Service<DQMStore>().operator->();
00100       }
00101       catch (cms::Exception& e)
00102       {
00103         edm::LogInfo("EventStreamHttpReader")
00104           << "Service DQMStore not defined. Will not record the number of dropped events.";
00105       }
00106       dqmStoreAvailabiltyChecked_ = true;
00107     }
00108   }
00109 
00110 
00111 } //namespace edm
00112 
00113