4 #define PREPOST 11 // This is also defined in TRG_Reader.cxx.
7 #include "trgStructures2003.h"
8 #include "TRG_Reader.hh"
10 using namespace OLDEVP;
19 int Bank_TRGD::HerbSwap2003(
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(&(gs2003->EvtDesc.TCUdataBytes),1);
30 swapHerb4bytes(&(gs2003->EvtDesc.bunchXing_hi),1);
31 swapHerb4bytes(&(gs2003->EvtDesc.bunchXing_lo),1);
32 swapHerb2bytes(&(gs2003->EvtDesc.actionWdDetectorBitMask),1);
33 swapHerb2bytes(&(gs2003->EvtDesc.TrgToken),1);
34 swapHerb2bytes(&(gs2003->EvtDesc.addBits),1);
35 swapHerb2bytes(&(gs2003->EvtDesc.DSMInput),1);
36 swapHerb2bytes(&(gs2003->EvtDesc.externalBusy),1);
37 swapHerb2bytes(&(gs2003->EvtDesc.modifiedBusyStatus),1);
38 swapHerb2bytes(&(gs2003->EvtDesc.physicsWord),1);
39 swapHerb2bytes(&(gs2003->EvtDesc.TriggerWord),1);
40 swapHerb2bytes(&(gs2003->EvtDesc.DSMAddress),1);
41 swapHerb2bytes(&(gs2003->EvtDesc.contaminationBusyStatus),1);
42 swapHerb2bytes(&(gs2003->EvtDesc.npre),1);
43 swapHerb2bytes(&(gs2003->EvtDesc.npost),1);
44 swapHerb2bytes(&(gs2003->EvtDesc.dummy),1);
46 swapHerb2bytes(&(gs2003->TrgSum.TrgSumBytes),1);
47 swapHerb2bytes(&(gs2003->TrgSum.TrgSumHeader),1);
48 swapHerb4bytes(&(gs2003->TrgSum.L1Sum[0]),2);
49 swapHerb4bytes(&(gs2003->TrgSum.L2Sum[0]),2);
50 swapHerb2bytes(&(gs2003->TrgSum.L0SumBytes),1);
51 swapHerb2bytes(&(gs2003->TrgSum.L0SumHeader),1);
52 swapHerb2bytes(&(gs2003->TrgSum.DSMdata.CPA[0]),32);
53 swapHerb2bytes(&(gs2003->TrgSum.DSMdata.quadDSM[0]),8);
54 swapHerb2bytes(&(gs2003->TrgSum.DSMdata.lastDSM[0]),8);
55 swapHerb2bytes(&(gs2003->TrgSum.DSMdata.VTX[0]),8);
56 swapHerb2bytes(&(gs2003->TrgSum.DSMdata.EMC[0]),8);
57 swapHerb2bytes(&(gs2003->TrgSum.DSMdata.BCdata[0]),16);
58 swapHerb2bytes(&(gs2003->TrgSum.DSMdata.specialTriggers[0]),8);
59 swapHerb2bytes(&(gs2003->TrgSum.DSMdata.FPD[0]),8);
60 swapHerb2bytes(&(gs2003->TrgSum.L1SumBytes),1);
61 swapHerb2bytes(&(gs2003->TrgSum.L1SumHeader),1);
62 swapHerb4bytes(&(gs2003->TrgSum.L1Result[0]),32);
63 swapHerb2bytes(&(gs2003->TrgSum.L2SumBytes),1);
64 swapHerb2bytes(&(gs2003->TrgSum.L2SumHeader),1);
65 swapHerb4bytes(&(gs2003->TrgSum.L2Result[0]),32);
70 if( 4*header.BankLength <
int((1+gs2003->EvtDesc.npre+gs2003->EvtDesc.npost) *
sizeof(
RawTrgDet2003)) ) {
71 gs2003->EvtDesc.npre=0; gs2003->EvtDesc.npost=0;
return -1;
74 numToSwap=1+gs2003->EvtDesc.npost+gs2003->EvtDesc.npre; assert(numToSwap<50&&numToSwap>0);
75 assert(numToSwap>=0&&numToSwap<=PREPOST);
78 for(i=0;i<numToSwap;i++) {
79 swapHerb2bytes(&(gs2003->RAW[i].RawDetBytes),1);
80 swapHerb2bytes(&(gs2003->RAW[i].CTBdataBytes),1);
81 swapHerb2bytes(&(gs2003->RAW[i].MWCdataBytes),1);
82 swapHerb4bytes(&(gs2003->RAW[i].MWCfiller),1);
83 swapHerb2bytes(&(gs2003->RAW[i].BEMCdataBytes),1);
84 swapHerb4bytes(&(gs2003->RAW[i].BEMCfiller),1);
85 swapHerb2bytes(&(gs2003->RAW[i].BEMClayer1[0]),48);
86 swapHerb2bytes(&(gs2003->RAW[i].EEMCdataBytes),1);
87 swapHerb4bytes(&(gs2003->RAW[i].EEMCfiller),1);
88 swapHerb2bytes(&(gs2003->RAW[i].EEMClayer1[0]),16);
89 swapHerb2bytes(&(gs2003->RAW[i].FPDdataBytes),1);
90 swapHerb4bytes(&(gs2003->RAW[i].FPDfiller),1);
91 swapHerb2bytes(&(gs2003->RAW[i].FPDEastNSLayer1[0]),8);
92 swapHerb2bytes(&(gs2003->RAW[i].FPDEastTBLayer1[0]),8);
93 swapHerb2bytes(&(gs2003->RAW[i].FPDWestNSLayer1[0]),8);
94 swapHerb2bytes(&(gs2003->RAW[i].FPDWestTBLayer1[0]),8);
95 swapHerb2bytes(&(gs2003->RAW[i].BBCdataBytes),1);
96 swapHerb4bytes(&(gs2003->RAW[i].BBCfiller),1);
97 swapHerb2bytes(&(gs2003->RAW[i].BBClayer1[0]),16);
98 swapHerb2bytes(&(gs2003->RAW[i].ZDClayer1[0]),8);
113 void TRG_Reader::SanityCheck2003(
char *ptr,
int check_s=1) {
118 x=gs2003->TrgSum.L1SumBytes; assert(x==0x0084||x==0x8400);
119 x=gs2003->TrgSum.L2SumBytes; assert(x==0x0084||x==0x8400);