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