CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Attributes

evf::FUShmRawCell Class Reference

#include <FUShmRawCell.h>

List of all members.

Public Member Functions

unsigned int buResourceId () const
void clear ()
void dump () const
unsigned int eventSize () const
unsigned int evtNumber () const
unsigned char * fedAddr (unsigned int i) const
unsigned int fedSize (unsigned int i) const
unsigned int fuResourceId () const
 FUShmRawCell (unsigned int payloadSize)
unsigned int getLumiSection () const
unsigned int index () const
void initialize (unsigned int index)
bool markFed (unsigned int i, unsigned int size, unsigned char *addr)
bool markSuperFrag (unsigned int i, unsigned int size, unsigned char *addr)
unsigned int nFed () const
unsigned int nSuperFrag () const
unsigned char * payloadAddr () const
unsigned int payloadSize () const
unsigned int readFed (unsigned int i, unsigned char *buffer) const
void setBuResourceId (unsigned int id)
void setEvtNumber (unsigned int evt)
void setFuResourceId (unsigned int id)
void setLumiSection (unsigned int)
unsigned char * superFragAddr (unsigned int i) const
unsigned int superFragSize (unsigned int i) const
unsigned char * writeData (unsigned char *data, unsigned int dataSize)
 ~FUShmRawCell ()

Static Public Member Functions

static unsigned int size (unsigned int payloadSize)

Private Attributes

unsigned int buResourceId_
unsigned int evtNumber_
unsigned int fedOffset_
unsigned int fedSizeOffset_
unsigned int fuResourceId_
unsigned int index_
unsigned int lumiSection_
unsigned int nFed_
unsigned int nSuperFrag_
unsigned int payloadOffset_
unsigned int payloadPosition_
unsigned int payloadSize_
unsigned int superFragOffset_
unsigned int superFragSizeOffset_

Detailed Description

Definition at line 7 of file FUShmRawCell.h.


Constructor & Destructor Documentation

FUShmRawCell::FUShmRawCell ( unsigned int  payloadSize)

Definition at line 29 of file FUShmRawCell.cc.

References fedAddr(), fedOffset_, fedSizeOffset_, nFed_, nSuperFrag_, payloadAddr(), payloadOffset_, payloadSize_, superFragAddr(), superFragOffset_, and superFragSizeOffset_.

Referenced by size().

  : payloadSize_(payloadSize)
  , nFed_(NFED_MAX)
  , nSuperFrag_(NSUPERFRAG_MAX)
  , lumiSection_(0)
{
  fedSizeOffset_=sizeof(FUShmRawCell);
  unsigned int* fedSizeAddr;
  fedSizeAddr=(unsigned int*)((unsigned long)this+fedSizeOffset_);
  new(fedSizeAddr) unsigned int[nFed_];
  
  fedOffset_=fedSizeOffset_+sizeof(unsigned int)*nFed_;
  unsigned int* fedAddr;
  fedAddr=(unsigned int*)((unsigned long)this+fedOffset_);
  new(fedAddr) unsigned int[nFed_];
  
  superFragSizeOffset_=fedOffset_+sizeof(unsigned int)*nFed_;
  unsigned int* superFragSizeAddr;
  superFragSizeAddr=(unsigned int*)((unsigned long)this+superFragSizeOffset_);
  new(superFragSizeAddr) unsigned int[nSuperFrag_];
  
  superFragOffset_=superFragSizeOffset_+sizeof(unsigned int)*nSuperFrag_;
  unsigned char* superFragAddr;
  superFragAddr=(unsigned char*)((unsigned long)this+superFragOffset_);
  new(superFragAddr) unsigned char[nSuperFrag_];
  
  payloadOffset_=superFragOffset_+sizeof(unsigned int)*nSuperFrag_;
  unsigned char* payloadAddr;
  payloadAddr=(unsigned char*)((unsigned long)this+payloadOffset_);
  new(payloadAddr) unsigned char[payloadSize_];
}
FUShmRawCell::~FUShmRawCell ( )

