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
daq_device_gauss.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file daq_device_gauss.cc
1
#include "
daq_device_gauss.h
"
2
3
#include <strings.h>
4
#include "
simpleRandom.h
"
5
6
using namespace
std;
7
8
daq_device_gauss::daq_device_gauss
(
const
int
eventtype
9
,
const
int
subeventid
10
,
const
int
trigger_enabled)
11
{
12
13
m_eventType = eventtype;
14
m_subeventid = subeventid;
15
_mean = 0;
16
_sigma = 1.;
17
18
R
=
new
simpleRandom
(876565);
19
20
if
(trigger_enabled)
21
{
22
th =
new
pulserTriggerHandler
(m_eventType);
23
registerTriggerHandler
(th);
24
}
25
else
26
{
27
th = 0;
28
}
29
}
30
31
daq_device_gauss::~daq_device_gauss
()
32
{
33
delete
R
;
34
35
clearTriggerHandler
();
36
delete
th;
37
}
38
39
40
41
// the put_data function
42
43
int
daq_device_gauss::put_data
(
const
int
etype,
int
* adr,
const
int
length
)
44
{
45
46
int
len = 0;
47
48
if
(etype != m_eventType )
// not our id
49
{
50
return
0;
51
}
52
53
54
sevt = (
subevtdata_ptr
) adr;
55
// set the initial subevent length
56
sevt->sub_length =
SEVTHEADERLENGTH
;
57
58
// update id's etc
59
sevt->sub_id = m_subeventid;
60
sevt->sub_type=4;
61
sevt->sub_decoding =
ID4EVT
;
62
sevt->reserved[0] = 0;
63
sevt->reserved[1] = 0;
64
65
66
int
*d = (
int
*) &sevt->data;
67
68
int
ia;
69
70
float
scale=10;
71
for
( ia = 0; ia < 4; ia++)
72
{
73
*d++ =
R
->gauss(_mean , scale * _sigma );
74
scale *=10;
75
len++;
76
}
77
78
79
sevt->sub_padding = len%2;
80
len = len + (len%2);
81
sevt->sub_length += len;
82
return
sevt->sub_length;
83
}
84
85
86
void
daq_device_gauss::identify
(std::ostream&
os
)
const
87
{
88
89
os <<
"Gaussian Distribution Device Event Type: "
<< m_eventType <<
" Subevent id: "
<< m_subeventid;
90
91
if
(th)
92
{
93
os <<
" ** Trigger enabled"
;
94
}
95
96
os << endl;
97
98
}
99
100
int
daq_device_gauss::max_length
(
const
int
etype)
const
101
{
102
if
(etype != m_eventType)
return
0;
103
return
(4 +
SEVTHEADERLENGTH
);
104
}
105
106
int
daq_device_gauss::init
()
107
{
108
109
return
0;
110
}
111
112
// the rearm() function
113
int
daq_device_gauss::rearm
(
const
int
etype)
114
{
115
if
(etype != m_eventType)
return
0;
116
return
0;
117
}
118
119
rcdaq
blob
master
daq_device_gauss.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:47
using
1.8.2 with
sPHENIX GitHub integration