File indexing completed on 2025-08-02 08:21:01
0001 #include "daq_device_gauss.h"
0002
0003 #include <strings.h>
0004 #include "simpleRandom.h"
0005
0006 using namespace std;
0007
0008 daq_device_gauss::daq_device_gauss(const int eventtype
0009 , const int subeventid
0010 , const int trigger_enabled)
0011 {
0012
0013 m_eventType = eventtype;
0014 m_subeventid = subeventid;
0015 _mean = 0;
0016 _sigma = 1.;
0017
0018 R = new simpleRandom (876565);
0019
0020 if (trigger_enabled)
0021 {
0022 th = new pulserTriggerHandler(m_eventType);
0023 registerTriggerHandler(th);
0024 }
0025 else
0026 {
0027 th = 0;
0028 }
0029 }
0030
0031 daq_device_gauss::~daq_device_gauss()
0032 {
0033 delete R;
0034
0035 clearTriggerHandler();
0036 delete th;
0037 }
0038
0039
0040
0041
0042
0043 int daq_device_gauss::put_data(const int etype, int * adr, const int length )
0044 {
0045
0046 int len = 0;
0047
0048 if (etype != m_eventType )
0049 {
0050 return 0;
0051 }
0052
0053
0054 sevt = (subevtdata_ptr) adr;
0055
0056 sevt->sub_length = SEVTHEADERLENGTH;
0057
0058
0059 sevt->sub_id = m_subeventid;
0060 sevt->sub_type=4;
0061 sevt->sub_decoding = ID4EVT;
0062 sevt->reserved[0] = 0;
0063 sevt->reserved[1] = 0;
0064
0065
0066 int *d = (int *) &sevt->data;
0067
0068 int ia;
0069
0070 float scale=10;
0071 for ( ia = 0; ia < 4; ia++)
0072 {
0073 *d++ = R->gauss(_mean , scale * _sigma );
0074 scale *=10;
0075 len++;
0076 }
0077
0078
0079 sevt->sub_padding = len%2;
0080 len = len + (len%2);
0081 sevt->sub_length += len;
0082 return sevt->sub_length;
0083 }
0084
0085
0086 void daq_device_gauss::identify(std::ostream& os) const
0087 {
0088
0089 os << "Gaussian Distribution Device Event Type: " << m_eventType << " Subevent id: " << m_subeventid;
0090
0091 if (th)
0092 {
0093 os << " ** Trigger enabled";
0094 }
0095
0096 os << endl;
0097
0098 }
0099
0100 int daq_device_gauss::max_length(const int etype) const
0101 {
0102 if (etype != m_eventType) return 0;
0103 return (4 + SEVTHEADERLENGTH);
0104 }
0105
0106 int daq_device_gauss::init()
0107 {
0108
0109 return 0;
0110 }
0111
0112
0113 int daq_device_gauss::rearm(const int etype)
0114 {
0115 if (etype != m_eventType) return 0;
0116 return 0;
0117 }
0118
0119