Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
daq_device_deadtime.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file daq_device_deadtime.cc
1 
2 
3 #include <iostream>
4 
5 #include <daq_device_deadtime.h>
6 
7 using namespace std;
8 
10  , const int subeventid
11  , const int n_ticks
12  , const int n_words
13  , const int trigger_enabled)
14 {
15 
16  m_eventType = eventtype;
17  m_subeventid = subeventid;
18  number_of_ticks = n_ticks;
19  number_of_words = n_words;
20  if (trigger_enabled)
21  {
22  th = new pulserTriggerHandler(m_eventType);
24  }
25  else
26  {
27  th = 0;
28  }
29 }
30 
32 {
33  if ( th)
34  {
36  delete th;
37  }
38 }
39 
40 
41 
42 // the put_data function
43 
44 int daq_device_deadtime::put_data(const int etype, int * adr, const int length )
45 {
46 
47 
48  if (etype != m_eventType ) // not our id
49  {
50  return 0;
51  }
52 
53  if ( number_of_ticks) usleep ( number_of_ticks);
54 
55  if ( number_of_words)
56  {
57 
58  if ( daq_getEventFormat() ) // we are writing PRDF
59  {
60  formatPacketHdr(adr);
61 
62  packetdata_ptr sevt = (packetdata_ptr) adr;
63 
64  // update id's etc
65  sevt->sub_id = m_subeventid;
66  sevt->sub_type=4;
67  sevt->sub_decoding = 30000 + ID4EVT;
68 
69  int padding = number_of_words%2;
70  sevt->structureinfo += padding;
71  sevt->sub_length += number_of_words + padding;
72  return sevt->sub_length;
73  }
74  else
75  {
76  sevt = (subevtdata_ptr) adr;
77  // set the initial subevent length
78  sevt->sub_length = SEVTHEADERLENGTH;
79 
80  // update id's etc
81  sevt->sub_id = m_subeventid;
82  sevt->sub_type=4;
83  sevt->sub_decoding = ID4EVT;
84  sevt->reserved[0] = 0;
85  sevt->reserved[1] = 0;
86 
87  sevt->sub_padding = number_of_words%2;
88  sevt->sub_length += number_of_words + sevt->sub_padding;
89  return sevt->sub_length;
90  }
91  }
92  return 0;
93 }
94 
95 
96 void daq_device_deadtime::identify(std::ostream& os) const
97 {
98 
99  os << "Deadtime Device Event Type: " << m_eventType
100  << " n_ticks: " << number_of_ticks << " n_words: " << number_of_words;
101 
102  if (th)
103  {
104  os << " ** Trigger enabled";
105  }
106 
107  os << endl;
108 
109 }
110 
111 int daq_device_deadtime::max_length(const int etype) const
112 {
113  if (etype != m_eventType) return 0;
114 
115  if ( number_of_words)
116  {
117  return SEVTHEADERLENGTH + number_of_words +2;
118  }
119 
120  return 0;
121 }
122 
124 {
125 
126  return 0;
127 }
128 
129 // the rearm() function
130 int daq_device_deadtime::rearm(const int etype)
131 {
132  return 0;
133 }
134