CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalEmap.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CalibCalorimetry/HcalTPGAlgos
4 // Class : HcalEmap
5 //
6 // Implementation:
7 // structure and functionality for HCAL electronic map
8 // NOTE!
9 // Keep xdaq and Oracle dependencies out of here!
10 //
11 // Original Author: Gena Kukartsev, kukarzev@fnal.gov
12 // Created: Tue Oct 14 14:30:20 CDT 2009
13 // $Id: HcalEmap.cc,v 1.2 2010/08/06 20:24:03 wmtan Exp $
14 //
15 
16 #include <stdio.h>
17 #include <iostream>
18 #include <fstream>
19 #include <sstream>
20 #include <vector>
23 
24 using namespace std;
25 
26 
27 
28 
29 int HcalEmap::read_map( std::string filename )
30 {
31  int lines=0;
32 
33  std::string _row;
34  ifstream inFile( filename . c_str(), std::ios::in );
35  if (!inFile){
36  std::cout << "Unable to open file with the electronic map: " << filename << std::endl;
37  }
38  else{
39  std::cout << "File with the electronic map opened successfully: " << filename << std::endl;
40  }
41  while ( getline( inFile, _row ) > 0 ){
42  HcalEmapRow aRow;
43  char fpga[32];
44  char subdet[32];
45 
46  int _read;
47  const char * _format = "%d %d %d %s %d %d %d %d %s %d %d %d";
48  _read = sscanf( _row . c_str(), _format,
49  &(aRow.rawId),
50  &(aRow.crate), &(aRow.slot),
51  fpga,
52  &(aRow.dcc),
53  &(aRow.spigot),&(aRow.fiber),&(aRow.fiberchan),
54  subdet,
55  &(aRow.ieta), &(aRow.iphi), &(aRow.idepth) );
56  if ( _read >= 12 ){
57  lines++;
58 
59  aRow . subdet .append( subdet );
60  aRow . topbottom .append( fpga );
61 
62  map . push_back( aRow );
63  }
64  }
65  inFile.close();
66  std::cout << "HcalEmap: " << lines << " lines read" << std::endl;
67 
68  return 0;
69 }
70 
71 
72 
73 std::vector<HcalEmap::HcalEmapRow> & HcalEmap::get_map( void )
74 {
75  return map;
76 }
77 
78 
80  return rawId < other.rawId;
81 }
82 
83 
84 
85 //
86 // _____ test procedures for the HcalEmap class _____________________________
87 //
89 {
90  HcalEmap map( filename );
91  return 0;
92 }
93 
int test_read_map(std::string filename)
Definition: HcalEmap.cc:88
dictionary map
Definition: Association.py:205
std::vector< HcalEmap::HcalEmapRow > & get_map(void)
Definition: HcalEmap.cc:73
bool operator<(const HcalEmapRow &other) const
Definition: HcalEmap.cc:79
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
int read_map(std::string filename)
Definition: HcalEmap.cc:29