Definition at line 63 of file FUShmRawCell.cc.

{

}

Member Function Documentation

unsigned int evf::FUShmRawCell::buResourceId ( ) const [inline]

Definition at line 24 of file FUShmRawCell.h.

References buResourceId_.

Referenced by evf::FUResourceTable::discard().

{ return buResourceId_; }
void FUShmRawCell::clear ( void  )

Definition at line 147 of file FUShmRawCell.cc.

References buResourceId_, fedSizeOffset_, fuResourceId_, i, lumiSection_, nFed(), nSuperFrag(), payloadPosition_, and superFragSizeOffset_.

Referenced by evf::FUResource::allocate(), evf::FUShmBuffer::releaseRawCell(), and evf::FUShmServer::writeNext().

{
  fuResourceId_=0xffffffff;
  buResourceId_=0xffffffff;
  lumiSection_ =0;
  unsigned int* fedSizeAddr;
  fedSizeAddr=(unsigned int*)((unsigned long)this+fedSizeOffset_);
  for (unsigned int i=0;i<nFed();i++) *fedSizeAddr++=0;

  unsigned int* superFragSizeAddr;
  superFragSizeAddr=(unsigned int*)((unsigned long)this+superFragSizeOffset_);
  for (unsigned int i=0;i<nSuperFrag();i++) *superFragSizeAddr++=0;

  payloadPosition_=0;
}
void FUShmRawCell::dump ( void  ) const

Definition at line 165 of file FUShmRawCell.cc.

References gather_cfg::cout, fedAddr(), fedSize(), i, j, nFed(), and size().

{
  for (unsigned int i=0;i<nFed();i++) {
    cout<<"fed "<<i<<": "<<flush;
    unsigned char* addr=fedAddr(i);
    unsigned int   size=fedSize(i);
    cout.fill(0);
    cout<<setiosflags(ios::right);
    for (unsigned int j=0;j<size;j++)
      cout<<setw(2)<<hex<<(int)addr[j]<<dec<<" "<<flush;
    cout<<endl;
  }
}
unsigned int FUShmRawCell::eventSize ( ) const

Definition at line 140 of file FUShmRawCell.cc.

References payloadPosition_.

Referenced by evf::FUShmBuffer::writeErrorEventData().

{
  return payloadPosition_;
}
unsigned int evf::FUShmRawCell::evtNumber ( ) const [inline]
unsigned char * FUShmRawCell::fedAddr ( unsigned int  i) const

Definition at line 94 of file FUShmRawCell.cc.

References gather_cfg::cout, fedOffset_, i, nFed(), payloadAddr(), and query::result.

Referenced by dump(), evf::FUResourceTable::dumpEvent(), FUShmRawCell(), markFed(), readFed(), and evf::FUShmBuffer::writeErrorEventData().

{
  if (i>=nFed()) {cout<<"invalid fed index '"<<i<<"'."<<endl; return 0; }
  unsigned int* fedOffsetAddr;
  fedOffsetAddr=(unsigned int*)((unsigned long)this+fedOffset_);
  fedOffsetAddr+=i;
  unsigned int   fedOffset=*fedOffsetAddr;
  unsigned char* result=(unsigned char*)((unsigned long)payloadAddr()+fedOffset);
  return result;
}
unsigned int FUShmRawCell::fedSize ( unsigned int  i) const

Definition at line 82 of file FUShmRawCell.cc.

References gather_cfg::cout, fedSizeOffset_, i, nFed(), and query::result.

Referenced by dump(), evf::FUResourceTable::dumpEvent(), FUShmReader::fillRawData(), readFed(), evf::FUShmClient::readNext(), and evf::FUShmBuffer::writeErrorEventData().

