ROOT logo
//____________________________________________________________________
//
// $Id$
//
// Test I/O of ALiFMDMap
//
/** @file    TestMap.C
    @author  Christian Holm Christensen <cholm@nbi.dk>
    @date    Sat Dec 16 01:29:03 2006
    @brief   Test of uniquenss of map
    @ingroup FMD_script     
*/
#include "STEER/AliFMDFloatMap.h"
#include <TArrayI.h>
#include <iostream>
#include <iomanip>
#include <map>

struct Check 
{
  UShort_t d;
  Char_t   r;
  UShort_t s;
  UShort_t t;
  Float_t  v;
};

std::ostream& operator<<(std::ostream& o, const Check& c) 
{
  UShort_t v = UShort_t(c.v);
  o << "FMD" << c.d << c.r << '[' 
    << std::setw(2) << c.s << ',' 
    << std::setw(3) << c.t << "] (" 
    << std::setw(6) << v << ')';
   return o;
}

Check Name(UShort_t d, Char_t r, UShort_t s, UShort_t t, Float_t v) 
{
  Check c;
  c.d = d;
  c.r = r;
  c.s = s;
  c.t = t;
  c.v = v;
  return c;
}


void
TestMap() 
{
  AliFMDFloatMap m;
  // m.SetBit(AliFMDMap::kNeedUShort);
  typedef std::map<Int_t, Check> CheckMap;
  CheckMap c;
  
  for (UShort_t d = 1; d <= 3; d++) {
    Char_t rings[] = { 'I', 'O', '\0' };
    for (Char_t* rp = rings; *rp; rp++) {
      Char_t r = *rp;
      std::cout << "FMD" << d << r << " " << std::flush;
      for (UShort_t s = 0; s < 40; s++) {
	std::cout << "." << std::flush;
	for (UShort_t t = 0; t < 512; t++) {
	  Int_t i = m.CheckIndex(d, r, s, t);
	  CheckMap::iterator z = c.find(i);
	  Float_t v = (t + 512 * (s + 40 * ((r=='I'? 0 : 1) + 2 * d)));
	  if (z != c.end()) 
	    std::cout << '\n' << Name(d,r,s,t,v)  << " but aleady seen " 
		      << z->second  << std::flush;
	  else {
	    m(d,r,s,t) = v;
	    c[i] = Name(d,r,s,t,v);
	  } // else
	} // for t
      } // for s 
      std::cout << "done" << std::endl;
    }
  }
}

    
	
 TestMap.C:1
 TestMap.C:2
 TestMap.C:3
 TestMap.C:4
 TestMap.C:5
 TestMap.C:6
 TestMap.C:7
 TestMap.C:8
 TestMap.C:9
 TestMap.C:10
 TestMap.C:11
 TestMap.C:12
 TestMap.C:13
 TestMap.C:14
 TestMap.C:15
 TestMap.C:16
 TestMap.C:17
 TestMap.C:18
 TestMap.C:19
 TestMap.C:20
 TestMap.C:21
 TestMap.C:22
 TestMap.C:23
 TestMap.C:24
 TestMap.C:25
 TestMap.C:26
 TestMap.C:27
 TestMap.C:28
 TestMap.C:29
 TestMap.C:30
 TestMap.C:31
 TestMap.C:32
 TestMap.C:33
 TestMap.C:34
 TestMap.C:35
 TestMap.C:36
 TestMap.C:37
 TestMap.C:38
 TestMap.C:39
 TestMap.C:40
 TestMap.C:41
 TestMap.C:42
 TestMap.C:43
 TestMap.C:44
 TestMap.C:45
 TestMap.C:46
 TestMap.C:47
 TestMap.C:48
 TestMap.C:49
 TestMap.C:50
 TestMap.C:51
 TestMap.C:52
 TestMap.C:53
 TestMap.C:54
 TestMap.C:55
 TestMap.C:56
 TestMap.C:57
 TestMap.C:58
 TestMap.C:59
 TestMap.C:60
 TestMap.C:61
 TestMap.C:62
 TestMap.C:63
 TestMap.C:64
 TestMap.C:65
 TestMap.C:66
 TestMap.C:67
 TestMap.C:68
 TestMap.C:69
 TestMap.C:70
 TestMap.C:71
 TestMap.C:72
 TestMap.C:73
 TestMap.C:74
 TestMap.C:75
 TestMap.C:76
 TestMap.C:77
 TestMap.C:78
 TestMap.C:79
 TestMap.C:80
 TestMap.C:81
 TestMap.C:82
 TestMap.C:83
 TestMap.C:84
 TestMap.C:85