Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
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
if
(
EventData
->
data
[i] <= 0)
138
{
139
std::cout <<
"found 0-length packet"
<< std::endl;
140
errorcode
=-1;
141
break
;
142
}
143
144
// each data[i] is the start of a subevent;
145
// we map it on a subevent_ptr
146
147
sevt_ptr = (
subevtdata_ptr
) &
EventData
->
data
[i];
148
149
// now we see what type of subevent we are supposed
150
// to return
151
152
pmap
[sevt_ptr->
sub_id
] = (
PHDWORD
*) &
EventData
->
data
[
i
];
153
// std::cout << __FILE__ << " " << __LINE__ << " subid, adr " << sevt_ptr->sub_id << " " << pmap[sevt_ptr->sub_id] << " " << *(pmap[sevt_ptr->sub_id]) << std::endl;
154
}
155
hasMap
= 1;
156
157
return
0;
158
}
159
160
Packet
*
oncsEvent::makePacket
(
PHDWORD
*pp,
const
int
hitFormat)
161
{
162
int
wanted_hitformat;
163
164
subevtdata_ptr
sevt_ptr = (
subevtdata_ptr
) pp;
165
166
if
(hitFormat) wanted_hitformat = hitFormat;
167
else
wanted_hitformat = sevt_ptr->
sub_decoding
;
168
169
switch
(wanted_hitformat)
170
{
171
172
case
(
ID4EVT
):
173
return
new
174
oncsSub_id4evt
( sevt_ptr);
175
break
;
176
177
case
(
ID2EVT
):
178
return
new
179
oncsSub_id2evt
( sevt_ptr );
180
break
;
181
182
case
(
IDCSTR
):
183
return
new
184
oncsSub_idcstr
( sevt_ptr );
185
break
;
186
187
case
(
IDSIS3300
):
188
return
new
189
oncsSub_idsis3300
( sevt_ptr );
190
break
;
191
192
case
(
IDSIS3300R
):
193
return
new
194
oncsSub_idsis3300r
( sevt_ptr );
195
break
;
196
197
case
(
IDCAENV792
):
198
return
new
199
oncsSub_idcaenv792
( sevt_ptr );
200
break
;
201
202
case
(
IDCAENV1742
):
203
return
new
204
oncsSub_idcaenv1742
( sevt_ptr );
205
break
;
206
207
208
case
(
IDRCPETDATA
):
209
return
new
210
oncsSub_idrcpetdata
( sevt_ptr );
211
break
;
212
213
214
case
(
IDBSPETDATA
):
215
return
new
216
oncsSub_idbspetdata
( sevt_ptr );
217
break
;
218
219
case
(
IDUPPETDATA
):
220
return
new
221
oncsSub_iduppetdata
( sevt_ptr );
222
break
;
223
224
case
(
IDUPPETDATA_V104
):
225
return
new
226
oncsSub_iduppetdata_v104
( sevt_ptr );
227
break
;
228
229
case
(
IDUPPETPARAMS
):
230
return
new
231
oncsSub_iduppetparams
( sevt_ptr );
232
break
;
233
234
case
(
IDSRSV01
):
235
return
new
236
oncsSub_idsrs_v01
( sevt_ptr );
237
break
;
238
239
case
(
IDFNALMWPC
):
240
return
241
new
oncsSub_idfnalmwpc
( sevt_ptr );
242
break
;
243
244
case
(
IDFNALMWPCV2
):
245
return
246
new
oncsSub_idfnalmwpcv2
( sevt_ptr );
247
break
;
248
249
case
(
IDDRS4V1
):
250
return
new
251
oncsSub_iddrs4v1
( sevt_ptr );
252
break
;
253
254
case
(
IDMVTXV0
):
255
return
new
256
oncsSub_idmvtxv0
( sevt_ptr );
257
break
;
258
259
case
(
IDDIGITIZERV1
):
260
return
new
261
oncsSub_iddigitizerv1
( sevt_ptr );
262
break
;
263
264
case
(
IDTPCFEEV1
):
265
return
new
266
oncsSub_idtpcfeev1
( sevt_ptr );
267
break
;
268
269
case
(
IDTPCFEEV2
):
270
return
new
271
oncsSub_idtpcfeev2
( sevt_ptr );
272
break
;
273
274
case
(
IDTPCFEEV3
):
275
return
new
276
oncsSub_idtpcfeev3
( sevt_ptr );
277
break
;
278
279
case
(
IDINTTV0
):
280
return
new
281
oncsSub_idinttv0
( sevt_ptr );
282
break
;
283
284
case
(
IDDREAMV0
):
285
return
new
286
oncsSub_iddreamv0
( sevt_ptr );
287
break
;
288
289
case
(
IDMVTXV1
):
290
return
new
291
oncsSub_idmvtxv1
( sevt_ptr );
292
break
;
293
294
case
(
IDMVTXV2
):
295
return
new
296
oncsSub_idmvtxv2
( sevt_ptr );
297
break
;
298
299
case
(
IDMVTXV3
):
300
return
new
301
oncsSub_idmvtxv3
( sevt_ptr );
302
break
;
303
304
case
(
IDGL1V0
):
305
return
new
306
oncsSub_idgl1v0
( sevt_ptr );
307
break
;
308
309
default
:
310
switch
(sevt_ptr->
sub_type
)
311
{
312
case
1:
313
return
new
oncsSubevent_w1
(sevt_ptr);
314
break
;
315
case
2:
316
return
new
oncsSubevent_w2
(sevt_ptr);
317
break
;
318
case
4:
319
return
new
oncsSubevent_w4
(sevt_ptr);
320
break
;
321
default
:
322
return
new
oncsSubevent_w4
(sevt_ptr);
323
}
324
325
return
0;
326
}
327
328
return
0;
329
}
330
331
332
int
oncsEvent::getPacketList
(
Packet
* sl[],
const
int
ne)
333
{
334
335
336
if
(!
hasMap
)
createMap
();
337
if
(
errorcode
)
return
0;
338
339
std::map <int, PHDWORD *>::const_iterator
it
;
340
341
342
int
entries = 0;
343
344
for
( it =
pmap
.begin() ; it !=
pmap
.end(); ++
it
)
345
{
346
if
( entries == ne)
break
;
347
PHDWORD
*
p
= it->second;
348
//std::cout << __FILE__ << " " << __LINE__ << " subid, adr " << it->first << " " << it->second << " " << *(it->second) << std::endl;
349
350
sl[entries++] =
makePacket
(p);
351
}
352
353
return
entries;
354
}
355
356
357
358
359
// existSubevent (const int)
360
361
int
362
oncsEvent::existPacket
(
const
int
id
)
363
{
364
int
i
;
365
subevtdata_ptr
sevt_ptr;
366
367
int
datalength =
EventData
->
evt_length
-
EVTHEADERLENGTH
;
368
369
// loop through the subevents and see if we locate the id
370
371
for
(i=0; i<datalength; i+=
EventData
->
data
[
i
])
372
{
373
374
// each data[i] is the start of a subevent;
375
// we map it on a subevent_ptr
376
377
sevt_ptr = (
subevtdata_ptr
) &
EventData
->
data
[i];
378
379
// now we see what type of subevent we are supposed
380
// to return
381
382
if
( sevt_ptr->
sub_id
==
id
)
return
1;
383
384
}
385
return
0;
386
}
387
388
389
// the Copy routine
390
int
391
oncsEvent::Copy
(
int
*
array
,
const
unsigned
int
length
,
int
*nw,
const
char
*what)
392
{
393
394
if
(length<
getEvtLength
() )
395
{
396
*nw = 0;
397
return
-1;
398
}
399
char
*to = (
char
*) array;
400
char
*from;
401
unsigned
int
l;
402
if
( strcmp (what,
"DATA"
) ==0 )
403
{
404
from= (
char
*) &
EventData
->
data
[0];
405
l =
getEvtLength
() -
EVTHEADERLENGTH
;
406
}
407
else
408
{
409
from= (
char
*)
EventData
;
410
l =
getEvtLength
();
411
}
412
// for (i=0; i<l ; i++) *to++ = *from++;
413
//
414
*nw = l;
415
memcpy (to, from, l*4);
416
return
0;
417
}
online_distribution
blob
master
newbasic
oncsEvent.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:27
using
1.8.2 with
sPHENIX GitHub integration