Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HDET.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: HDET.h
4 // Created: Fri Apr 22 07:05:40 EDT 2016
5 // Creator: davidl (on Darwin harriet 13.4.0 i386)
6 //
7 
8 #ifndef _HDET_
9 #define _HDET_
10 
11 #include <list>
12 #include <string>
13 #include <utility>
14 #include <sstream>
15 #include <iostream>
16 using namespace std;
17 
18 #include <JANA/jerror.h>
19 
20 #ifdef HAVE_ET
21 #include <et.h>
22 #endif // HAVE_ET
23 
24 
25 class HDET{
26  public:
27 
28  enum{
29  HDET_OK=0, // Everything is hunky-dory
30  HDET_ERROR, // General error
31  HDET_NO_ET_SUPPORT, // ET library not compiled in
32  HDET_TIMEOUT, // Timeout trying to read ET event
33  HDET_ET_SYSTEM_DEAD, // ET system is dead
34  HDET_ALLOC_FAILED, // Failed to allocate a buffer
35  HDET_BAD_FORMAT // EVIO data in ET event has bad format
36  }ERRORCODE_t;
37 
38 
39  HDET(string source_name, int ET_STATION_NEVENTS=10, bool ET_STATION_CREATE_BLOCKING=false);
40  virtual ~HDET();
41 
42  bool read(uint32_t* &buff, uint32_t &buff_len, bool allow_swap);
43  void PrintEVIOBlockHeader(uint32_t *buff);
44  void PrintStats(void);
45  void DumpBinary(const uint32_t *iptr, const uint32_t *iend, uint32_t MaxWords=0, const uint32_t *imark=NULL);
46 
47 
48  string source_name;
50  stringstream err_mess; // last error message
51  uint32_t err_code; // last error code
54 
55  uint64_t Net_events;
56  uint64_t Nevio_blocks;
57  uint64_t Nevio_events;
58  uint64_t Net_timeouts;
59 
60 
61 #ifdef HAVE_ET
62  et_sys_id sys_id;
63  et_att_id att_id;
64  et_stat_id sta_id;
65 #endif
66 
67  int VERBOSE;
68  bool swap_needed; // true if block header indicates swapping is needed
69 
70  list<pair<uint32_t*, uint32_t> > et_buffs;
71  list<pair<uint32_t*, uint32_t> > et_buff_pool;
72 
73  protected:
74 
75  void ClearErrorMessage(void){ err_mess.str(""); err_mess.clear();}
76  void SetErrorMessage(string mess){ ClearErrorMessage(); err_mess<<mess;}
77 
78  public:
79 
80  //------------------------
81  // HexStr
82  //------------------------
83  inline string HexStr(uint32_t v)
84  {
85  char str[256];
86  sprintf(str, "0x%08x", v);
87 
88  return string(str);
89  }
90 
91  //------------------------
92  // HexStr
93  //------------------------
94  inline string HexStr(uint16_t v)
95  {
96  char str[256];
97  sprintf(str, "0x%04x", v);
98 
99  return string(str);
100  }
101 
102  //------------------------
103  // HexStr
104  //------------------------
105  inline string HexStr(uint8_t v)
106  {
107  char str[256];
108  sprintf(str, "0x%02x", v);
109 
110  return string(str);
111  }
112 };
113 
114 #endif // _HDET_
115 
uint64_t Nevio_blocks
Definition: HDET.h:56
char str[256]
bool ET_STATION_CREATE_BLOCKING
Definition: HDET.h:53
char string[256]
sprintf(text,"Post KinFit Cut")
uint64_t Nevio_events
Definition: HDET.h:57
uint32_t err_code
Definition: HDET.h:51
list< pair< uint32_t *, uint32_t > > et_buffs
Definition: HDET.h:70
string HexStr(uint8_t v)
Definition: HDET.h:105
int VERBOSE
Definition: HDET.h:67
bool swap_needed
Definition: HDET.h:68
string HexStr(uint16_t v)
Definition: HDET.h:94
bool is_connected
Definition: HDET.h:49
stringstream err_mess
Definition: HDET.h:50
string source_name
Definition: HDET.h:48
int ET_STATION_NEVENTS
Definition: HDET.h:52
void ClearErrorMessage(void)
Definition: HDET.h:75
list< pair< uint32_t *, uint32_t > > et_buff_pool
Definition: HDET.h:71
string HexStr(uint32_t v)
Definition: HDET.h:83
Definition: HDET.h:25
uint64_t Net_timeouts
Definition: HDET.h:58
void SetErrorMessage(string mess)
Definition: HDET.h:76
uint64_t Net_events
Definition: HDET.h:55