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 {
76  if (eventSize_!=0)
77  cout<<"FUShmRecoCell::writeInitMsg() WARNING: overwriting data!"<<endl;
78 
79  if (dataSize>payloadSize_) {
80  cout<<"FUShmRecoCell::writeInitMsg() ERROR: data does not fit!"<<endl;
81  return;
82  }
83 
84  rawCellIndex_=0xffffffff;
85  runNumber_ =0xffffffff;
86  evtNumber_ =0xffffffff;
89  fuGuid_ =fuGuid;
90  type_ =0;
91  unsigned char* targetAddr=payloadAddr();
92  memcpy(targetAddr,data,dataSize);
93  eventSize_=dataSize;
94 }
95 
96 
97 //______________________________________________________________________________
98 void FUShmRecoCell::writeEventData(unsigned int rawCellIndex,
99  unsigned int runNumber,
100  unsigned int evtNumber,
101  unsigned int outModId,
102  unsigned int fuProcessId,
103  unsigned int fuGuid,
104  unsigned char *data,
105  unsigned int dataSize)
106 {
107  if (eventSize_!=0)
108  cout<<"FUShmRecoCell::writeEventData() WARNING: overwriting data!"<<endl;
109 
110  if (dataSize>payloadSize_) {
111  cout<<"FUShmRecoCell::writeEventData() ERROR: data does not fit!"<<endl;
112  return;
113  }
114 
120  fuGuid_ =fuGuid;
121  type_ =1;
122  unsigned char* targetAddr=payloadAddr();
123  memcpy(targetAddr,data,dataSize);
124  eventSize_=dataSize;
125 }
126 
127 
128 //______________________________________________________________________________
129 void FUShmRecoCell::writeErrorEvent(unsigned int rawCellIndex,
130  unsigned int runNumber,
131  unsigned int evtNumber,
132  unsigned int fuProcessId,
133  unsigned char *data,
134  unsigned int dataSize)
135 {
136  if (eventSize_!=0)
137  cout<<"FUShmRecoCell::writeEventData() WARNING: overwriting data!"<<endl;
138 
139  if (dataSize>payloadSize_) {
140  cout<<"FUShmRecoCell::writeEventData() ERROR: data does not fit!"<<endl;
141  return;
142  }
143 
147  outModId_ =0xffffffff;
149  fuGuid_ =0;
150  type_ =2;
151  unsigned char* targetAddr=payloadAddr();
152  memcpy(targetAddr,data,dataSize);
153  eventSize_=dataSize;
154 }
155 
156 
157 //______________________________________________________________________________
158 unsigned int FUShmRecoCell::size(unsigned int payloadSize)
159 {
160  return sizeof(FUShmRecoCell)+sizeof(unsigned char)*payloadSize;
161 }
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:70
unsigned int outModId_
Definition: FUShmRecoCell.h:74
unsigned int payloadSize() const
Definition: FUShmRecoCell.h:31
unsigned int type_
Definition: FUShmRecoCell.h:77
FUShmRecoCell(unsigned int payloadSize)
unsigned int fuGuid_
Definition: FUShmRecoCell.h:76
unsigned char * payloadAddr() const
unsigned int evtNumber() const
Definition: FUShmRecoCell.h:25
unsigned int rawCellIndex() const
Definition: FUShmRecoCell.h:23
unsigned int runNumber_
Definition: FUShmRecoCell.h:72
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:80
unsigned int payloadOffset_
Definition: FUShmRecoCell.h:79
void writeInitMsg(unsigned int outModId, unsigned int fuProcessId, unsigned int fuGuid, unsigned char *data, unsigned int dataSize)
unsigned int outModId() const
Definition: FUShmRecoCell.h:26
unsigned int fuProcessId_
Definition: FUShmRecoCell.h:75
tuple cout
Definition: gather_cfg.py:41
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:78
unsigned int rawCellIndex_
Definition: FUShmRecoCell.h:71
unsigned int evtNumber_
Definition: FUShmRecoCell.h:73