Subversion Repositories f9daq

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
56 f9daq 1
#ifndef _EVENT_H_
2
#define _EVENT_H_
3
#ifdef COMMENT
4
/*--------------------------------------------------------------------------*
5
 *                                                                          *
6
 *              HERA-B  Online  Event  Format  Structures                   *
7
 *                                                                          *
8
 *                                                                          *
9
 *    Hera-B events are are formatted online as described in the memo:      *
10
 *    "Protocols & Data Formats in Hera-B" available on the DAQ-Notes       *
11
 *    WWW page. The format consisted of one or more nested data blocks      *
12
 *    as illustrated below. Each block contains a header, a data field      *
13
 *    and a trailer. The data field of many blocks (e.g. Event and SLB      *
14
 *    blocks) is composed of additional block of similar format. For        *
15
 *    example, the data portion of an SLB block consists of one or more     *
16
 *    FED blocks. This is illustrated in the following example, where       *
17
 *    EVTH/EVTT are the event header/trailer, SLBH/SLBT are the SLB         *
18
 *    block header/trailer and FEDH is the SLB sub-block.                   *
19
 *                                                                          *
20
 *       +---+---+---+-...-+---+-...-+---+---+-...-+---+---+                *
21
 *       | E | S | F |  d  | F |  d  | S | S |     | S | E |                *
22
 *       | V | L | E |  a  | E |  a  | L | L |     | L | V |                *
23
 *       | T | B | D |  t  | D |  t  | B | B |     | B | T |                *
24
 *       | H | H | H |  a  | H |  a  | T | H |     | T | T |                *
25
 *       +---+---+---+-...-+---+-...-+---+---+-...-+---+---+                *
26
 *                                                                          *
27
 *    Block alignment:                                                      *
28
 *    SLB and Event level blocks are aligned on a long word boundaries.     *
29
 *    If an SLB block has a length that is not a multiple of 4, the         *
30
 *    header length field will reflect this fact, but the following block   *
31
 *    will not start until the next 4-byte boundary. The FED sub-blocks     *
32
 *    within the SLB block also have long-word alignment. The length        *
33
 *    field of the FED sub-block does not include any additional padding    *
34
 *    to expand the field length. Padding bytes are undefined, but it is    *
35
 *    recommended that they be filled with zeroes.                          *
36
 *                                                                          *
37
 *--------------------------------------------------------------------------*/
38
#endif
39
 
