MarlinTPC  1.2.0
ChannelPosMap.h
1 #include <iostream>
2 #include <fstream>
3 #include <sstream>
4 #include <map>
5 
6 #include "GEAR.h"
7 
8 namespace marlintpc
9 {
10 
14 class ChannelPosMap : public std::map< std::pair<int,int> , gear::Vector2D> {
15 
16 public:
17 
18 
19  ChannelPosMap(const std::string& file){
20 
21  std::ifstream f( file.c_str() , std::ios::in ) ;
22 
23  if( ! f.good() ){
24 
25  std::string mess( " \n cannot open file with channel to position mapping : \n " ) ;
26  mess += file ;
27  throw Exception( mess ) ;
28  }
29 
30  while ( f.good() ){
31 
32  std::string s ;
33 
34  std::getline( f , s ) ;
35 
36  if( s[0] != '#' ){
37 
38  std::stringstream ss( s ) ;
39 
40  int rcu, channel ;
41  float x,y;
42 
43  ss >> rcu >> channel >> x >> y ;
44 
45  //std::cout << "channel : " << channel << " rcu " << rcu << " x: " << x << " y: " << y << std::endl ;
46 
47  this->insert( std::make_pair( std::make_pair( channel, rcu ) , gear::Vector2D( x, y ) ) ) ;
48  }
49 
50 
51  }
52  f.close() ;
53 
54  }
55 
56 } ;
57 }
58 
Helper class that creates (is) a simple map of hardware channel to position of the pad center (x...
Definition: ChannelPosMap.h:14