]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSevent.h
bug in increment corrected
[u/mrichter/AliRoot.git] / PHOS / AliPHOSevent.h
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  *
32  ***************************************************************************/
33 /* modified for root convention */
34
35
36 #ifndef __event_h__
37 #define __event_h__
38
39 /* Unique version identifier */
40 #define EVENT_H_ID 0x00020018
41
42 /* Possible Values for type in eventHeaderStruct */
43
44    /* Mask to separate the event type from the event flags */
45 #define EVENT_TYPE_MASK      ((UInt_t)0x0000FFFF)
46 #define EVENT_FLAGS_MASK     ((UInt_t)~EVENT_TYPE_MASK)
47
48    /* Event error flags: */
49 #define EVENT_ERROR          ((UInt_t)0x80000000)
50 #define EVENT_DATA_TRUNCATED ((UInt_t)0x40000000)
51
52    /* Event flags: */
53 #define EVENT_EQUIPMENT      ((UInt_t)0x00010000)
54 #define EVENT_SWAPPED        ((UInt_t)0x00020000)
55
56    /* Event types: */
57 #define START_OF_RUN         ((UInt_t)1)
58 #define END_OF_RUN           ((UInt_t)2)
59 #define START_OF_RUN_FILES   ((UInt_t)3)
60 #define END_OF_RUN_FILES     ((UInt_t)4)
61 #define START_OF_BURST       ((UInt_t)5)
62 #define END_OF_BURST         ((UInt_t)6)
63 #define PHYSICS_EVENT        ((UInt_t)7)
64 #define CALIBRATION_EVENT    ((UInt_t)8)
65 #define END_OF_LINK          ((UInt_t)9)
66 #define EVENT_FORMAT_ERROR   ((UInt_t)10)
67
68 #define EVENT_TYPE_MIN       1
69 #define EVENT_TYPE_MAX       10
70
71    /* System attributes */
72 #define START_OF_RUN_START   0
73 #define START_OF_RUN_END     1
74 #define END_OF_RUN_START     0
75 #define END_OF_RUN_END       1
76 #define NO_EVENT_BUILDING    2
77
78 /* The following enumeration can be used once the EVENT_TYPE_MASK has been
79  * applied to the raw event type */
80 enum eventType {
81   startOfRun =       START_OF_RUN,
82   endOfRun =         END_OF_RUN,
83   startOfRunFiles =  START_OF_RUN_FILES,
84   endOfRunFiles =    END_OF_RUN_FILES,
85   startOfBurst =     START_OF_BURST,
86   endOfBurst =       END_OF_BURST,
87   physicsEvent =     PHYSICS_EVENT,
88   calibrationEvent = CALIBRATION_EVENT,
89   endOfLink =        END_OF_LINK,
90   formatError =      EVENT_FORMAT_ERROR
91 };
92
93 #define EVENT_MAGIC_NUMBER         ((UInt_t)0xDA1E5AFE)
94 #define EVENT_MAGIC_NUMBER_SWAPPED ((UInt_t)0xFE5A1EDA)
95
96 #define HEADER_LENGTH        sizeof( struct eventHeaderStruct )
97
98 /* Maximum size for any event (excluding the header) */
99 #define EVENT_DATA_MAX_SIZE  ( 100 * 1024 )
100
101 /* Maximum size for any event (including the header) */
102 #define EVENT_MAX_SIZE       ( HEADER_LENGTH + EVENT_DATA_MAX_SIZE )
103
104 /* The detectorId mask */
105 typedef UInt_t detectorIdType;
106 #define MAX_DETECTOR         ((int)94)
107 #define SUPER_EVENT_MASK     ((int)(1 << 31))
108 #define SUPER_EVENT_BIT      ((int)(MAX_DETECTOR+1))
109 #define MASK_LENGTH          ((int)(MAX_DETECTOR/32)+1)
110
111 /* The typeAttribute mask */
112 #define ATTRIBUTE_WORDS 2
113 #define ATTRIBUTE_BYTES ( ATTRIBUTE_WORDS * 4 )
114 #define ATTRIBUTE_BITS  ( ATTRIBUTE_BYTES * 8 )
115 #define ATTRIBUTE_TO_NUM( bit ) (((bit)&0x20)>>5)
116 #define ATTRIBUTE_TO_BIT( bit ) (1<<((bit)&0x1f))
117 #define SET_ATTRIBUTE( mask, bit ) \
118   (mask)[ ATTRIBUTE_TO_NUM(bit) ] |= ATTRIBUTE_TO_BIT( bit )
119 #define CLEAR_ATTRIBUTE( mask, bit ) \
120   (mask)[ ATTRIBUTE_TO_NUM(bit) ] &= ~(ATTRIBUTE_TO_BIT( bit ))
121 #define TEST_ATTRIBUTE( mask, bit ) \
122   (((mask)[ ATTRIBUTE_TO_NUM(bit) ] & ATTRIBUTE_TO_BIT( bit )) != 0 )
123
124 struct eventHeaderStruct { 
125   Int_t eventSize;          /* size of event in Bytes  */
126   UInt_t eventMagic;         /* magic number used for consistency check */
127   UInt_t eventType;          /* event type */
128   UInt_t eventHeadSize;       /* size of header in bytes */
129   UInt_t eventRunNb;         /* run number */
130   UInt_t burstNb;       /* burst number */
131   UInt_t nbInRun;       /* event number in run */
132   UInt_t nbInBurst;     /* event number in burst */
133   UInt_t triggerNb;     /* trigger number for this detector */
134   UInt_t fileSeqNb;     /* file sequence number for multifiles run */
135   detectorIdType  detectorId[MASK_LENGTH]; /* detector identification */
136   UInt_t time;          /* time in seconds since 0.00 GMT 1.1.1970 */
137   UInt_t usec;          /* microseconds */
138   UInt_t errorCode;
139   UInt_t deadTime;
140   UInt_t deadTimeusec;
141   UInt_t eventTypeAttribute[ATTRIBUTE_WORDS]; /* event type id mask */
142 };
143
144 struct eventStruct {
145     struct eventHeaderStruct eventHeader;
146     unsigned short rawData[1];
147 };
148 #endif