CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes

edm::FUShmOutputModule Class Reference

#include <FUShmOutputModule.h>

Inheritance diagram for edm::FUShmOutputModule:
evf::OutputModule

List of all members.

Public Member Functions

void clearDatasetCounts ()
void countEventForDatasets (EventMsgView const &eventMessage)
void doOutputEvent (EventMsgBuilder const &eventMessage)
void doOutputHeader (InitMsgBuilder const &initMessage)
 FUShmOutputModule (edm::ParameterSet const &ps)
unsigned int getCounts ()
std::vector< unsigned int > & getDatasetCounts ()
std::vector< std::string > getDatasetNames ()
std::string getStreamId ()
void insertStreamAndDatasetInfo (edm::ParameterSet &streams, edm::ParameterSet datasets)
void parseDatasets (InitMsgView const &initMessage)
void sendPostponedInitMsg ()
void sendPostponedStart ()
void setNExpectedEPs (unsigned int EPs)
void setPostponeInitMsg ()
void start ()
void stop ()
void unregisterFromShm ()
 ~FUShmOutputModule ()

Static Public Member Functions

static void fillDescription (ParameterSetDescription &)

Private Attributes

unsigned int count_
std::vector< unsigned int > datasetCounts_
std::vector< StringsdatasetPaths_
std::vector< std::pair
< std::string,
edm::EventSelector * > > 
dpEventSelectors_
std::string name_
unsigned int nExpectedEPs_
unsigned int numDatasets_
std::vector< std::string > selectedDatasetNames_
evf::FUShmBuffershmBuffer_
std::string streamId_
unsigned int totalPaths_

Static Private Attributes

static uint32 fuGuidValue_ = 0
static bool fuIdsInitialized_ = false

Detailed Description

Definition at line 59 of file FUShmOutputModule.h.


Constructor & Destructor Documentation

edm::FUShmOutputModule::FUShmOutputModule ( edm::ParameterSet const &  ps)

Definition at line 44 of file FUShmOutputModule.cc.

References FDEBUG, fuGuidValue_, fuIdsInitialized_, dttmaxenums::L, name_, and edm::Guid::toString().

                                                               :
    shmBuffer_(0)
    , name_(ps.getParameter<std::string>( "@module_label" ))
    , count_(0)
    , nExpectedEPs_(0)
    , numDatasets_(0)
    , streamId_()
  {
    FDEBUG(9) << "FUShmOutputModule: constructor" << endl;
    if(edm::Service<evf::ShmOutputModuleRegistry>())
      edm::Service<evf::ShmOutputModuleRegistry>()->registerModule(name_, this);  
    if (! fuIdsInitialized_) {
      fuIdsInitialized_ = true;

      edm::Guid guidObj(true);
      std::string guidString = guidObj.toString();

      uLong crc = crc32(0L, Z_NULL, 0);
      Bytef* buf = (Bytef*)guidString.data();
      crc = crc32(crc, buf, guidString.length());
      fuGuidValue_ = crc;
    }
  }
edm::FUShmOutputModule::~FUShmOutputModule ( )

Definition at line 68 of file FUShmOutputModule.cc.

References SM_SharedMemoryHandle::detachShmBuffer(), FDEBUG, and sm_sharedmemory.

  {
    FDEBUG(9) << "FUShmOutputModule: FUShmOutputModule destructor" << endl;
    sm_sharedmemory.detachShmBuffer();
    //shmdt(shmBuffer_);
  }

Member Function Documentation

void edm::FUShmOutputModule::clearDatasetCounts ( ) [inline]

Definition at line 80 of file FUShmOutputModule.h.

References datasetCounts_, and i.

                              {
            for (unsigned int i=0;i<datasetCounts_.size();i++) datasetCounts_[i]=0;
    }
void edm::FUShmOutputModule::countEventForDatasets ( EventMsgView const &  eventMessage)

Definition at line 202 of file FUShmOutputModule.cc.

References datasetCounts_, dpEventSelectors_, EventMsgView::hltTriggerBits(), i, numDatasets_, edm::second(), and totalPaths_.

Referenced by doOutputEvent().

  {
    if (!numDatasets_) return;
    uint8 hlt_out[totalPaths_];
    eventMessage.hltTriggerBits( hlt_out );
    for (size_t i=0;i<numDatasets_;i++) {
      if ( dpEventSelectors_[i].second->acceptEvent( hlt_out, totalPaths_)) {
        datasetCounts_[i]++;
      }
    }
  }
void edm::FUShmOutputModule::doOutputEvent ( EventMsgBuilder const &  eventMessage)

Definition at line 133 of file FUShmOutputModule.cc.

