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
oncsSub_idtpcfeev1.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file oncsSub_idtpcfeev1.cc
1
#include "
oncsSub_idtpcfeev1.h
"
2
3
#include <string.h>
4
#include <stdint.h>
5
#include <stdint.h>
6
7
using namespace
std;
8
9
oncsSub_idtpcfeev1::oncsSub_idtpcfeev1
(
subevtdata_ptr
data
)
10
:
oncsSubevent_w4
(data)
11
{
12
13
_nsamples
= 0;
14
_nchannels
= 0;
15
_nchips
= 0;
16
_is_decoded
= 0;
17
18
memset(
array
, 0, 64*1002*
sizeof
(uint32_t) );
19
20
21
}
22
23
24
oncsSub_idtpcfeev1::~oncsSub_idtpcfeev1
()
25
{
26
// if (array) delete [][] array;
27
}
28
29
30
#define HEADER_LENGTH 7U
31
32
int
oncsSub_idtpcfeev1::decode
()
33
{
34
35
if
(
_is_decoded
)
return
0;
36
_is_decoded
= 1;
37
38
int
recv_length =
getLength
() -
SEVTHEADERLENGTH
-
getPadding
();
39
40
_nsamples
= 0;
41
_nchannels
= 32;
42
43
uint32_t *
buffer
= ( uint32_t *) &
SubeventHdr
->
data
;
44
unsigned
int
payload_len = buffer[1] & 0xffff;
45
46
_bx_count
= ((buffer[4] & 0xffff) << 4) | (buffer[5] & 0xf);
47
48
for
(
int
i
= 0;
i
< recv_length;
i
+= (payload_len+1))
49
{
50
payload_len = (buffer[
i
+1] & 0xffff);
51
unsigned
int
channel
= buffer[
i
+3] & 0x1f;
52
unsigned
int
sampa_addr = (buffer[
i
+3] >> 5) & 0xf;
53
54
if
( sampa_addr > 1)
55
{
56
_broken
= 1;
57
return
0;
58
}
59
if
( channel >= 32 )
60
{
61
_broken
= 2;
62
return
0;
63
}
64
65
if
( sampa_addr >
_nchips
)
66
{
67
_nchips
= sampa_addr;
68
}
69
for
(
unsigned
int
s
= 0;
s
< payload_len -
HEADER_LENGTH
;
s
++)
70
{
71
array
[sampa_addr*32 +
channel
][
s
] = buffer[
i
+
s
+
HEADER_LENGTH
] & 0xffff;
72
}
73
_nsamples
= payload_len -
HEADER_LENGTH
;
74
}
75
76
_nchips
++;
77
78
return
0;
79
}
80
81
82
int
oncsSub_idtpcfeev1::iValue
(
const
int
ch,
const
int
sample)
83
{
84
decode
();
85
86
if
( sample >= (
int
)
_nsamples
|| sample < 0
87
|| ch >= (
int
) (
_nchips
*
_nchannels
) || ch < 0 )
return
0;
88
89
return
array
[ch][sample];
90
91
}
92
int
oncsSub_idtpcfeev1::iValue
(
const
int
chip,
const
int
ch,
const
int
sample)
93
{
94
if
( sample >= (
int
)
_nsamples
|| sample < 0
95
|| chip >= (
int
)
_nchips
|| chip < 0
96
|| ch >= (
int
)
_nchannels
|| ch < 0 )
return
0;
97
98
return
iValue
(chip*32 + ch, sample);
99
100
}
101
102
int
oncsSub_idtpcfeev1::iValue
(
const
int
n
,
const
char
*what)
103
{
104
105
decode
();
106
107
if
( strcmp(what,
"SAMPLES"
) == 0 )
108
{
109
return
_nsamples
;
110
}
111
112
if
( strcmp(what,
"CHANNELS"
) == 0 )
113
{
114
return
_nchannels
;
115
}
116
117
if
( strcmp(what,
"CHIPS"
) == 0 )
118
{
119
return
_nchips
;
120
}
121
122
if
( strcmp(what,
"BROKEN"
) == 0 )
123
{
124
return
_broken
;
125
}
126
127
if
( strcmp(what,
"BCTR"
) == 0 )
128
{
129
return
_bx_count
;
130
}
131
132
return
0;
133
134
}
135
136
void
oncsSub_idtpcfeev1::dump
(
OSTREAM
&
os
)
137
{
138
identify
(os);
139
140
os <<
"Chips: "
<<
iValue
(0,
"CHIPS"
) << std::endl;
141
os <<
"Channels: "
<<
iValue
(0,
"CHANNELS"
) << std::endl;
142
os <<
"Samples: "
<<
iValue
(0,
"SAMPLES"
) << std::endl;
143
os <<
"Beam Crossing: "
<<
iValue
(0,
"BCTR"
) << std::endl;
144
os << endl;
145
146
for
(
int
chip = 0; chip <
iValue
(0,
"CHIPS"
); chip++)
147
{
148
cout <<
" chip sample +++++++++++++++ Chip "
<< chip <<
" ++++++++"
<< endl;
149
for
(
int
s
= 0;
s
<
iValue
(0,
"SAMPLES"
);
s
++)
150
{
151
152
os << setw(3) << chip << setw(5) <<
s
<<
" | "
;
153
154
for
(
int
c
= 0;
c
<
iValue
(0,
"CHANNELS"
);
c
++)
155
{
156
os << setw(4) <<
iValue
(chip,
c
, s) <<
" "
;
157
}
158
os << endl;
159
}
160
os << endl;
161
}
162
163
}
online_distribution
blob
master
newbasic
oncsSub_idtpcfeev1.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:27
using
1.8.2 with
sPHENIX GitHub integration