AliRoot Core  3dc7879 (3dc7879)
TestAltroMapping.C
Go to the documentation of this file.
1 //____________________________________________________________________
2 //
3 // $id$
4 //
5 // Check integrety of Hardware2Detector and Detector2Hardware
6 //
10 #ifndef __CINT__
11 # include <TString.h>
12 // # include <FMD/AliFMDParameters.h>
13 # include <FMD/AliFMDAltroMapping.h>
14 // # include <FMD/AliFMDUShortMap.h>
15 // # include <FMD/AliFMDBoolMap.h>
16 # include <AliLog.h>
17 # include <TError.h>
18 # include <iostream>
19 #endif
20 bool show_all=false;
21 
22 //____________________________________________________________________
27 const Char_t*
28 Addr2Str(UInt_t ddl, UInt_t hwaddr, UShort_t timebin)
29 {
30  static TString s;
31  UInt_t board = (hwaddr >> 7) & 0x1F;
32  UInt_t chip = (hwaddr >> 4) & 0x7;
33  UInt_t chan = hwaddr & 0xF;
34  s = Form("(0x%05X,0x%02X,0x%1X,0x%1X,%04d)", ddl, board, chip, chan, timebin);
35  return s.Data();
36 }
37 
38 //____________________________________________________________________
45 const Char_t*
46 Det2Str(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, UShort_t sam)
47 {
48  static TString s;
49  s = Form("FMD%d%c[%2d,%3d]-%d", det, ring, sec, str, sam);
50  return s.Data();
51 }
52 
53 //____________________________________________________________________
66 void
67 PrintTrans(UShort_t det, Char_t ring, UShort_t sec, Short_t str, UShort_t sam,
68  UInt_t ddl, UInt_t hwaddr, UShort_t timebin,
69  UShort_t odet, Char_t oring, UShort_t osec, Short_t ostr,
70  UShort_t osam)
71 {
72  static TString s1, s2, s3;
73  s1 = Det2Str(det, ring, sec, str, sam);
74  s2 = Addr2Str(ddl,hwaddr,timebin);
75  s3 = Det2Str(odet, oring, osec, ostr, osam);
76  Info("TestHWMap","%s -> %s -> %s", s1.Data(), s2.Data(), s3.Data());
77 }
78 
79 //____________________________________________________________________
90 void
91 CheckTrans(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, UShort_t sam,
92  UInt_t ddl, UInt_t hwaddr, UShort_t timebin,
93  UShort_t odet, Char_t oring, UShort_t osec, UShort_t ostr,
94  UShort_t osam)
95 {
96  bool ok = true;
97  if (det != odet) {
98  Warning("TestHWMap", "Detector # differ %d != %d", det, odet);
99  ok = false;
100  }
101  if (ring != oring) {
102  Warning("TestHWMap", "Ring Id differ %c != %c", ring, oring);
103  ok = false;
104  }
105  if (sec != osec) {
106  Warning("TestHWMap", "Sector # differ %d != %d", sec, osec);
107  ok = false;
108  }
109  if (str != ostr) {
110  ok = false;
111  Warning("TestHWMap", "Strip # differ %d != %d", str, ostr);
112  }
113  if (sam != osam) {
114  ok = false;
115  Warning("TestHWMap", "Sample # differ %d != %d", sam, osam);
116  }
117 
118  if (!show_all) {
119  if (!ok)
120  PrintTrans(det,ring,sec,str,sam,
121  ddl,hwaddr,timebin,
122  odet,oring,osec,ostr,osam);
123  }
124 }
125 
126 //____________________________________________________________________
129 void
130 TestAltroMapping(bool sa=false, Int_t min=1, Int_t max=3)
131 {
132  show_all = sa;
133  // AliLog::SetModuleDebugLevel("FMD", 1);
134  // if (min < 1 || min > 3) min = 1;
135  if (max < min) max = min;
136  // AliFMDParameters* param = AliFMDParameters::Instance();
138  UShort_t presamp = 19;
139  UShort_t oversamp = 4;
140 
141  for (UShort_t det = min; det <= max; det++) {
142  for (UShort_t rng = 0; rng < 2; rng++) {
143  Char_t ring = (rng == 0 ? 'I' : 'O');
144  Int_t nsec = (ring == 'I' ? 20 : 40);
145  Int_t nstr = (ring == 'I' ? 512 : 256);
146  for (UShort_t sec = 0; sec < nsec; sec++) {
147  for (Short_t str = 0; str < nstr; str ++ /*= 128*/) {
148  for(UShort_t sam = 0; sam < oversamp; sam++) {
149  UShort_t ddl, hwaddr;
150  UShort_t timebin;
151  if (!m.Detector2Hardware(det, ring, sec, str, sam,
152  presamp, oversamp,
153  ddl, hwaddr, timebin)) {
154  Warning("TestHWMap", "detector to hardware failed on %s",
155  Det2Str(det, ring, sec, str, sam));
156  continue;
157  }
158  UShort_t odet, osec, osam;
159  Short_t ostr;
160  Char_t oring;
161  if (!m.Hardware2Detector(ddl, hwaddr, timebin,
162  presamp, oversamp,
163  odet, oring, osec, ostr, osam)){
164  Warning("TestHWMap", "hardware to detector failed on %s",
165  Addr2Str(ddl, hwaddr, timebin));
166  continue;
167  }
168  if (show_all)
169  PrintTrans(det,ring,sec,str,sam,
170  ddl,hwaddr,timebin,
171  odet,oring,osec,ostr,osam);
172  CheckTrans(det,ring,sec,str,sam,
173  ddl,hwaddr,timebin,
174  odet,oring,osec,ostr,osam);
175  }
176  }// Loop over strips
177  } // Loop over sectors
178  } // Loop over rings
179  } // Loop over detectors
180 }
181 
182 
183 //____________________________________________________________________
184 //
185 // EOF
186 //
187 
188 
189 
190 
const Char_t * Addr2Str(UInt_t ddl, UInt_t hwaddr, UShort_t timebin)
Bool_t Hardware2Detector(UShort_t ddl, UShort_t hwaddr, UShort_t timebin, UShort_t preSamples, UShort_t sampleRate, UShort_t &det, Char_t &ring, UShort_t &sec, Short_t &str, UShort_t &sam) const
void TestAltroMapping(bool sa=false, Int_t min=1, Int_t max=3)
void CheckTrans(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, UShort_t sam, UInt_t ddl, UInt_t hwaddr, UShort_t timebin, UShort_t odet, Char_t oring, UShort_t osec, UShort_t ostr, UShort_t osam)
Bool_t Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, UShort_t sam, UShort_t preSamples, UShort_t sampleRate, UShort_t &ddl, UShort_t &board, UShort_t &altro, UShort_t &channel, UShort_t &timebin) const
Class that encodes a map to/from ALTRO hardware address to FMD detector coordinates.
bool show_all
void PrintTrans(UShort_t det, Char_t ring, UShort_t sec, Short_t str, UShort_t sam, UInt_t ddl, UInt_t hwaddr, UShort_t timebin, UShort_t odet, Char_t oring, UShort_t osec, Short_t ostr, UShort_t osam)
const Char_t * Det2Str(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, UShort_t sam)