Bug fix by Theodor
[u/mrichter/AliRoot.git] / TRD / AliTRDtrapConfig.h
1 #ifndef ALITRDTRAPCONFIG_H\r
2 #define ALITRDTRAPCONFIG_H\r
3 \r
4 #include <TObject.h>\r
5 #include <TString.h>\r
6 #include <TClonesArray.h>\r
7 \r
8 class AliTRDtrapConfig : public TObject\r
9 {\r
10  public:\r
11   static AliTRDtrapConfig* Instance();\r
12 \r
13   enum TrapReg_t { kSML0, \r
14                   kSML1, \r
15                   kSML2,\r
16                   kSMMODE,\r
17                   kNITM0,\r
18                   kNITM1,\r
19                   kNITM2,\r
20                   kNIP4D,\r
21                   kCPU0CLK,\r
22                   kCPU1CLK,\r
23                   kCPU2CLK,\r
24                   kCPU3CLK,\r
25                   kNICLK,\r
26                   kFILCLK,\r
27                   kPRECLK,\r
28                   kADCEN,\r
29                   kNIODE,\r
30                   kNIOCE,\r
31                   kNIIDE,\r
32                   kNIICE,\r
33                   kARBTIM,      \r
34                   kIA0IRQ0,     \r
35                   kIA0IRQ1,     \r
36                   kIA0IRQ2,     \r
37                   kIA0IRQ3,     \r
38                   kIA0IRQ4,     \r
39                   kIA0IRQ5,     \r
40                   kIA0IRQ6,     \r
41                   kIA0IRQ7,     \r
42                   kIA0IRQ8,     \r
43                   kIA0IRQ9,     \r
44                   kIA0IRQA,     \r
45                   kIA0IRQB,     \r
46                   kIA0IRQC,     \r
47                   kIRQSW0,      \r
48                   kIRQHW0,      \r
49                   kIRQHL0,      \r
50                   kIA1IRQ0,     \r
51                   kIA1IRQ1,     \r
52                   kIA1IRQ2,     \r
53                   kIA1IRQ3,     \r
54                   kIA1IRQ4,     \r
55                   kIA1IRQ5,     \r
56                   kIA1IRQ6,     \r
57                   kIA1IRQ7,     \r
58                   kIA1IRQ8,     \r
59                   kIA1IRQ9,     \r
60                   kIA1IRQA,     \r
61                   kIA1IRQB,     \r
62                   kIA1IRQC,     \r
63                   kIRQSW1,      \r
64                   kIRQHW1,      \r
65                   kIRQHL1,      \r
66                   kIA2IRQ0,     \r
67                   kIA2IRQ1,     \r
68                   kIA2IRQ2,     \r
69                   kIA2IRQ3,     \r
70                   kIA2IRQ4,     \r
71                   kIA2IRQ5,     \r
72                   kIA2IRQ6,     \r
73                   kIA2IRQ7,     \r
74                   kIA2IRQ8,     \r
75                   kIA2IRQ9,     \r
76                   kIA2IRQA,     \r
77                   kIA2IRQB,     \r
78                   kIA2IRQC,     \r
79                   kIRQSW2,      \r
80                   kIRQHW2,      \r
81                   kIRQHL2,      \r
82                   kIA3IRQ0,     \r
83                   kIA3IRQ1,     \r
84                   kIA3IRQ2,     \r
85                   kIA3IRQ3,     \r
86                   kIA3IRQ4,     \r
87                   kIA3IRQ5,     \r
88                   kIA3IRQ6,     \r
89                   kIA3IRQ7,     \r
90                   kIA3IRQ8,     \r
91                   kIA3IRQ9,     \r
92                   kIA3IRQA,     \r
93                   kIA3IRQB,     \r
94                   kIA3IRQC,     \r
95                   kIRQSW3,      \r
96                   kIRQHW3,      \r
97                   kIRQHL3,      \r
98                   kCTGDINI,     \r
99                   kCTGCTRL,     \r
100                   kC08CPU0,     \r
101                   kC09CPU0,     \r
102                   kC10CPU0,     \r
103                   kC11CPU0,     \r
104                   kC12CPUA,     \r
105                   kC13CPUA,     \r
106                   kC14CPUA,     \r
107                   kC15CPUA,     \r
108                   kC08CPU1,     \r
109                   kC09CPU1,     \r
110                   kC10CPU1,     \r
111                   kC11CPU1,     \r
112                   kC08CPU2,     \r
113                   kC09CPU2,     \r
114                   kC10CPU2,     \r
115                   kC11CPU2,     \r
116                   kC08CPU3,     \r
117                   kC09CPU3,     \r
118                   kC10CPU3,     \r
119                   kC11CPU3,     \r
120                   kNMOD,        \r
121                   kNDLY,        \r
122                   kNED,         \r
123                   kNTRO,        \r
124                   kNRRO,        \r
125                   kNES,         \r
126                   kNTP,         \r
127                   kNBND,        \r
128                   kNP0,         \r
129                   kNP1,         \r
130                   kNP2,         \r
131                   kNP3,         \r
132                   kNCUT,        \r
133                   kTPPT0,       \r
134                   kTPFS,        \r
135                   kTPFE,        \r
136                   kTPPGR,       \r
137                   kTPPAE,       \r
138                   kTPQS0,       \r
139                   kTPQE0,       \r
140                   kTPQS1,       \r
141                   kTPQE1,       \r
142                   kEBD,         \r
143                   kEBAQA,       \r
144                   kEBSIA,       \r
145                   kEBSF,        \r
146                   kEBSIM,       \r
147                   kEBPP,        \r
148                   kEBPC,        \r
149                   kEBIS,        \r
150                   kEBIT,        \r
151                   kEBIL,        \r
152                   kEBIN,        \r
153                   kFLBY,        \r
154                   kFPBY,        \r
155                   kFGBY,        \r
156                   kFTBY,        \r
157                   kFCBY,        \r
158                   kFPTC,        \r
159                   kFPNP,        \r
160                   kFPCL,        \r
161                   kFGTA,        \r
162                   kFGTB,        \r
163                   kFGCL,        \r
164                   kFTAL,        \r
165                   kFTLL,        \r
166                   kFTLS,        \r
167                   kFCW1,        \r
168                   kFCW2,        \r
169                   kFCW3,        \r
170                   kFCW4,        \r
171                   kFCW5,        \r
172                   kTPFP,        \r
173                   kTPHT,        \r
174                   kTPVT,        \r
175                   kTPVBY,       \r
176                   kTPCT,        \r
177                   kTPCL,        \r
178                   kTPCBY,       \r
179                   kTPD,         \r
180                   kTPCI0,       \r
181                   kTPCI1,       \r
182                   kTPCI2,       \r
183                   kTPCI3,       \r
184                   kADCMSK,      \r
185                   kADCINB,      \r
186                   kADCDAC,      \r
187                   kADCPAR,      \r
188                   kADCTST,      \r
189                   kSADCAZ,      \r
190                   kFGF0,        \r
191                   kFGF1,        \r
192                   kFGF2,        \r
193                   kFGF3,        \r
194                   kFGF4,        \r
195                   kFGF5,        \r
196                   kFGF6,        \r
197                   kFGF7,        \r
198                   kFGF8,        \r
199                   kFGF9,        \r
200                   kFGF10,       \r
201                   kFGF11,       \r
202                   kFGF12,       \r
203                   kFGF13,       \r
204                   kFGF14,       \r
205                   kFGF15,       \r
206                   kFGF16,       \r
207                   kFGF17,       \r
208                   kFGF18,       \r
209                   kFGF19,       \r
210                   kFGF20,       \r
211                   kFGA0,        \r
212                   kFGA1,        \r
213                   kFGA2,        \r
214                   kFGA3,        \r
215                   kFGA4,        \r
216                   kFGA5,        \r
217                   kFGA6,        \r
218                   kFGA7,        \r
219                   kFGA8,        \r
220                   kFGA9,        \r
221                   kFGA10,       \r
222                   kFGA11,       \r
223                   kFGA12,       \r
224                   kFGA13,       \r
225                   kFGA14,       \r
226                   kFGA15,       \r
227                   kFGA16,       \r
228                   kFGA17,       \r
229                   kFGA18,       \r
230                   kFGA19,       \r
231                   kFGA20,       \r
232                   kFLL00,       \r
233                   kFLL01,       \r
234                   kFLL02,       \r
235                   kFLL03,       \r
236                   kFLL04,       \r
237                   kFLL05,       \r
238                   kFLL06,       \r
239                   kFLL07,       \r
240                   kFLL08,       \r
241                   kFLL09,       \r
242                   kFLL0A,       \r
243                   kFLL0B,       \r
244                   kFLL0C,       \r
245                   kFLL0D,       \r
246                   kFLL0E,       \r
247                   kFLL0F,       \r
248                   kFLL10,       \r
249                   kFLL11,       \r
250                   kFLL12,       \r
251                   kFLL13,       \r
252                   kFLL14,       \r
253                   kFLL15,       \r
254                   kFLL16,       \r
255                   kFLL17,       \r
256                   kFLL18,       \r
257                   kFLL19,       \r
258                   kFLL1A,       \r
259                   kFLL1B,       \r
260                   kFLL1C,       \r
261                   kFLL1D,       \r
262                   kFLL1E,       \r
263                   kFLL1F,       \r
264                   kFLL20,       \r
265                   kFLL21,       \r
266                   kFLL22,       \r
267                   kFLL23,       \r
268                   kFLL24,       \r
269                   kFLL25,       \r
270                   kFLL26,       \r
271                   kFLL27,       \r
272                   kFLL28,       \r
273                   kFLL29,       \r
274                   kFLL2A,       \r
275                   kFLL2B,       \r
276                   kFLL2C,       \r
277                   kFLL2D,       \r
278                   kFLL2E,       \r
279                   kFLL2F,       \r
280                   kFLL30,       \r
281                   kFLL31,       \r
282                   kFLL32,       \r
283                   kFLL33,       \r
284                   kFLL34,       \r
285                   kFLL35,       \r
286                   kFLL36,       \r
287                   kFLL37,       \r
288                   kFLL38,       \r
289                   kFLL39,       \r
290                   kFLL3A,       \r
291                   kFLL3B,       \r
292                   kFLL3C,       \r
293                   kFLL3D,       \r
294                   kFLL3E,       \r
295                   kFLL3F,       \r
296                   kPASADEL,     \r
297                   kPASAPHA,     \r
298                   kPASAPRA,     \r
299                   kPASADAC,     \r
300                   kPASACHM,     \r
301                   kPASASTL,     \r
302                   kPASAPR1,     \r
303                   kPASAPR0,     \r
304                   kSADCTRG,     \r
305                   kSADCRUN,     \r
306                   kSADCPWR,     \r
307                   kL0TSIM,      \r
308                   kSADCEC,      \r
309                   kSADCMC,      \r
310                   kSADCOC,      \r
311                   kSADCGTB,     \r
312                   kSEBDEN,      \r
313                   kSEBDOU,      \r
314                   kTPL00,       \r
315                   kTPL01,       \r
316                   kTPL02,       \r
317                   kTPL03,       \r
318                   kTPL04,       \r
319                   kTPL05,       \r
320                   kTPL06,       \r
321                   kTPL07,       \r
322                   kTPL08,       \r
323                   kTPL09,       \r
324                   kTPL0A,       \r
325                   kTPL0B,       \r
326                   kTPL0C,       \r
327                   kTPL0D,       \r
328                   kTPL0E,       \r
329                   kTPL0F,       \r
330                   kTPL10,       \r
331                   kTPL11,       \r
332                   kTPL12,       \r
333                   kTPL13,       \r
334                   kTPL14,       \r
335                   kTPL15,       \r
336                   kTPL16,       \r
337                   kTPL17,       \r
338                   kTPL18,       \r
339                   kTPL19,       \r
340                   kTPL1A,       \r
341                   kTPL1B,       \r
342                   kTPL1C,       \r
343                   kTPL1D,       \r
344                   kTPL1E,       \r
345                   kTPL1F,       \r
346                   kTPL20,       \r
347                   kTPL21,       \r
348                   kTPL22,       \r
349                   kTPL23,       \r
350                   kTPL24,       \r
351                   kTPL25,       \r
352                   kTPL26,       \r
353                   kTPL27,       \r
354                   kTPL28,       \r
355                   kTPL29,       \r
356                   kTPL2A,       \r
357                   kTPL2B,       \r
358                   kTPL2C,       \r
359                   kTPL2D,       \r
360                   kTPL2E,       \r
361                   kTPL2F,       \r
362                   kTPL30,       \r
363                   kTPL31,       \r
364                   kTPL32,       \r
365                   kTPL33,       \r
366                   kTPL34,       \r
367                   kTPL35,       \r
368                   kTPL36,       \r
369                   kTPL37,       \r
370                   kTPL38,       \r
371                   kTPL39,       \r
372                   kTPL3A,       \r
373                   kTPL3B,       \r
374                   kTPL3C,       \r
375                   kTPL3D,       \r
376                   kTPL3E,       \r
377                   kTPL3F,       \r
378                   kTPL40,       \r
379                   kTPL41,       \r
380                   kTPL42,       \r
381                   kTPL43,       \r
382                   kTPL44,       \r
383                   kTPL45,       \r
384                   kTPL46,       \r
385                   kTPL47,       \r
386                   kTPL48,       \r
387                   kTPL49,       \r
388                   kTPL4A,       \r
389                   kTPL4B,       \r
390                   kTPL4C,       \r
391                   kTPL4D,       \r
392                   kTPL4E,       \r
393                   kTPL4F,       \r
394                   kTPL50,       \r
395                   kTPL51,       \r
396                   kTPL52,       \r
397                   kTPL53,       \r
398                   kTPL54,       \r
399                   kTPL55,       \r
400                   kTPL56,       \r
401                   kTPL57,       \r
402                   kTPL58,       \r
403                   kTPL59,       \r
404                   kTPL5A,       \r
405                   kTPL5B,       \r
406                   kTPL5C,       \r
407                   kTPL5D,       \r
408                   kTPL5E,       \r
409                   kTPL5F,       \r
410                   kTPL60,       \r
411                   kTPL61,       \r
412                   kTPL62,       \r
413                   kTPL63,       \r
414                   kTPL64,       \r
415                   kTPL65,       \r
416                   kTPL66,       \r
417                   kTPL67,       \r
418                   kTPL68,       \r
419                   kTPL69,       \r
420                   kTPL6A,       \r
421                   kTPL6B,       \r
422                   kTPL6C,       \r
423                   kTPL6D,       \r
424                   kTPL6E,       \r
425                   kTPL6F,       \r
426                   kTPL70,       \r
427                   kTPL71,       \r
428                   kTPL72,       \r
429                   kTPL73,       \r
430                   kTPL74,       \r
431                   kTPL75,       \r
432                   kTPL76,       \r
433                   kTPL77,       \r
434                   kTPL78,       \r
435                   kTPL79,       \r
436                   kTPL7A,       \r
437                   kTPL7B,       \r
438                   kTPL7C,       \r
439                   kTPL7D,       \r
440                   kTPL7E,       \r
441                   kTPL7F,       \r
442                   kMEMRW,       \r
443                   kMEMCOR,      \r
444                   kDMDELA,      \r
445                   kDMDELS,      \r
446                   kLastReg };   // enum of all TRAP registers, to be used for access to them\r
447 \r
448   inline const char* GetRegName(TrapReg_t reg)       { return fRegs[reg].name.Data(); }\r
449   inline UShort_t    GetRegAddress(TrapReg_t reg)    { return fRegs[reg].addr; }\r
450   inline UShort_t    GetRegNBits(TrapReg_t reg)      { return fRegs[reg].nbits; }\r
451   inline UInt_t      GetRegResetValue(TrapReg_t reg) { return fRegs[reg].res_val; }\r
452 \r
453   TrapReg_t          GetRegByAddress(Int_t address);\r
454 \r
455   Int_t  GetTrapReg(TrapReg_t reg, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1);\r
456   Bool_t PrintTrapReg(TrapReg_t reg, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1);\r
457   Bool_t PrintTrapAddr(Int_t addr, Int_t det = -1, Int_t rob = -1, Int_t mcm = -1);\r
458 \r
459   Bool_t SetTrapReg(TrapReg_t reg, Int_t value);\r
460   Bool_t SetTrapReg(TrapReg_t reg, Int_t value, Int_t det);\r
461   Bool_t SetTrapReg(TrapReg_t reg, Int_t value, Int_t det, Int_t rob, Int_t mcm);\r
462 \r
463   void InitRegs();\r
464   void ResetRegs();\r
465 \r
466   Bool_t LoadConfig();\r
467   Bool_t LoadConfig(Int_t det, TString filename);\r
468 \r
469   Int_t  ExtAliToAli( UInt_t dest, UShort_t linkpair, UShort_t rocType);\r
470 \r
471  protected:\r
472   static AliTRDtrapConfig *fgInstance;  // pointer to instance (singleton)\r
473 \r
474   struct SimpleReg_t {\r
475     TString   name;   // Name of the register\r
476     UShort_t  addr;    // Address in GIO of TRAP\r
477     UShort_t  nbits;   // Number of bits, from 1 to 32\r
478     UInt_t    res_val; // reset value\r
479     SimpleReg_t(char *nnn = 0, UShort_t a = 0, UShort_t n = 0, UInt_t r = 0) : \r
480       name(nnn), addr(a), nbits(n), res_val(r) {}\r
481   };\r
482 \r
483   struct RegValue_t {\r
484     enum {\r
485       kInvalid = 0,\r
486       kGlobal,\r
487       kIndividual\r
488     } state;\r
489     union {\r
490       Int_t globalValue;\r
491       Int_t *individualValue;\r
492     };\r
493   };\r
494 \r
495   SimpleReg_t fRegs[kLastReg];          // array of TRAP registers\r
496   RegValue_t fRegisterValue[kLastReg];  // array of TRAP register values in use\r
497 \r
498   Bool_t AddValues(UInt_t det, UInt_t cmd, UInt_t extali, UInt_t addr, UInt_t data);\r
499   Short_t GetRobAB( UShort_t robsel, UShort_t linkpair );  // Converts the ROB part of the extended ALICE ID to robs\r
500   Short_t ChipmaskToMCMlist( Int_t cmA, Int_t cmB, UShort_t linkpair ); // Converts the chipmask to a list of MCMs \r
501 \r
502   static const UInt_t fgkScsnCmdWrite=10;  // Command number for the write command \r
503   static const Int_t fgkMaxLinkPairs=4;    // number of linkpairs used during configuration\r
504   static const Int_t fgkMaxMcm;            // max. no. of MCMs to be treated\r
505   static const Int_t fMcmlistSize=256;     // list of MCMs to which a value has to be written\r
506 \r
507   Int_t fMcmlist[fMcmlistSize];  // stores the list of MCMs after the conversion from extAliID -> AliID\r
508 \r
509   AliTRDtrapConfig(); // private constructor due to singleton implementation\r
510 \r
511 /* not yet used\r
512   struct BlockDescr_t {\r
513     UShort_t addr;\r
514     UShort_t nregs;\r
515     UShort_t nbits;\r
516     UShort_t step;\r
517   };\r
518 \r
519   struct CmdReg_t {\r
520     char *name;\r
521     UShort_t addr;\r
522   };\r
523 \r
524   enum DbankProp_t { kDBankEmpty = 0,\r
525                     kDBankHeader,\r
526                     kDBankData,\r
527                     kDBankNoB,\r
528                     kDBankCRC,\r
529                     kDBankEHeader,\r
530                     kDBankSCSNData };\r
531 */\r
532 \r
533   ClassDef(AliTRDtrapConfig, 2);\r
534 };\r
535 \r
536 #endif\r
537 \r