{
  if (i>=nFed()) {cout<<"invalid fed index '"<<i<<"'."<<endl; return 0; }
  unsigned int* fedSizeAddr;
  fedSizeAddr=(unsigned int*)((unsigned long)this+fedSizeOffset_);
  fedSizeAddr+=i;
  unsigned int result=*fedSizeAddr;
  return result;
}
unsigned int evf::FUShmRawCell::fuResourceId ( ) const [inline]

Definition at line 23 of file FUShmRawCell.h.

References fuResourceId_.

Referenced by evf::FUResourceTable::discard(), and evf::FUResourceTable::dropEvent().

{ return fuResourceId_; }
unsigned int evf::FUShmRawCell::getLumiSection ( ) const [inline]

Definition at line 54 of file FUShmRawCell.h.

References lumiSection_.

Referenced by FUShmReader::fillRawData().

{return lumiSection_;}
unsigned int evf::FUShmRawCell::index ( ) const [inline]
void FUShmRawCell::initialize ( unsigned int  index)

Definition at line 74 of file FUShmRawCell.cc.

References index(), index_, and lumiSection_.

Referenced by evf::FUShmBuffer::initialize().

bool FUShmRawCell::markFed ( unsigned int  i,
unsigned int  size,
unsigned char *  addr 
)

Definition at line 214 of file FUShmRawCell.cc.

References gather_cfg::cout, fedAddr(), fedOffset_, fedSizeOffset_, i, nFed(), evf::evtn::offset(), payloadAddr(), payloadSize(), and size().

Referenced by evf::FUResource::findFEDs(), evf::FUResource::process(), and evf::FUShmServer::writeNext().

{
  if (i>=nFed())
    {cout<<"invalid fed index '"<<i<<"'."<<endl; return false; }
  if (addr<payloadAddr())
    { cout<<"invalid fed addr '0x"<<hex<<(unsigned long)addr<<dec<<"'."<<endl; return false; }

  unsigned long offset=(unsigned long)addr-(unsigned long)payloadAddr();

  if (offset>=payloadSize())
    { cout<<"invalid fed addr '0x"<<hex<<(unsigned long)addr<<dec<<"'."<<endl; return false; }

  unsigned int* fedSizeAddr;
  fedSizeAddr=(unsigned int*)((unsigned long)this+fedSizeOffset_);
  fedSizeAddr+=i;
  *fedSizeAddr=size;

  unsigned int* fedAddr;
  fedAddr=(unsigned int*)((unsigned long)this+fedOffset_);
  fedAddr+=i;
  *fedAddr=offset;

  return true;
}
bool FUShmRawCell::markSuperFrag ( unsigned int  i,
unsigned int  size,
unsigned char *  addr 
)

Definition at line 243 of file FUShmRawCell.cc.

References gather_cfg::cout, i, nSuperFrag(), evf::evtn::offset(), payloadAddr(), payloadSize(), size(), superFragAddr(), superFragOffset_, and superFragSizeOffset_.

Referenced by evf::FUResource::fillSuperFragPayload(), and evf::FUResource::process().

{
  if (i>=nSuperFrag())
    {cout<<"invalid sf index '"<<i<<"'."<<endl; return false; }
  if (addr<payloadAddr())
    {cout<<"invalid sf addr '0x"<<hex<<(unsigned long)addr<<dec<<"'."<<endl;return false;}

  unsigned int offset=(unsigned long)addr-(unsigned long)payloadAddr();

  if (offset>=payloadSize())
    {cout<<"invalid sf addr '0x"<<hex<<(unsigned long)addr<<dec<<"'."<<endl;return false;}

  unsigned int* superFragSizeAddr;
  superFragSizeAddr=(unsigned int*)((unsigned long)this+superFragSizeOffset_);
  superFragSizeAddr+=i;
  *superFragSizeAddr=size;

  unsigned int* superFragAddr;
  superFragAddr=(unsigned int*)((unsigned long)this+superFragOffset_);
  superFragAddr+=i;
  *superFragAddr=offset;

  return true;
}
unsigned int evf::FUShmRawCell::nFed ( ) const [inline]
unsigned int evf::FUShmRawCell::nSuperFrag ( ) const [inline]

