1.	Data Format

An event in trigger consists of an event descriptor, a trigger summary and a block of raw data. 
There may or may not be additional raw data blocks for the pre and post histroy crossings.

Event Descriptor:

28 byte Event Descriptor Constructed in level 1 and containing all TCU  readout



2 bytes byte-count	 		Length of Event Descriptor including this header (28 B)

1 bytes header	 		"E" in ASCII for Event Descriptor

1 byte version number			allows up to 256 separate formats for trigger events

			this has 4 bits for major version and 4 bits for minor



4 bytes data			 MS 32 bits of 64-bit Bunch Crossing Number

4 bytes data			 LS 32 bits of 64-bit Bunch Crossing Number

2 bytes data		 	Token

2 bytes data		 	Action Word:	4 bits TRG Cmd

				4 bits DAQ Cmd

				8 bits Detector Bitmask

				this bit packing is compiler specific

				

2 bytes data		 Output from last DSM board, saved on TCU

2 bytes data	 	 Address of raw data for this crossing in DSM buffers

1 byte data		 Busy bits at start of this Bunch Crossing

1 byte data		 Priority and Pileup flags

2 bytes data		 Trigger Word

2 bytes data		 Number of pre-History raw data blocks - Npre

2 bytes data		 Number of post-History raw data blocks - Npost



Trigger Summary         

 Level 1 and level 2 results are here, along with the data from the DSMs in the TCU crate



2 bytes byte-count	 		Length of Trigger Summary, including this header (400 B)

2 bytes header	 		"TS" in ASCII for Trigger Summary

8 bytes data			L1Sum[2]
8 bytes data			L2Sum[2]

2 bytes byte-count	 		byte count for DSMs read out for L1 (l = 128 (8 DSMs))

2 bytes header		 	"L0" in ASCII



l44 bytes data			 Data from DSMs in TCU crate

	64 bytes		Coarse pixel array
	16 bytes		CTB+MWC 3rd level DSM Input Buffer
	16 bytes		Last DSM Input buffer
	16 bytes		ZDC DSM
	32 bytes		Bunch Crossing Counter DSMs


2 bytes byte-count	 		byte count for L1 results (m = 128)

2 bytes header		 	"L1" in ASCII



m bytes data			 L1 Results

			Note: first 4 bytes are used as L1 status for event filters



2 bytes byte-count			 byte count for L2 results (n = 128)

2 bytes header			 "L2" in ASCII



n bytes data			 L2 Results

			Note: first 4 bytes are for L2 status for event filters



NOTE: the first raw data block is always for the triggered crossing. The data for the Npre cross-
ings comes immediately after that, and the Npost data blocks come last



Raw Data Blocks:

These are the bytes read from the DSMs for each event.

 

2 byte byte-count:	 		Length of RAW data block including this header (416 B)

2 byte header:			 "RD"



2 byte byte-count:			 Length of CTB data block including this header

2 byte header:		 	"CT"



x bytes data			 Data from DSMs in CTB crate (x = 256)



2 byte byte-count:			 byte count for MWC and ZDC 

2 byte header:			 "MZ"



y bytes data			 Data from DSMs in MWC/ZDC crate (y = 128)



2 byte byte-count:			 byte count for EMC DSMs 

2 byte header:			 "EC"



------------ below here is just to give an idea



z bytes data			 Data from DSMs in EMC crates (z = 32)



----------------------------------------------------------------------

the RAW data block is repeated here npre and npost times.