StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
l3TrgReader.cxx
1 #include "l3TrgReader.h"
2 #include <rtsLog.h>
3 #include <stdio.h>
4 
5 #ifndef TRG_VERSION
6 #define TRG_VERSION 0x32
7 #endif
8 
9 #include "daqFormats.h"
10 //#include "TRG/trgStructures.h"
11 
12 #include <string.h>
13 
14 int l3TrgReader::readL3P(L3_P *l3p)
15 {
16  if (l3p == NULL) return -1;
17 
18  if (l3p->trig.off == 0) return -1;
19 
20  char *trgBuf = (char*)l3p + l3p->trig.off*4;
21 
22 
23  unsigned char version;
24 
25  if (l3p->bh.format_number <= 7) {
26  version = ((unsigned char *)trgBuf)[0];
27 
28  if (version > 0x20) {
29  LOG(ERR,"L3_P fn=%d should not contain TRG=0x%x",
30  l3p->bh.format_number,version,0,0,0);
31  return -1;
32  }
33  } else {
34  version = ((TrgDataType*)trgBuf)->EvtDesc.TrgDataFmtVer;
35 
36  if (version <= 0x20) {
37  LOG(ERR,"L3_P fn=%d should not contain TRG=0x%x",
38  l3p->bh.format_number,version,0,0,0);
39  return -1;
40  }
41  }
42 
43 
44  switch (version) {
45 
46  case 0x12:
47  case 0x13:
48  return readV12(trgBuf);
49 
50  case 0x20:
51  return readV20(trgBuf);
52 
53  case 0x21:
54  return readV21(trgBuf);
55 
56  default:
57  LOG(ERR,"l3Trg: Unknown trigger format: 0x%x (0x%08x) %s\n",
58  version, *((long*)trgBuf), (char*)trgBuf,0,0,0);
59  return -1;
60  }
61 
62 
63 }
64 
65 
66 int l3TrgReader::read(void *buffer)
67 {
68  LOG(ERR,"WARNING: l3TrgReader::read is obsolete",0,0,0,0,0);
69 
70  unsigned char version = ((unsigned char *)buffer)[0];
71 
72  switch (version) {
73 
74  case 0x12:
75  case 0x13:
76  //l3Log("l3Trg: Going into readV12\n");
77  return readV12(buffer);
78 
79  case 0x20:
80  //l3Log("l3Trg: Going into readV20\n");
81  return readV20(buffer);
82 
83  case 0x21:
84  // Starting Jan 2004, we get the full TrgDataType in one block
85  // instead of three chunks for evtDesc, trgSum and rawTrgDet
86  // The reading of this still has to be implemented...
87 
88  return readV21(buffer);
89 
90  default:
91  //l3Log("l3Trg: Unknown trigger format: 0x%x\n", version);
92  return -1;
93  }
94 }
95 
96 
97 void l3TrgReader::reset()
98 {
99  token = 0;
100  bunchXing_hi = 0;
101  bunchXing_lo = 0;
102 
103  physicsWord = 0;
104  triggerWord = 0;
105 
106  memset(ZDC, 0, 16);
107  memset(CTB, 0, 256);
108 }
void version(std::ostream &os=std::cout)
print HepMC version
Definition: Version.h:27