CMS 3D CMS Logo

evf::BUEvent Class Reference

#include <EventFilter/AutoBU/interface/BUEvent.h>

List of all members.

Public Member Functions

 BUEvent (unsigned int buResourceId, unsigned int bufferSize=0x400000)
unsigned int bufferSize () const
unsigned int buResourceId () const
void dump ()
unsigned int evtNumber () const
unsigned int evtSize () const
unsigned char * fedAddr (unsigned int i) const
unsigned int fedId (unsigned int i) const
unsigned int fedSize (unsigned int i) const
void initialize (unsigned int evtNumber)
unsigned int nFed () const
bool writeFed (unsigned int id, unsigned char *data, unsigned int size)
bool writeFedHeader (unsigned int i)
bool writeFedTrailer (unsigned int i)
virtual ~BUEvent ()

Static Public Member Functions

static bool computeCrc ()
static void setComputeCrc (bool computeCrc)

Private Attributes

unsigned char * buffer_
unsigned int bufferSize_
unsigned int buResourceId_
unsigned int evtNumber_
unsigned int evtSize_
unsigned intfedId_
unsigned intfedPos_
unsigned intfedSize_
unsigned int nFed_

Static Private Attributes

static bool computeCrc_ = true


Detailed Description

Definition at line 8 of file BUEvent.h.


Constructor & Destructor Documentation

BUEvent::BUEvent ( unsigned int  buResourceId,
unsigned int  bufferSize = 0x400000 
)

Definition at line 41 of file BUEvent.cc.

References buffer_, fedId_, fedPos_, and fedSize_.

00042   : buResourceId_(buResourceId)
00043   , evtNumber_(0xffffffff)
00044   , evtSize_(0)
00045   , bufferSize_(bufferSize)
00046   , nFed_(0)
00047   , fedId_(0)
00048   , fedPos_(0)
00049   , fedSize_(0)
00050   , buffer_(0)
00051 {
00052   fedId_  = new unsigned int[1024];
00053   fedPos_ = new unsigned int[1024];
00054   fedSize_= new unsigned int[1024];
00055   buffer_ = new unsigned char[bufferSize];
00056 }

BUEvent::~BUEvent (  )  [virtual]

Definition at line 60 of file BUEvent.cc.

References buffer_, fedId_, fedPos_, and fedSize_.

00061 {
00062   if (0!=fedId_)   delete [] fedId_;
00063   if (0!=fedPos_)  delete [] fedPos_;
00064   if (0!=fedSize_) delete [] fedSize_;
00065   if (0!=buffer_)  delete [] buffer_;
00066 }


Member Function Documentation

unsigned int evf::BUEvent::bufferSize (  )  const [inline]

Definition at line 30 of file BUEvent.h.

References bufferSize_.

00030 { return bufferSize_; }

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

Definition at line 27 of file BUEvent.h.

References buResourceId_.

Referenced by evf::BU::createMsgChain().

00027 { return buResourceId_; }

static bool evf::BUEvent::computeCrc (  )  [inline, static]

Definition at line 36 of file BUEvent.h.

References computeCrc_.

Referenced by writeFedTrailer().

00036 { return computeCrc_; }

void BUEvent::dump ( void   ) 

Definition at line 153 of file BUEvent.cc.

References addr, lat::endl(), evtNumber(), fedAddr(), fedId(), fedSize(), i, int, j, and nFed().

00154 {
00155   ostringstream oss; oss<<"/tmp/autobu_evt"<<evtNumber()<<".dump";
00156   ofstream fout(oss.str().c_str());
00157   fout.fill('0');
00158   
00159   fout<<"#\n# evt "<<evtNumber()<<"\n#\n"<<endl;
00160   for (unsigned int i=0;i<nFed();i++) {
00161     if (fedSize(i)==0) continue;
00162     fout<<"# fedid "<<fedId(i)<<endl;
00163     unsigned char* addr=fedAddr(i);
00164     for (unsigned int j=0;j<fedSize(i);j++) {
00165       fout<<setiosflags(ios::right)<<setw(2)<<hex<<(int)(*addr)<<dec;
00166       if ((j+1)%8) fout<<" "; else fout<<endl;
00167       ++addr;
00168     }
00169     fout<<endl;
00170   }
00171   fout.close();
00172 }

unsigned int evf::BUEvent::evtNumber (  )  const [inline]

Definition at line 28 of file BUEvent.h.

References evtNumber_.

Referenced by evf::BU::createMsgChain(), dump(), and writeFedHeader().

00028 { return evtNumber_; }

unsigned int evf::BUEvent::evtSize (  )  const [inline]

Definition at line 29 of file BUEvent.h.

References evtSize_.

Referenced by evf::BU::sending().

00029 { return evtSize_; }

unsigned char * BUEvent::fedAddr ( unsigned int  i  )  const

Definition at line 146 of file BUEvent.cc.

References buffer_, and fedPos_.

Referenced by evf::BU::createMsgChain(), dump(), writeFed(), writeFedHeader(), and writeFedTrailer().

00147 {
00148   return (buffer_+fedPos_[i]);
00149 }

unsigned int evf::BUEvent::fedId ( unsigned int  i  )  const [inline]

Definition at line 32 of file BUEvent.h.

References fedId_.

Referenced by dump(), and writeFedHeader().

00032 { return fedId_[i]; }

unsigned int evf::BUEvent::fedSize ( unsigned int  i  )  const [inline]

Definition at line 33 of file BUEvent.h.

References fedSize_.

Referenced by evf::BU::createMsgChain(), dump(), and writeFedTrailer().

00033 { return fedSize_[i]; }

