CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/EventFilter/Utilities/plugins/EvFRecordInserter.cc

Go to the documentation of this file.
00001 #include "EvFRecordInserter.h"
00002 
00003 #include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
00004 #include "FWCore/Utilities/interface/Exception.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007 
00008 namespace evf{
00009 
00010   EvFRecordInserter::EvFRecordInserter( const edm::ParameterSet& pset) 
00011     : evc_(0)
00012     , ehi_(0LL)
00013     , last_(0)
00014     , label_(pset.getParameter<edm::InputTag>("inputTag"))
00015   {}
00016     void EvFRecordInserter::analyze(const edm::Event & e, const edm::EventSetup& c)
00017     {
00018       edm::Handle<FEDRawDataCollection> rawdata;
00019       e.getByLabel(label_,rawdata);
00020       unsigned int id = fedinterface::EVFFED_ID;
00021       const FEDRawData& data = rawdata->FEDData(id);
00022       size_t size=data.size();
00023       unsigned char * cdata = const_cast<unsigned char*>(data.data());
00024       timeval now;
00025       gettimeofday(&now,0);
00026       evc_++;
00027       uint32_t ldiff = 0;
00028       if(e.id().event()-last_ < 0xff)
00029         ldiff = e.id().event()-last_;
00030       else
00031         ldiff = 0xff;
00032       ehi_ = (ehi_<<8)+(uint64_t)ldiff;
00033       last_ = e.id().event();
00034       if(size>0){
00035         ef_.setEPTimeStamp(((uint64_t)(now.tv_sec) << 32) 
00036                            + (uint64_t)(now.tv_usec),cdata);
00037         
00038         ef_.setEPProcessId(getpid(),cdata);
00039         ef_.setEPEventId(e.id().event(), cdata);
00040         ef_.setEPEventCount(evc_, cdata);
00041         ef_.setEPEventHisto(ehi_, cdata);
00042       }
00043     }
00044     
00045 
00046 } // end namespace evf