CMS 3D CMS Logo

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 //
14 
15 #include <stdio.h>
16 #include <iostream>
17 #include <fstream>
18 #include <sstream>
19 #include <vector>
22 
23 using namespace std;
24 
25 
26 
27 
29 {
30  int lines=0;
31 
32  std::string _row;
33  ifstream inFile( filename . c_str(), std::ios::in );
34  if (!inFile){
35  std::cout << "Unable to open file with the electronic map: " << filename << std::endl;
36  }
37  else{
38  std::cout << "File with the electronic map opened successfully: " << filename << std::endl;
39  }
40  while (getline( inFile, _row )) {
41  HcalEmapRow aRow;
42  char fpga[32];
43  char subdet[32];
44 
45  int _read;
46  const char * _format = "%d %d %d %s %d %d %d %d %s %d %d %d";
47  _read = sscanf( _row . c_str(), _format,
48  &(aRow.rawId),
49  &(aRow.crate), &(aRow.slot),
50  fpga,
51  &(aRow.dcc),
52  &(aRow.spigot),&(aRow.fiber),&(aRow.fiberchan),
53  subdet,
54  &(aRow.ieta), &(aRow.iphi), &(aRow.idepth) );
55  if ( _read >= 12 ){
56  lines++;
57 
58  aRow . subdet .append( subdet );
59  aRow . topbottom .append( fpga );
60 
61  map . push_back( aRow );
62  }
63  }
64  inFile.close();
65  std::cout << "HcalEmap: " << lines << " lines read" << std::endl;
66 
67  return 0;
68 }
69 
70 
71 
72 std::vector<HcalEmap::HcalEmapRow> & HcalEmap::get_map( void )
73 {
74  return map;
75 }
76 
77 
79  return rawId < other.rawId;
80 }
81 
82 
83 
84 //
85 // _____ test procedures for the HcalEmap class _____________________________
86 //
88 {
89  HcalEmap map( filename );
90  return 0;
91 }
92 
int test_read_map(std::string filename)
Definition: HcalEmap.cc:87
std::vector< HcalEmap::HcalEmapRow > & get_map(void)
Definition: HcalEmap.cc:72
bool operator<(const HcalEmapRow &other) const
Definition: HcalEmap.cc:78
int read_map(std::string filename)
Definition: HcalEmap.cc:28