CMS 3D CMS Logo

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

#include <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
 

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_, bufferSize(), fedId_, fedPos_, and fedSize_.

43  , evtNumber_(0xffffffff)
44  , evtSize_(0)
46  , nFed_(0)
47  , fedId_(0)
48  , fedPos_(0)
49  , fedSize_(0)
50  , buffer_(0)
51 {
52  fedId_ = new unsigned int[1024];
53  fedPos_ = new unsigned int[1024];
54  fedSize_= new unsigned int[1024];
55  buffer_ = new unsigned char[bufferSize];
56 }
unsigned char * buffer_
Definition: BUEvent.h:54
unsigned int evtNumber_
Definition: BUEvent.h:47
unsigned int buResourceId_
Definition: BUEvent.h:46
unsigned int buResourceId() const
Definition: BUEvent.h:27
unsigned int * fedId_
Definition: BUEvent.h:51
unsigned int nFed_
Definition: BUEvent.h:50
unsigned int bufferSize_
Definition: BUEvent.h:49
unsigned int * fedPos_
Definition: BUEvent.h:52
unsigned int * fedSize_
Definition: BUEvent.h:53
unsigned int bufferSize() const
Definition: BUEvent.h:30
unsigned int evtSize_
Definition: BUEvent.h:48
BUEvent::~BUEvent ( )
virtual

Definition at line 60 of file BUEvent.cc.

References buffer_, fedId_, fedPos_, and fedSize_.

61 {
62  if (0!=fedId_) delete [] fedId_;
63  if (0!=fedPos_) delete [] fedPos_;
64  if (0!=fedSize_) delete [] fedSize_;
65  if (0!=buffer_) delete [] buffer_;
66 }
unsigned char * buffer_
Definition: BUEvent.h:54
unsigned int * fedId_
Definition: BUEvent.h:51
unsigned int * fedPos_
Definition: BUEvent.h:52
unsigned int * fedSize_
Definition: BUEvent.h:53

Member Function Documentation

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

Definition at line 30 of file BUEvent.h.

References bufferSize_.

Referenced by BUEvent().

30 { return bufferSize_; }
unsigned int bufferSize_
Definition: BUEvent.h:49
unsigned int evf::BUEvent::buResourceId ( ) const
inline

Definition at line 27 of file BUEvent.h.

References buResourceId_.

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

27 { return buResourceId_; }
unsigned int buResourceId_
Definition: BUEvent.h:46
static bool evf::BUEvent::computeCrc ( )
inlinestatic

Definition at line 36 of file BUEvent.h.

References computeCrc_.

Referenced by setComputeCrc(), and writeFedTrailer().

36 { return computeCrc_; }
static bool computeCrc_
Definition: BUEvent.h:56
void BUEvent::dump ( void  )

Definition at line 153 of file BUEvent.cc.

References evtNumber(), fedAddr(), fedId(), fedSize(), makeHLTPrescaleTable::fout, i, j, and nFed().

154 {
155  ostringstream oss; oss<<"/tmp/autobu_evt"<<evtNumber()<<".dump";
156  ofstream fout(oss.str().c_str());
157  fout.fill('0');
158 
159  fout<<"#\n# evt "<<evtNumber()<<"\n#\n"<<endl;
160  for (unsigned int i=0;i<nFed();i++) {
161  if (fedSize(i)==0) continue;
162  fout<<"# fedid "<<fedId(i)<<endl;
163  unsigned char* addr=fedAddr(i);
164  for (unsigned int j=0;j<fedSize(i);j++) {
165  fout<<setiosflags(ios::right)<<setw(2)<<hex<<(int)(*addr)<<dec;
166  if ((j+1)%8) fout<<" "; else fout<<endl;
167  ++addr;
168  }
169  fout<<endl;
170  }
171  fout.close();
172 }
int i
Definition: DBlmapReader.cc:9
unsigned int evtNumber() const
Definition: BUEvent.h:28
unsigned char * fedAddr(unsigned int i) const
Definition: BUEvent.cc:146
int j
Definition: DBlmapReader.cc:9
unsigned int fedId(unsigned int i) const
Definition: BUEvent.h:32
unsigned int fedSize(unsigned int i) const
Definition: BUEvent.h:33
unsigned int nFed() const
Definition: BUEvent.h:31
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().

28 { return evtNumber_; }
unsigned int evtNumber_
Definition: BUEvent.h:47
unsigned int evf::BUEvent::evtSize ( ) const
inline

Definition at line 29 of file BUEvent.h.

References evtSize_.

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

29 { return evtSize_; }
unsigned int evtSize_
Definition: BUEvent.h:48
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().

147 {
148  return (buffer_+fedPos_[i]);
149 }
int i
Definition: DBlmapReader.cc:9
unsigned char * buffer_
Definition: BUEvent.h:54
unsigned int * fedPos_
Definition: BUEvent.h:52
unsigned int evf::BUEvent::fedId ( unsigned int  i) const
inline

Definition at line 32 of file BUEvent.h.

References fedId_, and i.

Referenced by dump(), and writeFedHeader().

32 { return fedId_[i]; }
int i
Definition: DBlmapReader.cc:9
unsigned int * fedId_
Definition: BUEvent.h:51
unsigned int evf::BUEvent::fedSize ( unsigned int  i) const
inline

Definition at line 33 of file BUEvent.h.

References fedSize_, and i.

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

33 { return fedSize_[i]; }
int i
Definition: DBlmapReader.cc:9
unsigned int * fedSize_
Definition: BUEvent.h:53
void BUEvent::initialize ( unsigned int  evtNumber)

