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_iddrs4v1.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file oncsSub_iddrs4v1.cc
1
#include "
oncsSub_iddrs4v1.h
"
2
#include <string.h>
3
#include <iostream>
4
#include <iomanip>
5
6
using namespace
std;
7
8
oncsSub_iddrs4v1::oncsSub_iddrs4v1
(
subevtdata_ptr
data
)
9
:
oncsSubevent_w4
(data)
10
{
11
wave
= 0;
12
// int dummy;
13
// decode(&dummy);
14
}
15
16
oncsSub_iddrs4v1::~oncsSub_iddrs4v1
()
17
{
18
if
(
wave
)
delete
[]
wave
;
19
}
20
21
int
*
oncsSub_iddrs4v1::decode
(
int
*nwout)
22
{
23
24
25
samples
=
SubeventHdr
->
data
& 0xffff;
26
enabled_channelmask
= (
SubeventHdr
->
data
>> 16) & 0xf;
27
28
float
*d = (
float
*) &
SubeventHdr
->
data
;
29
d++;
30
int
len =
samples
;
31
for
(
int
i
=0;
i
<4;
i
++)
32
{
33
if
(
enabled_channelmask
& ( 1<<
i
) )
34
{
35
channel_offset
[
i
] = len;
36
len +=
samples
;
37
}
38
}
39
wave
=
new
float
[len];
40
memcpy (
wave
, d, len *
sizeof
(
float
));
41
42
*nwout = 0;
43
return
0;
44
}
45
46
float
oncsSub_iddrs4v1::rValue
(
const
int
isample,
const
char
* what)
47
{
48
if
( isample < 0 || isample >
samples
)
return
0;
49
50
if
( !
wave
)
51
{
52
int
dummy
;
53
decode
(&dummy);
54
}
55
56
57
if
( strcmp(what,
"TIME"
) == 0 )
58
{
59
return
wave
[isample];
// the first 1024 sample are the time base
60
}
61
return
0;
62
63
}
64
65
int
oncsSub_iddrs4v1::iValue
(
const
int
i
,
const
char
* what)
66
{
67
if
( !
wave
)
68
{
69
int
dummy
;
70
decode
(&dummy);
71
}
72
73
if
( strcmp(what,
"SAMPLES"
) == 0 )
74
{
75
return
samples
;
76
}
77
78
else
if
( strcmp(what,
"ENABLED"
) == 0 )
79
{
80
return
( (
enabled_channelmask
& ( 1 << i)) !=0);
81
}
82
83
return
0;
84
}
85
86
float
oncsSub_iddrs4v1::rValue
(
const
int
isample,
const
int
ich)
87
{
88
if
( isample < 0 || isample > 1023)
return
0;
89
if
( ich < 0 || ich > 4)
return
0;
90
91
if
(ich == 4)
return
rValue
(isample,
"TIME"
);
92
93
if
( !
wave
)
94
{
95
int
dummy
;
96
decode
(&dummy);
97
}
98
99
return
wave
[
channel_offset
[ich] +isample];
100
101
}
102
103
104
void
oncsSub_iddrs4v1::dump
(
OSTREAM
&
os
)
105
{
106
identify
(os);
107
int
i
;
108
109
os <<
" Samples "
<<
iValue
(0,
"SAMPLES"
) <<
" enabled channnels: "
;
110
for
( i = 0; i< 4; i++)
111
{
112
if
(
iValue
(i,
"ENABLED"
) )
113
{
114
os <<
" "
<<
i
;
115
}
116
}
117
os << endl;
118
119
os <<
" ch | time"
;
120
if
(
enabled_channelmask
& 1) os <<
" ch0"
;
121
if
(
enabled_channelmask
& 2) os <<
" ch1"
;
122
if
(
enabled_channelmask
& 4) os <<
" ch2"
;
123
if
(
enabled_channelmask
& 8) os <<
" ch3"
;
124
os << endl;
125
126
for
( i = 0; i <
samples
; i++)
127
{
128
os << setw(5) << i <<
" | "
;
129
os << setw(10) <<
rValue
(i,
"TIME"
) <<
" "
;
130
if
(
enabled_channelmask
& 1) os << setw(10) <<
rValue
(i, 0) <<
" "
;
131
if
(
enabled_channelmask
& 2) os << setw(10) <<
rValue
(i, 1) <<
" "
;
132
if
(
enabled_channelmask
& 4) os << setw(10) <<
rValue
(i, 2) <<
" "
;
133
if
(
enabled_channelmask
& 8) os << setw(10) <<
rValue
(i, 3) <<
" "
;
134
os << endl;
135
}
136
}
137
138
online_distribution
blob
master
newbasic
oncsSub_iddrs4v1.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:27
using
1.8.2 with
sPHENIX GitHub integration