8 #include <rtsSystems.h>
11 #define TRG_VERSION 0x20
12 #include <daqFormats.h>
22 static unsigned char ctbMap[240] = {
23 7, 6, 5, 4, 3, 23, 22, 21, 20, 19,
24 2, 1, 0, 15, 14, 18, 17, 16, 31, 30,
25 13, 12, 11, 10, 9, 29, 28, 27, 26, 25,
26 39, 38, 37, 36, 35, 55, 54, 53, 52, 51,
27 34, 33, 32, 47, 46, 50, 49, 48, 63, 62,
28 45, 44, 43, 42, 41, 61, 60, 59, 58, 57,
29 71, 70, 69, 68, 67, 87, 86, 85, 84, 83,
30 66, 65, 64, 79, 78, 82, 81, 80, 95, 94,
31 77, 76, 75, 74, 73, 93, 92, 91, 90, 89,
32 103, 102, 101, 100, 99, 119, 118, 117, 116, 115,
33 98, 97, 96, 111, 110, 114, 113, 112, 127, 126,
34 109, 108, 107, 106, 105, 125, 124, 123, 122, 121,
35 135, 134, 133, 132, 131, 151, 150, 149, 148, 147,
36 130, 129, 128, 143, 142, 146, 145, 144, 159, 158,
37 141, 140, 139, 138, 137, 157, 156, 155, 154, 153,
38 167, 166, 165, 164, 163, 183, 182, 181, 180, 179,
39 162, 161, 160, 175, 174, 178, 177, 176, 191, 190,
40 173, 172, 171, 170, 169, 189, 188, 187, 186, 185,
41 199, 198, 197, 196, 195, 215, 214, 213, 212, 211,
42 194, 193, 192, 207, 206, 210, 209, 208, 223, 222,
43 205, 204, 203, 202, 201, 221, 220, 219, 218, 217,
44 231, 230, 229, 228, 227, 247, 246, 245, 244, 243,
45 226, 225, 224, 239, 238, 242, 241, 240, 255, 254,
46 237, 236, 235, 234, 233, 253, 252, 251, 250, 249,
50 static unsigned char mwcMap[96] = {
51 71, 70, 69, 68, 67, 66, 65, 64, 79, 78, 77, 76,
52 95, 94, 93, 92, 87, 86, 85, 84, 83, 82, 81, 80,
53 99, 98, 97, 96, 111, 110, 109, 108, 103, 102, 101, 100,
54 119, 118, 117, 116, 115, 114, 113, 112, 127, 126, 125, 124,
55 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12,
56 31, 30, 29, 28, 23, 22, 21, 20, 19, 18, 17, 16,
57 35, 34, 33, 32, 47, 46, 45, 44, 39, 38, 37, 36,
58 55, 54, 53, 52, 51, 50, 49, 48, 63, 62, 61, 60,
65 int trgReader20(
char *arg,
struct trg_t *trg)
68 int sdes, ssum, sraw ;
71 struct TRGD *trgd = (
struct TRGD *)arg ;
74 if(trgd->bh.byte_order != DAQ_RAW_FORMAT_ORDER) swap=1;
76 len = swap ? swap32(trgd->bh.length)*4 : trgd->bh.length;
78 sdes =
sizeof(trgd->bh) +
sizeof(trgd->desc) ;
79 ssum = sdes +
sizeof(trgd->sum) ;
80 sraw = ssum +
sizeof(trgd->raw[0]) ;
83 LOG(NOTE,
"No TRG Summaries, or Raw...",0,0,0,0,0) ;
87 LOG(NOTE,
"TRG: Summaries ONLY!",0,0,0,0,0) ;
91 LOG(DBG,
"len %d, desc len %d, sum len %d, raw trg 0 len %d, all raw len %d",
92 len,
sizeof(trgd->desc),
sizeof(trgd->sum),
sizeof(trgd->raw[0]),
sizeof(trgd->raw)) ;
94 LOG(DBG,
"evt desc bytes %d, sum bytes %d, raw bytes %d",trgd->desc.TCUdataBytes,
95 trgd->sum.TrgSumBytes,trgd->raw[0].RawDetBytes,0,0) ;
99 pre = swap ? swap16(trgd->desc.npre) : trgd->desc.npre ;
100 post = swap ? swap16(trgd->desc.npost) : trgd->desc.npost ;
102 int trg_length = len -
sizeof(
struct bankHeader) - 40 ;
103 int exp_length =
sizeof(
EvtDescData) +
sizeof(trgd->sum) +
sizeof(trgd->raw[0]) +
104 sizeof(trgd->raw[0])*pre +
sizeof(trgd->raw[0])*post ;
106 if(trg_length != exp_length) {
107 LOG(NOTE,
"Trigger data: is %d, expect %d bytes, pre %d, post %d",
108 trg_length, exp_length,pre,post,0) ;
111 LOG(DBG,
"Trigger data: is %d, expect %d bytes, pre %d, post %d",
112 trg_length, exp_length,pre,post,0) ;
116 trg->tcubits = swap ? swap16(trgd->desc.DSMInput) : trgd->desc.DSMInput;
117 trg->detlive = swap ? swap16(trgd->desc.externalBusy) : trgd->desc.externalBusy ;
120 LOG(DBG,
"TrgDataFmtVer 0x%X, 0x%04X %c %c", trgd->desc.TrgDataFmtVer,
121 trgd->sum.TrgSumHeader,
122 trgd->raw[0].CTBdataHeader[0],
123 trgd->raw[0].CTBdataHeader[1],0) ;
124 LOG(DBG,
"TrgSumBytes %d, 0x%04X %c %c %c", trgd->sum.TrgSumBytes,
125 trgd->sum.L0SumHeader,
126 trgd->raw[0].RawDetHeader[0],
127 trgd->raw[0].RawDetHeader[1],0) ;
130 trg->CTB[i] = trgd->raw[0].CTB[ctbMap[i]] ;
134 trg->MWC[i] = trgd->raw[0].MWC[mwcMap[i]] ;
139 trg->BEMC[0][i] = trgd->raw[0].BEMCEast[i] ;
143 trg->BEMC[1][i] = trgd->raw[0].BEMCWest[i] ;
147 trg->BEMC_l1[i] = swap ? swap16(trgd->raw[0].BEMClayer1[i]) : trgd->raw[0].BEMClayer1[i] ;
153 trg->EEMC[i] = trgd->raw[0].EEMC[i] ;
156 trg->EEMC_l1[i] = swap ? swap16(trgd->raw[0].EEMClayer1[i]) : trgd->raw[0].EEMClayer1[i];
164 trg->FPD[0][0][i] = trgd->raw[0].FPDEastNSLayer0[i] ;
167 trg->FPD_l1[0][0][i] = swap ? swap16(trgd->raw[0].FPDEastNSLayer1[i]) : trgd->raw[0].FPDEastNSLayer1[i] ;
171 trg->FPD[0][1][i] = trgd->raw[0].FPDEastTBLayer0[i] ;
174 trg->FPD_l1[0][1][i] = swap ? swap16(trgd->raw[0].FPDEastTBLayer1[i]) : trgd->raw[0].FPDEastTBLayer1[i] ;
178 trg->FPD[1][0][i] = trgd->raw[0].FPDWestNSLayer0[i] ;
181 trg->FPD_l1[1][0][i] = swap ? swap16(trgd->raw[0].FPDWestNSLayer1[i]) : trgd->raw[0].FPDWestNSLayer1[i];
185 trg->FPD[1][1][i] = trgd->raw[0].FPDWestTBLayer0[i] ;
188 trg->FPD_l1[1][1][i] = swap ? swap16(trgd->raw[0].FPDWestTBLayer1[i]) : trgd->raw[0].FPDWestTBLayer1[i];
195 trg->BBC[i] = trgd->raw[0].BBC[i] ;
198 trg->BBC_l1[i] = swap ? swap16(trgd->raw[0].BBClayer1[i]) : trgd->raw[0].BBClayer1[i] ;
203 trg->ZDC[i] = trgd->raw[0].ZDC[i] ;
206 trg->ZDC_l1[i] = swap ? swap16(trgd->raw[0].ZDClayer1[i]) : trgd->raw[0].ZDClayer1[i];
209 trg->trg_sum = NULL ;