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
packet_starscaler.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file packet_starscaler.cc
1
#include "
packet_starscaler.h
"
2
3
Packet_starscaler::Packet_starscaler
(
PACKET_ptr
data
)
4
:
Packet_w4
(data)
5
{
6
s_vectorlength
= 0;
7
s_vector
= 0;
8
}
9
10
Packet_starscaler::~Packet_starscaler
()
11
{
12
#if !defined(SunOS) && !defined(OSF1)
13
smap
.clear();
14
if
(
s_vector
)
delete
[]
s_vector
;
15
#endif
16
}
17
18
int
*
Packet_starscaler::decode
(
int
*nwout)
19
{
20
21
#if !defined(SunOS) && !defined(OSF1)
22
int
dlength
=
getDataLength
();
23
s_vectorlength
= dlength/2;
24
25
26
27
int
*
p
=
new
int
[
s_vectorlength
];
28
s_vector
=
new
long
long
[
s_vectorlength
];
29
s_vector
[0] = 0;
30
int
*
m
= (
int
*)
findPacketDataStart
(
packet
);
31
32
int
i
;
33
for
( i = 0; i <
s_vectorlength
; i++)
34
{
35
int
l = i*2;
36
p[
i
] = (( m[l+1]>>8) & 0xffffff);
37
long
long
lsb = (
unsigned
int) m[l];
38
long
long
msb = (
unsigned
int) m[l+1];
39
s_vector
[
i
] = lsb | (( msb &0xff) <<32);
40
smap
[p[
i
]] =
i
;
41
42
}
43
44
45
*nwout =
s_vectorlength
;
46
return
p
;
47
#else
48
return
0;
49
#endif
50
51
}
52
53
// ------------------------------------------------------
54
55
long
long
Packet_starscaler::lValue
(
const
int
chan)
56
{
57
#if !defined(SunOS) && !defined(OSF1)
58
if
(
decoded_data1
== NULL )
59
{
60
if
( (
decoded_data1
=
decode
(&
data1_length
))==NULL)
61
return
0;
62
}
63
64
65
66
if
(chan < 0 || chan >= (1<<24) )
return
0;
67
68
std::map <int, int>::iterator
it
;
69
if
( ( it =
smap
.find(chan) ) ==
smap
.end() )
70
{
71
return
0;
72
}
73
74
int
index
= it->second;
75
76
if
( index < 0 || index >=
s_vectorlength
)
77
{
78
79
return
0;
80
}
81
return
s_vector
[
index
];
82
83
#else
84
return
0;
85
#endif
86
87
}
88
89
int
Packet_starscaler::iValue
(
const
int
index
)
90
{
91
#if !defined(SunOS) && !defined(OSF1)
92
if
(
decoded_data1
== NULL )
93
{
94
if
( (
decoded_data1
=
decode
(&
data1_length
))==NULL)
95
return
0;
96
}
97
98
99
100
if
(index < 0 || index >=
s_vectorlength
)
return
0;
101
102
return
decoded_data1
[
index
];
103
104
#else
105
return
0;
106
#endif
107
108
}
109
110
int
Packet_starscaler::iValue
(
const
int
ich,
const
char
*what)
111
{
112
113
if
(
decoded_data1
== NULL )
114
{
115
if
( (
decoded_data1
=
decode
(&
data1_length
))==NULL)
116
return
0;
117
}
118
119
if
( strcmp(what,
"CHANNELCOUNT"
)==0)
120
{
121
return
s_vectorlength
-1;
122
}
123
return
0;
124
125
}
126
127
void
Packet_starscaler::dump
(
OSTREAM
&
os
)
128
{
129
130
131
this->
identify
(os);
132
133
int
i
;
134
135
for
( i= 0; i <
iValue
(0,
"CHANNELCOUNT"
); i++)
136
{
137
os << i <<
" "
<< std::setw(10) <<
iValue
(i) <<
" | "
<< std::setw(12) <<
lValue
(
iValue
(i)) << std::endl;
138
}
139
}
140
online_distribution
blob
master
newbasic
packet_starscaler.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:28
using
1.8.2 with
sPHENIX GitHub integration