StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
trgReader10.cxx
1 #include <stdio.h>
2 #include <string.h>
3 #include <arpa/inet.h>
4 #include <rtsLog.h>
5 #include <rtsSystems.h>
6 
7 
8 //#include <evpSupport.h>
9 
10 //#ifndef TRG_VERSION
11 #define TRG_VERSION 0x32
12 //#endif
13 
14 #include <daqFormats.h>
15 #include <rts.h> // for the sake of swap32 entry
16 
17 #include "daq_trg.h"
18 
19 extern int trgReader32(char *trgd, int bytes, int swap, struct trg_t *trg);
20 
21 // 2007, read the pointer banks then delagate to version 0x32...
22 
23 int trgReader10(char *buff, struct trg_t *trg_t)
24 {
25  TRGD *trgd = (TRGD *)buff;
26 
27  int swap = 0;
28  if(trgd->bh.byte_order != DAQ_RAW_FORMAT_ORDER) swap=1;
29 
30  buff += sizeof(bankHeader); // skip TRGD bank header!
31 
32  TrgTowerTrnfer *trg = (TrgTowerTrnfer *)buff;
33 
34  int byteCount_Version = swap32(trg->byteCount_Version);
35 
36 //-- int byteCount = byteCount_Version >> 8;
37  int version = byteCount_Version & 0xff;
38 
39  if(version != 0x10) {
40  LOG(ERR, "Incorrect trigger header version 0x%x rather than 0x10", version);
41  return -1;
42  }
43 
44  // offset to legacy trg banks...
45  int evtdesc_off = swap32(trg->OffsetBlock[TRG_INDEX].offset);
46  LOG(DBG, "evtdesc_off = %d sizeof(TrgTowerTrnfer-4)=%d",evtdesc_off,sizeof(TrgTowerTrnfer)-4);
47 
48  if(evtdesc_off == 0) {
49  LOG(ERR, "No trigger data available, offset = 0");
50  return -1;
51  }
52 
53  EvtDescData *evtdesc = (EvtDescData *)(buff + evtdesc_off);
54 // u_int *x = (u_int *)evtdesc;
55 
56  int version2 = evtdesc->TrgDataFmtVer;
57 
58  if(version2 != 0x32) {
59  LOG(ERR, "Incorrect trigger data version 0x%x rather than 0x32 (0x%x)", version2, *evtdesc);
60  return -1;
61  }
62 
63  return trgReader32((char *)evtdesc, swap32(trg->OffsetBlock[TRG_INDEX].length), swap, trg_t);
64 }
void version(std::ostream &os=std::cout)
print HepMC version
Definition: Version.h:27
Definition: daq_trg.h:9