1 #include <STEER/AliFMDFloatMap.h>
3 #include <STEER/AliLog.h>
5 //____________________________________________________________________
6 struct Printer : public AliFMDMap::ForOne
8 Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t, Float_t v)
10 printf("FMD%d%c[%2d,%3d] = %8.3f\n", d, r, s, t, v);
13 Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t, Int_t v)
15 printf("FMD%d%c[%2d,%3d] = %d\n", d, r, s, t, v);
19 //____________________________________________________________________
20 struct Tester : public AliFMDMap::ForOne
22 Tester(AliFMDFloatMap& m) : fMap(&m) { }
23 Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t, Float_t)
25 Int_t idx = fMap->CalcIndex(d, r, s, t);
28 fMap->CalcCoords(idx, rd, rr, rs, rt);
30 if (d != rd || r != rr || s != rs || t != rt)
31 printf("Mismatch FMD%d%c[%2d,%3d] -> %5d -> FMD%d%c[%2d,%3d]\n",
32 d, r, s, t, idx, rd, rr, rs, rt);
35 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Int_t){return kTRUE;}
38 //____________________________________________________________________
39 struct Filler : public AliFMDMap::ForOne
41 Filler(AliFMDFloatMap& map) : fMap(&map) {}
42 Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t, Float_t)
44 fMap->operator()(d, r, s, t) = MakeVal(d, r, s, t);
47 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Int_t)
51 static Float_t MakeVal(UShort_t d, Char_t r, UShort_t s, UShort_t t)
53 UShort_t ir = r == 'I' ? 0 : 1;
54 Float_t val = d * 1000 + ir * 100 + s + 0.001 * t;
60 //____________________________________________________________________
61 struct Unity : public AliFMDMap::ForOne
63 Unity(AliFMDFloatMap& map) : fMap(&map) {}
64 Bool_t operator()(UShort_t d, Char_t r, UShort_t s, UShort_t t, Float_t)
66 fMap->operator()(d, r, s, t) = 1;
69 Bool_t operator()(UShort_t, Char_t, UShort_t, UShort_t, Int_t) {return kTRUE;}
73 //____________________________________________________________________
75 FillMap(AliFMDFloatMap& m, Bool_t useFiller=kTRUE)
82 for (UShort_t d = 1; d <= 3; d++) {
83 UShort_t nRng = (d == 1 ? 1 : 2);
84 for (UShort_t q = 0; q < nRng; q++) {
85 Char_t r = (q == 0 ? 'I' : 'O');
86 UShort_t nSec = 1; // (q == 0 ? 20 : 40);
87 UShort_t nStr = (q == 0 ? 512 : 256);
88 for (UShort_t s = 0; s < nSec; s++) {
89 for (UShort_t t = 0; t < nStr; t++) {
90 m(d, r, s, t) = Filler::MakeVal(d, r, s, t);
96 //____________________________________________________________________
98 PrintMap(AliFMDFloatMap& map)
103 //____________________________________________________________________
105 FillOne(AliFMDFloatMap& map)
111 //____________________________________________________________________
113 TestIndex(AliFMDFloatMap& map, Bool_t useTester=kTRUE)
120 for (UShort_t d = 1; d <= 3; d++) {
121 UShort_t nRng = (d == 1 ? 1 : 2);
122 for (UShort_t q = 0; q < nRng; q++) {
123 Char_t r = (q == 0 ? 'I' : 'O');
124 UShort_t nSec = 1; // (q == 0 ? 20 : 40);
125 UShort_t nStr = (q == 0 ? 512 : 256);
126 for (UShort_t s = 0; s < nSec; s++) {
127 for (UShort_t t = 0; t < nStr; t++) {
128 Int_t idx = map.CalcIndex(d, r, s, t);
132 map.CalcCoords(idx, rd, rr, rs, rt);
134 if (d != rd || r != rr || s != rs || t != rt)
135 printf("Mismatch FMD%d%c[%2d,%3d] -> %5d -> FMD%d%c[%2d,%3d]\n",
136 d, r, s, t, idx, rd, rr, rs, rt);
146 // AliLog::SetModuleDebugLevel("FMD", 1);
147 AliFMDFloatMap m1(0, 0, 0, 0);
159 AliFMDFloatMap m3(3, 2, 1, 512);
160 TestIndex(m3, kFALSE);