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_, summarizeEdmComparisonLogfiles::success, and evf::FUShmBuffer::writeErrorEventData().

44 {
45  if (0!=shmBuffer_) {
46  edm::LogInfo("FUShmReader")<<"detach from shared memory segment."<<endl;
47  if (lastCellIndex_<0xffffffff) {
48  edm::LogWarning("FUShmReader") << "Class destructor called without received STOP event!"<<endl;
49  if (lastCellIndex_<0xfffffffe)//not sending lumi cell to the error stream
51  bool success = shmBuffer_->removeClientPrcId(getpid());
52  if (!success)
53  edm::LogWarning("ShmMissingPID")<<"Destructor: did not find pid in shared memory index"<<endl;
54  }
55  shmdt(shmBuffer_);
56  }
57 }
bool writeErrorEventData(unsigned int runNumber, unsigned int fuProcessId, unsigned int iRawCell, bool checkValue)
Definition: FUShmBuffer.cc:746
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

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 65 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, evf::evt::STOPPER, and summarizeEdmComparisonLogfiles::success.

68 {
69  // just in case the reader hasn't yet attached to the shm segment
70  if (0==shmBuffer_) {
71  shmBuffer_=FUShmBuffer::getShmBuffer();
72  if(0==shmBuffer_) {
73  edm::LogError("NoShmBuffer")<<"Failed to retrieve shm segment."<<endl;
74  throw cms::Exception("NullPointer")<<"Failed to retrieve shm segment."<<endl;
75  }
76  }
77 
78  // discard old event
79  if(0!=event_) {
81  event_ = 0;
82  }
83 
84  // wait for an event to become available, retrieve it
86 
87  // if the event is 'stop', the reader is being told to shut down!
89  if (state==evt::STOP) {
90  edm::LogInfo("ShutDown")<<"Received STOP event, shut down."<<endl;
91  std::cout << getpid() << " Received STOP event, shut down." << std::endl;
92  if(newCell->getEventType() != evt::STOPPER){
93  edm::LogError("InconsistentStopCell") << getpid()
94  << " GOT what claims to be a STOPPER event but eventType is "
95  << newCell->getEventType()
96  << std::endl;
97  }
98  bool pidstatus=true;
99  bool success = shmBuffer_->scheduleRawEmptyCellForDiscard(newCell,pidstatus);
100  if (!success) //should not happen for STOPPER cell
101  edm::LogError("InconsistentStopCell")<<"fillRawData:STOP: failed to discard STOP event raw cell!"<<endl;
102  else if (!pidstatus)
103  edm::LogWarning("ShmMissingPID")<<"fillRawData:STOP: did not find pid in shared memory pid index"<<endl;
104  shmdt(shmBuffer_);
105  shmBuffer_=0;
106  event_=0;
107  lastCellIndex_=0xffffffff;
108  return 0;
109  }
110  else if(state==evt::LUMISECTION){
111  unsigned int ls = newCell->getLumiSection();
112  if(newCell->getEventType() != evt::EOL){
113  edm::LogError("InconsistentLsCell") << getpid()
114  << " GOT what claims to be an EOL event but eventType is "
115  << newCell->getEventType()
116  << " and ls is " << ls
117  << std::endl;
119  }
121  lastCellIndex_=0xfffffffe;
122  if(ls==0){
123  edm::LogError("ZeroLsCell") << getpid()
124  << " GOT an EOL event for ls 0!!!"
125  << std::endl;
126  return fillRawData(eID, tstamp, data);
127  }
128  return (-1)*ls;
129  }
130  // getting an 'empty' event here is a pathological condition !!!
131  else if(state==evt::EMPTY){
132  edm::LogError("EmptyRawCell")
133  <<"Received empty event, this should not happen !!!" <<endl;
134  std::cout << getpid() << "Received EPTY event!!! ERROR." << std::endl;
135  return fillRawData(eID, tstamp, data);
136  }
137  else assert(state==evt::RAWREADING);
138 
139  // read the event data into the fwk raw data format
140  evtNumber_ =newCell->evtNumber();
141  lastCellIndex_=newCell->index();
143  for (unsigned int i=0;i<newCell->nFed();i++) {
144  unsigned int fedSize=newCell->fedSize(i);
145  if (fedSize>0) {
146  FEDRawData& fedData=event_->FEDData(i);
147  fedData.resize(fedSize);
148  newCell->readFed(i,fedData.data());
149  }
150  }
151 
152  // reading the cell is finished (new state will be 'isProcessing')
154  eID=EventID(runNumber_,1U,evtNumber_);
155  data=event_;
156  if(evtNumber_==0)
157  std::cout << getpid() << " ShmReader got event number zero !!! "
158  << std::endl;
159  return 1;
160 }
FUShmRawCell * rawCellToRead()
Definition: FUShmBuffer.cc:317
int i
Definition: DBlmapReader.cc:9
int fillRawData(edm::EventID &eID, edm::Timestamp &tstamp, FEDRawDataCollection *&data)
Definition: FUShmReader.cc:65
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:638
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:121
unsigned int fedSize(unsigned int i) const
Definition: FUShmRawCell.cc:82
unsigned int runNumber_
Definition: FUShmReader.h:40
void finishReadingRawCell(FUShmRawCell *cell)
Definition: FUShmBuffer.cc:410
void scheduleRawCellForDiscard(unsigned int iCell)
Definition: FUShmBuffer.cc:454
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 convertSQLiteXML::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().