StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
trgStructures_32.h
1 /* Header Number: x.y
2 * Package Name: All
3 * Created: z. milosevich 06Dec99
4 * Description: Global trigger structure header file.
5 * Contains definitions of trigger data structures
6 * History:
7 *
8 * 06Dec99 zm Created so offline can use and after modification for mod 8 DMA reads
9 * 08Dec99 zm Changed Event Descriptor Structure to previous length
10 * 03Feb00 zm Changed "ushort ZDCDSM[8]" to "BYTE ZDC[16]" in L0_DSM_Data structure
11 * 22Jul00 egj Added L0RegBytes and L0RegHeader to trgDataHeaders and TrgSumData.
12 * Also added Mult_Reg, ZDC_Reg and Spare_Reg to TrgSumData, making a
13 * total of 16 extra bytes. I compensated for this by removing 16 bytes,
14 * (4 uints) from L2Result, wich is currently unused.
15 * 08Dec00 JMN Changed char hdr[2] in TrgSummary to unsigned short, which is packed
16 * 25Feb01 JMN Redesigned and expanded abbreviations to full.
17 * 12Mar01 JMN Added additional changes from ZM
18 * 30May01 JMN NBNBNBNB Changed FORMAT version from 0x12 to 0x13
19 * 02Jun01 zm defined bit 6 in addBits info FIFO3 for L2.5 abort
20 * 27Jun01 JMN Added definition of number of bytes used in trigger summary headers
21 * 28Jun01 JMN Added definition of ADD_BITs
22 * 10Apr02 zm basic strawman for new structures with new TCU and added detectors
23 * 22May02 zm removed references to current non-existent trigger event header
24 * 24May02 zm incorporated eleanor's comments
25 * 24May02 zm the L0_DSM_Data instance changed from DSM to DSMdata to be able to compile on linux
26 * 19Jun02 zm removed or commented out references to TrgEvtHeader
27 * 05Aug02 JMN changes in event descriptor - moved filler word to end
28 * 15Aug02 HjC correct bytes for FPD
29 * 21Nov02 zm corrections based on eleanor's email: L0 layout for bunch xing,
30 * special and fpd elements; fpd broken down for east/west nort/south
31 * vs top/bottom and layer 1 or 0;
32 * also finished XXX_DATA_OFFSET and RAW_XXX_LEN for passing data from
33 * dsm
34 * 30Aug03 JMN Added RAW_MAX_LEN being maximum length possible in chain block transfer
35 * 14Sep03 JMN Added new dsmMemcpy2Buf
36 * 02Nov03 JMN Modified dsmMemcpy2Buf to ensure dsmData is 8-byte aligned.
37 * 04Nov03 EGJ Modified RawTrgDet to add in ZDCSMD[32]
38 * 28Oct04 JMN Modified RawTrgDet to increased BBC storage from 80 to 96
39 * Format version changed from 0x21 to 0x22
40 * 14Nov05 JMN Added source NodeID as first word of data buffer to L2
41 * 16Mar06 CWP Added offsets into L2Result
42 * 20Dec06 JMN Added changes: L2Result increased to 64 ints,
43 * MWC name changed to MIX with 7 DSMs from MTD, VPD and TOF (112 bytes)
44 * FPE changed to 9 DSMs (144 bytes)
45 * FPW changed to 16 DSMs (256) bytes
46 * new array QQT installed after BBC
47 * Block of commented OFFSETs and LEN removed.
48 * Commented out xx_SUM_LEN where xx is L0, L1, L2; and L0_REG_LEN. Unused?
49 * Since these are significant changes, Format changed to 3.0
50 * 05Jan07 JMN Changed CPA[32] to MTD[8],VPD[8],CPA[16]
51 * 29Mar07 JMN Updated L2_Results offsets for CP
52 * 03Apr07 JMN Order MTD,VPD,CPA is changed to CPA,MTD,VPD to reflect order of DSMs in the L1 crate
53 * 07Oct07 JMN Added new TrgTowerTrnfer structure to define combined trigger and EMC data that will
54 * be transmitted from L2 to DAQ in from November 2007.
55 * 24Oct07 JMN Version number changed from 3.1 to 3.2 following re-arrangement of DSMs in MIX and
56 * BBC crates. Two extra DSMs for PP2PP are in the MIX crate ahead of TOF, so total
57 * length increases by 32 bytes.
58 * 25Oct07 JMN A new set of L2_RESULTS offsets have been defined by Jan Balewski
59 * 27Oct07 JMN Added BTOW_LEN and ETOW_LEN
60 * 29Oct07 JMN Corrected above - removed 4 bytes for CRC not sent.
61 * 30Oct07 JMN Now added 4 byte hole to BTOW and ETOW lengths
62 * 13Nov07 JMN DAQ Headers no longer in EMC data - change definition of BTOW_LEN and ETOW_LEN
63 * Pre/post data will not be sent to DAQ - change definition of TRG_TOWER_LEN
64 */
65 
66 #ifndef trgStructures_h
67 #define trgStructures_h
68 
69 #define MAX_OFFSET 25 /* Maximum number of offsets in TrgTowerTrnfer OffsetBlock */
70 #define MAX_L0_DATA_BLOCKS 11 /* Maximum number of L0 Data Blocks: current + npre + npost */
71 #define MAX_RAW_DATA_BLOCKS 11 /* Maximum number of Raw Data Blocks: current + npre + npost */
72 #define FORMAT_VERSION 0x32 /* Format Version number for trigger data */
73 #define TRANSFER_VERSION 0x10 /* Format Version number for definition of TrgTowerTrnfer structure */
74 #define EV_DESC_LEN sizeof(EvtDescData) /* Number of bytes in event descriptor */
75 #define L0DSM_DATA_LEN sizeof(L0_DSM_Data) /* Size of data block in L0 DSM Tree */
76 #define RAW_DET_DATA_LEN sizeof(RawTrgDet) /* Size of Raw Detector Data from DSM clients and QT boards */
77 #define TRG_SUM_LEN sizeof(TrgSumData) /* Number of bytes in the trigger summary for DAQ with headers */
78 #define BTOW_LEN ((64 + 2 + 30*164)*2) /* BTOW header + 4 byte hole + data */
79 #define ETOW_LEN ((64 + 2 + 6*164)*2) /* ETOW header + 4 byte hole + data */
80 #define L1_DATA_LEN (EV_DESC_LEN+TRG_SUM_LEN) /* Size of data passed from L1ANA to L2 */
81 #define TRG_EVT_LEN (L1_DATA_LEN+(MAX_RAW_DATA_BLOCKS*RAW_DET_DATA_LEN)) /* Max size of a trigger event */
82 #define TRG_TOWER_LEN (4 + (MAX_OFFSET*8) + L1_DATA_LEN + RAW_DET_DATA_LEN + BTOW_LEN + ETOW_LEN) /* Max size of Trg/DAQ transfer data */
83 
84 #define RAW_MAX_LEN 272 /* Maximum length of any Chain Block Transfer */
85 
86 #define TRG_INDEX 0 /* Offset/length of trigger data: TrgDataType */
87 #define BTOW_INDEX 1 /* Offset/length of BTOW data: */
88 #define ETOW_INDEX 2 /* Offset/length of ETOW data: */
89 #define RAW_TRG_INDEX 3 /* Block of 11 contiguous offsets to rawTriggerDet[] */
90 
91 #define L2RESULTS_2008_OFFSET_TRG 0
92 #define L2RESULTS_2008_OFFSET_EMC_CHECK 1
93 #define L2RESULTS_2008_OFFSET_JPSI 2
94 #define L2RESULTS_2008_OFFSET_UPS 8
95 #define L2RESULTS_2008_OFFSET_EMC_PED 14
96 #define L2RESULTS_2008_OFFSET_GAMMA 20
97 #define L2RESULTS_2008_OFFSET_DIJET 32
98 //#define L2RESULTS_2007_OFFSET_TRG 0
99 //#define L2RESULTS_2007_OFFSET_EMC_PED 1
100 //#define L2RESULTS_2007_OFFSET_PIG 2
101 //#define L2RESULTS_2007_OFFSET_UPS 6
102 //#define L2RESULTS_2007_OFFSET_DISPVER 14
103 //#define L2RESULTS_OFFSET_TRG 0
104 //#define L2RESULTS_OFFSET_EMC_CHECK 1
105 //#define L2RESULTS_OFFSET_JPSI 2
106 //#define L2RESULTS_OFFSET_UPS 8
107 //#define L2RESULTS_OFFSET_DIJET 14
108 //#define L2RESULTS_OFFSET_EMC_PED 19
109 //#define L2RESULTS_OFFSET_PIG 20
110 #define ADD_BIT_PILEUP 0 /* Contamination/Pileup bit in event descriptor add-bits */
111 #define ADD_BIT_FORCE 5 /* Force store of this event */
112 #define ADD_BIT_L2_5 6 /* Level 2.5 abort */
113 #define ADD_BIT_SIM 7 /* Simulated event - used by DAQ */
114 
115 /********** Trigger Structures ***********/
116 
117 /* Event Descriptor Data Structures */
118 
119 typedef struct {
120 unsigned short TCUdataBytes;
121 char TCUEvtDesc;
122 unsigned char TrgDataFmtVer;
123 unsigned int bunchXing_hi;
124 unsigned int bunchXing_lo; /* Two parts of RHIC bunch crossing number */
125 unsigned short actionWdDetectorBitMask; /* from Fifo 1 */
126 unsigned char actionWdTrgCommand; /* from Fifo 1 */
127 unsigned char actionWdDaqCommand; /* from Fifo 1 */
128 unsigned short TrgToken; /* from Fifo 2 */
129 unsigned short addBits; /* from Fifo 2 - bit 0=Contamination; bit 6=L2.5 abort; bit 7=1 is fake data */
130 unsigned short DSMInput; /* from Fifo 3 */
131 unsigned short externalBusy; /* from Fifo 3 */
132 unsigned short modifiedBusyStatus; /* from Fifo 4 */
133 unsigned short physicsWord; /* from Fifo 4 */
134 unsigned short TriggerWord; /* from Fifo 5 */
135 unsigned short DSMAddress; /* from Fifo 6 */
136 unsigned short contaminationBusyStatus; /* from Fifo 6 */
137 unsigned short npre; /* pre value for detector raw data */
138 unsigned short npost; /* post value for detector raw data */
139 unsigned short dummy; /* dummy - filler */
140 } EvtDescData; /* 40 bytes total */
141 
142 /* Trigger Summary Data Structures */
143 
144 /* L0 DSM data structures */
145 
146 typedef struct {
147 unsigned short CPA[16]; /* Contents of 2 CTB DSM Input Buffers (IB's) - coarse pixel array */
148 unsigned short MTD[8]; /* TAC values for MTD's MRPCs and overlapping CTB trays */
149 unsigned short VPD[8]; /* ADC & TAC values for VPD detectors*/
150 unsigned short CTB[8]; /* CTB ADC sums and topology for East & West combined */
151 unsigned short lastDSM[8]; /* Contents of last DSM IB - results of all DSM trees */
152 unsigned short VTX[8]; /* Separate ZDC and BBC DSMs have been replaced with this one */
153 unsigned short EMC[8]; /* Contents of 1 EMC IB - results of separate BEMC and EEMC DSMs */
154 unsigned short BCdata[16]; /* Contents of 2 Bunch Crossing DSMs IB's */
155 unsigned short specialTriggers[8]; /* Contents of 1 Special Trigger DSM - all the special trigger requests */
156 unsigned short FPD[8]; /* Contents of 1 FPD IB - we are installing this DSM this year but it */
157 } L0_DSM_Data; /* 192 bytes total */
158 
159 
160 /* Summary data */
161 
162 typedef struct {
163 unsigned short TrgSumBytes;
164 unsigned short TrgSumHeader;
165 unsigned int L1Sum[2]; /* L1 Summary */
166 unsigned int L2Sum[2]; /* L2 Summary */
167 unsigned short L0SumBytes;
168 unsigned short L0SumHeader;
169 L0_DSM_Data DSMdata; /* L0 DSM Data from DSM Tree */
170 unsigned short L1SumBytes;
171 unsigned short L1SumHeader;
172 unsigned int L1Result[32]; /* Result from L1 CPU */
173 unsigned short L2SumBytes;
174 unsigned short L2SumHeader;
175 unsigned int L2Result[64]; /* Result from L2 CPU. Increased by 128 bytes from version 3.0 */
176 } TrgSumData; /* 608 bytes total */
177 
178 /* Data structure passed between L1ANA and L2 */
179 
180 typedef struct {
181 EvtDescData EvtDesc; /* L1 Event Descriptor Data */
182 TrgSumData TrgSum; /* Summary data */
183 } L1dataType; /* 648 bytes */
184 
185 /* Raw Trigger Detector data structures */
186 
187 typedef struct {
188 unsigned short RawDetBytes;
189 char RawDetHeader[2];
190 unsigned short CTBdataBytes;
191 char CTBdataHeader[2];
192 unsigned char CTB[256]; /* CTB raw data. Data address must be 8-byte aligned for DMA transfer */
193 unsigned short MIXdataBytes;
194 char MIXdataHeader[2];
195 unsigned int MIXfiller; /* Dummy to bring data address to mod 8 */
196 unsigned char MTD[32]; /* MTD raw data from 2 DSMs */
197 unsigned char VPD[64]; /* VPD raw data from 4 DSMs */
198 unsigned char P2P[32]; /* P2P raw data from 2 DSMs */
199 unsigned char TOF[16]; /* TOF raw data from 1 DSM */
200 unsigned short BEMCdataBytes;
201 char BEMCdataHeader[2];
202 unsigned int BEMCfiller; /* Dummy to bring data address to mod 8 */
203 unsigned char BEMCEast[240]; /* next year there will be 15 DSMs covering the East half, all in one crate */
204 unsigned char BEMCWest[240]; /* this year there will be 15 DSMs covering the West half, all in one crate */
205 unsigned short BEMClayer1[48]; /* there will be 6 DSMs at layer1 even if only 3 of them have input this year*/
206 unsigned short EEMCdataBytes;
207 char EEMCdataHeader[2];
208 unsigned int EEMCfiller; /* Dummy to bring data address to mod 8 */
209 unsigned short EEMClayer1[16]; /* the two layer1 DSMs are at the LHS of the crate so they get read first */
210 unsigned char EEMC[144]; /* next there are the 9 layer0 DSMs, of which only 4-5 have input this year */
211 unsigned short FPDdataBytes;
212 char FPDdataHeader[2];
213 unsigned int FPDfiller; /* Dummy to bring data address to mod 8 */
214 unsigned char FPDEastNSLayer0[112]; /* fpd east north/south layer 0 */
215 unsigned short FPDEastNSLayer1[8]; /* fpd east north/south layer 1 */
216 unsigned char FPDEastTBLayer0[16]; /* fpd east top/bottom layer 0 */
217 unsigned char FPDW[256]; /* fpd west */
218 unsigned short BBCdataBytes;
219 char BBCdataHeader[2];
220 unsigned int BBCfiller; /* Dummy to bring data address to mod 8 */
221 unsigned char BBC[96]; /* increased from 80 to 96 for the addition of a DSM after layer 0 DSMs */
222 unsigned short BBClayer1[16]; /* this is the layer1 DSM that feeds the VTX DSM */
223 unsigned char ZDC[16]; /* this is the original ZDC DSM */
224 unsigned short ZDClayer1[8]; /* this is the new layer1 ZDC DSM that also feeds the VTX DSM */
225 unsigned char ZDCSMD[32]; /* this is the 2 layer0 DSM for the ZDC SMD detector */
226 unsigned short QQTdataBytes; /* this is new in version 3.0 for data from QT boards */
227 char QQTdataHeader[2];
228 unsigned int QQTfiller; /* Dummy to bring data address to mod 8 */
229 unsigned int QQTdata[1600]; /* data block for FMS. New in version 3.0 */
230 } RawTrgDet; /* 8200 bytes total */
231 
232 /* Trigger Event Structure */
233 
234 typedef struct {
235 EvtDescData EvtDesc; /* L1 Event Descriptor Data : 40 bytes */
236 TrgSumData TrgSum; /* Summary data: 608 bytes */
237 RawTrgDet rawTriggerDet[MAX_RAW_DATA_BLOCKS]; /* Raw Detector Data with pre and post History: 11*8200 bytes */
238 } TrgDataType; /* 90848 bytes */
239 
240 /* Combined Trigger and EMC data block transferred from L2 to DAQ */
241 
242 typedef struct {
243 int offset; /* Offset (in bytes) from the start of TrgTowerTrnfer to data */
244 int length; /* Length (in bytes) of data */
245 } TrgOfflen;
246 
247 typedef struct {
248 int byteCount_Version; /* Transfer count in MS 24 bits; Version in LS 8 bits */
249  TrgOfflen OffsetBlock[MAX_OFFSET]; /* Offset/length into transferData */
250  int transferData[1]; /* Place holder array for trigger, BTOW and ETOW */
251 } TrgTowerTrnfer; /* Maximum possible length 103124 bytes */
252 
253 /* Data block for DSMs and L1 to pass to L2 via myriMemcpy2 */
254 
255 typedef struct {
256  int src_nodeId; /* Source nodeId */
257  int cur_token;
258  int Npre,Npost;
259  unsigned int localClock; /* Local DSM clock */
260  int numGroup; /* Number of DSMs in first group */
261  int numDSM; /* Total number of DSMs */
262  int dummy; /* Ensure alignment of long long */
263  long long dsmData[RAW_MAX_LEN*MAX_RAW_DATA_BLOCKS/8]; /* Make this 8-byte aligned */
264 } dsmMemcpy2Buf;
265 
266 #endif