CMS 3D CMS Logo

FUShmReader Class Reference

#include <EventFilter/ShmReader/interface/FUShmReader.h>

Inheritance diagram for FUShmReader:

DaqBaseReader

List of all members.

Public Member Functions

bool fillRawData (edm::EventID &eID, edm::Timestamp &tstamp, FEDRawDataCollection *&data)
 overload to fill the fed collection to be put in the transient event store.
 FUShmReader ()
virtual ~FUShmReader ()

Private Attributes

FEDRawDataCollectionevent_
unsigned int evtNumber_
unsigned int lastCellIndex_
unsigned int runNumber_
evf::FUShmBuffershmBuffer_


Detailed Description

Definition at line 10 of file FUShmReader.h.


Constructor & Destructor Documentation

FUShmReader::FUShmReader (  ) 

Definition at line 31 of file FUShmReader.cc.

References shmBuffer_.

00032   : event_(0)
00033   , shmBuffer_(0)
00034   , runNumber_(0xffffffff)
00035   , evtNumber_(0xffffffff)
00036   , lastCellIndex_(0xffffffff)
00037 {
00038   shmBuffer_=FUShmBuffer::getShmBuffer();
00039 }

FUShmReader::~FUShmReader (  )  [virtual]

Definition at line 43 of file FUShmReader.cc.

References lat::endl(), lastCellIndex_, evf::FUShmBuffer::removeClientPrcId(), runNumber_, shmBuffer_, and evf::FUShmBuffer::writeErrorEventData().

00044 {
00045   if (0!=shmBuffer_) {
00046     edm::LogInfo("FUShmReader")<<"detach from shared memory segment."<<endl;
00047     if (lastCellIndex_<0xffffffff) {
00048       shmBuffer_->writeErrorEventData(runNumber_,getpid(),lastCellIndex_);
00049       shmBuffer_->removeClientPrcId(getpid());
00050     }
00051     shmdt(shmBuffer_);
00052   }
00053 }


Member Function Documentation

bool FUShmReader::fillRawData ( edm::EventID eID,
edm::Timestamp tstamp,
FEDRawDataCollection *&  data 
) [virtual]

overload to fill the fed collection to be put in the transient event store.

NOTE: the FEDRawDataCollection data must be created (with new) withing the method; ownership is passed to the caller.

Implements DaqBaseReader.

Definition at line 61 of file FUShmReader.cc.

References FEDRawData::data(), evf::dqm::EMPTY, lat::endl(), event_, evf::FUShmRawCell::evtNumber(), evtNumber_, evf::FUShmBuffer::evtState(), Exception, FEDRawDataCollection::FEDData(), evf::FUShmRawCell::fedSize(), evf::FUShmBuffer::finishReadingRawCell(), i, evf::FUShmRawCell::index(), lastCellIndex_, evf::FUShmRawCell::nFed(), evf::FUShmBuffer::rawCellToRead(), evf::evt::RAWREADING, evf::FUShmRawCell::readFed(), FEDRawData::resize(), runNumber_, evf::FUShmBuffer::scheduleRawCellForDiscard(), evf::FUShmBuffer::scheduleRawEmptyCellForDiscard(), shmBuffer_, and state.

00064 {
00065   // just in case the reader hasn't yet attached to the shm segment
00066   if (0==shmBuffer_) {
00067     shmBuffer_=FUShmBuffer::getShmBuffer();
00068     if(0==shmBuffer_) {
00069       edm::LogError("NoShmBuffer")<<"Failed to retrieve shm segment."<<endl;
00070       throw cms::Exception("NullPointer")<<"Failed to retrieve shm segment."<<endl;
00071     }
00072   }
00073   
00074   // discard old event
00075   if(0!=event_) {
00076     shmBuffer_->scheduleRawCellForDiscard(lastCellIndex_);
00077     event_ = 0;
00078   }
00079   
00080   // wait for an event to become available, retrieve it
00081   FUShmRawCell* newCell=shmBuffer_->rawCellToRead();
00082   
00083   // if the event is 'empty', the reader is being told to shut down!
00084   evt::State_t state=shmBuffer_->evtState(newCell->index());
00085   if (state==evt::EMPTY) {
00086     edm::LogInfo("ShutDown")<<"Received empty event, shut down."<<endl;
00087     shmBuffer_->scheduleRawEmptyCellForDiscard(newCell);
00088     shmdt(shmBuffer_);
00089     shmBuffer_=0;
00090     event_=0;
00091     lastCellIndex_=0xffffffff;
00092     return false;
00093   }
00094   else assert(state==evt::RAWREADING);
00095   
00096   // read the event data into the fwk raw data format
00097   evtNumber_    =newCell->evtNumber();
00098   lastCellIndex_=newCell->index();
00099   event_        =new FEDRawDataCollection();
00100   for (unsigned int i=0;i<newCell->nFed();i++) {
00101     unsigned int fedSize=newCell->fedSize(i);
00102     if (fedSize>0) {
00103       FEDRawData& fedData=event_->FEDData(i);
00104       fedData.resize(fedSize);
00105       newCell->readFed(i,fedData.data());
00106     }
00107   }
00108   
00109   // reading the cell is finished (new state will be 'isProcessing')
00110   shmBuffer_->finishReadingRawCell(newCell);
00111   eID=EventID(runNumber_,evtNumber_);
00112   data=event_;
00113   
00114   return true;
00115 }


Member Data Documentation

FEDRawDataCollection* FUShmReader::event_ [private]

Definition at line 34 of file FUShmReader.h.

Referenced by fillRawData().

unsigned int FUShmReader::evtNumber_ [private]

Definition at line 38 of file FUShmReader.h.

Referenced by fillRawData().

unsigned int FUShmReader::lastCellIndex_ [private]

Definition at line 39 of file FUShmReader.h.

Referenced by fillRawData(), and ~FUShmReader().

unsigned int FUShmReader::runNumber_ [private]

Definition at line 37 of file FUShmReader.h.

Referenced by fillRawData(), and ~FUShmReader().

evf::FUShmBuffer* FUShmReader::shmBuffer_ [private]

Definition at line 35 of file FUShmReader.h.

Referenced by fillRawData(), FUShmReader(), and ~FUShmReader().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:21:08 2009 for CMSSW by  doxygen 1.5.4