StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
code2005.cxx
1 // This is the analog of duplicated.code for the version of trgStructures.h
2 // which I (Herb) label "2005".
3 
4 #define PREPOST 11 // This is also defined in TRG_Reader.cxx.
5 
6 #include <assert.h>
7 #include "trgStructures2005.h"
8 #include "TRG_Reader.hh"
9 
10 typedef struct {
11  EvtDescData2005 EvtDesc; /* L1 Event Descriptor Data */
12  TrgSumData2005 TrgSum; /* summary data */
13  RawTrgDet2005 RAW[PREPOST];
15 MarilynMonroe *gs2005;
16 using namespace OLDEVP;
17 
18 int Bank_TRGD::HerbSwap2005(char *ptr) {
19  int numToSwap,returnValue,i;
20 
21  gs2005=(MarilynMonroe*)ptr;
22 
23  assert(header.ByteOrder==0x01020304||header.ByteOrder==0x04030201);
24  if(header.ByteOrder==0x04030201) return 0;
25  returnValue=header.swap();
26  assert(header.ByteOrder==0x04030201);
27 
28  swapHerb2bytes(&(gs2005->EvtDesc.TCUdataBytes),1);
29  swapHerb4bytes(&(gs2005->EvtDesc.bunchXing_hi),1);
30  swapHerb4bytes(&(gs2005->EvtDesc.bunchXing_lo),1);
31  swapHerb2bytes(&(gs2005->EvtDesc.actionWdDetectorBitMask),1);
32  swapHerb2bytes(&(gs2005->EvtDesc.TrgToken),1);
33  swapHerb2bytes(&(gs2005->EvtDesc.addBits),1);
34  swapHerb2bytes(&(gs2005->EvtDesc.DSMInput),1);
35  swapHerb2bytes(&(gs2005->EvtDesc.externalBusy),1);
36  swapHerb2bytes(&(gs2005->EvtDesc.modifiedBusyStatus),1);
37  swapHerb2bytes(&(gs2005->EvtDesc.physicsWord),1);
38  swapHerb2bytes(&(gs2005->EvtDesc.TriggerWord),1);
39  swapHerb2bytes(&(gs2005->EvtDesc.DSMAddress),1);
40  swapHerb2bytes(&(gs2005->EvtDesc.contaminationBusyStatus),1);
41  swapHerb2bytes(&(gs2005->EvtDesc.npre),1);
42  swapHerb2bytes(&(gs2005->EvtDesc.npost),1);
43  swapHerb2bytes(&(gs2005->EvtDesc.dummy),1);
44 
45  swapHerb2bytes(&(gs2005->TrgSum.TrgSumBytes),1);
46  swapHerb2bytes(&(gs2005->TrgSum.TrgSumHeader),1);
47  swapHerb4bytes(&(gs2005->TrgSum.L1Sum[0]),2);
48  swapHerb4bytes(&(gs2005->TrgSum.L2Sum[0]),2);
49  swapHerb2bytes(&(gs2005->TrgSum.L0SumBytes),1);
50  swapHerb2bytes(&(gs2005->TrgSum.L0SumHeader),1);
51  swapHerb2bytes(&(gs2005->TrgSum.DSMdata.CPA[0]),32);
52  swapHerb2bytes(&(gs2005->TrgSum.DSMdata.quadDSM[0]),8);
53  swapHerb2bytes(&(gs2005->TrgSum.DSMdata.lastDSM[0]),8);
54  swapHerb2bytes(&(gs2005->TrgSum.DSMdata.VTX[0]),8);
55  swapHerb2bytes(&(gs2005->TrgSum.DSMdata.EMC[0]),8);
56  swapHerb2bytes(&(gs2005->TrgSum.DSMdata.BCdata[0]),16);
57  swapHerb2bytes(&(gs2005->TrgSum.DSMdata.specialTriggers[0]),8);
58  swapHerb2bytes(&(gs2005->TrgSum.DSMdata.FPD[0]),8);
59  swapHerb2bytes(&(gs2005->TrgSum.L1SumBytes),1);
60  swapHerb2bytes(&(gs2005->TrgSum.L1SumHeader),1);
61  swapHerb4bytes(&(gs2005->TrgSum.L1Result[0]),32);
62  swapHerb2bytes(&(gs2005->TrgSum.L2SumBytes),1);
63  swapHerb2bytes(&(gs2005->TrgSum.L2SumHeader),1);
64  swapHerb4bytes(&(gs2005->TrgSum.L2Result[0]),32);
65 
66  numToSwap=1+gs2005->EvtDesc.npost+gs2005->EvtDesc.npre; assert(numToSwap<50&&numToSwap>0);
67  assert(numToSwap>=0&&numToSwap<=PREPOST);
68  int maxToSwap = 4*header.BankLength-(sizeof(EvtDescData2005)+sizeof(TrgSumData2005));
69  maxToSwap/=sizeof(RawTrgDet2005);
70  if (numToSwap>maxToSwap) return -1;
71 
72  for(i=0;i<numToSwap;i++) { // loop over NPRE, NPOST as well
73  swapHerb2bytes(&(gs2005->RAW[i].RawDetBytes),1);
74  swapHerb2bytes(&(gs2005->RAW[i].CTBdataBytes),1);
75  swapHerb2bytes(&(gs2005->RAW[i].MWCdataBytes),1);
76  swapHerb4bytes(&(gs2005->RAW[i].MWCfiller),1);
77  swapHerb2bytes(&(gs2005->RAW[i].BEMCdataBytes),1);
78  swapHerb4bytes(&(gs2005->RAW[i].BEMCfiller),1);
79  swapHerb2bytes(&(gs2005->RAW[i].BEMClayer1[0]),48);
80  swapHerb2bytes(&(gs2005->RAW[i].EEMCdataBytes),1);
81  swapHerb4bytes(&(gs2005->RAW[i].EEMCfiller),1);
82  swapHerb2bytes(&(gs2005->RAW[i].EEMClayer1[0]),16);
83  swapHerb2bytes(&(gs2005->RAW[i].FPDdataBytes),1);
84  swapHerb4bytes(&(gs2005->RAW[i].FPDfiller),1);
85  swapHerb2bytes(&(gs2005->RAW[i].FPDEastNSLayer1[0]),8);
86  swapHerb2bytes(&(gs2005->RAW[i].FPDEastTBLayer1[0]),8);
87  swapHerb2bytes(&(gs2005->RAW[i].FPDWestNSLayer1[0]),8);
88  swapHerb2bytes(&(gs2005->RAW[i].FPDWestTBLayer1[0]),8);
89  swapHerb2bytes(&(gs2005->RAW[i].BBCdataBytes),1);
90  swapHerb4bytes(&(gs2005->RAW[i].BBCfiller),1);
91  swapHerb2bytes(&(gs2005->RAW[i].BBClayer1[0]),16);
92  swapHerb2bytes(&(gs2005->RAW[i].ZDClayer1[0]),8);
93  }
94 
95  return returnValue;
96 }
97 
107 void TRG_Reader::SanityCheck2005(char *ptr, int check_s=1) {
108 
109  gs2005=(MarilynMonroe*)ptr;
110  unsigned short x;
111 
112  x=gs2005->TrgSum.L1SumBytes; assert(x==0x0084||x==0x8400);
113  x=gs2005->TrgSum.L2SumBytes; assert(x==0x0084||x==0x8400);
114 
115  if (check_s){
116  assert( gs2005->RAW[0].RawDetHeader[0] =='R');
117  assert( gs2005->RAW[0].RawDetHeader[1] =='D');
118  assert( gs2005->RAW[0].CTBdataHeader[0] =='C');
119  assert( gs2005->RAW[0].CTBdataHeader[1] =='T');
120  assert( gs2005->RAW[0].MWCdataHeader[0] =='M');
121  assert( gs2005->RAW[0].MWCdataHeader[1] =='W');
122  assert( gs2005->RAW[0].BEMCdataHeader[0]=='E');
123  assert( gs2005->RAW[0].BEMCdataHeader[1]=='M');
124  } else {
125  cout << "TRG_Reader::SanityCheck2005 : Data position sanity check is disabled" << endl;
126  }
127 }