#include <PixelMapping.h>
|
| | PixelMapping (const std::string &csvFilename) |
| void | mapping (const std::string &geographicalID, int *hashID, int *bec, int *layer, int *phimod, int *etamod) const |
| int | getID (const std::string &geographicalID) const |
| bool | contains (const std::string &geographicalID) const |
| int | nModules () const |
Definition at line 18 of file PixelMapping.h.
◆ Coordinates
◆ PixelMapping()
| pix::PixelMapping::PixelMapping |
( |
const std::string & | csvFilename | ) |
|
Definition at line 18 of file PixelMapping.cxx.
18 {
19
20
21
23 fs.open(csvFilename.c_str());
24 if (not
fs.is_open()){
25 const std::string
msg =
"Failed to open the mapping file: " + csvFilename;
26 throw std::runtime_error(
msg);
27 }
29
30 std::regex
re(R
"delim(^(.*), (\d+), (-?\d+), (\d+), (\d+), (-?\d+)$)delim");
31 auto dissectMatch=[](
const std::smatch &
m)->std::pair<std::string, Coordinates>{
32 static constexpr size_t expectedSize(7);
33 static constexpr size_t coordStart(2);
34 std::pair<std::string, PixelMapping::Coordinates>
result{};
35 if (
m.size()!=expectedSize)
return result;
36 const std::string
name =
m[1];
38
39 for (
size_t i(0);
i!=coords.size();++
i){
40 try{
41 coords[
i] = std::stoi(
m.str(i+coordStart));
42 } catch (std::invalid_argument &e){
43 const std::string
msg =
"PixelMapping: Line of csv file in unexpected format, \n"+ std::string(m[0]);
44 throw std::runtime_error(
msg);
45 }
46 }
47 return {
name, coords};
48 };
49 while (std::getline(
fs, line)){
50
51 if (line[0] == '#') continue;
53 bool matched = std::regex_match(line, m,
re);
54 if (not matched){
55 std::cout<<
"line in unexpected format:\n"<<
line<<std::endl;
56 continue;
57 }
59 if (not Ok){
60 std::cout<<
"repeated entry:\n"<<
line<<std::endl;
61 }
62 }
64 }
const boost::regex re(r_e)
std::unordered_map< std::string, Coordinates > m_internalMap
std::array< int, 5 > Coordinates
◆ contains()
| bool pix::PixelMapping::contains |
( |
const std::string & | geographicalID | ) |
const |
◆ getID()
| int pix::PixelMapping::getID |
( |
const std::string & | geographicalID | ) |
const |
Definition at line 84 of file PixelMapping.cxx.
84 {
87 std::cout<<"id "<<geographicalID<<" not found in mapping"<<std::endl;
88 return -1;
89 }
90 const auto & coordinates = pName->second;
91 return coordinates[0];
92}
◆ mapping()
| void pix::PixelMapping::mapping |
( |
const std::string & | geographicalID, |
|
|
int * | hashID, |
|
|
int * | bec, |
|
|
int * | layer, |
|
|
int * | phimod, |
|
|
int * | etamod ) const |
Definition at line 68 of file PixelMapping.cxx.
68 {
71 std::cout<<"id "<<geographicalID<<" not found in mapping"<<std::endl;
72 return;
73 }
74 const auto & coordinates = pName->second;
75 *hashID = coordinates[0];
76 *
bec = coordinates[1];
77 *
layer = coordinates[2];
80 return;
81 }
phimod(flags, cells_name, *args, **kw)
etamod(flags, cells_name, *args, **kw)
◆ nModules()
| int pix::PixelMapping::nModules |
( |
| ) |
const |
◆ m_internalMap
| std::unordered_map<std::string,Coordinates > pix::PixelMapping::m_internalMap |
|
private |
The documentation for this class was generated from the following files: