Use VMC id's rather than TGeo id's
[u/mrichter/AliRoot.git] / FMD / scripts / TestAltroMapping.C
CommitLineData
502fbe9a 1//____________________________________________________________________
2//
3// $id$
4//
5// Check integrety of Hardware2Detector and Detector2Hardware
6//
9b48326f 7/** @defgroup ALTRO_test ALTRO test
8 @ingroup FMD_script
9*/
502fbe9a 10//____________________________________________________________________
9b48326f 11/** @ingroup ALTRO_test
12 @param ddl
13 @param hwaddr
14 @return */
502fbe9a 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 ALTRO_test
28 @param det
29 @param ring
30 @param sec
31 @param str
32 @return */
502fbe9a 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 ALTRO_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*/
502fbe9a 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 ALTRO_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*/
502fbe9a 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)
a9579262 82 Warning("TestHWMap", "Detector # differ %d != %d", det, odet);
502fbe9a 83 if (ring != oring)
a9579262 84 Warning("TestHWMap", "Ring Id differ %c != %c", ring, oring);
502fbe9a 85 if (sec != osec)
86 Warning("TestHWMap", "Sector # differ %d != %d", sec, osec);
87 if (str != ostr)
88 Warning("TestHWMap", "Strip # differ %d != %d", str, ostr);
89}
90
91//____________________________________________________________________
9b48326f 92/** @ingroup ALTRO_test
93 */
502fbe9a 94void
a9579262 95TestAltroMapping(Int_t min=2, Int_t max=0)
502fbe9a 96{
a9579262 97 // if (min < 1 || min > 3) min = 1;
98 if (max < min) max = min;
502fbe9a 99 AliFMDParameters* param = AliFMDParameters::Instance();
100 AliFMDAltroMapping m;
101
a9579262 102 for (UShort_t det = min; det <= max; det++) {
502fbe9a 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++) {
108 for (UShort_t str = 0; str < nstr; str += 128) {
109 UInt_t ddl, hwaddr;
110 if (!m.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 (!m.Hardware2Detector(ddl, hwaddr, odet, oring, osec, ostr)){
118 Warning("TestHWMap", "hardware to detector failed on %s",
119 Addr2Str(ddl, hwaddr));
120 continue;
121 }
122 PrintTrans(det,ring,sec,str,ddl,hwaddr,odet,oring,osec,ostr);
123 CheckTrans(det,ring,sec,str,odet,oring,osec,ostr);
124 }// Loop over strips
125 } // Loop over sectors
126 } // Loop over rings
127 } // Loop over detectors
128}
129
130
131//____________________________________________________________________
132//
133// EOF
134//
135
136
137
138