Definition at line 34 of file FUShmRawCell.h.

References nSuperFrag_.

Referenced by evf::FUResource::allocate(), clear(), markSuperFrag(), superFragAddr(), and superFragSize().

{ return nSuperFrag_; }
unsigned char * FUShmRawCell::payloadAddr ( ) const

Definition at line 132 of file FUShmRawCell.cc.

References payloadOffset_, and query::result.

Referenced by fedAddr(), FUShmRawCell(), markFed(), markSuperFrag(), superFragAddr(), and evf::FUShmBuffer::writeErrorEventData().

{
  unsigned char* result=(unsigned char*)((unsigned long)this+payloadOffset_);
  return result;
}
unsigned int evf::FUShmRawCell::payloadSize ( ) const [inline]

Definition at line 27 of file FUShmRawCell.h.

References payloadSize_.

Referenced by evf::FUResource::allocate(), markFed(), markSuperFrag(), and size().

{ return payloadSize_; }
unsigned int FUShmRawCell::readFed ( unsigned int  i,
unsigned char *  buffer 
) const

Definition at line 181 of file FUShmRawCell.cc.

References fedAddr(), fedSize(), and size().

Referenced by FUShmReader::fillRawData(), and evf::FUShmClient::readNext().

{
  unsigned int   size=fedSize(i);
  unsigned char* addr=fedAddr(i);
  memcpy(buffer,addr,size);
  return size;
}
void evf::FUShmRawCell::setBuResourceId ( unsigned int  id) [inline]

Definition at line 41 of file FUShmRawCell.h.

References buResourceId_, and ExpressReco_HICollisions_FallBack::id.

void evf::FUShmRawCell::setEvtNumber ( unsigned int  evt) [inline]

Definition at line 42 of file FUShmRawCell.h.

References evtNumber_.

Referenced by evf::FUResource::findFEDs().

{ evtNumber_   =evt; }
void evf::FUShmRawCell::setFuResourceId ( unsigned int  id) [inline]

Definition at line 40 of file FUShmRawCell.h.

References fuResourceId_, and ExpressReco_HICollisions_FallBack::id.

Referenced by evf::FUResource::allocate().

void FUShmRawCell::setLumiSection ( unsigned int  ls)
unsigned int FUShmRawCell::size ( unsigned int  payloadSize) [static]

Definition at line 272 of file FUShmRawCell.cc.

References FUShmRawCell(), NFED_MAX, NSUPERFRAG_MAX, and payloadSize().

Referenced by dump(), markFed(), markSuperFrag(), and readFed().

{
  return 
    sizeof(FUShmRawCell)+
    sizeof(unsigned int)*2*(NFED_MAX+NSUPERFRAG_MAX)+
    sizeof(unsigned char)*payloadSize;
}
unsigned char * FUShmRawCell::superFragAddr ( unsigned int  i) const

Definition at line 119 of file FUShmRawCell.cc.

References gather_cfg::cout, i, nSuperFrag(), payloadAddr(), query::result, and superFragOffset_.

Referenced by evf::FUResource::findFEDs(), FUShmRawCell(), and markSuperFrag().

{
  if (i>=nSuperFrag()) {cout<<"invalid fed index '"<<i<<"'."<<endl; return 0; }
  unsigned int* superFragOffsetAddr;
  superFragOffsetAddr=(unsigned int*)((unsigned long)this+superFragOffset_);
  superFragOffsetAddr+=i;
  unsigned int   superFragOffset=*superFragOffsetAddr;
  unsigned char* result=(unsigned char*)((unsigned long)payloadAddr()+superFragOffset);
  return result;
}
unsigned int FUShmRawCell::superFragSize ( unsigned int  i) const

Definition at line 107 of file FUShmRawCell.cc.

References gather_cfg::cout, i, nSuperFrag(), query::result, and superFragSizeOffset_.

