#include <EventFilter/AutoBU/interface/BUEvent.h>
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 int * | fedId_ |
unsigned int * | fedPos_ |
unsigned int * | fedSize_ |
unsigned int | nFed_ |
Static Private Attributes | |
static bool | computeCrc_ = true |
Definition at line 8 of file BUEvent.h.
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] |
unsigned int evf::BUEvent::bufferSize | ( | ) | const [inline] |
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_; }
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().
Definition at line 33 of file BUEvent.h.
References fedSize_.
Referenced by evf::BU::createMsgChain(), dump(), and writeFedTrailer().
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 37 of file BUEvent.h.
References computeCrc_.
Referenced by evf::BU::actionPerformed(), and evf::BU::BU().
00037 { computeCrc_=computeCrc; }
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 }
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 }
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 }
unsigned char* evf::BUEvent::buffer_ [private] |
unsigned int evf::BUEvent::bufferSize_ [private] |
unsigned int evf::BUEvent::buResourceId_ [private] |
bool BUEvent::computeCrc_ = true [static, private] |
unsigned int evf::BUEvent::evtNumber_ [private] |
unsigned int evf::BUEvent::evtSize_ [private] |
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().