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 <cstdio>
16 #include <iostream>
17 #include <fstream>
18 #include <sstream>
19 #include <vector>
22 
23 using namespace std;
24 
26  int lines = 0;
27 
28  std::string _row;
29  ifstream inFile(filename.c_str(), std::ios::in);
30  if (!inFile) {
31  std::cout << "Unable to open file with the electronic map: " << filename << std::endl;
32  } else {
33  std::cout << "File with the electronic map opened successfully: " << filename << std::endl;
34  }
35  while (getline(inFile, _row)) {
36  HcalEmapRow aRow;
37  char fpga[32];
38  char subdet[32];
39 
40  int _read;
41  const char* _format = "%d %d %d %s %d %d %d %d %s %d %d %d";
42  _read = sscanf(_row.c_str(),
43  _format,
44  &(aRow.rawId),
45  &(aRow.crate),
46  &(aRow.slot),
47  fpga,
48  &(aRow.dcc),
49  &(aRow.spigot),
50  &(aRow.fiber),
51  &(aRow.fiberchan),
52  subdet,
53  &(aRow.ieta),
54  &(aRow.iphi),
55  &(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 std::vector<HcalEmap::HcalEmapRow>& HcalEmap::get_map(void) { return map; }
72 
73 bool HcalEmap::HcalEmapRow::operator<(const HcalEmap::HcalEmapRow& other) const { return rawId < other.rawId; }
74 
75 //
76 // _____ test procedures for the HcalEmap class _____________________________
77 //
80  return 0;
81 }
int test_read_map(std::string filename)
Definition: HcalEmap.cc:78
std::string subdet
Definition: HcalEmap.h:41
std::string topbottom
Definition: HcalEmap.h:41
std::vector< HcalEmap::HcalEmapRow > & get_map(void)
Definition: HcalEmap.cc:71
bool operator<(const HcalEmapRow &other) const
Definition: HcalEmap.cc:73
int read_map(std::string filename)
Definition: HcalEmap.cc:25