Increasing histo clu. lay.1 upper lim.
[u/mrichter/AliRoot.git] / RAW / event.h
CommitLineData
f3a800f8 1/****************************************************************************
2 *
3 * event.h: DATE event data format
4 *
5 * Revision History:
6 * V01.00 RD PVV 09-Jan-97 Initial version
7 * V01.01 AV 24-Feb-97 Added START_OF_RUN_FILES and triggerNb
8 * V02.02 RD 13-Mar-97 Detector ID mask type added
9 * V02.03 PVV 20-Mar-97 Detector ID on 128 bits
10 * V02.03 RD PVV 20-Mar-97 Added EVENT_DATA_TRUNCATED
11 * V02.04 PVV 06-May-97 Added EVENT_TYPE_MASK
12 * V02.05 RD PVV 09-May-97 Increase EVENT_DATA_MAX_SIZE to 50 K
13 * V02.06 WB MG 22-May-97 Added END_OF_RUN_FILES
14 * V02.07 WB 23-May-97 Added errorCode, deadTime, deadTimeusec
15 * EVENT_DATA_MAX_SIZE set to 100 * 1024
16 * MAX_DETECTORS set to 126
17 * V02.08 PVV 02-Jun-97 Modify the encoding of types
18 * V02.09 WB RD PVV 28-Jul-98 Add fileSeqNb in the header.
19 * Reduce detector mask to 3 long
20 * V02.10 RD 31-Jul-98 (start|end)OfRunFiles added to eventType
21 * V02.11 PVV RD 02-Sep-98 Event type re-numbered
22 * Equipment bit added to event type
23 * V02.12 AV PVV RD 03-Sep-98 FileSeqNo moved before detectorId
24 * V02.13 RD 08-Oct-98 32 bits fields defined as long32
25 * V02.13 RD 19-Feb-99 Endianness/swap definitions added
26 * V02.14 WB PVV RD 21-Jun-99 typeAttribute added
27 * V02.15 RD 27-Jul-99 Macros for typeAttribute handling added
28 * V02.16 RD 19-Nov-99 Bug in Attributes test/set fixed
29 * V02.17 WB PVV RD 08-May-00 System attributes for SOR and EOR added
30 * V02.18 RD 18-May-00 EVENT_H_ID added
31 * V02.19 RD 10-Aug-00 Macros for detectorId handling added
32 * V03.00 RD 23-Nov-00 Version for DATE V4
33 * V03.01 AV KS 05-Apr-02 Introduction of eventLocationDescriptorStruct
34 * V03.02 KS 10-May-02 Added ATTR_KEEP_PAGES for COLE
35 * RD 30-Apr-04 Added definitions for the Common Data Header
36 * RD 24-Jun-04 Added definitions for HLT DECISION
37 * RD 13-Jul-04 Added macros to OR attributes
38 * V03.03 RD 25-May-05 Added eventTimestamp
39 * V03.04 RD 17-Aug-05 Added VANGUARD and REARGUARD events
40 * V03.05 RD 05-Sep-05 Added SYSTEM and DETECTOR software tri evts
41 * V03.06 RD 14-Sep-05 VANGUARD/REARGUARD changed into START_OF_DATA
42 * and END_OF_DATA
07afbf5b 43 * V03.07 RD 26-Jul-06 Modifications for CDH version 2
44 * KS 20-Dec-06 Corrected CDH layout for MBZ[22-23] and
45 * L1 trigger message [14-21]
46 * V03.08 RD 17-Jan-07 Added "BY DETECTOR" event system attribute
47 * V03.09 RD 08-Feb-07 Moved trigger and detector masks down 1 bit
f3a800f8 48 *
49 * Preprocessor definitions:
50 * NDEBUG Define BEFORE including this file to disable run-time checks on
51 * various parameters
52 *
53 * Related facilities:
54 * validateEvent.c Validation program, should be run after EACH change to
55 * the definitions given here below
56 ***************************************************************************/
57#ifndef __event_h__
58#define __event_h__
59
60#define EVENT_MAJOR_VERSION_NUMBER 0x0003
07afbf5b 61#define EVENT_MINOR_VERSION_NUMBER 0x0009
f3a800f8 62
63/* ========== System includes ========= */
64#include <string.h> /* Needed by: memset, memcpy */
65#include <assert.h> /* Needed by: assert */
66
67/* ========== Definitions for the event header ========== */
68
69/* ---------- Header base size ---------- */
70/* This value must be updated for each change in the eventHeaderStruct */
71#define EVENT_HEAD_BASE_SIZE 68
72
73/* ---------- Event size ---------- */
74typedef unsigned long32 eventSizeType;
75
76/* ---------- Magic signature and its byte-swapped version ---------- */
77typedef unsigned long32 eventMagicType;
78#define EVENT_MAGIC_NUMBER ((eventMagicType)0xDA1E5AFE)
79#define EVENT_MAGIC_NUMBER_SWAPPED ((eventMagicType)0xFE5A1EDA)
80
81/* ---------- Header size ---------- */
82typedef unsigned long32 eventHeadSizeType;
83
84/* ---------- Unique version identifier ---------- */
85#define EVENT_CURRENT_VERSION \
86 (((EVENT_MAJOR_VERSION_NUMBER<<16)&0xffff0000)|\
87 (EVENT_MINOR_VERSION_NUMBER&0x0000ffff))
88typedef unsigned long32 eventVersionType;
89
90/* ---------- Event type ---------- */
91typedef unsigned long32 eventTypeType;
92#define START_OF_RUN ((eventTypeType) 1)
93#define END_OF_RUN ((eventTypeType) 2)
94#define START_OF_RUN_FILES ((eventTypeType) 3)
95#define END_OF_RUN_FILES ((eventTypeType) 4)
96#define START_OF_BURST ((eventTypeType) 5)
97#define END_OF_BURST ((eventTypeType) 6)
98#define PHYSICS_EVENT ((eventTypeType) 7)
99#define CALIBRATION_EVENT ((eventTypeType) 8)
100#define EVENT_FORMAT_ERROR ((eventTypeType) 9)
101#define START_OF_DATA ((eventTypeType)10)
102#define END_OF_DATA ((eventTypeType)11)
103#define SYSTEM_SOFTWARE_TRIGGER_EVENT ((eventTypeType)12)
104#define DETECTOR_SOFTWARE_TRIGGER_EVENT ((eventTypeType)13)
105#define EVENT_TYPE_MIN 1
106#define EVENT_TYPE_MAX 13
107enum eventTypeEnum {
108 startOfRun = START_OF_RUN,
109 endOfRun = END_OF_RUN,
110 startOfRunFiles = START_OF_RUN_FILES,
111 endOfRunFiles = END_OF_RUN_FILES,
112 startOfBurst = START_OF_BURST,
113 endOfBurst = END_OF_BURST,
114 physicsEvent = PHYSICS_EVENT,
115 calibrationEvent = CALIBRATION_EVENT,
116 formatError = EVENT_FORMAT_ERROR,
117 startOfData = START_OF_DATA,
118 endOfData = END_OF_DATA,
119 systemSoftwareTriggerEvent = SYSTEM_SOFTWARE_TRIGGER_EVENT,
120 detectorSoftwareTriggerEvent = DETECTOR_SOFTWARE_TRIGGER_EVENT
121};
122#define EVENT_TYPE_OK(t) (((t) >= EVENT_TYPE_MIN) && (((t) <= EVENT_TYPE_MAX)))
123
124/* ---------- Run number ---------- */
125typedef unsigned long32 eventRunNbType;
126
127/* ---------- The eventId field ---------- */
128#define EVENT_ID_BYTES 8
129#define EVENT_ID_WORDS ((EVENT_ID_BYTES) >> 2)
130typedef unsigned long32 eventIdType[EVENT_ID_WORDS];
131
132 /* PERIOD - ORBIT - BUNCH crossing type events */
133#define EVENT_ID_MAX_PERIOD 0x0fffffff
134#define EVENT_ID_MAX_ORBIT 0x00ffffff
135#define EVENT_ID_MAX_BUNCH_CROSSING 0x00000fff
136#define LOAD_EVENT_ID(id,s,o,bc) \
137 (EVENT_ID_SET_PERIOD(id,s), \
138 EVENT_ID_SET_ORBIT(id,o), \
139 EVENT_ID_SET_BUNCH_CROSSING(id,bc))
140#define EVENT_ID_GET_BUNCH_CROSSING(id) ((id)[1]&0x00000fff)
141#define EVENT_ID_GET_ORBIT(id) \
142 ((((id)[0]<<20)&0xf00000)|(((id)[1]>>12)&0xfffff))
143#define EVENT_ID_GET_PERIOD(id) (((id)[0]>>4)&0x0fffffff)
144
145#define EVENT_ID_SET_BUNCH_CROSSING(id,v) \
146 (assert(((v)>=0)&&((v)<=EVENT_ID_MAX_BUNCH_CROSSING)), \
147 (id)[1]=((id)[1]&0xfffff000)|((v)&0xfff))
148#define EVENT_ID_SET_ORBIT(id,v) \
149 (assert(((v)>=0)&&((v)<=EVENT_ID_MAX_ORBIT)), \
150 (id)[0]=(((id)[0])&0xfffffff0)|(((v)&0x00f00000)>>20), \
151 (id)[1]=(((id)[1])&0x00000fff)|(((v)&0x000fffff)<<12))
152#define EVENT_ID_SET_PERIOD(id,v) \
153 (assert(((v)>=0)&&((v)<=EVENT_ID_MAX_PERIOD)), \
154 (id)[0]=(((id)[0])&0x0000000f)|(((v)&0x0fffffff)<<4))
155
156 /* RAW type event */
157#define EVENT_ID_MAX_NB_IN_RUN 0xffffffff
158#define EVENT_ID_MAX_BURST_NB 0x00000fff
159#define EVENT_ID_MAX_NB_IN_BURST 0x000fffff
160#define LOAD_RAW_EVENT_ID(id,nir,bn,nib) \
161 (assert(((bn)>=0) && ((bn)<=EVENT_ID_MAX_BURST_NB) && \
162 ((nib)>=0) && ((nib)<=EVENT_ID_MAX_NB_IN_BURST)), \
163 (id)[0]=nir, \
164 (id)[1]=((bn<<20)&0xfff00000)|(nib&0x000fffff))
165#define EVENT_ID_SET_NB_IN_RUN(id,nir) \
166 (assert(((nir)>=0)&&((nir)<=EVENT_ID_MAX_NB_IN_RUN)), \
167 (id)[0]=(nir))
168#define EVENT_ID_SET_BURST_NB(id,bn) \
169 (assert(((bn)>=0)&&((bn)<=EVENT_ID_MAX_BURST_NB)), \
170 (id)[1]=((id)[1]&0x000fffff)|(((bn)<<20)&0xfff00000))
171#define EVENT_ID_SET_NB_IN_BURST(id,nib) \
172 (assert(((nib)>=0)&&((nib)<=EVENT_ID_MAX_NB_IN_BURST)), \
173 (id)[1]=((id)[1]&0xfff00000)|((nib)&0x000fffff))
174#define EVENT_ID_GET_NB_IN_RUN(id) ((id)[0])
175#define EVENT_ID_GET_BURST_NB(id) (((id)[1]>>20)&0x00000fff)
176#define EVENT_ID_GET_NB_IN_BURST(id) ((id)[1]&0x000fffff)
177
178 /* All events */
179#define EQ_EVENT_ID(a,b) ((((a)[0])==((b)[0]))&&(((a)[1])==((b)[1])))
180#define GT_EVENT_ID(a,b) \
181 (((((a)[0])>((b)[0])))||((((a)[0])==((b)[0]))&&(((a)[1])>((b)[1]))))
182#define LT_EVENT_ID(a,b) \
183 ((((a)[0])<((b)[0])) || ((((a)[0])==((b)[0]))&&(((a)[1])<((b)[1]))))
184#define GE_EVENT_ID(a,b) (!LT_EVENT_ID(a,b))
185#define LE_EVENT_ID(a,b) (!GT_EVENT_ID(a,b))
186#define COPY_EVENT_ID(from,to) \
187 memcpy((void*)to,(const void*)from,EVENT_ID_BYTES)
188#define ADD_EVENT_ID(a,b) ((a)[1]+=(b)[1],(a)[0]+=(b)[0])
189#define SUB_EVENT_ID(a,b) ((a)[1]-=(b)[1],(a)[0]-=(b)[0])
190#define ZERO_EVENT_ID(id) memset(id,0,EVENT_ID_BYTES)
191
192/* ---------- Trigger pattern (and relative masks) ---------- */
193#define EVENT_TRIGGER_PATTERN_BYTES 8
194#define EVENT_TRIGGER_PATTERN_WORDS ((EVENT_TRIGGER_PATTERN_BYTES)>>2)
195typedef unsigned long32 eventTriggerPatternType[EVENT_TRIGGER_PATTERN_WORDS];
07afbf5b 196#define EVENT_TRIGGER_ID_MIN 0
197#define EVENT_TRIGGER_ID_MAX 49
f3a800f8 198#define CHECK_TRIGGER(t) (assert(((t)>=EVENT_TRIGGER_ID_MIN) && \
199 ((t)<=EVENT_TRIGGER_ID_MAX)))
200#define TRIGGER_TO_BIT(t) (1<<((t)&0x1f))
201#define TRIGGER_TO_WORD(t) (CHECK_TRIGGER(t), (t)>>5)
07afbf5b 202#define ZERO_TRIGGER_PATTERN(p) ((p)[0]=0, (p)[1]=0)
f3a800f8 203#define SET_TRIGGER_IN_PATTERN(p,id) (p)[TRIGGER_TO_WORD(id)] |= \
204 TRIGGER_TO_BIT(id)
205#define CLEAR_TRIGGER_IN_PATTERN(p,id) (p)[TRIGGER_TO_WORD(id)] &= \
206 ~(TRIGGER_TO_BIT(id))
207#define FLIP_TRIGGER_IN_PATTERN(p,id) (p)[TRIGGER_TO_WORD(id)] ^= \
208 TRIGGER_TO_BIT(id)
209#define TEST_TRIGGER_IN_PATTERN(p,id) (((p)[TRIGGER_TO_WORD(id)] & \
210 TRIGGER_TO_BIT(id)) != 0)
07afbf5b 211#define TRIGGER_PATTERN_INVALID(p) (((p)[1] & 0x80000000) == 0)
212#define TRIGGER_PATTERN_VALID(p) (((p)[1] & 0x80000000) != 0)
213#define VALIDATE_TRIGGER_PATTERN(p) ((p)[1] |= 0x80000000)
214#define INVALIDATE_TRIGGER_PATTERN(p) ((p)[1] &= 0x7fffffff)
215#define COPY_TRIGGER_PATTERN(f,t) ((t)[0] = (f)[0], (t)[1]=(f)[1])
216#define TRIGGER_PATTERN_OK(p) (((p)[1] & 0x7fe00000) == 0)
f3a800f8 217
218/* ---------- Detectors cluster (and relative masks) ---------- */
219#define EVENT_DETECTOR_PATTERN_BYTES 4
220#define EVENT_DETECTOR_PATTERN_WORDS (EVENT_DETECTOR_PATTERN_BYTES>>2)
221typedef unsigned long32 eventDetectorPatternType[EVENT_DETECTOR_PATTERN_WORDS];
07afbf5b 222#define EVENT_DETECTOR_ID_MIN 0
223#define EVENT_DETECTOR_HW_ID_MAX 23
224#define EVENT_DETECTOR_ID_MAX 30
f3a800f8 225#define CHECK_DETECTOR(d) (assert(((d) >= EVENT_DETECTOR_ID_MIN) &&\
226 ((d) <= EVENT_DETECTOR_ID_MAX)))
227#define DETECTOR_TO_BIT(d) (CHECK_DETECTOR(d), 1<<(d))
228#define ZERO_DETECTOR_PATTERN(p) ((p)[0] = 0)
229#define SET_DETECTOR_IN_PATTERN(p,d) ((p)[0] |= DETECTOR_TO_BIT(d))
230#define CLEAR_DETECTOR_IN_PATTERN(p,d) ((p)[0] &= ~(DETECTOR_TO_BIT(d)))
231#define FLIP_DETECTOR_IN_PATTERN(p,d) ((p)[0] ^= DETECTOR_TO_BIT(d))
232#define TEST_DETECTOR_IN_PATTERN(p,d) (((p)[0] & DETECTOR_TO_BIT(d))!=0)
07afbf5b 233#define DETECTOR_PATTERN_INVALID(p) (((p)[0] & 0x80000000) == 0)
234#define DETECTOR_PATTERN_VALID(p) (((p)[0] & 0x80000000) != 0)
235#define VALIDATE_DETECTOR_PATTERN(p) ((p)[0] |= 0x80000000)
236#define INVALIDATE_DETECTOR_PATTERN(p) ((p)[0] &= 0x7fffffff)
f3a800f8 237#define COPY_DETECTOR_PATTERN(f,t) ((t)[0] = (f)[0])
07afbf5b 238#define DETECTOR_PATTERN_OK(p) (((p)[0] & 0x3f000000) == 0)
239#define EVENT_DETECTOR_ITS_SPD 0
240#define EVENT_DETECTOR_ITS_SDD 1
241#define EVENT_DETECTOR_ITS_SSD 2
242#define EVENT_DETECTOR_TPC 3
243#define EVENT_DETECTOR_TRD 4
244#define EVENT_DETECTOR_TOF 5
245#define EVENT_DETECTOR_HMPID 6
246#define EVENT_DETECTOR_PHOS 7
247#define EVENT_DETECTOR_CPV 8
248#define EVENT_DETECTOR_PMD 9
249#define EVENT_DETECTOR_MUON_TRK 10
250#define EVENT_DETECTOR_MOUN_TRG 11
251#define EVENT_DETECTOR_FMD 12
252#define EVENT_DETECTOR_T0 13
253#define EVENT_DETECTOR_V0 14
254#define EVENT_DETECTOR_ZDC 15
255#define EVENT_DETECTOR_ACORDE 16
256#define EVENT_DETECTOR_TRG 17
257#define EVENT_DETECTOR_EMCAL 18
258#define EVENT_DETECTOR_HLT 19
259#define EVENT_DETECTOR_DAQ_TEST 30
f3a800f8 260
261/* ---------- The sizes and positions of the typeAttribute field ---------- */
262#define ALL_ATTRIBUTE_WORDS 3
263#define ALL_ATTRIBUTE_BYTES (ALL_ATTRIBUTE_WORDS * 4)
264#define ALL_ATTRIBUTE_BITS (ALL_ATTRIBUTE_BYTES * 8)
265#define USER_ATTRIBUTE_WORDS 2
266#define USER_ATTRIBUTE_BYTES (USER_ATTRIBUTE_WORDS * 4)
267#define USER_ATTRIBUTE_BITS (USER_ATTRIBUTE_BYTES * 8)
268#define FIRST_USER_ATTRIBUTE 0
269#define LAST_USER_ATTRIBUTE (USER_ATTRIBUTE_BITS - 1)
270#define SYSTEM_ATTRIBUTE_WORDS 1
271#define SYSTEM_ATTRIBUTE_BYTES (SYSTEM_ATTRIBUTE_WORDS * 4)
272#define SYSTEM_ATTRIBUTE_BITS (SYSTEM_ATTRIBUTE_BYTES * 8)
273#define FIRST_SYSTEM_ATTRIBUTE USER_ATTRIBUTE_BITS
274#define LAST_SYSTEM_ATTRIBUTE (USER_ATTRIBUTE_BITS + \
275 SYSTEM_ATTRIBUTE_BITS - 1)
276typedef unsigned long32 eventTypeAttributeType[ALL_ATTRIBUTE_WORDS];
277
278 /* Word and bit definitions */
279#define SYS_ATTR_2_W(b) (assert(((b)>=64)&&((b)<=95)),2)
280#define USR_ATTR_2_W(b) (assert(((b)>= 0)&&((b)<=63)),(b)>>5)
281#define ATTR_2_W(b) (assert(((b)>= 0)&&((b)<=95)),(b)>>5)
282#define ATTR_2_B(b) (1<<((b)&0x1f))
283
284 /* Macros to handle all attributes without distinction */
285#define RESET_ATTRIBUTES(m) ((m)[2] = (m)[1] = (m)[0] = 0)
286#define SET_ANY_ATTRIBUTE(m,b) (m)[ATTR_2_W(b)] |= ATTR_2_B(b)
287#define CLEAR_ANY_ATTRIBUTE(m,b) (m)[ATTR_2_W(b)] &= ~(ATTR_2_B(b))
288#define FLIP_ANY_ATTRIBUTE(m,b) (m)[ATTR_2_W(b)] ^= ATTR_2_B(b)
289#define TEST_ANY_ATTRIBUTE(m,b) (((m)[ATTR_2_W(b)] & ATTR_2_B(b))!= 0)
290#define COPY_ALL_ATTRIBUTES( from, to ) \
291 memcpy((void *)&to[0], (const void *)&from[0], ALL_ATTRIBUTE_BYTES)
292#define OR_ALL_ATTRIBUTES( from, to ) \
293 ((to)[2] |= (from)[2], (to)[1] |= (from)[1], (to)[0] |= (from)[0])
294
295 /* Macros to handle SYSTEM attributes */
296#define RESET_SYSTEM_ATTRIBUTES(m) ((m)[2] = 0)
297#define SET_SYSTEM_ATTRIBUTE(m,b) (m)[SYS_ATTR_2_W(b)] |= ATTR_2_B(b)
298#define CLEAR_SYSTEM_ATTRIBUTE(m,b) (m)[SYS_ATTR_2_W(b)] &= ~(ATTR_2_B(b))
299#define FLIP_SYSTEM_ATTRIBUTE(m,b) (m)[SYS_ATTR_2_W(b)] ^= ATTR_2_B(b)
300#define TEST_SYSTEM_ATTRIBUTE(m,b) (((m)[SYS_ATTR_2_W(b)] & ATTR_2_B(b)) != 0)
301#define COPY_SYSTEM_ATTRIBUTES( from, to ) \
302 memcpy((void *)&to[2], (const void *)&from[2], SYSTEM_ATTRIBUTE_BYTES)
303#define OR_SYSTEM_ATTRIBUTES( from, to ) ((to)[2] |= (from)[2])
304
305 /* Macros to handle USER attributes */
306#define RESET_USER_ATTRIBUTES(m) ((m)[0] = (m)[1] = 0)
307#define SET_USER_ATTRIBUTE(m,b) (m)[USR_ATTR_2_W(b)] |= ATTR_2_B(b)
308#define CLEAR_USER_ATTRIBUTE(m,b) (m)[USR_ATTR_2_W(b)] &= ~(ATTR_2_B(b))
309#define FLIP_USER_ATTRIBUTE(m,b) (m)[USR_ATTR_2_W(b)] ^= ATTR_2_B(b)
310#define TEST_USER_ATTRIBUTE(m,b) (((m)[USR_ATTR_2_W(b)] & ATTR_2_B(b)) != 0)
311#define COPY_USER_ATTRIBUTES( from, to ) \
312 memcpy((void *)&to[0], (const void *)&from[0], USER_ATTRIBUTE_BYTES)
313#define OR_USER_ATTRIBUTES( from, to ) \
314 ((to)[1] |= (from)[1], (to)[0] |= (from)[0])
315
316 /* System attributes assignment */
317#define ATTR_P_START 64 /* Start of a phase */
318#define ATTR_P_END 65 /* End of a phase */
319#define ATTR_START_OF_RUN_START ATTR_P_START/* Start of SOR phase */
320#define ATTR_START_OF_RUN_END ATTR_P_END /* End of SOR phase */
321#define ATTR_END_OF_RUN_START ATTR_P_START/* Start of EOR phase */
322#define ATTR_END_OF_RUN_END ATTR_P_END /* End of SOR phase */
323#define ATTR_EVENT_SWAPPED 66 /* Swapped event header */
324#define ATTR_EVENT_PAGED 67 /* Paged event */
325#define ATTR_SUPER_EVENT 68 /* Super event */
326#define ATTR_ORBIT_BC 69 /* Orbit/bunch crossing in ID*/
327#define ATTR_KEEP_PAGES 70 /* Do not deallocate pages */
328#define ATTR_HLT_DECISION 71 /* Event contains HLT decis. */
07afbf5b 329#define ATTR_BY_DETECTOR_EVENT 72 /* Event created by "by det."*/
f3a800f8 330
331#define ATTR_EVENT_DATA_TRUNCATED 94 /* Truncated payload */
332#define ATTR_EVENT_ERROR 95 /* Invalid event content */
333
334#define SYSTEM_ATTRIBUTES_OK(m) \
335 ((((m)[2]) & ~(ATTR_2_B(ATTR_P_START) | \
336 ATTR_2_B(ATTR_P_END) | \
337 ATTR_2_B(ATTR_EVENT_SWAPPED) | \
338 ATTR_2_B(ATTR_EVENT_PAGED) | \
339 ATTR_2_B(ATTR_SUPER_EVENT) | \
340 ATTR_2_B(ATTR_ORBIT_BC) | \
341 ATTR_2_B(ATTR_KEEP_PAGES) | \
342 ATTR_2_B(ATTR_HLT_DECISION) | \
07afbf5b 343 ATTR_2_B(ATTR_BY_DETECTOR_EVENT) | \
f3a800f8 344 ATTR_2_B(ATTR_EVENT_DATA_TRUNCATED) | \
345 ATTR_2_B(ATTR_EVENT_ERROR))) == 0)
346
347/* ---------- LDC and GDC identifier ---------- */
348typedef unsigned long32 eventHostIdType;
349typedef eventHostIdType eventLdcIdType;
350typedef eventHostIdType eventGdcIdType;
351#define HOST_ID_MIN ((eventHostIdType)0) /* The minimum allowed ID */
352#define HOST_ID_MAX ((eventHostIdType)511) /* The maximum allowed ID */
353#define VOID_ID ((eventHostIdType)-1) /* Unloaded ID */
354
355/* ---------- timestamp ---------- */
356/* The following definition is in common for 32 and 64 bit machines.
357 In both architectures, the field must be loaded into a time_t
358 variable before being used. Failure to do so may cause undefined
359 results up to the early termination of the process.
360
361 The recommended procedure to use this field is the following:
362
363 #include <time.h>
364
365 time_t t;
366
367 t = eventHeaderStruct.eventTimestamp;
368 cTime( &t ); (or whatever else can be done with a time_t)
369
370 Please note that the available timestamp will wrap sometime
371 around Jan 18, 19:14:07, 2038...
372*/
373typedef unsigned long32 eventTimestampType;
374
375/* ---------- The event header structure (with + without data) ---------- */
376struct eventHeaderStruct {
377 eventSizeType eventSize;
378 eventMagicType eventMagic;
379 eventHeadSizeType eventHeadSize;
380 eventVersionType eventVersion;
381 eventTypeType eventType;
382 eventRunNbType eventRunNb;
383 eventIdType eventId;
384 eventTriggerPatternType eventTriggerPattern;
385 eventDetectorPatternType eventDetectorPattern;
386 eventTypeAttributeType eventTypeAttribute;
387 eventLdcIdType eventLdcId;
388 eventGdcIdType eventGdcId;
389 eventTimestampType eventTimestamp;
390};
391
392struct eventStruct {
393 struct eventHeaderStruct eventHeader;
394 unsigned short eventRawData[1];
395};
396
397/* ========== Definitions for the Vector ========== */
398typedef short eventVectorBankIdType;
399typedef unsigned int eventVectorSizeType;
400typedef unsigned int eventVectorOffsetType;
401
402struct eventVectorStruct {
403 eventVectorBankIdType eventVectorBankId;
404 unsigned eventVectorPointsToVector : 1;
405 eventVectorSizeType eventVectorSize;
406 eventVectorOffsetType eventVectorStartOffset;
407};
408
409/* ========== Definitions for the payload descriptor ========== */
410typedef unsigned long32 eventNumEquipmentsType;
411typedef struct eventVectorStruct eventExtensionVectorType;
412
413struct vectorPayloadDescriptorStruct {
414 eventNumEquipmentsType eventNumEquipments;
415 eventExtensionVectorType eventExtensionVector;
416};
417
418/* ========== Definitions for the equipment header ========== */
419typedef long32 equipmentSizeType;
420typedef long32 equipmentTypeType;
421typedef long32 equipmentIdType;
422typedef eventTypeAttributeType equipmentTypeAttributeType;
423typedef long32 equipmentBasicElementSizeType;
424
425struct equipmentHeaderStruct {
426 equipmentSizeType equipmentSize;
427 equipmentTypeType equipmentType;
428 equipmentIdType equipmentId;
429 equipmentTypeAttributeType equipmentTypeAttribute;
430 equipmentBasicElementSizeType equipmentBasicElementSize;
431};
432
433struct equipmentDescriptorStruct {
434 struct equipmentHeaderStruct equipmentHeader;
435 struct eventVectorStruct equipmentVector;
436};
437
438struct equipmentStruct {
439 struct equipmentHeaderStruct equipmentHeader;
440 unsigned short equipmentRawData[1];
441};
442
443/* ========== Definition of the event location for the simpleFifo ========== */
444struct eventLocationDescriptorStruct {
445 eventVectorBankIdType eventBankId;
446 eventVectorOffsetType eventOffset;
447};
448
449/* ========== Global macros ========== */
450
451/* The macro PAGED_EVENT_SIZE receives in input the ADDRESS of a paged
452 event and returns the size (in bytes) of the first page of the
453 event */
454#define PAGED_EVENT_SIZE( event ) \
455 (EVENT_HEAD_BASE_SIZE +sizeof( struct vectorPayloadDescriptorStruct ) + \
456 ((*(eventNumEquipmentsType *)((void*)event+EVENT_HEAD_BASE_SIZE))* \
457 (sizeof( struct equipmentDescriptorStruct ))))
458
459/* ========== Common data header ========== */
460#define CDH_SIZE (8 * 4)
07afbf5b 461#define CDH_VERSION 2
f3a800f8 462
463#define CDH_TRIGGER_OVERLAP_ERROR_BIT 0
464#define CDH_TRIGGER_MISSING_ERROR_BIT 1
465#define CDH_DATA_PARITY_ERROR_BIT 2
466#define CDH_CONTROL_PARITY_ERROR_BIT 3
467#define CDH_TRIGGER_INFORMATION_UNAVAILABLE_BIT 4
468#define CDH_FEE_ERROR_BIT 5
469#define CDH_HLT_DECISION_BIT 6
470#define CDH_HLT_PAYLOAD_BIT 7
07afbf5b 471#define CDH_DDG_PAYLOAD_BIT 8
472#define CDH_TRIGGER_L1_TIME_VIOLATION_ERROR_BIT 9
473#define CDH_TRIGGER_L2_TIME_VIOLATION_ERROR_BIT 10
474#define CDH_TRIGGER_PREPULSE_ERROR_BIT 11
475#define CDH_TRIGGER_ERROR_BIT 12
f3a800f8 476
477/* Please note how the above data structure has been
478 defined for LE systems. Code running on BE systems
479 must have all fields reverted to work correctly! */
480struct commonDataHeaderStruct {
481 unsigned cdhBlockLength : 32;
482 /* ------------------------------------- */
483 unsigned cdhEventId1 : 12;
07afbf5b 484 unsigned cdhMBZ1 : 2;
485 unsigned cdhL1TriggerMessage : 8;
f3a800f8 486 unsigned cdhMBZ0 : 2;
f3a800f8 487 unsigned cdhVersion : 8;
488 /* ------------------------------------- */
489 unsigned cdhEventId2 : 24;
07afbf5b 490 unsigned cdhMBZ2 : 8;
f3a800f8 491 /* ------------------------------------- */
492 unsigned cdhParticipatingSubDetectors : 24;
493 unsigned cdhBlockAttributes : 8;
494 /* ------------------------------------- */
495 unsigned cdhMiniEventId : 12;
496 unsigned cdhStatusErrorBits : 16;
07afbf5b 497 unsigned cdhMBZ3 : 4;
f3a800f8 498 /* ------------------------------------- */
499 unsigned cdhTriggerClassesLow : 32;
500 /* ------------------------------------- */
501 unsigned cdhTriggerClassesHigh : 18;
07afbf5b 502 unsigned cdhMBZ4 : 10;
f3a800f8 503 unsigned cdhRoiLow : 4;
504 /* ------------------------------------- */
505 unsigned cdhRoiHigh : 32;
506};
507
508#endif