Definition at line 74 of file BUEvent.cc.

References evtNumber_, evtSize_, and nFed_.

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

75  {
76  evtNumber_=evtNumber & 0xFFFFFF; // 24 bits only available in the FED headers
77  evtSize_=0;
78  nFed_=0;
79  }
unsigned int evtNumber() const
Definition: BUEvent.h:28
unsigned int evtNumber_
Definition: BUEvent.h:47
unsigned int nFed_
Definition: BUEvent.h:50
unsigned int evtSize_
Definition: BUEvent.h:48
unsigned int evf::BUEvent::nFed ( ) const
inline

Definition at line 31 of file BUEvent.h.

References nFed_.

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

31 { return nFed_; }
unsigned int nFed_
Definition: BUEvent.h:50
static void evf::BUEvent::setComputeCrc ( bool  computeCrc)
inlinestatic

Definition at line 37 of file BUEvent.h.

References computeCrc(), and computeCrc_.

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

static bool computeCrc_
Definition: BUEvent.h:56
static bool computeCrc()
Definition: BUEvent.h:36
bool BUEvent::writeFed ( unsigned int  id,
unsigned char *  data,
unsigned int  size 
)

Definition at line 83 of file BUEvent.cc.

References bufferSize_, gather_cfg::cout, evtSize_, fedAddr(), fedId_, fedPos_, fedSize_, nFed_, and findQualityFiles::size.

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

84 {
85  if (evtSize_+size > bufferSize_) {
86  cout<<"BUEvent::writeFed() ERROR: buffer overflow."<<endl;
87  return false;
88  }
89 
90  if (nFed_==1024) {
91  cout<<"BUEvent::writeFed() ERROR: too many feds (max=1024)."<<endl;
92  return false;
93  }
94 
95  fedId_[nFed_] =id;
98  if (0!=data) memcpy(fedAddr(nFed_),data,size);
99  ++nFed_;
100  evtSize_+=size;
101  return true;
102 }
unsigned int * fedId_
Definition: BUEvent.h:51
unsigned char * fedAddr(unsigned int i) const
Definition: BUEvent.cc:146
unsigned int nFed_
Definition: BUEvent.h:50
unsigned int bufferSize_
Definition: BUEvent.h:49
unsigned int * fedPos_
Definition: BUEvent.h:52
unsigned int * fedSize_
Definition: BUEvent.h:53
tuple cout
Definition: gather_cfg.py:41
tuple size
Write out results.
unsigned int evtSize_
Definition: BUEvent.h:48
bool BUEvent::writeFedHeader ( unsigned int  i)

Definition at line 106 of file BUEvent.cc.

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

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

107 {
108  if (i>=nFed_) {
109  cout<<"BUEvent::writeFedHeader() ERROR: invalid fed index '"<<i<<"'."<<endl;
110  return false;
111  }
112 
113  fedh_t *fedHeader=(fedh_t*)fedAddr(i);
114  fedHeader->eventid =evtNumber();
115  fedHeader->eventid|=0x50000000;
116  fedHeader->sourceid=(fedId(i) << 8) & FED_SOID_MASK;
117 
118  return true;
119 }
int i
Definition: DBlmapReader.cc:9
unsigned int evtNumber() const
Definition: BUEvent.h:28
unsigned int sourceid
Definition: fed_header.h:32
unsigned char * fedAddr(unsigned int i) const
Definition: BUEvent.cc:146
unsigned int nFed_
Definition: BUEvent.h:50
unsigned int fedId(unsigned int i) const
Definition: BUEvent.h:32
#define FED_SOID_MASK
Definition: fed_header.h:42
unsigned int eventid
Definition: fed_header.h:33
tuple cout
Definition: gather_cfg.py:41
bool BUEvent::writeFedTrailer ( unsigned int  i)

Definition at line 123 of file BUEvent.cc.

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

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

124 {
125  if (i>=nFed_) {
126  cout<<"BUEvent::writeFedTrailer() ERROR: invalid fed index '"<<i<<"'."<<endl;
127  return false;
128  }
129 
130  fedt_t *fedTrailer=(fedt_t*)(fedAddr(i)+fedSize(i)-sizeof(fedt_t));
131  fedTrailer->eventsize =fedSize(i);
132  fedTrailer->eventsize/=8; //wc in fed trailer in 64bit words
133  fedTrailer->eventsize|=0xa0000000;
134  fedTrailer->conscheck =0x0;
135 
136  if (BUEvent::computeCrc()) {
137  unsigned short crc=evf::compute_crc(fedAddr(i),fedSize(i));
138  fedTrailer->conscheck=(crc<<FED_CRCS_SHIFT);
139  }
140 
141  return true;
142 }
int i
Definition: DBlmapReader.cc:9
struct fedt_struct fedt_t
unsigned int conscheck
Definition: fed_trailer.h:32
unsigned char * fedAddr(unsigned int i) const
Definition: BUEvent.cc:146
unsigned int nFed_
Definition: BUEvent.h:50
unsigned short compute_crc(unsigned char *buffer, unsigned int bufSize)
Definition: CRC16.h:67
static bool computeCrc()
Definition: BUEvent.h:36
#define FED_CRCS_SHIFT
Definition: fed_trailer.h:51
unsigned int fedSize(unsigned int i) const
Definition: BUEvent.h:33
unsigned int eventsize
Definition: fed_trailer.h:33
tuple cout
Definition: gather_cfg.py:41

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
staticprivate

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().