40
#ifdef __cplusplus
41
extern "C" {
42
#endif
43
 
44
/*********************************
45
 *
46
 *    Record IDs -
47
 *
48
 *    Note: The definition of most record IDs are specific to the
49
 *          individual components i.e. the record type is uniquely
50
 *          identified by the combination of the component ID and
51
 *          the record ID. The record IDs are therefore left to the
52
 *          disgression of the detector groups. The IDs listed here
53
 *          are those used by the central DAQ, and several suggested
54
 *
55
 *********************************/
56
#define RID_MASK_ERROR      0x8000     /* Error in Record */
57
#define RID_NORMAL_EVENT    0x3000     /* Normal/error event envelope  */
58
#define RID_ERROR_EVENT     0xb000     /* - with error */
59
#define RID_NORMAL_SLB0     0x2000     /* Normal standard SLB    */
60
#define RID_ERROR_SLB0      0xa000     /* - with error */
61
#define RID_SPARSE_SLB0     0x2001     /* - with sparse data  */
62
#define RID_NORMAL_SLBDBG   0x2800     /* Addidtional SLB record for debugging */
63
#define RID_ERROR_SLBDBG    0xa800     /* - with error */
64
#define RID_SPARSE_SLBDBG   0x2801     /* - with sparse data */
65
#define RID_NORMAL_FEDRAW   0x1000     /* Normal/Error raw FED data    */
66
#define RID_ERROR_FEDRAW    0x9000     /*       (component dependent)  */
67
#define RID_NORMAL_DEFAULT_SPARSE   0x100A     /* Normal/Error sparsified data */
68
#define RID_NORMAL_SPARSE   0x1001     /* Normal/Error sparsified data */
69
#define RID_ERROR_SPARSE    0x9001     /*       (component dependent)  */
70
#define RID_NORMAL_FEDDBG   0x1800     /* Normal/Error raw FED data    */
71
#define RID_ERROR_FEDDBG    0x9800     /*       (component dependent)  */
72
#define RID_SPARSE_FEDDBG   0x1801     /* Normal/Error sparsified data */
73
#define RID_NORMAL_COOKED   0x1002     /* Normal/Error cooked FED data */
74
#define RID_ERROR_COOKED    0x9002     /*       (component dependent)  */
75
/****************
76
* Error Masks -
77
* Note: The mask will be non-zero on error
78
*       if the data given is in import format
79
*       This is basically a bit test for the first bit
80
*********************/
81
#define RID_ERROR_MASK(i) (((i)&0x8000)?(i):0)
82
#define RID_MASK_FEDRAW(i) RID_ERROR_MASK(i)
83
#define RID_MASK_EVENT(i)  RID_ERROR_MASK(i)
84
#define RID_MASK_SLB0(i)   RID_ERROR_MASK(i)
85
#define RID_MASK_SPARSE(i) RID_ERROR_MASK(i)
86
#define RID_MASK_COOKED(i) RID_ERROR_MASK(i)
87
/*********************************
88
 *
89
 *    Event record format format
90
 *
91
 *********************************/
92
struct EVENT_HDR {
93
  int length;             /* event length including header and trailer            */
94
  unsigned short recid;   /* event block ID (0x3000 - 0x3fff)                     */
95
  short format;           /* format identifier                                    */
96
  int   sltevt;           /* second level trigger number                          */
97
  int   compmask;         /* component mask (defined in component.h)              */
98
  int   evtmask;          /* event mask (trigger code, or etc.)                   */
99
};
100
 
101
typedef struct EVENT_HDR envelope;     /* for backwards compatibility */
102
typedef struct EVENT_HDR EVENT_HDR;
103
 
104
struct EVENT_TAIL {
105
  int sltevt;};           /* second level trigger number                 */
106
 
107
typedef struct EVENT_TAIL EVENT_TAIL;
108
 
109
#define RUNTYPE(ptr)  (((struct EVENT_HDR *) ptr)->evtmask >> 16)
110
#define RUNTYPEI(ptr) (import_i(((struct EVENT_HDR *) ptr)->evtmask) >> 16)
111
 
112
/*********************************
113
 *
114
 *    SLB data block format
115
 *
116
 *********************************/
117
 
118
struct SLB_HDR {
119
  int   length;           /* SLB block length including header and trailer */
120
  unsigned short recid;   /* SLB record ID (0x2000 - 0x2fff)               */
121
  short fltevt;           /* FLT event number                              */
122
  short compid;           /* component id (defined in component.h)         */
123
  short slbid;            /* identified of the SLB generating this block   */
124
  int   nodeid;};         /* destination node                              */
125
 
126
typedef struct SLB_HDR slbrec;        /* for backwards compatibility       */
127
typedef struct SLB_HDR SLB_HDR;
128
 
129
struct SLB_SUBHDR {
130
  short length;           /* FED block length including header and trailer */
131
  short fedid;            /* ID of FED producing this block                */
132
  unsigned short recid;   /* FED record ID (0x1000 - 0x1fff)               */
133
  short bxid;};           /* Bx number                                     */
134
 
135
typedef struct SLB_SUBHDR SLB_SUBHDR;
136
 
137
struct SLB_TAIL {
138
  unsigned short recid;   /* Record ID                                     */
139
  short fltevt;};         /* FLT event number                              */
140
 
141
typedef struct SLB_TAIL SLB_TAIL;
142
 
143
/*********************************
144
 *
145
 *    FED data block format
146
 *
147
 *    Note that the header and trailer described here are used only
148
 *    on the readout links. This bloxk must be padded to a 48-bit
149
 *    boundary to allow it to be transferred over the sharc link. The
150
 *    length field doesn't include the padding bytes.
151
 *
152
 *********************************/
153
struct FED_HDR {
154
  short length;           /* FED block length including header and trailer */
155
  unsigned short recid;   /* FED record ID (0x1000 - 0x1fff)               */
156
  short fltevt;           /* FLT event number                              */
157
  short bxid;             /* Bx number                                     */
158
  short compid;           /* component id (defined in component.h)         */
159
  short fedid;};          /* ID of FED producing this block                */
160
 
161
typedef struct FED_HDR FED_HDR;
162
 
163
struct FED_TAIL {
164
  short fltevt;};         /* FLT event number                              */
165
 
166
typedef struct FED_TAIL FED_TAIL;
167
 
168
/*********************************
169
 *
170
 *    Event data provided by the event builder.
171
 *    CompID: 0x0000, RecID: 0x2000
172
 *
173
 *********************************/
174
struct EVT_DATA {
175
  int run_number;               /* Run number                 */
176
  int event_time;               /* Time event was built       */
177
  int event_status;             /* event status/error code    */
178
  int flt_status;               /* FLT trigger number         */
179
  int slp_node;                 /* SLP processing node        */
180
  int slt_status;               /* SLT trigger number/status  */
181
  int exp_number;               /* Experiment Number          */
182
  int farm_node;                /* Farm node                  */
183
  int   BX_long;                /* bits 0 to 31 of the BX tag (at time trigger issued)  */
184
  short BX_upper;               /* bits 32 to 47 of the BX tag (at time trigger issued) */
185
  short FCS_tcode;              /* FCS trigger code for event                           */
186
  short physBX;                 /* physical BX == hera bucket ID of event               */
187
  short FLT_BX;                 /* pipeline cell triggered on by FLT for this event     */
188
  short fltevt;                 /* flt event number as delivered by FCS                 */
189
  short fill;
190
  int   dbKey;                  /* key to tables used to process event      */
191
  int   dbVersion;              /* version of key table used for this event */
192
};
193
typedef struct EVT_DATA EVT_DATA;
194
 
195
struct EVT_DATA_RECORD {
196
  SLB_HDR  hdr;
197
  EVT_DATA data;
198
  SLB_TAIL tail;};
199
 
200
typedef struct EVT_DATA_RECORD EVT_DATA_RECORD;
201
 
202
#ifdef __cplusplus
203
}
204
#endif
205
 
206
#endif