StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RC_Config.h
1 #ifndef RC_CONFIG_HH
2 #define RC_CONFIG_HH
3 
4 #include <sys/types.h>
5 #include <rtsSystems.h>
6 #include <netinet/in.h>
7 
8 /***********************************************************************************
9  * Configuration files for online
10  *
11  * The configuration files are organized into tiers
12  *
13  * TIER 1 - Internal trigger configuration (named)
14  * DICT - Dictionary structure for trigger configurations
15  * SETUP - Sets of parameters that can be choosen as a group
16  * RUN - Parameters that are set independently each run
17  *
18  ************************************************************************************/
19 
20 #include <stdio.h>
21 #include <string.h>
22 #include <rts.h>
23 
24 #define CONFIG_VERSION 2004
25 
26 #ifdef RTS_PROJECT_PP
27 #define RC_PARAM_FILE_BASE_PATH "/PP/conf/handler/"
28 #define TRG_BASE_PATH "/PP/conf/handler"
29 #define DAQ_BASE_PATH "/PP/conf/handler"
30 #else
31 #define RC_PARAM_FILE_BASE_PATH "/RTS/conf/handler/"
32 #define TRG_BASE_PATH "/home/startrg/trg/handler/conf"
33 #define DAQ_BASE_PATH "/RTS/conf/handler"
34 #endif
35 
36 
37 #define TRG_CONFIG_FILE_NAME ""
38 #define DAQ_CONFIG_FILE_NAME ""
39 #define SC_CONFIG_FILE_NAME ""
40 #define L3_CONFIG_FILE_NAME ""
41 
42 #define MAX_REGISTERS 1500
43 
44 #define CFG_MAX_LABELS_LEGACY 200
45 #define MAX_TRG_DICT_ENTRIES_LEGACY 1500
46 
47 #define CFG_MAX_LABELS 2000
48 #define MAX_TRG_DICT_ENTRIES 6000
49 
50 #define MAX_ID 64
51 #define MAX_SUB 4
52 #define MAX_INST 100
53 #define MAX_TCD 20
54 
55 #define MAX_NODES 400
56 #define MAX_EVBS 25
57 
58 #define MAX_THREADS 400
59 #define MAX_STR_LEN 40
60 
61 #define TRIGGERS_MAX 64
62 #define OLD_TRIGGERS_MAX 32
63 
64 #define EVP_GROUP_MAX 32 // Number of EVP groups...
65 #define CONDPERTRG_MAX 4 // Conditions per Trigger
66 //#define PWDEF_BYTES TRIGGERS_MAX / 8
67 //#define TWDEF_BYTES TRIGGERS_MAX / 8 // Assume at most 4 detector groupings
68 
69 //#define MAX_TW (1<<16) /* in principle max values for pw/tw */
70 //#define MAX_PW (1<<12)
71 
72 // #define NUM_PHYSICS_BITS 16 // correct values but not used...
73 // #define NUM_DET_BITS 12
74 
75 #define RTS_STAT_TOKENS_DONE 8
76 #define RTS_STAT_FORCE 9
77 #define RTS_STAT_REQUEST 10
78 
79 #define RTS_STARTRUN_FLAG 1
80 #define RTS_STOPRUN_FLAG 2
81 #define RTS_SENDCONFIG_FLAG 4
82 #define RTS_STOPRUN_SECOND_FLAG 8
83 
84 
85 typedef unsigned int UINT32;
86 typedef unsigned short UINT16;
87 typedef unsigned char UINT8;
88 typedef unsigned long long int UINT64;
89 
90 class UINT128 {
91  public:
92  UINT32 x[4];
93 
94  UINT128() {
95  zero();
96  }
97 
98  void zero() {
99  x[0] = 0;
100  x[1] = 0;
101  x[2] = 0;
102  x[3] = 0;
103  }
104 
105  int is_set(int bit) {
106  int byt=bit/32;
107  bit = bit % 32;
108 
109  return (x[byt] & (1<<bit)) ? 1 : 0;
110  }
111 
112  void set(int bit) {
113  int byt=bit/32;
114  bit = bit % 32;
115 
116  x[byt] |= (1<<bit);
117  }
118 
119  void clear(int bit) {
120  int byt=bit/32;
121  bit = bit % 32;
122  x[byt] &= (~(1<<bit));
123  }
124 
125  char *tostring(char *out = (char *)NULL) {
126  static char _out[70];
127 
128  if(out == NULL) out = _out;
129  sprintf(out, "%08x-%08x-%08x-%08x", x[3], x[2], x[1], x[0]);
130  return out;
131  }
132 
133 };
134 
135 
136 #define L1_DSM_OBJECT 1
137 #define BC1_DSM_OBJECT 2
138 #define MXQ_QT_OBJECT 3
139 #define MIX_DSM_OBJECT 4
140 #define BCW_DSM_OBJECT 5
141 #define BCE_DSM_OBJECT 6
142 #define EQ3_QT_OBJECT 7 // Changed EPQ > EQ3. JMN 8/15/17
143 #define BBC_DSM_OBJECT 8
144 #define BBQ_QT_OBJECT 9
145 #define FMS_DSM_OBJECT 10
146 #define QT1_FMS_OBJECT 11
147 #define QT2_FMS_OBJECT 12
148 #define QT3_FMS_OBJECT 13
149 #define QT4_FMS_OBJECT 14
150 #define TRG_OBJECT 29
151 #define DAQ_OBJECT 30 // Reserved for DAQ use..
152 #define PHYSICS_BIT_OBJECT 32
153 #define DETECTOR_BIT_OBJECT 33
154 #define TCD_OBJECT 34
155 #define L1_OBJECT 35
156 #define L2_OBJECT 36
157 #define L3_OBJECT 37 // Reserved for L3 use...
158 #define EQ1_QT_OBJECT 38 // Changed FQ1 > EQ1. JMN 8/15/17
159 #define EQ2_QT_OBJECT 39 // Changed FQ2 > EQ2. JMN 8/15/17
160 #define FCS_OBJECT 40
161 #define DSM2_OBJECT 41
162 
163 #define BIT_OBJECT 100 // Reserved for TCU bit labels
164 
165 
166 /************************************************************************************
167  * STAR_CFG fully defines the STAR run
168  ************************************************************************************/
169 
170 class SimpleXmlDoc;
171 
172 // Configuration file functions...The functions get properly swapped
173 // versions of the configuration file.
174 //
175 // The file is stored big endian, even (stupidly?) on little endian
176 // machines...
177 //
178 
179 // fills filename
180 struct ic_msg;
181 
182 char *cmd2name(int cmd);
183 char *getConfigBaseXml(char *filename, int port, int trg);
184 char *getConfigBaseXml(char *filename, ic_msg *m);
185 char *getConfigBase(char *filename, int port, int trg);
186 char *getConfigBase(char *filename, ic_msg *m);
187 
188 SimpleXmlDoc *getConfigFileXml(SimpleXmlDoc *xml, ic_msg *m, int sz=0);
189 SimpleXmlDoc *getConfigFileXml(SimpleXmlDoc *xml, char *filename, int sz=0);
190 
191 // fills cfg, returns sizeof(cfg)
192 //int getConfigFile(STAR_CFG *cfg, ic_msg *m);
193 //int getConfigFile(STAR_CFG *cfg, char *filename);
194 
195 // puts cfg into filename, returns sizeof(cfg)
196 //int putConfigFile(STAR_CFG *cfg, char *filename);
197 
199 // Trigger Definition stuff
201 
202 
203 //struct TrgCfg;
204 struct TrgPS;
205 
206 char *confNum2String(UINT32 conf_num);
207 int string2ConfNum(char *str);
208 UINT32 getCrateMask4TrgDet(int det); //obsolete
209 int getConfNumForNode(int node);
210 UINT16 getTrgDetRequiredMask(char *node, int board=-1); //obsolete
211 
212 //void writeRCCNF(char *fn, STAR_CFG *cfg); // write rc def file...
213 void writeRCCNF(char *fn, SimpleXmlDoc *xml);
214 
215 //bool node_inrun(int node, STAR_CFG *cfg);
216 //bool system_inrun(int sys, STAR_CFG *cfg);
217 //void maskDetectorsInRun(STAR_CFG *cfg);
218 bool system_inrun(int sys, SimpleXmlDoc *xml);
219 void maskDetectorsInRun(SimpleXmlDoc *xml);
220 
221 
222 //bool cfgBuildPS(TrgPS *ps, RC_Config *rccfg);
223 bool cfgBuildPS(TrgPS *ps, SimpleXmlDoc *xml);
224 
225 
226 
227 struct TrgPSEntry {
228  int l0ps;
229  float l1ps; // This is the floating version of the L0PS.
230  float l2ps;
231  float l3ps;
232 };
233 
234 struct TrgPS {
235  TrgPSEntry ps[TRIGGERS_MAX];
236 };
237 
238 struct EthServer
239 {
240  UINT16 node;
241  UINT16 task;
242  UINT32 ip;
243  UINT32 port;
244 };
245 
247 {
248  char name[40];
249  EthServer server;
250 };
251 
252 // Reads from all.conf
253 // returns -1 if no server, 0 if server exists.
254 int getEthServer(int node, int task, EthServer *eth, int force_vlan=0);
255 char *ReadAllDotConf(int node, int task, char *param, char *result=(char *)NULL, char *paramfilename=(char *)"/RTS/conf/handler/all.conf");
256 int getAllEthServers(EthServerName *list, int max);
257 
259 
260 //
261 // token based EVB determination for LXSB & GB
262 //
263 
265 {
266  public:
267  EvbChooser(int _force_vlan=0) { weights_set = 0; force_vlan=_force_vlan; };
268  void configure(SimpleXmlDoc *xml);
269 
270  //void configure(STAR_CFG *cfg, int legacy);
271 
272  // These return error if no evbs in run, but otherwise
273  // return a valid EVB even if the token is invalid
274  EthServer *choose(int token); // returns ptr (NULL on error)
275  int chooseIdx(int token); // returns idx (-1 on error)
276 
277  // This returns an error if the token is invalid.
278  int chooseIdx_proper(int token);
279 
280  EthServer servers[50]; // linearized servers
281  int nservers;
282 
283  int getIdxByNode(int evbnode);
284 
285  int getEvb4Token(int token) { return evb4token[token]; }
286 
287  // private:
288  int evbNodes[MAX_EVBS][5]; // idx to server by evb/server
289  int nevbserv[MAX_EVBS]; // nservers by evb
290 
291  int evt_ctrs_by_server[MAX_EVBS];
292  int weights_by_evb[MAX_EVBS];
293  int weights_set;
294 
295  void readWeights();
296  void clearWeightedEvbEvents();
297  int nextWeightedServer(int seq, int token);
298 
299  int nevbs;
300  int evb4token[4096];
301 
302  int force_vlan;
303 };
304 
305 #define RHIC_TRG "RHICTRG\0"
306 #define RHIC_TRG2 "RHICTRG2"
307 #define TRG_UDP_PORT 8060
308 #define TRG_UDP_PORT2 8061
309 
310 struct RHIC_Trigger {
311  char marker[8];
312  int idx; // which counter
313  int type; // 1 counter, 2 scaler
314  int source; // 0 - 20 (evb), 100 (L0)
315  float value; // the value...
316 };
317 
319  char marker[8];
320  UINT32 evttime;
321  UINT32 tmslice;
322  UINT32 type;
323  UINT32 source;
324  float v0, v1, v2, v3;
325 };
326 
328  float ps[TRIGGERS_MAX];
329  float measured_rate[TRIGGERS_MAX];
330 
331  float trgDet_ps;
332 
333  float py_ps[TRIGGERS_MAX];
334  float py_desiredRate[TRIGGERS_MAX];
335  float py_scalerRate[TRIGGERS_MAX];
336  float py_predictedRate[TRIGGERS_MAX];
337 
338  float measuredFrequency;
339 };
340 
341 #define HLT_UDP_PORT 8062
342 
344  int run_number;
345  int nprimary;
346  float xvertex;
347  float yvertex;
348  float zvertex;
349 };
350 #endif
351 
352 
353 
354 
355 
Definition: iccp.h:685