StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rtsSystems.h
1 #ifndef _RTS_SYSTEMS_H_
2 #define _RTS_SYSTEMS_H_
3 
4 #include <stdio.h>
5 #include <sys/types.h>
6 //#include <rtsLog.h>
7 
8 /*
9  HISTORY:
10  * 11/06/2000, Tonko, completelly revamped from daqSystems.h
11 
12 */
13 
14 
15 
16 /*
17  Tonko, 7/13/00, added the Trigger's detector Bitmask (as found in EventDescriptor)
18  THIS SHOULD BE MAINTAINED BY TRIGGER!!!!!
19 
20  Tonko, 5/8/01, added FPD and moved EMC to 6 and added SMD at old EMCs place
21  John, 8/7/01, replaced RICH with SSD and moved down ETOW, ESMD and PMD into
22  region 0-13 which is the region of valid LIVE
23  John, 10/23/02 Updated TRG_xxx_INSTANCE and TRG_xxx_NODEID (Jeff consulted)
24  Tonko, 10/07/03 Untangled BTOW, BSMD, ETOW & ESMD and retired EMC names...
25 */
26 
27 /* This is _obsolete_ */
28 #define TRG_TPC_BIT 0
29 
30 #define TRG_SVT_BIT 1
31 
32 #define TRG_BSMD_BIT 2
33 
34 #define TRG_FTPC_BIT 3
35 
36 #define TRG_TOF_BIT 4
37 
38 #define TRG_SSD_BIT 5 // used to be RICH
39 
40 #define TRG_BTOW_BIT 6
41 #define TRG_EMC_BIT TRG_BTOW_BIT // use "BTOW"
42 
43 #define TRG_FPD_BIT 7
44 #define TRG_FP2_BIT TRG_FPD_BIT // same bit as for older FPD
45 
46 #define TRG_ETOW_BIT 8
47 #define TRG_EEC_BIT TRG_ETOW_BIT // use "ETOW"
48 
49 #define TRG_ESMD_BIT 9
50 
51 #define TRG_PMD_BIT 10
52 
53 //#define TRG_MWC_BIT 11
54 
55 #define TRG_CTB_BIT 14 // does not have a LIVE bit
56 
57 #define TRG_BBC_BIT 15 // does not have a LIVE bit
58 
59 
60 
61 /* TCD IDs - slot positions in the TCD crate */
62 #define TCD_ESMD 6
63 #define TCD_BBC 7
64 #define TCD_ETOW 8
65 #define TCD_SSD 9
66 #define TCD_FPD 10
67 #define TCD_TOF 11 //
68 #define TCD_SVT 12 //
69 #define TCD_SVT_CD 13 // SVT's cable driver slot
70 #define TCD_MIX 14
71 #define TCD_BSMD 15 //
72 #define TCD_CTB 16
73 #define TCD_BTOW 17 //
74 #define TCD_FTPC 18 //
75 #define TCD_PMD 19 //
76 #define TCD_TPC 20 //
77 #define TCD_VPD 21 // Tonko,March07,instead of: TPC's cable driver slot
78 
79 #define TCD_HFT TCD_TPC // for now HFT uses TPC TCD???
80 #define TCD_TPX TCD_TPC // 2007: TPX uses TCP
81 
82 // Trigger Detector groupings...
83 #define TPC_GRP 0
84 #define FPD_GRP 1
85 #define TOF_GRP 2
86 #define SSD_GRP 7
87 #define BTOW_GRP 3
88 #define BSMD_GRP 4
89 #define ETOW_GRP 5
90 #define ESMD_GRP 6
91 #define PMD_GRP 7
92 
93 /* RTS Node Id, Tonko, 11/06/2000
94 
95 The RTS Node Id is a 16 bit identifier which is used to uniquelly determine
96 a particular node in the STAR RTS tree. At the same time it is used by the
97 myrinet libraries.
98 
99 To make life sane these 16 bits are partitioned into 4 subfields according
100 to the bits:
101 
102 SYSTEM <= 10 or SYSTEM=15 (regular)
103 
104 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
105 
106 SYSTEM---> ROUTE SUBSYS INSTANCE-------------->
107 
108 10 < SYSTEM < 20 (EXT)
109 
110 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
111 
112 EXT-------> x x System------------> INSTANCE->
113 
114 20 <= SYSTEM < 32 (EXT2)
115 
116 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
117 
118 EXT2------> SYSTEM----------> INSTANCE----------->
119 
120 
121 SYSTEM is 4 bits, ROUTE is 2 bits, SUBSYSTEM is 2 bits and the particular
122 INSTANCE is 8 bits. The INSTANCE itself can be any number from (0-255) and
123 thus can additionally be sub-partitioned if this makes sense and adds to
124 human readability.
125 
126 SYSTEM is either DAQ, TRG, SC or L3 as well as all the detectors. Generally
127 it should correspond to the bit in DAQ EVB's DATAP bank under "detectors
128 presence bits" word.
129 
130 ROUTE is a Myrinet concept and should be 0 for all the systems where Myrinet
131 makes no sense. SUBSYS depends on the SYSTEM and can be used if it makes
132 sense. INSTANCE is just the count of nodes. This should generally _not_
133 start with 0 i.e. node called TPC01 should have a '1' as the INSTANCE.
134 
135 There are 2 reserved NodeIds:
136  0x0000
137  0xFFFF
138 
139 0x0000 is used to mean "self" in various subroutines and 0xFFFF is used to
140 mean ERROR or UNKNOWN in other misc. parts of code.
141 
142 */
143 
144 
145 /* special nodes */
146 #define LOCALHOST_NODE 0
147 #define MY_NODE 0
148 #define ERROR_NODE 0xFFFF /* -1 */
149 
150 
151 /*
152 Known RTS systems. For historical reasons, the detectors used to use XXX_ID
153 so we keep it here for source compatibility
154 */
155 
156 #define TPC_SYSTEM 0
157 #define TPC_ID TPC_SYSTEM
158 
159 #define SVT_SYSTEM 1
160 #define SVT_ID SVT_SYSTEM
161 
162 #define TOF_SYSTEM 2
163 #define TOF_ID TOF_SYSTEM
164 
165 /* this is just the Barrel Tower EMC! */
166 #define BTOW_SYSTEM 3
167 #define BTOW_ID BTOW_SYSTEM
168 
169 
170 /* Frozen as of 8/2002, Tonko */
171 #define FPD_SYSTEM 4
172 #define FPD_ID FPD_SYSTEM
173 
174 #define FTP_SYSTEM 5
175 #define FTP_ID FTP_SYSTEM
176 
177 /* extendes the post-April 2002 systems */
178 #define EXT_SYSTEM 6
179 #define EXT_ID EXT_SYSTEM
180 
181 /* Frozen as of 8/2002, Tonko */
182 #define RIC_SYSTEM 7
183 #define RIC_ID RIC_SYSTEM
184 
185 #define TRG_SYSTEM 8
186 #define TRG_ID TRG_SYSTEM
187 
188 #define L3_SYSTEM 9
189 #define L3_ID L3_SYSTEM
190 
191 #define SC_SYSTEM 10 /* slow controls */
192 #define SC_ID SC_SYSTEM
193 
194 /* Reserver for super-future extensions */
195 #define EXT2_SYSTEM 11
196 #define EXT2_ID EXT2_SYSTEM
197 
198 #define PMD_SYSTEM 12
199 #define PMD_ID PMD_SYSTEM
200 
201 #define SSD_SYSTEM 13
202 #define SSD_ID SSD_SYSTEM
203 
204 /* Endcap Tower!*/
205 #define ETOW_SYSTEM 14
206 #define ETOW_ID ETOW_SYSTEM
207 
208 #define DAQ_SYSTEM 15
209 #define DAQ_ID DAQ_SYSTEM
210 #define RTS_SYSTEM DAQ_SYSTEM /* global */
211 
212 // the "new" (2002-03) FPD
213 #define FP2_SYSTEM 16
214 #define FP2_ID FP2_SYSTEM
215 
216 #define PP_SYSTEM 17 /* pp2pp */
217 #define PP_ID PP_SYSTEM
218 
219 #define BSMD_SYSTEM 18
220 #define BSMD_ID BSMD_SYSTEM
221 
222 #define ESMD_SYSTEM 19
223 #define ESMD_ID ESMD_SYSTEM
224 
225 #define TPX_SYSTEM 20
226 #define TPX_ID TPX_SYSTEM /* DAQ1000 detector */
227 
228 #define HFT_SYSTEM 21
229 #define HFT_ID HFT_SYSTEM /* Heavy Flavor Tracker */
230 
231 #define RTS_NUM_SYSTEMS 22 /* current maximum. Can not be greater than 32! */
232 
233 #define PP_SEQE_INSTANCE 1
234 #define PP_SEQW_INSTANCE 2
235 #define PP_TRG_INSTANCE 3
236 #define PP_TEST_INSTANCE 4
237 
238 /*
239  Subsystems (These are overloaded for each system)
240 */
241 
242 #define TRG_L1_SUBSYS 1
243 #define TRG_L2_SUBSYS 2
244 
245 #define GL3_SUBSYS 1
246 #define SL3_SUBSYS 2
247 
248 #define EVB_SUBSYS 1
249 #define GB_SUBSYS 2
250 
251 /*
252  Instances (overloaded for each system)
253 */
254 
255 #ifndef RTS_PROJECT_PP
256 #define DAQMAN_INSTANCE 1
257 #endif
258 
259 #define BB_INSTANCE 2
260 
261 #ifndef RTS_PROJECT_PP
262 #define EVP_INSTANCE 3
263 #endif
264 
265 //#define GB_INSTANCE 4
266 #define BDB_INSTANCE 4 // we'll keep the BDB controller's node_id the same...
267 
268 #define BB2_INSTANCE 5
269 //#define TM_INSTANCE GB_INSTANCE
270 #define EVB_INSTANCE BB_INSTANCE
271 #define EVB02_INSTANCE BB2_INSTANCE
272 #define RC_CLIENT_INSTANCE 14
273 #define CLIENT_INSTANCE 15
274 
275 
276 #ifdef RTS_PROJECT_PP
277 #define DAQMAN_INSTANCE BB_INSTANCE
278 #define EVP_INSTANCE BB_INSTANCE
279 #endif
280 
281 #define TRG_INSTANCE 1
282 #define TRG_L1_INSTANCE 2
283 #define TRG_L2_INSTANCE 3
284 #define TRG_TCD_INSTANCE 4
285 #define TRG_RCC_INSTANCE 5
286 #define TRG_CTB_INSTANCE 6
287 // #define TRG_EEC_INSTANCE 7 jml Aug 21,03
288 #define TRG_SCALER48_INSTANCE 7
289 #define TRG_MIX_INSTANCE 8
290 #define TRG_BC1_INSTANCE 9
291 #define TRG_BCE_INSTANCE 10
292 #define TRG_BCW_INSTANCE 11
293 #define TRG_SCALER_INSTANCE 12
294 #define TRG_BBC_INSTANCE 13
295 #define TRG_FPE_INSTANCE 14
296 #define TRG_FMS_INSTANCE 15
297 #define TRG_L0_INSTANCE 16 // Tonko. Feb25,03
298 #define TRG_QT1_INSTANCE 17
299 #define TRG_QT2_INSTANCE 18
300 #define TRG_QT3_INSTANCE 19
301 #define TRG_QT4_INSTANCE 20
302 
303 #define L3EVP_INSTANCE 1
304 #define L3DISP_INSTANCE 2
305 
306 /******************** RC/DAQ nodes ****************/
307 /* Tonko, Jun 6, 2003 - EVB & GB extensions */
308 /*
309  Tonko Comments:
310 
311  EVB) the Linux based EVBs will be EVB_NODES(1)... and
312  we keep the old names...
313  GB) the new Linux GB will be GB_NODES(1) and the old MVME
314  in the main crate will continue to be called
315  BDB_NODE
316 */
317 #define EVB_NODES(x) ((DAQ_SYSTEM<<12) | (EVB_SUBSYS<<8) | (x))
318 #define GB_NODES(x) ((DAQ_SYSTEM<<12) | (GB_SUBSYS<<8 ) | (x))
319 #define GB_NODE GB_NODES(1)
320 
321 
322 #define BB_NODE ((DAQ_SYSTEM<<12) | BB_INSTANCE)
323 
324 #ifdef RTS_PROJECT_PP
325 
326 #define DAQMAN_NODE BB_NODE
327 #define EVP_NODE BB_NODE
328 #define BB2_NODE BB_NODE
329 
330 #else
331 
332 #define DAQMAN_NODE ((DAQ_SYSTEM<<12) | DAQMAN_INSTANCE)
333 #define EVP_NODE ((DAQ_SYSTEM<<12) | EVP_INSTANCE)
334 #define BB2_NODE ((DAQ_SYSTEM<<12) | BB2_INSTANCE)
335 
336 #endif
337 
338 /* aliases and shortcuts */
339 #define RC_NODE DAQMAN_NODE /* for the time being...*/
340 #define LOG_NODE DAQMAN_NODE
341 #define MON_NODE DAQMAN_NODE
342 
343 
344 #define RC_CLIENT_NODE ((DAQ_SYSTEM<<12) | RC_CLIENT_INSTANCE)
345 #define CLIENT_NODE ((DAQ_SYSTEM<<12) | CLIENT_INSTANCE)
346 
347 // Tonko: changed this, Nov 4, 2003
348 //#define EVB01_NODE BB_NODE
349 //#define EVB02_NODE BB2_NODE
350 //#define EVB_NODE EVB01_NODE
351 // this will also go away!
352 #define EVB_NODE EVB_NODES(1)
353 
354 
355 #define BDB_NODE ((DAQ_SYSTEM<<12) | BDB_INSTANCE) // old GB...
356 
357 /* singular detectors */
358 #define RIC01_NODE ((RIC_SYSTEM<<12) | 1)
359 #define RIC02_NODE ((RIC_SYSTEM<<12) | 2)
360 #define RIC_NODE RIC01_NODE
361 
362 #define TOF01_NODE ((TOF_SYSTEM<<12) | 1) // DAQ end
363 #define TOF02_NODE ((TOF_SYSTEM<<12) | 2) // Platform
364 #define TOF03_NODE ((TOF_SYSTEM<<12) | 3) // new, test node
365 #define TOF_NODE TOF01_NODE
366 #define TOF_NODES ((TOF_SYSTEM<<12) | (x)) // shorthand
367 
368 #define FPD01_NODE ((FPD_SYSTEM<<12) | 1)
369 #define FPD02_NODE ((FPD_SYSTEM<<12) | 2)
370 #define FPD_NODE FPD01_NODE
371 /* added IP steering */
372 #define FPD_DEST_HOST "gb.daq.bnl.local"
373 #define FPD_PORT 5211
374 
375 /* multi-node detectors */
376 #define TPC_NODES(x) ((TPC_SYSTEM<<12) | (x))
377 
378 #define FTP_NODES(x) ((FTP_SYSTEM<<12) | (x))
379 
380 #define SVT_NODES(x) ((SVT_SYSTEM<<12) | (x))
381 
382 /* separated the Endcap (EEC) from the Barrel (EMC), Tonko, 4/4/2002 */
383 /* Barrel */
384 
385 #define BTOW_NODE ((BTOW_SYSTEM<<12) | 1)
386 
387 #define BSMD_NODE ((EXT_SYSTEM<<12)|(BSMD_SYSTEM<<4)|1)
388 #define BSMD_NODES(x) ((EXT_SYSTEM<<12)|(BSMD_SYSTEM<<4) | (x)) /* Tonko, split into 3 crates */
389 
390 #define BPRE_NODE ((BTOW_SYSTEM<<12) | 2) /* NOT really known yet! */
391 
392 /* Extended (post April 2002) Detectors */
393 #define PMD01_NODE ((EXT_SYSTEM<<12)|(PMD_SYSTEM<<4) | 1)
394 #define PMD02_NODE ((EXT_SYSTEM<<12)|(PMD_SYSTEM<<4) | 2)
395 #define PMD03_NODE ((EXT_SYSTEM<<12)|(PMD_SYSTEM<<4) | 3)
396 #define PMD_NODES(x) ((EXT_SYSTEM<<12)|(PMD_SYSTEM<<4) | (x))
397 /* the main node is PMD03 */
398 #define PMD_NODE PMD03_NODE
399 /* Added TCP/IP steering */
400 #define PMD_DEST_HOST "gb.daq.bnl.local"
401 #define PMD_PORT_1 5201
402 #define PMD_PORT_2 5202 // becomes 5202 soon!
403 
404 #define SSD01_NODE ((EXT_SYSTEM<<12)|(SSD_SYSTEM<<4) | 1)
405 #define SSD_NODE SSD01_NODE
406 
407 
408 #define FP201_NODE ((EXT_SYSTEM<<12)|(FP2_SYSTEM<<4) | 1)
409 #define FP2_NODE FP201_NODE
410 
411 /* Endcap */
412 
413 #define ETOW_NODE ((EXT_SYSTEM<<12)|(ETOW_SYSTEM<<4)|1)
414 #define ESMD_NODE ((EXT_SYSTEM<<12)|(ESMD_SYSTEM<<4)|1)
415 
416 
417 /* Level III */
418 #define L3_NODES(x) ((L3_SYSTEM<<12) | (SL3_SUBSYS<<8) | (x))
419 #define SL3_NODES(x) ((L3_SYSTEM<<12) | (SL3_SUBSYS<<8) | (x))
420 #define GL3_NODES(x) ((L3_SYSTEM<<12) | (GL3_SUBSYS<<8) | (x))
421 #define L3EVP_NODE ((L3_SYSTEM<<12) | 1)
422 #define L3DISP_NODE ((L3_SYSTEM<<12) | 2)
423 #define GL3_NODE GL3_NODES(1)
424 
425 /* Trigger */
426 #define TRG_NODE ((TRG_SYSTEM<<12) | TRG_INSTANCE)
427 #define TRG_L1_NODE ((TRG_SYSTEM<<12) | TRG_L1_INSTANCE)
428 //#define TRG_L2_NODE ((TRG_SYSTEM<<12) | TRG_L2_INSTANCE)
429 #define TRG_L2_NODE ((TRG_SYSTEM<<12) | (TRG_L2_SUBSYS<<8) | (1))
430 #define TRG_TCD_NODE ((TRG_SYSTEM<<12) | TRG_TCD_INSTANCE)
431 #define TRG_RCC_NODE ((TRG_SYSTEM<<12) | TRG_RCC_INSTANCE)
432 #define TRG_CTB_NODE ((TRG_SYSTEM<<12) | TRG_CTB_INSTANCE)
433 #define TRG_L1_NODES(x) ((TRG_SYSTEM<<12) | (TRG_L1_SUBSYS<<8) | (x))
434 #define TRG_L2_NODES(x) ((TRG_SYSTEM<<12) | (TRG_L2_SUBSYS<<8) | (x))
435 #define TRG_MIX_NODE ((TRG_SYSTEM<<12) | TRG_MIX_INSTANCE)
436 #define TRG_BC1_NODE ((TRG_SYSTEM<<12) | TRG_BC1_INSTANCE)
437 #define TRG_BCE_NODE ((TRG_SYSTEM<<12) | TRG_BCE_INSTANCE)
438 #define TRG_BCW_NODE ((TRG_SYSTEM<<12) | TRG_BCW_INSTANCE)
439 #define TRG_SCALER_NODE ((TRG_SYSTEM<<12) | TRG_SCALER_INSTANCE)
440 #define TRG_BBC_NODE ((TRG_SYSTEM<<12) | TRG_BBC_INSTANCE)
441 #define TRG_FPE_NODE ((TRG_SYSTEM<<12) | TRG_FPE_INSTANCE)
442 #define TRG_FMS_NODE ((TRG_SYSTEM<<12) | TRG_FMS_INSTANCE)
443 #define TRG_L0_NODE ((TRG_SYSTEM<<12) | TRG_L0_INSTANCE) // Tonko, Feb25,03
444 #define TRG_QT1_NODE ((TRG_SYSTEM<<12) | TRG_QT1_INSTANCE)
445 #define TRG_QT2_NODE ((TRG_SYSTEM<<12) | TRG_QT2_INSTANCE)
446 #define TRG_QT3_NODE ((TRG_SYSTEM<<12) | TRG_QT3_INSTANCE)
447 #define TRG_QT4_NODE ((TRG_SYSTEM<<12) | TRG_QT4_INSTANCE)
448 
449 #define TRG_SCALER48_NODE ((TRG_SYSTEM<<12) | TRG_SCALER48_INSTANCE)
450 
451 /* Temporary... for zoran...*/
452 #define TDI_NODE ((TRG_SYSTEM<<12) | TRG_TDI_INSTANCE)
453 
454 #define L201_NODE TRG_L2_NODES(1)
455 
456 /* Slow Controls */
457 #define SC_NODE ((SC_SYSTEM<<12) | 1)
458 
459 /* PP2PP */ /* IGNORED for STAR 2007+ runs! */
460 #define PP_SEQE_NODE ((EXT_SYSTEM<<12) | ((PP_SYSTEM)<<4) | PP_SEQE_INSTANCE)
461 
462 /* this is known as Sector1 aka ppdaq2 aka Yellow */
463 #define PP_SEQ1_NODE PP_SEQE_NODE
464 
465 #define PP_SEQW_NODE ((EXT_SYSTEM<<12) | ((PP_SYSTEM)<<4) | PP_SEQW_INSTANCE)
466 /* this is known as Sector2 aka ppdaq5 aka Blue */
467 #define PP_SEQ2_NODE PP_SEQW_NODE
468 
469 #define PP_TRG_NODE ((EXT_SYSTEM<<12) | ((PP_SYSTEM)<<4) | PP_TRG_INSTANCE)
470 #define PP_TEST_NODE ((EXT_SYSTEM<<12) | ((PP_SYSTEM)<<4) | PP_TEST_INSTANCE)
471 
472 /* Tonko, Aug 2007, ready for 2007 */
473 #define PP_NODES(x) ((EXT_SYSTEM<<12) | ((PP_SYSTEM)<<4) | (x))
474 
475 #define TPX_NODES(x) ((EXT2_SYSTEM<<12) | ((TPX_SYSTEM)<<7) | (x))
476 #define HFT_NODES(x) ((EXT2_SYSTEM<<12) | ((HFT_SYSTEM)<<7) | (x))
477 
478 
479 extern inline const char *rts2name(int rts_id)
480 {
481  switch(rts_id) {
482  case TPC_SYSTEM :
483  return "TPC" ;
484  case SVT_SYSTEM :
485  return "SVT" ;
486  case TOF_SYSTEM :
487  return "TOF" ;
488  case BTOW_SYSTEM :
489  return "BTOW" ;
490  case FPD_SYSTEM :
491  return "FPD" ;
492  case FTP_SYSTEM :
493  return "FTP" ;
494  case PMD_SYSTEM :
495  return "PMD" ;
496  case SSD_SYSTEM :
497  return "SSD" ;
498  case ETOW_SYSTEM :
499  return "ETOW" ;
500  case FP2_SYSTEM : // watch it!
501  return "FP2" ;
502  case BSMD_SYSTEM :
503  return "BSMD" ;
504  case ESMD_SYSTEM :
505  return "ESMD" ;
506  case DAQ_SYSTEM :
507  return "DAQ" ;
508  case TRG_SYSTEM :
509  return "TRG" ;
510  case L3_SYSTEM :
511  return "L3" ;
512  case SC_SYSTEM :
513  return "SC" ;
514  case TPX_SYSTEM :
515  return "TPX" ;
516  case HFT_SYSTEM :
517  return "HFT" ;
518  case PP_SYSTEM :
519  return "PP2PP" ;
520  default :
521  return NULL ; // unknown!
522  }
523 } ;
524 
525 extern inline int rts2det(int ix)
526 {
527  switch(ix) {
528  case TPC_ID :
529  case SVT_ID :
530  case TOF_ID :
531  case BTOW_ID :
532  case FPD_ID :
533  case FTP_ID :
534  case PMD_ID :
535  case SSD_ID :
536  case ETOW_ID :
537  case BSMD_ID :
538  case ESMD_ID :
539  case TPX_ID :
540  case HFT_ID :
541  case PP_ID :
542  return ix ;
543  default :
544  return -1 ;
545  }
546 
547 }
548 
549 extern inline int rts2tcd(int rts)
550 {
551  static const int map[32] = {
552  TCD_TPC,
553  TCD_SVT,
554  TCD_TOF,
555  TCD_BTOW,
556  TCD_FPD,
557  TCD_FTPC,
558  -1,
559  -1,
560  -1,
561  -1,
562  -1,
563  -1,
564  TCD_PMD,
565  TCD_SSD,
566  TCD_ETOW,
567  -1,
568  TCD_FPD,
569  -1,
570  TCD_BSMD,
571  TCD_ESMD,
572  TCD_TPX, /* TPX */
573  TCD_HFT,
574  -1,
575  -1,
576  -1,
577  -1,
578  } ;
579 
580  return map[rts] ;
581 
582 }
583 
584 extern inline int tcd2rts(int tcd)
585 {
586  static int map[32] = {
587  -1,
588  -1,
589  -1,
590  -1,
591  -1,
592  -1,
593  ESMD_SYSTEM,
594  -1,
595  ETOW_SYSTEM,
596  SSD_SYSTEM,
597  FPD_SYSTEM,
598  TOF_SYSTEM,
599  SVT_SYSTEM,
600  -1,
601  -1,
602  BSMD_SYSTEM,
603  -1,
604  BTOW_SYSTEM,
605  FTP_SYSTEM,
606  PMD_SYSTEM,
607  TPC_SYSTEM,
608  -1,
609  -1,
610  -1,
611  -1,
612  -1,
613  -1
614  -1,
615  -1,
616  -1,
617  -1,
618  -1,
619  -1
620  };
621 
622 // LOG(WARN,"tcd2rts: tcd %d, rts %d",tcd,map[tcd],0,0,0) ;
623  return map[tcd] ;
624 } ;
625 
626 
627 extern inline u_int grp2rts_mask(int grp)
628 {
629  u_int ret ;
630 
631  ret = 0 ;
632 
633  if(grp & (1<<TPC_GRP)) {
634  ret = (1<<TPC_SYSTEM) | (1<<SVT_SYSTEM) | (1<<FTP_SYSTEM) | (1<<TOF_SYSTEM) | (1<<TPX_SYSTEM) | (1<<HFT_SYSTEM) | (1<<PP_SYSTEM);
635  }
636  if(grp & (1<<SSD_GRP)) {
637  ret |= (1<<SSD_SYSTEM) ;
638  }
639  if(grp & (1<<PMD_GRP)) {
640  ret |= (1<<PMD_SYSTEM) ;
641  }
642  if(grp & (1<<ETOW_GRP)) {
643  ret |= (1<<ETOW_SYSTEM) ;
644  }
645  if(grp & (1<<ESMD_GRP)) {
646  ret |= (1<<ESMD_SYSTEM) ;
647  }
648  if(grp & (1<<BTOW_GRP)) {
649  ret |= (1<<BTOW_SYSTEM) ;
650  }
651  if(grp & (1<<BSMD_GRP)) {
652  ret |= (1<<BSMD_SYSTEM) ;
653  }
654  if(grp & (1<<FPD_GRP)) {
655  ret |= (1<<FPD_SYSTEM) ;
656  }
657 
658  return ret ;
659 }
660 
661 // goes from the RTS_SYSTEM id to the GRP id
662 extern inline int rts2grp(int rts)
663 {
664  switch(rts)
665  {
666  // Instance doesn't matter...
667  case TPC_ID:
668  case SVT_ID:
669  case FTP_ID:
670  case TOF_ID:
671  case PP_ID :
672  return TPC_GRP ;
673  case SSD_ID: return SSD_GRP;
674  case FPD_ID: return FPD_GRP;
675  case FP2_ID: return FPD_GRP;
676  case BTOW_ID: return BTOW_GRP;
677  case BSMD_ID: return BSMD_GRP;
678  case ETOW_ID: return ETOW_GRP;
679  case ESMD_ID: return ESMD_GRP;
680  case PMD_ID: return PMD_GRP;
681  case TPX_ID: return TPC_GRP;
682  case HFT_ID: return TPC_GRP;
683  default:
684  return 15 ; // this is an ERROR!
685  }
686 }
687 
688 
689 /*
690  Inverse's...
691 
692  MODIFIED FOR POST-APRIL02 EXT. DETECTORS! Tonko
693 */
694 
695 extern inline int GET_NODE(int sys, int subsys, int inst)
696 {
697  int node ;
698 
699  if((sys <= 10) || (sys==15)) {
700  node = (sys<<12) | (subsys<<8) | (inst);
701  }
702  else if (sys < 20) {
703  node = (EXT_SYSTEM << 12) | (sys<<4) | (inst);
704  }
705  else {
706  node = (EXT2_SYSTEM << 12) | (sys<<7) | (inst);
707  }
708 
709  return node ;
710 } ;
711 
712 extern inline int GET_SYSTEM(unsigned short node)
713 {
714  int id;
715  id = (node & 0xf000) >> 12;
716 
717  if(id == EXT_SYSTEM) return (node & 0x03f0) >> 4;
718  if(id == EXT2_SYSTEM) return (node & 0x0f80) >> 7;
719  return id;
720 }
721 
722 extern inline int GET_INSTANCE(unsigned short node)
723 {
724  int id;
725 
726  id = (node & 0xf000) >> 12;
727  if(id == EXT_SYSTEM) return node & 0xf;
728  if(id == EXT2_SYSTEM) return node & 0x7f;
729  return node & 0xff;
730 }
731 
732 extern inline int GET_SUBSYSTEM(unsigned short node)
733 {
734  int id = (node & 0xf000) >> 12;
735 
736  if(id == EXT_SYSTEM) return 0;
737  if(id == EXT2_SYSTEM) return 0;
738  return (node & 0x0300) >> 8;
739 }
740 
741 #define GET_NODE_PRE_APR2002(sys,subsys,inst) ((sys<<12) | (subsys<<8) | (inst))
742 #define GET_SYSTEM_PRE_APR2002(x) (((x) >> 12) & 0xf)
743 #define GET_INSTANCE_PRE_APR2002(x) ((x) & 0xff)
744 #define GET_SUBSYSTEM_PRE_APR2002(x) (((x) >> 8) & 0x3)
745 
746 #define GET_ROUTE(x) (((x) >> 10) & 0x3)
747 
748 #endif /* _RTS_SYSTEMS_H_ */
749 
750 
751