CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
FUShmReader Class Reference

#include <FUShmReader.h>

Inheritance diagram for FUShmReader:
DaqBaseReader

Public Member Functions

int fillRawData (edm::EventID &eID, edm::Timestamp &tstamp, FEDRawDataCollection *&data)
 
 FUShmReader ()
 
virtual void setRunNumber (edm::RunNumber_t runNumber)
 set the run number More...
 
virtual ~FUShmReader ()
 
- Public Member Functions inherited from DaqBaseReader
 DaqBaseReader ()
 
virtual ~DaqBaseReader ()
 

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.

32  : event_(0)
33  , shmBuffer_(0)
34  , runNumber_(0xffffffff)
35  , evtNumber_(0xffffffff)
36  , lastCellIndex_(0xffffffff)
37 {
38  // shmBuffer_=FUShmBuffer::getShmBuffer();
39 }
unsigned int lastCellIndex_
Definition: FUShmReader.h:42
FEDRawDataCollection * event_
Definition: FUShmReader.h:37
evf::FUShmBuffer * shmBuffer_
Definition: FUShmReader.h:38
unsigned int evtNumber_
Definition: FUShmReader.h:41
unsigned int runNumber_
Definition: FUShmReader.h:40
FUShmReader::~FUShmReader ( )
virtual

Definition at line 43 of file FUShmReader.cc.

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

44 {
45  if (0!=shmBuffer_) {
46  edm::LogInfo("FUShmReader")<<"detach from shared memory segment."<<endl;
47  if (lastCellIndex_<0xffffffff) {
49  shmBuffer_->removeClientPrcId(getpid());
50  }
51  shmdt(shmBuffer_);
52  }
53 }
unsigned int lastCellIndex_
Definition: FUShmReader.h:42
bool removeClientPrcId(pid_t prcId)
evf::FUShmBuffer * shmBuffer_
Definition: FUShmReader.h:38
unsigned int runNumber_
Definition: FUShmReader.h:40
bool writeErrorEventData(unsigned int runNumber, unsigned int fuProcessId, unsigned int iRawCell)
Definition: FUShmBuffer.cc:702

Member Function Documentation

int 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) within the method; ownership is passed to the caller.

Implements DaqBaseReader.

Definition at line 61 of file FUShmReader.cc.

References gather_cfg::cout, FEDRawData::data(), evf::evt::EMPTY, evf::evt::EOL, event_, evf::FUShmRawCell::evtNumber(), evtNumber_, evf::FUShmBuffer::evtState(), edm::hlt::Exception, FEDRawDataCollection::FEDData(), evf::FUShmRawCell::fedSize(), evf::FUShmBuffer::finishReadingRawCell(), evf::FUShmRawCell::getEventType(), evf::FUShmRawCell::getLumiSection(), i, evf::FUShmRawCell::index(), lastCellIndex_, python.rootplot.utilities::ls(), evf::evt::LUMISECTION, evf::FUShmRawCell::nFed(), evf::FUShmBuffer::rawCellToRead(), evf::evt::RAWREADING, evf::FUShmRawCell::readFed(), FEDRawData::resize(), runNumber_, evf::FUShmBuffer::scheduleRawCellForDiscard(), evf::FUShmBuffer::scheduleRawEmptyCellForDiscard(), evf::FUShmBuffer::sem_print(), shmBuffer_, evf::utils::state, evf::evt::STOP, and evf::evt::STOPPER.