void BUEvent::initialize ( unsigned int  evtNumber  ) 

Definition at line 74 of file BUEvent.cc.

References evtNumber_, evtSize_, and nFed_.

Referenced by evf::BU::generateEvent().

00075  {
00076    evtNumber_=evtNumber & 0xFFFFFF; // 24 bits only available in the FED headers
00077    evtSize_=0;
00078    nFed_=0;
00079  }

unsigned int evf::BUEvent::nFed (  )  const [inline]

Definition at line 31 of file BUEvent.h.

References nFed_.

Referenced by evf::BU::createMsgChain(), and dump().

00031 { return nFed_; }

static void evf::BUEvent::setComputeCrc ( bool  computeCrc  )  [inline, static]

Definition at line 37 of file BUEvent.h.

References computeCrc_.

Referenced by evf::BU::actionPerformed(), and evf::BU::BU().

bool BUEvent::writeFed ( unsigned int  id,
unsigned char *  data,
unsigned int  size 
)

Definition at line 83 of file BUEvent.cc.

References bufferSize_, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), evtSize_, fedAddr(), fedId_, fedPos_, fedSize_, and nFed_.

Referenced by evf::BU::generateEvent().

00084 {
00085   if (evtSize_+size > bufferSize_) {
00086     cout<<"BUEvent::writeFed() ERROR: buffer overflow."<<endl;
00087     return false;
00088   }
00089   
00090   if (nFed_==1024) {
00091     cout<<"BUEvent::writeFed() ERROR: too many feds (max=1024)."<<endl;
00092     return false;
00093   }
00094   
00095   fedId_[nFed_]  =id;
00096   fedPos_[nFed_] =evtSize_;
00097   fedSize_[nFed_]=size;
00098   if (0!=data) memcpy(fedAddr(nFed_),data,size);
00099   ++nFed_;
00100   evtSize_+=size;
00101   return true;
00102 }

bool BUEvent::writeFedHeader ( unsigned int  i  ) 

Definition at line 106 of file BUEvent.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fedh_struct::eventid, evtNumber(), FED_SOID_MASK, fedAddr(), fedId(), nFed_, and fedh_struct::sourceid.

Referenced by evf::BU::generateEvent().

00107 {
00108   if (i>=nFed_) {
00109     cout<<"BUEvent::writeFedHeader() ERROR: invalid fed index '"<<i<<"'."<<endl;
00110     return false;
00111   }
00112   
00113   fedh_t *fedHeader=(fedh_t*)fedAddr(i);
00114   fedHeader->eventid =evtNumber();
00115   fedHeader->eventid|=0x50000000;
00116   fedHeader->sourceid=(fedId(i) << 8) & FED_SOID_MASK;
00117   
00118   return true;
00119 }

bool BUEvent::writeFedTrailer ( unsigned int  i  ) 

Definition at line 123 of file BUEvent.cc.

References evf::compute_crc(), computeCrc(), fedt_struct::conscheck, GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fedt_struct::eventsize, FED_CRCS_SHIFT, fedAddr(), fedSize(), and nFed_.

Referenced by evf::BU::generateEvent().

00124 {
00125   if (i>=nFed_) {
00126     cout<<"BUEvent::writeFedTrailer() ERROR: invalid fed index '"<<i<<"'."<<endl;
00127     return false;
00128   }
00129   
00130   fedt_t *fedTrailer=(fedt_t*)(fedAddr(i)+fedSize(i)-sizeof(fedt_t));
00131   fedTrailer->eventsize =fedSize(i);
00132   fedTrailer->eventsize/=8; //wc in fed trailer in 64bit words
00133   fedTrailer->eventsize|=0xa0000000;
00134   fedTrailer->conscheck =0x0;
00135   
00136   if (BUEvent::computeCrc()) {
00137     unsigned short crc=evf::compute_crc(fedAddr(i),fedSize(i));
00138     fedTrailer->conscheck=(crc<<FED_CRCS_SHIFT);
00139   }
00140 
00141   return true;
00142 }


Member Data Documentation

unsigned char* evf::BUEvent::buffer_ [private]

Definition at line 54 of file BUEvent.h.

Referenced by BUEvent(), fedAddr(), and ~BUEvent().

unsigned int evf::BUEvent::bufferSize_ [private]

Definition at line 49 of file BUEvent.h.

Referenced by bufferSize(), and writeFed().

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

Definition at line 46 of file BUEvent.h.

Referenced by buResourceId().

bool BUEvent::computeCrc_ = true [static, private]

Definition at line 56 of file BUEvent.h.

Referenced by computeCrc(), and setComputeCrc().

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

Definition at line 47 of file BUEvent.h.

Referenced by evtNumber(), and initialize().

unsigned int evf::BUEvent::evtSize_ [private]

Definition at line 48 of file BUEvent.h.

Referenced by evtSize(), initialize(), and writeFed().

unsigned int* evf::BUEvent::fedId_ [private]

Definition at line 51 of file BUEvent.h.

Referenced by BUEvent(), fedId(), writeFed(), and ~BUEvent().

unsigned int* evf::BUEvent::fedPos_ [private]

Definition at line 52 of file BUEvent.h.

Referenced by BUEvent(), fedAddr(), writeFed(), and ~BUEvent().

unsigned int* evf::BUEvent::fedSize_ [private]

Definition at line 53 of file BUEvent.h.

Referenced by BUEvent(), fedSize(), writeFed(), and ~BUEvent().

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

Definition at line 50 of file BUEvent.h.

Referenced by initialize(), nFed(), writeFed(), writeFedHeader(), and writeFedTrailer().


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