References count_, countEventForDatasets(), FDEBUG, fuGuidValue_, SM_SharedMemoryHandle::getShmBuffer(), run_regression::ret, shmBuffer_, findQualityFiles::size, EventMsgBuilder::size(), sm_sharedmemory, EventMsgBuilder::startAddress(), and evf::FUShmBuffer::writeRecoEventData().

  {
    if(!shmBuffer_) edm::LogError("FUShmOutputModule") 
      << " Invalid shared memory buffer at first event"
      << " Make sure you configure the ResourceBroker before the FUEventProcessor! "
      << " No event is sent - this is fatal! Should throw here";
    else
    {
      count_++;
      unsigned char* buffer = (unsigned char*) eventMessage.startAddress();
      unsigned int size = eventMessage.size();
      EventMsgView eventView(eventMessage.startAddress());
      countEventForDatasets(eventView);
      unsigned int runid = eventView.run();
      unsigned int eventid = eventView.event();
      unsigned int outModId = eventView.outModId();
      FDEBUG(10) << "FUShmOutputModule: event size = " << size << std::endl;
      //bool ret = shmBuffer_->writeRecoEventData(runid, eventid, outModId, buffer, size);
      bool ret = sm_sharedmemory.getShmBuffer()->writeRecoEventData(runid, eventid, outModId, getpid(), fuGuidValue_, buffer, size);
      if(!ret) edm::LogError("FUShmOutputModule") << " Error with writing data to ShmBuffer";
    }
  }
void edm::FUShmOutputModule::doOutputHeader ( InitMsgBuilder const &  initMessage)

Definition at line 109 of file FUShmOutputModule.cc.

References count_, FDEBUG, fuGuidValue_, SM_SharedMemoryHandle::getShmBuffer(), nExpectedEPs_, InitMsgView::outputModuleId(), parseDatasets(), run_regression::ret, shmBuffer_, findQualityFiles::size, InitMsgBuilder::size(), sm_sharedmemory, InitMsgBuilder::startAddress(), and evf::FUShmBuffer::writeRecoInitMsg().

  {
    unsigned char* buffer = (unsigned char*) initMessage.startAddress();
    unsigned int size = initMessage.size();
    InitMsgView dummymsg(buffer);
    parseDatasets(dummymsg);
    count_ = 0;
    if(!shmBuffer_) shmBuffer_ = sm_sharedmemory.getShmBuffer();
    if(!shmBuffer_) edm::LogError("FUShmOutputModule") 
      << " Error getting shared memory buffer for INIT. " 
      << " Make sure you configure the ResourceBroker before the FUEventProcessor! "
      << " No INIT is sent - this is probably fatal!";
    if(shmBuffer_)
    {
      FDEBUG(10) << "writing out INIT message with size = " << size << std::endl;
      // no method in InitMsgBuilder to get the output module id, recast
      uint32 dmoduleId = dummymsg.outputModuleId();

      //bool ret = shmBuffer_->writeRecoInitMsg(dmoduleId, buffer, size);
      bool ret = sm_sharedmemory.getShmBuffer()->writeRecoInitMsg(dmoduleId, getpid(), fuGuidValue_, buffer, size,nExpectedEPs_);
      if(!ret) edm::LogError("FUShmOutputModule") << " Error writing preamble to ShmBuffer";
    }
  }
void edm::FUShmOutputModule::fillDescription ( ParameterSetDescription description) [static]

Definition at line 104 of file FUShmOutputModule.cc.

  {
  }
unsigned int edm::FUShmOutputModule::getCounts ( ) [inline, virtual]

Implements evf::OutputModule.

Definition at line 69 of file FUShmOutputModule.h.

References count_.

                            {
      return count_;
    }
std::vector<unsigned int>& edm::FUShmOutputModule::getDatasetCounts ( ) [inline]

Definition at line 79 of file FUShmOutputModule.h.

References datasetCounts_.

{return datasetCounts_;}
std::vector<std::string> edm::FUShmOutputModule::getDatasetNames ( ) [inline]
std::string edm::FUShmOutputModule::getStreamId ( ) [inline]

Definition at line 83 of file FUShmOutputModule.h.

References streamId_.

Referenced by evf::ShmOutputModuleRegistry::updateDatasetInfo().

{return streamId_;}
void edm::FUShmOutputModule::insertStreamAndDatasetInfo ( edm::ParameterSet streams,
edm::ParameterSet  datasets 
)

Definition at line 75 of file FUShmOutputModule.cc.

References datasetPaths_, edm::ParameterSet::getParameter(), i, name_, numDatasets_, selectedDatasetNames_, and streamId_.

Referenced by evf::ShmOutputModuleRegistry::insertStreamAndDatasetInfo().

  {
    if (numDatasets_) return;
    try {
      //compose dataset name string
      if (name_.size() > std::string("hltOutput").size() && name_.find("hltOutput")!=std::string::npos)
        streamId_=name_.substr(name_.find("hltOutput")+std::string("hltOutput").size());
      else return;

      //make local copy of dataset definitions
      if (streamId_.size()) {
        Strings streamDatasetList = streams.getParameter<Strings>(streamId_);
        for (size_t i=0;i<streamDatasetList.size();i++) {
          selectedDatasetNames_.push_back(streamDatasetList[i]);
          Strings thisDatasetPaths = datasets.getParameter<Strings>(streamDatasetList[i]); 
          datasetPaths_.push_back(thisDatasetPaths);
          numDatasets_++;
        }
      }
    }
    catch (...) {
      //not present:ignore
      selectedDatasetNames_.clear();
      datasetPaths_.clear();
      numDatasets_=0;
      streamId_=std::string();
    }
  }