Referenced by evf::FUResource::findFEDs().

{
  if (i>=nSuperFrag()) {cout<<"invalid sf index '"<<i<<"'."<<endl; return 0; }
  unsigned int* superFragSizeAddr;
  superFragSizeAddr=(unsigned int*)((unsigned long)this+superFragSizeOffset_);
  superFragSizeAddr+=i;
  unsigned int result=*superFragSizeAddr;
  return result;
}
unsigned char * FUShmRawCell::writeData ( unsigned char *  data,
unsigned int  dataSize 
)

Definition at line 192 of file FUShmRawCell.cc.

References gather_cfg::cout, payloadOffset_, payloadPosition_, payloadSize_, and query::result.

Referenced by evf::FUResource::fillSuperFragPayload(), evf::FUResource::process(), and evf::FUShmServer::writeNext().

{
  if (payloadPosition_+dataSize>payloadSize_) {
    cout<<"FUShmRawCell::writeData: data to be written does not fit!"<<endl;
    return 0;
  }
  
  // result = addr of data to be written *in* the cell
  unsigned char* result=
    (unsigned char*)((unsigned long)this+payloadOffset_+payloadPosition_);
  memcpy(result,data,dataSize);
  payloadPosition_+=dataSize;
  return result;
}

Member Data Documentation

unsigned int evf::FUShmRawCell::buResourceId_ [private]

Definition at line 67 of file FUShmRawCell.h.

Referenced by buResourceId(), clear(), and setBuResourceId().

unsigned int evf::FUShmRawCell::evtNumber_ [private]

Definition at line 68 of file FUShmRawCell.h.

Referenced by evtNumber(), and setEvtNumber().

unsigned int evf::FUShmRawCell::fedOffset_ [private]

Definition at line 74 of file FUShmRawCell.h.

Referenced by fedAddr(), FUShmRawCell(), and markFed().

unsigned int evf::FUShmRawCell::fedSizeOffset_ [private]

Definition at line 73 of file FUShmRawCell.h.

Referenced by clear(), fedSize(), FUShmRawCell(), and markFed().

unsigned int evf::FUShmRawCell::fuResourceId_ [private]

Definition at line 66 of file FUShmRawCell.h.

Referenced by clear(), fuResourceId(), and setFuResourceId().

unsigned int evf::FUShmRawCell::index_ [private]

Definition at line 65 of file FUShmRawCell.h.

Referenced by index(), and initialize().

unsigned int evf::FUShmRawCell::lumiSection_ [private]

Definition at line 72 of file FUShmRawCell.h.

Referenced by clear(), getLumiSection(), initialize(), and setLumiSection().

unsigned int evf::FUShmRawCell::nFed_ [private]

Definition at line 70 of file FUShmRawCell.h.

Referenced by FUShmRawCell(), and nFed().

unsigned int evf::FUShmRawCell::nSuperFrag_ [private]

Definition at line 71 of file FUShmRawCell.h.

Referenced by FUShmRawCell(), and nSuperFrag().

unsigned int evf::FUShmRawCell::payloadOffset_ [private]

Definition at line 77 of file FUShmRawCell.h.

Referenced by FUShmRawCell(), payloadAddr(), and writeData().

unsigned int evf::FUShmRawCell::payloadPosition_ [private]

Definition at line 78 of file FUShmRawCell.h.

Referenced by clear(), eventSize(), and writeData().

unsigned int evf::FUShmRawCell::payloadSize_ [private]

Definition at line 69 of file FUShmRawCell.h.

Referenced by FUShmRawCell(), payloadSize(), and writeData().

unsigned int evf::FUShmRawCell::superFragOffset_ [private]

Definition at line 76 of file FUShmRawCell.h.

Referenced by FUShmRawCell(), markSuperFrag(), and superFragAddr().

Definition at line 75 of file FUShmRawCell.h.

Referenced by clear(), FUShmRawCell(), markSuperFrag(), and superFragSize().