StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TRG_Reader.hh
1 /*
2  ***************************************************************************
3  * Author: Herb Ward
4  ***************************************************************************
5  * Description: definitions for TRG
6  *
7  *
8  * change log
9  *
10  ***************************************************************************
11 */
12 
13 #ifndef TRG_Reader_hh
14 #define TRG_Reader_hh
15 
17 #include "StDaqLib/GENERIC/EventReader.hh"
18 #include "StDaqLib/GENERIC/RecHeaderFormats.hh"
19 #include "StDaqLib/GENERIC/swaps.hh"
21 class Bank_TRGP: public Bank {
22 public:
23  Pointer theData; // unlike the TPC, we don't need an array here.
24 };
26  INT32 bunchCrossingNumber1; // Warning: These should be interpreted as unsigned with sth like
27  INT32 bunchCrossingNumber2; // unsigned int hh2 = *(unsigned int*)(&bunchCrossingNumber2).
28  // I declare them as INT32 (int) so that I can feed them to the
29  // generic byte-swapping function.
30  INT16 token;
31  INT16 actionWord;
32  INT16 lastDsmOutput;
33  INT16 dsmRawDataAddress;
34  unsigned char busyBits;
35  unsigned char trgFlags;
36  INT16 triggerWord;
37  INT16 nPre;
38  INT16 nPost;
39 };
40 struct trgSummary {
41  INT16 lengthTriggerSummary;
42  INT16 trgSummaryFormat;
43  unsigned char trgL0[2];
44  INT16 L0Length;
45  INT32 L0Data[32];
46  unsigned char trgL1[2];
47  INT16 L1Length;
48  INT32 L1Data[64];
49  unsigned char trgL2[2];
50  INT16 L2Length;
51  INT32 L2Data[64];
52 };
53 struct trgRawData {
54  INT16 lengthTriggerRaw;
55  INT16 trgRawFormat;
56  unsigned char trgCTB[2];
57  INT32 CTBdata[64];
58  unsigned char trgMWZ[2];
59  INT32 MWZdata[36]; // MWC+ZDC
60  unsigned char trgEMC[2];
61  INT32 EMCdata[120];
62 };
63 class Bank_TRGD: public Bank {
64 public:
65  trgEventDescriptor trgED;
66  trgSummary trgSum;
67  trgRawData trgRaw;
68 // Override default swap because of complicated structure of trg data bank.
69  int swap();
70  int swapHerb2bytes(unsigned short *data,int number);
71  int swapHerb4bytes(unsigned int *data,int number);
72  int swapHerb4bytes(unsigned long *data,int number);
73 
74  int swapHerb2bytes(short *data, int number)
75  {return swapHerb2bytes((unsigned short*)data,number);}
76  int swapHerb4bytes(int *data, int number)
77  {return swapHerb4bytes((unsigned int *)data,number);}
78  int swapHerb4bytes(long *data, int number)
79  {return swapHerb4bytes((unsigned long *)data,number);}
80  int HerbSwap();
81  int HerbSwap2000();
82  int HerbSwap2003(char*);
83  int HerbSwap2004(char*);
84  int HerbSwap2005(char*);
85  // void PrintAllTheData(FILE *ff);
86  // void PrintDataCompact(FILE *ff);
87  char *PrintHelp(char*,int);
88 };
89 
90 class TRG_Reader {
91  friend class EventReader;
92 public:
93  TRG_Reader(EventReader *er, Bank_TRGP *pTRGP);
94  ~TRG_Reader(){
95  if (pBankUnp) delete[] pBankUnp;
96  if (pTRGD) delete pTRGD;
97  };
98  Bank_TRGD *pBankTRGD; // Making this public saves 2 large layers of accessor functions.
99  int YearOfData(char *);
100  int S_mode;
101  int GetErr(){return mErr;}
102 
103 protected:
104  EventReader *ercpy; // copy of EventReader pointer
105  Bank_TRGP *pBankTRGP; // Bank Pointers
106  int mErr;
107  char *pBankUnp;
108  unsigned int sizeUnp;
110 
111 private:
112  void dumpWordsToScreenInHexAndExit(int);
113  void SanityCheck(int);
114  void SanityCheck2000(int);
115  void SanityCheck2003(char*, int);
116  void SanityCheck2004(char*, int);
117  void SanityCheck2005(char*, int);
118  void SanityCheck2007(char*, int);
119  void SanityCheck2008(char*, int);
120  int UnpackTrg2007(Bank_TRGP*);
121  int Swap2007_DescSum(char*);
122  int Swap2007_Raw(char*);
123  int UnpackTrg2008(Bank_TRGP*);
124  int Swap2008_TrgTowerTrnfer(char*);
125  int Swap2008_DescSum(char*);
126  int Swap2008_Raw(char*);
127 };
128 
129 TRG_Reader *getTRGReader(EventReader *er);
130 
131 #endif
Bank_TRGD * pTRGD
Size of unpacked bank space.
Definition: TRG_Reader.hh:109
unsigned int sizeUnp
Pointer to keep workspace for unpacked trigger struct.
Definition: TRG_Reader.hh:108
char * PrintHelp(char *, int)
for 2007 and later see TRG_Reader::UnpackTrg below
Definition: TRG_Reader.cxx:198
int YearOfData(char *)
This routine also exists in St_trg_Maker.
Definition: TRG_Reader.cxx:55