CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FUShmRecoCell.cc
Go to the documentation of this file.
1 //
3 // FUShmRecoCell
4 // -------------
5 //
6 // 17/03/2007 Philipp Schieferdecker <philipp.schieferdecker@cern.ch>
8 
9 
11 
12 #include <iostream>
13 #include <iomanip>
14 #include <cstring>
15 
16 using namespace std;
17 using namespace evf;
18 
19 
21 // construction/destruction
23 
24 //______________________________________________________________________________
25 FUShmRecoCell::FUShmRecoCell(unsigned int payloadSize)
26  : payloadSize_(payloadSize)
27 {
29  void* payloadAddr=(void*)((unsigned long)this+payloadOffset_);
30  new (payloadAddr) unsigned char[payloadSize_];
31 }
32 
33 
34 //______________________________________________________________________________
36 {
37 
38 }
39 
40 
42 // implementation of member functions
44 
45 //______________________________________________________________________________
46 void FUShmRecoCell::initialize(unsigned int index)
47 {
48  index_=index;
49  clear();
50 }
51 
52 
53 //______________________________________________________________________________
54 unsigned char* FUShmRecoCell::payloadAddr() const
55 {
56  unsigned char* result=(unsigned char*)((unsigned long)this+payloadOffset_);
57  return result;
58 }
59 
60 
61 //______________________________________________________________________________
63 {
64  eventSize_=0;
65  rawCellIndex_=0xffffffff;
66 }
67 
68 
69 //______________________________________________________________________________
70 void FUShmRecoCell::writeInitMsg(unsigned int outModId,
71  unsigned int fuProcessId,
72  unsigned int fuGuid,
73  unsigned char *data,
74  unsigned int dataSize,
75  unsigned int nExpectedEPs)
76 {
77  if (eventSize_!=0)
78  cout<<"FUShmRecoCell::writeInitMsg() WARNING: overwriting data!"<<endl;
79 
80  if (dataSize>payloadSize_) {
81  cout<<"FUShmRecoCell::writeInitMsg() ERROR: data does not fit!"<<endl;
82  return;
83  }
84 
85  rawCellIndex_=0xffffffff;
86  runNumber_ =0xffffffff;
87  evtNumber_ =0xffffffff;
90  fuGuid_ =fuGuid;
91  type_ =0;
92  unsigned char* targetAddr=payloadAddr();
93  memcpy(targetAddr,data,dataSize);
94  eventSize_=dataSize;
96 }
97 
98 
99 //______________________________________________________________________________
100 void FUShmRecoCell::writeEventData(unsigned int rawCellIndex,
101  unsigned int runNumber,
102  unsigned int evtNumber,
103  unsigned int outModId,
104  unsigned int fuProcessId,
105  unsigned int fuGuid,
106  unsigned char *data,
107  unsigned int dataSize)
108 {
109  if (eventSize_!=0)
110  cout<<"FUShmRecoCell::writeEventData() WARNING: overwriting data!"<<endl;
111 
112  if (dataSize>payloadSize_) {
113  cout<<"FUShmRecoCell::writeEventData() ERROR: data does not fit!"<<endl;
114  return;
115  }
116 
122  fuGuid_ =fuGuid;
123  type_ =1;
124  unsigned char* targetAddr=payloadAddr();
125  memcpy(targetAddr,data,dataSize);
126  eventSize_=dataSize;
127  nExpectedEPs_=0xffffffff;
128 }
129 
130 
131 //______________________________________________________________________________
132 void FUShmRecoCell::writeErrorEvent(unsigned int rawCellIndex,
133  unsigned int runNumber,
134  unsigned int evtNumber,
135  unsigned int fuProcessId,
136  unsigned char *data,
137  unsigned int dataSize)
138 {
139  if (eventSize_!=0)
140  cout<<"FUShmRecoCell::writeEventData() WARNING: overwriting data!"<<endl;
141 
142  if (dataSize>payloadSize_) {
143  cout<<"FUShmRecoCell::writeEventData() ERROR: data does not fit!"<<endl;
144  return;
145  }
146 
150  outModId_ =0xffffffff;
152  fuGuid_ =0;
153  type_ =2;
154  unsigned char* targetAddr=payloadAddr();
155  memcpy(targetAddr,data,dataSize);
156  eventSize_=dataSize;
157  nExpectedEPs_=0xffffffff;
158 }
159 
160 
161 //______________________________________________________________________________
162 unsigned int FUShmRecoCell::size(unsigned int payloadSize)
163 {
164  return sizeof(FUShmRecoCell)+sizeof(unsigned char)*payloadSize;
165 }
unsigned int index() const
Definition: FUShmRecoCell.h:22
void initialize(unsigned int index)
unsigned int runNumber() const
Definition: FUShmRecoCell.h:24
static unsigned int size(unsigned int payloadSize)
unsigned int fuGuid() const
Definition: FUShmRecoCell.h:28
unsigned int fuProcessId() const
Definition: FUShmRecoCell.h:27
unsigned int index_
Definition: FUShmRecoCell.h:72
unsigned int outModId_
Definition: FUShmRecoCell.h:76
unsigned int payloadSize() const
Definition: FUShmRecoCell.h:31
unsigned int type_
Definition: FUShmRecoCell.h:79
void writeInitMsg(unsigned int outModId, unsigned int fuProcessId, unsigned int fuGuid, unsigned char *data, unsigned int dataSize, unsigned int nExpectedEPs)
FUShmRecoCell(unsigned int payloadSize)
unsigned int fuGuid_
Definition: FUShmRecoCell.h:78
unsigned char * payloadAddr() const
unsigned int evtNumber() const
Definition: FUShmRecoCell.h:25
unsigned int nExpectedEPs() const
Definition: FUShmRecoCell.h:34
unsigned int rawCellIndex() const
Definition: FUShmRecoCell.h:23
unsigned int runNumber_
Definition: FUShmRecoCell.h:74
tuple result
Definition: query.py:137
void writeErrorEvent(unsigned int rawCellIndex, unsigned int runNumber, unsigned int evtNumber, unsigned int fuProcessId, unsigned char *data, unsigned int dataSize)
unsigned int eventSize_
Definition: FUShmRecoCell.h:82
unsigned int payloadOffset_
Definition: FUShmRecoCell.h:81
unsigned int nExpectedEPs_
Definition: FUShmRecoCell.h:83
unsigned int outModId() const
Definition: FUShmRecoCell.h:26
unsigned int fuProcessId_
Definition: FUShmRecoCell.h:77
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple cout
Definition: gather_cfg.py:121
void writeEventData(unsigned int rawCellIndex, unsigned int runNumber, unsigned int evtNumber, unsigned int outModId, unsigned int fuProcessId, unsigned int fuGuid, unsigned char *data, unsigned int dataSize)
unsigned int payloadSize_
Definition: FUShmRecoCell.h:80
unsigned int rawCellIndex_
Definition: FUShmRecoCell.h:73
unsigned int evtNumber_
Definition: FUShmRecoCell.h:75