StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
daq_det.h
1 #ifndef _DAQ_DET_H_
2 #define _DAQ_DET_H_
3 
4 
5 // the m_Modes are done such that the default value of 0
6 // will do whatever default for Offline:
7 // ADC data for most
8 // CLD data for TPX/TPC
9 
10 #include <sys/types.h> // for u_int
11 
12 #define m_Mode_DAQ_PED (1<<0) // calculate pedestals in Make
13 #define m_Mode_DAQ_GAIN (1<<1) // calculate gains in Make
14 #define m_Mode_DAQ_FCF_RAW (1<<2) // run cluster finder
15 #define m_Mode_DAQ_ADC (1<<3) // Make outputs ADC
16 #define m_Mode_DAQ_RAW (1<<4) // Make outputs RAW (used in realtime only!)
17 #define m_Mode_DAQ_FCF (1<<5) // Make(): runs floating point FCF
18 
19 #define m_Mode_DAQ_RT (1<<31) // working in realtime! Under ESB! do not use in Offline!
20 
21 
22 #define m_Debug_DAQ_PRINT (1<<0)
23 #define m_Debug_DAQ_CHECK (1<<1)
24 
25 
26 #define DET_PRESENT_SFS (1<<0)
27 #define DET_PRESENT_DATAP (1<<1)
28 #define DET_PRESENT_TRG (1<<2)
29 
30 // forward declarations
31 class daq_dta ;
32 class daqReader ;
33 class daq_det ;
34 
35 // helpers
36 extern int checkBank(const char *in, const char *expect) ;
37 extern int *legacyDetp(int rts_id, char *datap) ;
38 
39 
41 {
42 public:
43  daq_det_factory() {} ;
44  virtual ~daq_det_factory() {} ;
45 
46  static daq_det *make_det(int wh) ;
47 protected:
48  static daq_det_factory *det_factories[48] ; // for real dets
49  static daq_det_factory *pseudo_factories[48] ; // for pseudo/internal dets such as whole EMC
50  virtual daq_det *create() = 0 ;
51 } ;
52 
53 
54 class daq_det {
55 protected:
56 
57  u_char present ; // in this event: bitmask: 1 in DATAP; 2 in SFS
58 
59 
60  int run_num ; // of this run
61  u_int evt_num ; // in the run!
62 
63  int def_sector ;
64  int def_rdo ;
65 
66  u_int m_Mode ; // processing mod bitmask: see m_Mode_DAQ_xxx above
67 
68  u_int m_Debug ; // prints, header checks etc.
69 
70  // statics
71  static const int MAX_SEC = 0 ;
72  static const int MAX_RDO = 0 ;
73 
74  static int endianess ; // of the executing machine -- 0 is little, 1 is big
75 
76 
77  virtual int presence() ; // is this DET (not only the bank!) present in this event?
78  daqReader *caller ;
79 
80  const char *sfs_name ; // name in sfs bank (if any) i.e. "tpx"
81 
82 
83 
84 private:
85 
86 public:
87 
88 
89  daq_det(daqReader *caller = 0) ;
90  virtual ~daq_det() ;
91 
92  virtual int Init() ;
93  virtual int InitRun(int run) ;
94  virtual int Make() ;
95  virtual int FinishRun(int old_run) ;
96 
97 
98 
99  // needs to be overriden!
100  virtual daq_dta *get(const char *bank="*",int sec=-1, int row=-1, int pad=-1, void *p1=0, void *p2=0) ;
101  virtual int bad_sanity() ;
102 
103  // needs to be overriden!
104  virtual daq_dta *put(const char *bank="*",int c1=-1, int c2=-1, int c3=-1, void *p1=0, void *p2=0) ;
105 
106 
107 
108 
109  virtual void help() const ;
110 
111 
112  virtual int get_l2(char *buff, int buff_bytes, struct daq_trg_word *trg, int prompt) ;
113  virtual int get_token(char *buff, int buff_bytes) ;
114 
115 
116  virtual void SetMode(u_int mode=0) {
117  m_Mode=mode ;
118  } ;
119  virtual u_int GetMode() {
120  return m_Mode ;
121  } ;
122 
123  virtual void set_defaults(int sec, int rdo) {
124  def_sector = sec;
125  def_rdo = rdo ;
126  return ;
127  } ;
128 
129  virtual const char *GetCVS() const { // Offline
130  static const char cvs[]="Tag $Name: $: $Id: daq_det.h,v 1.12 2022/09/23 19:55:47 jml Exp $: built " __DATE__ " " __TIME__ ;
131  return cvs;
132  } ;
133 
134 
135  virtual unsigned int get_global_event_num() ;
136 
137  void managed_by(class daqReader *c) ;
138 
139 
140 
141  const char *name ; // detector's name i.e. "SVT"
142 
143  u_int event_mode ;
144 
145  char *in_buffer ;
146  int in_bytes ;
147 
148  char *out_buffer ;
149  int out_bytes ;
150 
151  int rts_id ; // RTS_ID
152 
153 } ;
154 
155 
156 
157 #endif