ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
testEventiterator.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file testEventiterator.cc
1 //
2 // testEventIterator mlp 9/11/96
3 //
4 // this iterator delivers test-type Event objects which can
5 // be used to debug the analysis software which uses the events
6 // delivered. The events contain 1 frame and one packet
7 
8 
9 #include <time.h>
10 
11 #include "testEventiterator.h"
12 #include <stdlib.h>
13 
14 #include "oncsEvent.h"
15 
17 {
18  delete R;
19 }
20 
22 {
23  R = new simpleRandom(876565);
24  current_event = 0;
25 
26  typedef struct evt_data
27  {
28  int evt_length;
29  int evt_type;
30  int evt_sequence;
31  int run_number;
32  int date;
33  int time;
34  int reserved[2];
35  int data[];
36  } *e_ptr;
37 
38 typedef struct subevt_data
39  {
40  int sub_length;
41  short sub_id;
42  short sub_type;
43  short sub_decoding;
44  short sub_padding;
45  int reserved;
46  int data[];
47  } *s_ptr;
48 
49 
50 
51  current_event = 0;
52 
53  e_ptr e = (e_ptr) e_data;
54 
55  e->evt_length = 8;
56  e->evt_type = 1;
57  e->evt_sequence = 1;
58  e->run_number = 1331;
59  e->date = 0;
60  e->time = time(0);
61  e->reserved[0] = 0;
62  e->reserved[1] = 0;
63 
64  e_sequence = & e->evt_sequence;
65  e_time = &e->time;
66 
67 
68  s_ptr s1001 = (s_ptr) e->data;
69 
70  s1001->sub_length = 4;
71  s1001->sub_id = 1001;
72  s1001->sub_type = 4;
73  s1001->sub_decoding = 6;
74  s1001->sub_padding = 0;
75  s1001->reserved = 0;
76 
77 
78  for (int i = 0; i < 20; i++)
79  {
80  s1001->data[i] = i;
81  s1001->sub_length++;
82  }
83 
84  e->evt_length += s1001->sub_length;
85 
86 
87  s_ptr s1002 = (s_ptr) &s1001->data[20];
88  s1002->sub_length = 4;
89  s1002->sub_id = 1002;
90  s1002->sub_type = 2;
91  s1002->sub_decoding = 5;
92  s1002->sub_padding = 0;
93  s1002->reserved = 0;
94 
95  short *x = (short *) &s1002->data;
96 
97  for (int i = 0; i < 64; i++)
98  {
99  x[i] = i;
100  }
101 
102  s1002->sub_length+=32;
103  e->evt_length += s1002->sub_length;
104 
105 
106  s_ptr s1003 = (s_ptr) &s1002->data[32];
107  s1003->sub_length = 8; // we have the length
108  s1003->sub_id = 1003;
109  s1003->sub_type = 4;
110  s1003->sub_decoding = 6;
111  s1003->sub_padding = 0;
112  s1003->reserved = 0;
113 
114  e_1003values = &(s1003->data[0]);
115 
116  s1003->data[0] = 0;
117  s1003->data[1] = 0;
118  s1003->data[2] = 0;
119  s1003->data[3] = 0;
120 
121  e->evt_length += s1003->sub_length;
122 
123 }
124 
125 
126 void
128 {
129  os << getIdTag() << std::endl;
130 
131 };
132 
133 const char *
135 {
136  return " -- testEventiterator (standard) ";
137 };
138 
139 
140 
141 Event *
143 {
144 
146  *e_time = time(0);
147  float scale = 10;
148 
149  for ( int i = 0; i < 4; i++)
150  {
151  e_1003values[i] = R->gauss(0 , scale );
152  scale *= 10.;
153  }
154 
155  Event *e = new oncsEvent(e_data);
156  e->convert();
157 
158  return e;
159 }