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