void edm::FUShmOutputModule::parseDatasets ( InitMsgView const &  initMessage)

Definition at line 185 of file FUShmOutputModule.cc.

References datasetCounts_, datasetPaths_, dpEventSelectors_, InitMsgView::hltTriggerNames(), i, numDatasets_, selectedDatasetNames_, and totalPaths_.

Referenced by doOutputHeader().

  {
     //reset counter
     for (size_t i=0;i<datasetCounts_.size();i++) datasetCounts_[i]=0;
     if (!numDatasets_) return;
     if (dpEventSelectors_.size()) return;
     Strings allPaths;
     initMessage.hltTriggerNames(allPaths);
     totalPaths_ = allPaths.size();
     for (size_t i=0;i<numDatasets_;i++)
     {
       dpEventSelectors_.push_back(std::pair<std::string,
         edm::EventSelector*>(selectedDatasetNames_[i],new edm::EventSelector(datasetPaths_[i],allPaths))); 
       datasetCounts_.push_back(0);
     }
  }
void edm::FUShmOutputModule::sendPostponedInitMsg ( )
void edm::FUShmOutputModule::sendPostponedStart ( )
void edm::FUShmOutputModule::setNExpectedEPs ( unsigned int  EPs)

Definition at line 174 of file FUShmOutputModule.cc.

References nExpectedEPs_.

                                                          {
    nExpectedEPs_ = EPs;
  }
void edm::FUShmOutputModule::setPostponeInitMsg ( )
void edm::FUShmOutputModule::start ( void  )

Definition at line 156 of file FUShmOutputModule.cc.

References SM_SharedMemoryHandle::getShmBuffer(), shmBuffer_, and sm_sharedmemory.

  {
    //shmBuffer_ = evf::FUShmBuffer::getShmBuffer();
    shmBuffer_ = sm_sharedmemory.getShmBuffer();
    if(0==shmBuffer_) 
      edm::LogError("FUShmOutputModule")<<"Failed to attach to shared memory";
  }
void edm::FUShmOutputModule::stop ( )

Definition at line 164 of file FUShmOutputModule.cc.

References SM_SharedMemoryHandle::detachShmBuffer(), FDEBUG, shmBuffer_, and sm_sharedmemory.

  {
    FDEBUG(9) << "FUShmOutputModule: sending terminate run" << std::endl;
    if(0!=shmBuffer_){
      sm_sharedmemory.detachShmBuffer();
      //shmdt(shmBuffer_);
      shmBuffer_ = 0;
    }
  }
void edm::FUShmOutputModule::unregisterFromShm ( )

Member Data Documentation

unsigned int edm::FUShmOutputModule::count_ [private]

Definition at line 96 of file FUShmOutputModule.h.

Referenced by doOutputEvent(), doOutputHeader(), and getCounts().

std::vector<unsigned int> edm::FUShmOutputModule::datasetCounts_ [private]

Definition at line 107 of file FUShmOutputModule.h.

Referenced by insertStreamAndDatasetInfo(), and parseDatasets().

std::vector<std::pair<std::string,edm::EventSelector*> > edm::FUShmOutputModule::dpEventSelectors_ [private]

Definition at line 108 of file FUShmOutputModule.h.

Referenced by countEventForDatasets(), and parseDatasets().

Definition at line 99 of file FUShmOutputModule.h.

Referenced by doOutputEvent(), doOutputHeader(), and FUShmOutputModule().

bool edm::FUShmOutputModule::fuIdsInitialized_ = false [static, private]

Initialize the static variables for the filter unit identifiers.

Definition at line 98 of file FUShmOutputModule.h.

Referenced by FUShmOutputModule().

std::string edm::FUShmOutputModule::name_ [private]

Definition at line 95 of file FUShmOutputModule.h.

Referenced by FUShmOutputModule(), and insertStreamAndDatasetInfo().

unsigned int edm::FUShmOutputModule::nExpectedEPs_ [private]

Definition at line 100 of file FUShmOutputModule.h.

Referenced by doOutputHeader(), and setNExpectedEPs().

unsigned int edm::FUShmOutputModule::numDatasets_ [private]
std::vector<std::string> edm::FUShmOutputModule::selectedDatasetNames_ [private]

Definition at line 106 of file FUShmOutputModule.h.

Referenced by getDatasetNames(), insertStreamAndDatasetInfo(), and parseDatasets().

Definition at line 94 of file FUShmOutputModule.h.

Referenced by doOutputEvent(), doOutputHeader(), start(), stop(), and unregisterFromShm().

std::string edm::FUShmOutputModule::streamId_ [private]

Definition at line 111 of file FUShmOutputModule.h.

Referenced by getStreamId(), and insertStreamAndDatasetInfo().

unsigned int edm::FUShmOutputModule::totalPaths_ [private]

Definition at line 109 of file FUShmOutputModule.h.

Referenced by countEventForDatasets(), and parseDatasets().