Fixes for reading zero-suppressed data. These should be propagated to
[u/mrichter/AliRoot.git] / FMD / scripts / TestHWMap.C
CommitLineData
bf000c32 1//____________________________________________________________________
2//
3// $id$
4//
5// Check integrety of Hardware2Detector and Detector2Hardware
6//
9b48326f 7/** @defgroup HW_Test Hardware map test
8 @ingroup FMD_script
9*/
bf000c32 10//____________________________________________________________________
9b48326f 11/** @ingroup HW_test
12 @param ddl
13 @param hwaddr
14 @return */
bf000c32 15Char_t*
16Addr2Str(UInt_t ddl, UInt_t hwaddr)
17{
18 static TString s;
19 UInt_t board = (hwaddr >> 7) & 0x1F;
20 UInt_t chip = (hwaddr >> 4) & 0x7;
21 UInt_t chan = hwaddr & 0xF;
22 s = Form("(0x%05X,0x%02X,0x%1X,0x%1X)", ddl, board, chip, chan);
23 return s.Data();
24}
25
26//____________________________________________________________________
9b48326f 27/** @ingroup HW_test
28 @param det
29 @param ring
30 @param sec
31 @param str
32 @return */
bf000c32 33Char_t*
34Det2Str(UShort_t det, Char_t ring, UShort_t sec, UShort_t str)
35{
36 static TString s;
37 s = Form("FMD%d%c[%2d,%3d]", det, ring, sec, str);
38 return s.Data();
39}
40
41//____________________________________________________________________
9b48326f 42/** @ingroup HW_test
43 @param det
44 @param ring
45 @param sec
46 @param str
47 @param ddl
48 @param hwaddr
49 @param odet
50 @param oring
51 @param osec
52 @param ostr
53*/
bf000c32 54void
55PrintTrans(UShort_t det, Char_t ring, UShort_t sec, UShort_t str,
56 UInt_t ddl, UInt_t hwaddr,
57 UShort_t odet, Char_t oring, UShort_t osec, UShort_t ostr)
58{
59 static TString s1, s2, s3;
60 s1 = Det2Str(det, ring, sec, str);
61 s2 = Addr2Str(ddl,hwaddr);
62 s3 = Det2Str(odet, oring, osec, ostr);
63 Info("TestHWMap","%s -> %s -> %s", s1.Data(), s2.Data(), s3.Data());
64}
65
66//____________________________________________________________________
9b48326f 67/** @ingroup HW_test
68 @param det
69 @param ring
70 @param sec
71 @param str
72 @param odet
73 @param oring
74 @param osec
75 @param ostr
76*/
bf000c32 77void
78CheckTrans(UShort_t det, Char_t ring, UShort_t sec, UShort_t str,
79 UShort_t odet, Char_t oring, UShort_t osec, UShort_t ostr)
80{
81 if (det != odet)
82 Waring("TestHWMap", "Detector # differ %d != %d", det, odet);
83 if (ring != oring)
84 Waring("TestHWMap", "Ring Id differ %c != %c", ring, oring);
85 if (sec != osec)
86 Warning("TestHWMap", "Sector # differ %d != %d", sec, osec);
1e8f773e 87 if ((str / 128) * 128 != ostr)
88 Warning("TestHWMap", "Strip # differ %d != %d", (str / 128) * 128, ostr);
bf000c32 89}
90
91//____________________________________________________________________
9b48326f 92/** @ingroup HW_test
93 */
bf000c32 94void
95TestHWMap()
96{
97 AliFMDParameters* param = AliFMDParameters::Instance();
1e8f773e 98 param->Init();
99 AliLog::SetModuleDebugLevel("FMD", 1);
bf000c32 100
1e8f773e 101 UInt_t oldddl = 0, oldhwaddr = 0xFFFFFFFF;
102 for (UShort_t det = 1; det <= 3; det++) {
bf000c32 103 for (UShort_t rng = 0; rng < 2; rng++) {
104 Char_t ring = (rng == 0 ? 'I' : 'O');
105 Int_t nsec = (ring == 'I' ? 20 : 40);
106 Int_t nstr = (ring == 'I' ? 512 : 256);
107 for (UShort_t sec = 0; sec < nsec; sec++) {
1e8f773e 108 for (UShort_t str = 0; str < nstr; str ++) {
bf000c32 109 UInt_t ddl, hwaddr;
110 if (!param->Detector2Hardware(det, ring, sec, str, ddl, hwaddr)) {
111 Warning("TestHWMap", "detector to hardware failed on %s",
112 Det2Str(det, ring, sec, str));
113 continue;
114 }
115 UShort_t odet, osec, ostr;
116 Char_t oring;
117 if (!param->Hardware2Detector(ddl, hwaddr, odet, oring, osec, ostr)){
118 Warning("TestHWMap", "hardware to detector failed on %s",
119 Addr2Str(ddl, hwaddr));
120 continue;
121 }
1e8f773e 122 if (oldddl != ddl || oldhwaddr != hwaddr) {
123 PrintTrans(det,ring,sec,str,ddl,hwaddr,odet,oring,osec,ostr);
124 oldddl = ddl;
125 oldhwaddr = hwaddr;
126 }
bf000c32 127 CheckTrans(det,ring,sec,str,odet,oring,osec,ostr);
128 }// Loop over strips
129 } // Loop over sectors
130 } // Loop over rings
131 } // Loop over detectors
132}
133
134
135//____________________________________________________________________
136//
137// EOF
138//
139
140
141
142