4 #define PREPOST 11 // This is also defined in TRG_Reader.cxx.
7 #include "trgStructures2004.h"
8 #include "TRG_Reader.hh"
17 using namespace OLDEVP;
19 int Bank_TRGD::HerbSwap2004(
char *ptr) {
20 int numToSwap,returnValue,i;
24 assert(header.ByteOrder==0x01020304||header.ByteOrder==0x04030201);
25 if(header.ByteOrder==0x04030201)
return 0;
26 returnValue=header.swap();
27 assert(header.ByteOrder==0x04030201);
29 swapHerb2bytes(&(gs2004->EvtDesc.TCUdataBytes),1);
30 swapHerb4bytes(&(gs2004->EvtDesc.bunchXing_hi),1);
31 swapHerb4bytes(&(gs2004->EvtDesc.bunchXing_lo),1);
32 swapHerb2bytes(&(gs2004->EvtDesc.actionWdDetectorBitMask),1);
33 swapHerb2bytes(&(gs2004->EvtDesc.TrgToken),1);
34 swapHerb2bytes(&(gs2004->EvtDesc.addBits),1);
35 swapHerb2bytes(&(gs2004->EvtDesc.DSMInput),1);
36 swapHerb2bytes(&(gs2004->EvtDesc.externalBusy),1);
37 swapHerb2bytes(&(gs2004->EvtDesc.modifiedBusyStatus),1);
38 swapHerb2bytes(&(gs2004->EvtDesc.physicsWord),1);
39 swapHerb2bytes(&(gs2004->EvtDesc.TriggerWord),1);
40 swapHerb2bytes(&(gs2004->EvtDesc.DSMAddress),1);
41 swapHerb2bytes(&(gs2004->EvtDesc.contaminationBusyStatus),1);
42 swapHerb2bytes(&(gs2004->EvtDesc.npre),1);
43 swapHerb2bytes(&(gs2004->EvtDesc.npost),1);
44 swapHerb2bytes(&(gs2004->EvtDesc.dummy),1);
46 swapHerb2bytes(&(gs2004->TrgSum.TrgSumBytes),1);
47 swapHerb2bytes(&(gs2004->TrgSum.TrgSumHeader),1);
48 swapHerb4bytes(&(gs2004->TrgSum.L1Sum[0]),2);
49 swapHerb4bytes(&(gs2004->TrgSum.L2Sum[0]),2);
50 swapHerb2bytes(&(gs2004->TrgSum.L0SumBytes),1);
51 swapHerb2bytes(&(gs2004->TrgSum.L0SumHeader),1);
52 swapHerb2bytes(&(gs2004->TrgSum.DSMdata.CPA[0]),32);
53 swapHerb2bytes(&(gs2004->TrgSum.DSMdata.quadDSM[0]),8);
54 swapHerb2bytes(&(gs2004->TrgSum.DSMdata.lastDSM[0]),8);
55 swapHerb2bytes(&(gs2004->TrgSum.DSMdata.VTX[0]),8);
56 swapHerb2bytes(&(gs2004->TrgSum.DSMdata.EMC[0]),8);
57 swapHerb2bytes(&(gs2004->TrgSum.DSMdata.BCdata[0]),16);
58 swapHerb2bytes(&(gs2004->TrgSum.DSMdata.specialTriggers[0]),8);
59 swapHerb2bytes(&(gs2004->TrgSum.DSMdata.FPD[0]),8);
60 swapHerb2bytes(&(gs2004->TrgSum.L1SumBytes),1);
61 swapHerb2bytes(&(gs2004->TrgSum.L1SumHeader),1);
62 swapHerb4bytes(&(gs2004->TrgSum.L1Result[0]),32);
63 swapHerb2bytes(&(gs2004->TrgSum.L2SumBytes),1);
64 swapHerb2bytes(&(gs2004->TrgSum.L2SumHeader),1);
65 swapHerb4bytes(&(gs2004->TrgSum.L2Result[0]),32);
67 numToSwap=1+gs2004->EvtDesc.npost+gs2004->EvtDesc.npre; assert(numToSwap<50&&numToSwap>0);
68 assert(numToSwap>=0&&numToSwap<=PREPOST);
71 if (numToSwap>maxToSwap)
return -1;
73 for(i=0;i<numToSwap;i++) {
74 swapHerb2bytes(&(gs2004->RAW[i].RawDetBytes),1);
75 swapHerb2bytes(&(gs2004->RAW[i].CTBdataBytes),1);
76 swapHerb2bytes(&(gs2004->RAW[i].MWCdataBytes),1);
77 swapHerb4bytes(&(gs2004->RAW[i].MWCfiller),1);
78 swapHerb2bytes(&(gs2004->RAW[i].BEMCdataBytes),1);
79 swapHerb4bytes(&(gs2004->RAW[i].BEMCfiller),1);
80 swapHerb2bytes(&(gs2004->RAW[i].BEMClayer1[0]),48);
81 swapHerb2bytes(&(gs2004->RAW[i].EEMCdataBytes),1);
82 swapHerb4bytes(&(gs2004->RAW[i].EEMCfiller),1);
83 swapHerb2bytes(&(gs2004->RAW[i].EEMClayer1[0]),16);
84 swapHerb2bytes(&(gs2004->RAW[i].FPDdataBytes),1);
85 swapHerb4bytes(&(gs2004->RAW[i].FPDfiller),1);
86 swapHerb2bytes(&(gs2004->RAW[i].FPDEastNSLayer1[0]),8);
87 swapHerb2bytes(&(gs2004->RAW[i].FPDEastTBLayer1[0]),8);
88 swapHerb2bytes(&(gs2004->RAW[i].FPDWestNSLayer1[0]),8);
89 swapHerb2bytes(&(gs2004->RAW[i].FPDWestTBLayer1[0]),8);
90 swapHerb2bytes(&(gs2004->RAW[i].BBCdataBytes),1);
91 swapHerb4bytes(&(gs2004->RAW[i].BBCfiller),1);
92 swapHerb2bytes(&(gs2004->RAW[i].BBClayer1[0]),16);
93 swapHerb2bytes(&(gs2004->RAW[i].ZDClayer1[0]),8);
108 void TRG_Reader::SanityCheck2004(
char *ptr,
int check_s=1) {
113 x=gs2004->TrgSum.L1SumBytes; assert(x==0x0084||x==0x8400);
114 x=gs2004->TrgSum.L2SumBytes; assert(x==0x0084||x==0x8400);
117 assert( gs2004->RAW[0].RawDetHeader[0] ==
'R');
118 assert( gs2004->RAW[0].RawDetHeader[1] ==
'D');
119 assert( gs2004->RAW[0].CTBdataHeader[0] ==
'C');
120 assert( gs2004->RAW[0].CTBdataHeader[1] ==
'T');
121 assert( gs2004->RAW[0].MWCdataHeader[0] ==
'M');
122 assert( gs2004->RAW[0].MWCdataHeader[1] ==
'W');
123 assert( gs2004->RAW[0].BEMCdataHeader[0]==
'E');
124 assert( gs2004->RAW[0].BEMCdataHeader[1]==
'M');
126 cout <<
"TRG_Reader::SanityCheck2004 : Data position sanity check is disabled" << endl;