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
oEvent.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file oEvent.cc
1
#include "
oEvent.h
"
2
#include "
EventTypes.h
"
3
4
#include "
A_Event.h
"
5
#include "
Cframe.h
"
6
#include "
frameRoutines.h
"
7
#include "
packetRoutines.h
"
8
#include "
packetConstants.h
"
9
10
#include <time.h>
11
12
// the constructor first ----------------
13
oEvent::oEvent
(
PHDWORD
* where,
const
int
length
14
,
const
int
irun,
const
int
etype,
const
int
evtseq)
15
{
16
event_base
= where;
17
evthdr
= (
evtdata_ptr
) where;
18
evthdr
->
evt_type
= etype;
19
max_length
=
length
;
20
maxSizeOfThisFrame
= 0;
21
prepare_next
(evtseq, irun);
22
}
23
24
void
oEvent::set_event_type
(
const
int
etype)
25
{
26
evthdr
->
evt_type
= etype;
27
}
28
29
int
oEvent::prepare_next
()
30
{
31
// re-initialize the event header length
32
evthdr
->
evt_length
=
EVTHEADERLENGTH
;
33
34
// if < 0, just increment the current seq. number
35
evthdr
->
evt_sequence
++;
36
37
// reset the current data index, and the leftover counter
38
current
= 0;
39
in_frame
= 0;
// indicate that we are just now assembling a frame
40
left
=
max_length
-
EVTHEADERLENGTH
;
41
evthdr
->
date
=
time
(0);
42
evthdr
->
time
= -1;
43
44
return
0;
45
46
}
47
48
int
oEvent::prepare_next
(
const
int
evtseq
49
,
const
int
irun )
50
{
51
// re-initialize the event header length
52
evthdr
->
evt_length
=
EVTHEADERLENGTH
;
53
54
// if < 0, just increment the current seq. number
55
56
evthdr
->
evt_sequence
= evtseq;
57
58
// if > 0, adjust the run number, else just keep it.
59
evthdr
->
run_number
=irun;
60
61
// reset the current data index, and the leftover counter
62
current
= 0;
63
in_frame
= 0;
// indicate that we are just now assembling a frame
64
left
=
max_length
-
EVTHEADERLENGTH
;
65
evthdr
->
date
=
time
(0);
66
evthdr
->
time
= -1;
67
68
return
0;
69
}
70
71
72
int
oEvent::addFrame
(
PHDWORD
*frame)
73
{
74
int
len
,i;
75
PHDWORD
*to = &(
evthdr
->
data
[
current
]);
76
PHDWORD
*from = frame;
77
78
len =
getFrameLength
(frame);
79
for
(i=0; i<
len
; i++) *to++ = *from++;
80
81
evthdr
->
evt_length
+=
len
;
82
current
+=
len
;
83
left
-=
len
;
84
in_frame
= 0;
85
return
len
;
86
}
87
88
89
90
int
oEvent::addPacket
(
const
Packet
*
p
)
91
{
92
93
int
additionalFrameLength = 0;
94
if
(!
in_frame
)
95
{
96
currentFramePtr
= &
evthdr
->
data
[
current
];
97
makeFrameHdr
(
currentFramePtr
,
left
,
98
rawData
,
oncsFrame
,101);
99
in_frame
= 1;
100
left
-=
currentFrameHdrLength
;
101
maxSizeOfThisFrame
=
left
;
102
additionalFrameLength =
currentFrameHdrLength
;
103
current
+=
currentFrameHdrLength
;
104
evthdr
->
evt_length
+=
currentFrameHdrLength
;
105
}
106
107
PHDWORD
* packetstart;
108
int
packetlength = p->
getLength
();
109
110
111
packetstart =
findFrameDataEnd
(
currentFramePtr
) +1;
112
113
p->
copyMe
( (
int
*)packetstart, packetlength );
114
115
if
(packetlength >0)
116
{
117
evthdr
->
evt_length
+= packetlength;
118
current
+= packetlength;
119
adjustFrameLength
(
currentFramePtr
,
maxSizeOfThisFrame
, packetlength, 1);
120
left
-= packetlength;
121
return
packetlength + additionalFrameLength;
122
}
123
else
return
-1;
124
}
125
126
127
128
int
oEvent::addUnstructPacketData
(
PHDWORD
*
data
,
129
const
int
length
,
130
const
int
id
,
131
const
int
wordsize,
132
const
int
hitformat)
133
{
134
135
int
additionalFrameLength = 0;
136
if
(!
in_frame
)
137
{
138
currentFramePtr
= &
evthdr
->
data
[
current
];
139
makeFrameHdr
(
currentFramePtr
,
left
,
140
rawData
,
oncsFrame
,101);
141
in_frame
= 1;
142
left
-=
currentFrameHdrLength
;
143
maxSizeOfThisFrame
=
left
;
144
additionalFrameLength =
currentFrameHdrLength
;
145
current
+=
currentFrameHdrLength
;
146
evthdr
->
evt_length
+=
currentFrameHdrLength
;
147
}
148
149
PHDWORD
* packetstart;
150
int
packetlength;
151
152
packetstart =
findFrameDataEnd
(
currentFramePtr
) +1;
153
154
makeUnstructPacket
(packetstart,
left
,
id
, wordsize, hitformat);
155
156
packetlength =
storePacketHits
(packetstart,
left
,
157
0, (
BYTE
*) data, length, 0);
158
159
if
(packetlength >0)
160
{
161
evthdr
->
evt_length
+= packetlength;
162
current
+= packetlength;
163
adjustFrameLength
(
currentFramePtr
,
maxSizeOfThisFrame
, packetlength, 1);
164
left
-= packetlength;
165
return
packetlength + additionalFrameLength;
166
}
167
else
return
-1;
168
}
169
online_distribution
blob
master
newbasic
oEvent.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:59
using
1.8.2 with
ECCE GitHub integration