ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
oncsEvent.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file oncsEvent.cc
1
#include <string.h>
2
3
#include "
oncsEvent.h
"
4
#include "
oncsStructures.h
"
5
#include "
oncsCollection.h
"
6
#include "
oncsSubConstants.h
"
7
8
// the constructor first ----------------
9
oncsEvent::oncsEvent
(
int
*
data
)
10
{
11
is_data_type
= 0;
12
hasMap
= 0;
13
errorcode
= 0;
14
EventData
= (
oncsevtdata_ptr
) data;
15
}
16
17
oncsEvent::~oncsEvent
()
18
{
19
if
(
is_data_type
)
delete
[] (
int
*)
EventData
;
20
}
21
22
// the info-type calls
23
unsigned
int
24
oncsEvent::getEvtLength
()
25
{
26
return
EventData
->
evt_length
;
27
}
28
29
int
30
oncsEvent::getEvtType
()
31
{
32
return
EventData
->
evt_type
;
33
}
34
35
int
36
oncsEvent::getEvtSequence
()
37
{
38
return
EventData
->
evt_sequence
;
39
}
40
41
time_t
42
oncsEvent::getTime
()
const
43
{
44
return
EventData
->
time
;
45
}
46
47
int
48
oncsEvent::getRunNumber
()
49
{
50
return
EventData
->
run_number
;
51
}
52
53
// PHTimeStamp *
54
// oncsEvent::getTimeStamp() const
55
// {
56
// return 0;
57
// }
58
59
60
void
oncsEvent::identify
(
OSTREAM
&os)
const
61
{
62
os << std::dec <<
" -- Event "
<<
SETW
(5) <<
EventData
->
evt_sequence
;
63
64
os <<
" Run: "
<<
SETW
(5) <<
EventData
->
run_number
;
65
66
os <<
" length: "
<<
SETW
(5) <<
EventData
->
evt_length
;
67
68
os <<
" type: "
<<
SETW
(2) <<
EventData
->
evt_type
69
<<
" ("
<<
get_evt_mnemonic
(
EventData
->
evt_type
) <<
")"
70
<<
" "
<<
getTime
()
71
<< std::endl;
72
73
74
};
75
76
int
oncsEvent::convert
()
77
{
78
if
(
is_data_type
)
return
-1;
79
80
int
*
tmp
;
81
82
tmp =
new
int
[
getEvtLength
()];
83
int
*from= (
int
*)
EventData
;
84
int
*to=
tmp
;
85
for
(
unsigned
int
k
=0;
k
<
getEvtLength
();
k
++)
86
{
87
*to++ = *from++;
88
}
89
90
EventData
= (
oncsevtdata_ptr
) tmp;
91
92
is_data_type
= 1;
93
return
0;
94
95
}
96
97
int
oncsEvent::is_pointer_type
()
const
98
{
99
if
(
is_data_type
)
return
0;
100
else
return
1;
101
}
102
103
104
Packet
*
105
oncsEvent::getPacket
(
const
int
id
,
const
int
hitFormat)
106
{
107
PHDWORD
*
pp
;
108
109
if
(!
hasMap
)
createMap
();
110
111
if
(
errorcode
)
return
0;
112
113
pp =
pmap
[id];
114
if
(!pp)
return
0;
115
116
return
makePacket
(pp,hitFormat);
117
118
}
119
120
Packet
*
121
oncsEvent::getPacket
(
const
int
id
)
122
{
123
return
getPacket
(
id
, 0);
124
}
125
126
int
oncsEvent::createMap
()
127
{
128
int
i;
129
subevtdata_ptr
sevt_ptr;
130
131
int
datalength =
EventData
->
evt_length
-
EVTHEADERLENGTH
;
132
133
// loop through the subevents and see if we locate the id
134
135
for
(i=0; i<datalength; i+=
EventData
->
data
[i])
136
{
137
// each data[i] is the start of a subevent;
138
// we map it on a subevent_ptr
139
140
sevt_ptr = (
subevtdata_ptr
) &
EventData
->
data
[i];
141
142
// now we see what type of subevent we are supposed
143
// to return
144
145
pmap
[sevt_ptr->
sub_id
] = (
PHDWORD
*) &
EventData
->
data
[i];
146
// std::cout << __FILE__ << " " << __LINE__ << " subid, adr " << sevt_ptr->sub_id << " " << pmap[sevt_ptr->sub_id] << " " << *(pmap[sevt_ptr->sub_id]) << std::endl;
147
}
148
hasMap
= 1;
149
150
return
0;
151
}
152
153
Packet
*
oncsEvent::makePacket
(
PHDWORD
*
pp
,
const
int
hitFormat)
154
{
155
int
wanted_hitformat;
156
157
subevtdata_ptr
sevt_ptr = (
subevtdata_ptr
) pp;
158
159
if
(hitFormat) wanted_hitformat = hitFormat;
160
else
wanted_hitformat = sevt_ptr->
sub_decoding
;
161
162
switch
(wanted_hitformat)
163
{
164
165
case
(
ID4EVT
):
166
return
new
167
oncsSub_id4evt
( sevt_ptr);
168
break
;
169
170
case
(
ID2EVT
):
171
return
new
172
oncsSub_id2evt
( sevt_ptr );
173
break
;
174
175
case
(
IDCSTR
):
176
return
new
177
oncsSub_idcstr
( sevt_ptr );
178
break
;
179
180
case
(
IDSIS3300
):
181
return
new
182
oncsSub_idsis3300
( sevt_ptr );
183
break
;
184
185
case
(
IDSIS3300R
):
186
return
new
187
oncsSub_idsis3300r
( sevt_ptr );
188
break
;
189
190
case
(
IDCAENV792
):
191
return
new
192
oncsSub_idcaenv792
( sevt_ptr );
193
break
;
194
195
case
(
IDCAENV1742
):
196
return
new
197
oncsSub_idcaenv1742
( sevt_ptr );
198
break
;
199
200
201
case
(
IDRCPETDATA
):
202
return
new
203
oncsSub_idrcpetdata
( sevt_ptr );
204
break
;
205
206
207
case
(
IDBSPETDATA
):
208
return
new
209
oncsSub_idbspetdata
( sevt_ptr );
210
break
;
211
212
case
(
IDUPPETDATA
):
213
return
new
214
oncsSub_iduppetdata
( sevt_ptr );
215
break
;
216
217
case
(
IDUPPETDATA_V104
):
218
return
new
219
oncsSub_iduppetdata_v104
( sevt_ptr );
220
break
;
221
222
case
(
IDUPPETPARAMS
):
223
return
new
224
oncsSub_iduppetparams
( sevt_ptr );
225
break
;
226
227
case
(
IDSRSV01
):
228
return
new
229
oncsSub_idsrs_v01
( sevt_ptr );
230
break
;
231
232
case
(
IDFNALMWPC
):
233
return
234
new
oncsSub_idfnalmwpc
( sevt_ptr );
235
break
;
236
237
case
(
IDFNALMWPCV2
):
238
return
239
new
oncsSub_idfnalmwpcv2
( sevt_ptr );
240
break
;
241
242
case
(
IDDRS4V1
):
243
return
new
244
oncsSub_iddrs4v1
( sevt_ptr );
245
break
;
246
247
case
(
IDMVTXV0
):
248
return
new
249
oncsSub_idmvtxv0
( sevt_ptr );
250
break
;
251
252
case
(
IDTPCFEEV1
):
253
return
new
254
oncsSub_idtpcfeev1
( sevt_ptr );
255
break
;
256
257
case
(
IDTPCFEEV2
):
258
return
new
259
oncsSub_idtpcfeev2
( sevt_ptr );
260
break
;
261
262
case
(
IDDREAMV0
):
263
return
new
264
oncsSub_iddreamv0
( sevt_ptr );
265
break
;
266
267
case
(
IDMVTXV1
):
268
return
new
269
oncsSub_idmvtxv1
( sevt_ptr );
270
break
;
271
272
case
(
IDMVTXV2
):
273
return
new
274
oncsSub_idmvtxv2
( sevt_ptr );
275
break
;
276
277
278
default
:
279
switch
(sevt_ptr->
sub_type
)
280
{
281
case
1:
282
return
new
oncsSubevent_w1
(sevt_ptr);
283
break
;
284
case
2:
285
return
new
oncsSubevent_w2
(sevt_ptr);
286
break
;
287
case
4:
288
return
new
oncsSubevent_w4
(sevt_ptr);
289
break
;
290
default
:
291
return
new
oncsSubevent_w4
(sevt_ptr);
292
}
293
294
return
0;
295
}
296
297
return
0;
298
}
299
300
301
int
oncsEvent::getPacketList
(
Packet
* sl[],
const
int
ne)
302
{
303
304
305
if
(!
hasMap
)
createMap
();
306
if
(
errorcode
)
return
0;
307
308
std::map <int, PHDWORD *>::const_iterator
it
;
309
310
311
int
entries = 0;
312
313
for
( it =
pmap
.begin() ; it !=
pmap
.end(); ++
it
)
314
{
315
if
( entries == ne)
break
;
316
PHDWORD
*
p
= it->second;
317
//std::cout << __FILE__ << " " << __LINE__ << " subid, adr " << it->first << " " << it->second << " " << *(it->second) << std::endl;
318
319
sl[entries++] =
makePacket
(p);
320
}
321
322
return
entries;
323
}
324
325
326
327
328
// existSubevent (const int)
329
330
int
331
oncsEvent::existPacket
(
const
int
id
)
332
{
333
int
i;
334
subevtdata_ptr
sevt_ptr;
335
336
int
datalength =
EventData
->
evt_length
-
EVTHEADERLENGTH
;
337
338
// loop through the subevents and see if we locate the id
339
340
for
(i=0; i<datalength; i+=
EventData
->
data
[i])
341
{
342
343
// each data[i] is the start of a subevent;
344
// we map it on a subevent_ptr
345
346
sevt_ptr = (
subevtdata_ptr
) &
EventData
->
data
[i];
347
348
// now we see what type of subevent we are supposed
349
// to return
350
351
if
( sevt_ptr->
sub_id
==
id
)
return
1;
352
353
}
354
return
0;
355
}
356
357
358
// the Copy routine
359
int
360
oncsEvent::Copy
(
int
* array,
const
unsigned
int
length
,
int
*nw,
const
char
*what)
361
{
362
363
if
(length<
getEvtLength
() )
364
{
365
*nw = 0;
366
return
-1;
367
}
368
char
*to = (
char
*) array;
369
char
*from;
370
unsigned
int
l;
371
if
( strcmp (what,
"DATA"
) ==0 )
372
{
373
from= (
char
*) &
EventData
->
data
[0];
374
l =
getEvtLength
() -
EVTHEADERLENGTH
;
375
}
376
else
377
{
378
from= (
char
*)
EventData
;
379
l =
getEvtLength
();
380
}
381
// for (i=0; i<l ; i++) *to++ = *from++;
382
//
383
*nw = l;
384
memcpy (to, from, l*4);
385
return
0;
386
}
online_distribution
blob
master
newbasic
oncsEvent.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:59
using
1.8.2 with
ECCE GitHub integration