A lot of changes after detector review:
[u/mrichter/AliRoot.git] / FMD / scripts / TestMap.C
CommitLineData
a9579262 1//____________________________________________________________________
2//
3// $Id$
4//
5// Test I/O of ALiFMDMap
6//
7/** @file TestMap.C
8 @author Christian Holm Christensen <cholm@nbi.dk>
9 @date Sat Dec 16 01:29:03 2006
10 @brief Test of uniquenss of map
11 @ingroup FMD_script
12*/
13#include "STEER/AliFMDFloatMap.h"
14#include <TArrayI.h>
15#include <iostream>
16#include <iomanip>
17#include <map>
18
19struct Check
20{
21 UShort_t d;
22 Char_t r;
23 UShort_t s;
24 UShort_t t;
25 Float_t v;
26};
27
28std::ostream& operator<<(std::ostream& o, const Check& c)
29{
30 UShort_t v = UShort_t(c.v);
31 o << "FMD" << c.d << c.r << '['
32 << std::setw(2) << c.s << ','
33 << std::setw(3) << c.t << "] ("
34 << std::setw(6) << v << ')';
35 return o;
36}
37
38Check Name(UShort_t d, Char_t r, UShort_t s, UShort_t t, Float_t v)
39{
40 Check c;
41 c.d = d;
42 c.r = r;
43 c.s = s;
44 c.t = t;
45 c.v = v;
46 return c;
47}
48
49
50void
51TestMap()
52{
53 AliFMDFloatMap m;
54 // m.SetBit(AliFMDMap::kNeedUShort);
55 typedef std::map<Int_t, Check> CheckMap;
56 CheckMap c;
57
58 for (UShort_t d = 1; d <= 3; d++) {
59 Char_t rings[] = { 'I', 'O', '\0' };
60 for (Char_t* rp = rings; *rp; rp++) {
61 Char_t r = *rp;
62 std::cout << "FMD" << d << r << " " << std::flush;
63 for (UShort_t s = 0; s < 40; s++) {
64 std::cout << "." << std::flush;
65 for (UShort_t t = 0; t < 512; t++) {
66 Int_t i = m.CheckIndex(d, r, s, t);
67 CheckMap::iterator z = c.find(i);
68 Float_t v = (t + 512 * (s + 40 * ((r=='I'? 0 : 1) + 2 * d)));
69 if (z != c.end())
70 std::cout << '\n' << Name(d,r,s,t,v) << " but aleady seen "
71 << z->second << std::flush;
72 else {
73 m(d,r,s,t) = v;
74 c[i] = Name(d,r,s,t,v);
75 } // else
76 } // for t
77 } // for s
78 std::cout << "done" << std::endl;
79 }
80 }
81}
82
83
84