64 {
65  // just in case the reader hasn't yet attached to the shm segment
66  if (0==shmBuffer_) {
67  shmBuffer_=FUShmBuffer::getShmBuffer();
68  if(0==shmBuffer_) {
69  edm::LogError("NoShmBuffer")<<"Failed to retrieve shm segment."<<endl;
70  throw cms::Exception("NullPointer")<<"Failed to retrieve shm segment."<<endl;
71  }
72  }
73 
74  // discard old event
75  if(0!=event_) {
77  event_ = 0;
78  }
79 
80  // wait for an event to become available, retrieve it
82 
83  // if the event is 'stop', the reader is being told to shut down!
85  if (state==evt::STOP) {
86  edm::LogInfo("ShutDown")<<"Received STOP event, shut down."<<endl;
87  std::cout << getpid() << " Received STOP event, shut down." << std::endl;
88  if(newCell->getEventType() != evt::STOPPER){
89  edm::LogError("InconsistentLsCell") << getpid()
90  << " GOT what claims to be a STOPPER event but eventType is "
91  << newCell->getEventType()
92  << std::endl;
93  }
95  shmdt(shmBuffer_);
96  shmBuffer_=0;
97  event_=0;
98  lastCellIndex_=0xffffffff;
99  return 0;
100  }
101  else if(state==evt::LUMISECTION){
102  unsigned int ls = newCell->getLumiSection();
103  if(newCell->getEventType() != evt::EOL){
104  edm::LogError("InconsistentLsCell") << getpid()
105  << " GOT what claims to be an EOL event but eventType is "
106  << newCell->getEventType()
107  << " and ls is " << ls
108  << std::endl;
110  }
111  //shmBuffer_->setEvtState(newCell->index(),evt::PROCESSING);
113  if(ls==0){
114  edm::LogError("ZeroLsCell") << getpid()
115  << " GOT an EOL event for ls 0!!!"
116  << std::endl;
117  return fillRawData(eID, tstamp, data);
118  }
119  return (-1)*ls;
120  }
121  // getting an 'empty' event here is a pathological condition !!!
122  else if(state==evt::EMPTY){
123  edm::LogError("EmptyRawCell")
124  <<"Received empty event, this should not happen !!!" <<endl;
125  std::cout << getpid() << "Received EPTY event!!! ERROR." << std::endl;
126  return fillRawData(eID, tstamp, data);
127  }
128  else assert(state==evt::RAWREADING);
129 
130  // read the event data into the fwk raw data format
131  evtNumber_ =newCell->evtNumber();
132  lastCellIndex_=newCell->index();
134  for (unsigned int i=0;i<newCell->nFed();i++) {
135  unsigned int fedSize=newCell->fedSize(i);
136  if (fedSize>0) {
137  FEDRawData& fedData=event_->FEDData(i);
138  fedData.resize(fedSize);
139  newCell->readFed(i,fedData.data());
140  }
141  }
142 
143  // reading the cell is finished (new state will be 'isProcessing')
145  eID=EventID(runNumber_,1U,evtNumber_);
146  data=event_;
147  if(evtNumber_==0)
148  std::cout << getpid() << " ShmReader got event number zero !!! "
149  << std::endl;
150  return 1;
151 }
FUShmRawCell * rawCellToRead()
Definition: FUShmBuffer.cc:304
int i
Definition: DBlmapReader.cc:9
int fillRawData(edm::EventID &eID, edm::Timestamp &tstamp, FEDRawDataCollection *&data)
Definition: FUShmReader.cc:61
unsigned int lastCellIndex_
Definition: FUShmReader.h:42
FEDRawDataCollection * event_
Definition: FUShmReader.h:37
evt::State_t evtState(unsigned int index)
unsigned int evtNumber() const
Definition: FUShmRawCell.h:28
unsigned int getLumiSection() const
Definition: FUShmRawCell.h:70
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:33
unsigned int getEventType() const
Definition: FUShmRawCell.h:69
evf::FUShmBuffer * shmBuffer_
Definition: FUShmReader.h:38
void scheduleRawEmptyCellForDiscard()
Definition: FUShmBuffer.cc:594
unsigned int readFed(unsigned int i, unsigned char *buffer) const
unsigned int evtNumber_
Definition: FUShmReader.h:41
char state
Definition: procUtils.cc:75
unsigned int index() const
Definition: FUShmRawCell.h:25
unsigned int nFed() const
Definition: FUShmRawCell.h:33
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
tuple cout
Definition: gather_cfg.py:41
unsigned int fedSize(unsigned int i) const
Definition: FUShmRawCell.cc:84
unsigned int runNumber_
Definition: FUShmReader.h:40
void finishReadingRawCell(FUShmRawCell *cell)
Definition: FUShmBuffer.cc:385
void scheduleRawCellForDiscard(unsigned int iCell)
Definition: FUShmBuffer.cc:420
virtual void FUShmReader::setRunNumber ( edm::RunNumber_t  runNumber)
inlinevirtual

set the run number

Reimplemented from DaqBaseReader.

Definition at line 26 of file FUShmReader.h.

References inputsource_file_cfi::runNumber, and runNumber_.

Member Data Documentation

FEDRawDataCollection* FUShmReader::event_
private

Definition at line 37 of file FUShmReader.h.

Referenced by fillRawData().

unsigned int FUShmReader::evtNumber_
private

Definition at line 41 of file FUShmReader.h.

Referenced by fillRawData().

unsigned int FUShmReader::lastCellIndex_
private

Definition at line 42 of file FUShmReader.h.

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

unsigned int FUShmReader::runNumber_
private

Definition at line 40 of file FUShmReader.h.

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

evf::FUShmBuffer* FUShmReader::shmBuffer_
private

Definition at line 38 of file FUShmReader.h.

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