CMS 3D CMS Logo

HGCalMappingTools.h
Go to the documentation of this file.
1 #ifndef _geometry_hgcalmapping_hgcalmappingtools_h_
2 #define _geometry_hgcalmapping_hgcalmappingtools_h_
3 
7 #include <map>
8 
9 namespace hgcal {
10 
11  namespace mappingtools {
12 
19  public:
21  typedef std::vector<HGCalEntityAttr> HGCalEntityRow;
22 
24 
29 
34  auto it = columnIndex_.find(col);
35  if (it == columnIndex_.end()) {
36  throw cms::Exception("ValueError") << "Request for unknown column " << col;
37  }
38  return row[it->second];
39  }
40  float getFloatAttr(std::string col, HGCalEntityRow &row) { return (float)atof(getAttr(col, row).c_str()); }
41  float getIntAttr(std::string col, HGCalEntityRow &row) { return atoi(getAttr(col, row).c_str()); }
42  const std::vector<HGCalEntityRow> &getEntries() { return entities_; }
44 
45  private:
47  std::map<HGCalEntityAttr, size_t> columnIndex_;
48  std::vector<HGCalEntityRow> entities_;
50  for (size_t i = 0; i < header.size(); i++) {
51  std::string cname = header[i];
52  colNames_.push_back(cname);
53  columnIndex_[cname] = i;
54  }
55  }
56  void addRow(HGCalEntityRow &row) { entities_.push_back(row); }
57  };
58 
59  uint16_t getEcondErx(uint16_t chip, uint16_t half);
60  uint32_t getElectronicsId(
61  bool zside, uint16_t fedid, uint16_t captureblock, uint16_t econdidx, int cellchip, int cellhalf, int cellseq);
62  uint32_t getSiDetId(bool zside, int moduleplane, int moduleu, int modulev, int celltype, int celliu, int celliv);
63  uint32_t getSiPMDetId(bool zside, int moduleplane, int modulev, int celltype, int celliu, int celliv);
64 
68  template <class T1, class T2>
69  std::pair<int32_t, int32_t> getModuleCellIndicesForSiCell(const T1 &modules, const T2 &cells, uint32_t detid) {
70  std::pair<int32_t, int32_t> key(-1, -1);
71 
72  //get the module and cell parts of the id
73  HGCSiliconDetId siid(detid);
74 
75  // match module det id
76  uint32_t modid = siid.moduleId().rawId();
77  for (int i = 0; i < modules.view().metadata().size(); i++) {
78  auto imod = modules.view()[i];
79  if (imod.detid() != modid)
80  continue;
81 
82  key.first = i;
83 
84  //match cell by type of module and by cell det id
85  DetId::Detector det(DetId::Detector::HGCalEE);
86  uint32_t cellid = 0x3ff & HGCSiliconDetId(det, 0, 0, 0, 0, 0, siid.cellU(), siid.cellV()).rawId();
87  for (int j = 0; j < cells.view().metadata().size(); j++) {
88  auto jcell = cells.view()[j];
89  if (jcell.typeidx() != imod.typeidx())
90  continue;
91  if (jcell.detid() != cellid)
92  continue;
93  key.second = j;
94  return key;
95  }
96 
97  return key;
98  }
99 
100  return key;
101  }
102 
106  template <class T1, class T2>
107  uint32_t getElectronicsIdForSiCell(const T1 &modules, const T2 &cells, uint32_t detid) {
108  std::pair<int32_t, int32_t> idx = getModuleCellIndicesForSiCell<T1, T2>(modules, cells, detid);
109  if (idx.first < 0 || idx.first < 0)
110  return 0;
111  return modules.view()[idx.first].eleid() + cells.view()[idx.second].eleid();
112  }
113 
114  } // namespace mappingtools
115 
116 } // namespace hgcal
117 
118 #endif
uint32_t getElectronicsIdForSiCell(const T1 &modules, const T2 &cells, uint32_t detid)
after getting the module/cell indices it returns the sum of the corresponding electronics ids ...
void addRow(HGCalEntityRow &row)
std::pair< int32_t, int32_t > getModuleCellIndicesForSiCell(const T1 &modules, const T2 &cells, uint32_t detid)
matches the module and cell info by detId and returns their indices (-1 is used in case index was not...
std::vector< HGCalEntityRow > entities_
float getIntAttr(std::string col, HGCalEntityRow &row)
std::vector< HGCalEntityAttr > HGCalEntityRow
int zside(DetId const &)
uint16_t getEcondErx(uint16_t chip, uint16_t half)
const std::vector< HGCalEntityRow > & getEntries()
HGCalEntityAttr getAttr(std::string col, HGCalEntityRow &row)
gets the attribute corresponding the column col in a row
uint32_t getSiPMDetId(bool zside, int moduleplane, int modulev, int celltype, int celliu, int celliv)
key
prepare the HTCondor submission files and eventually submit them
float getFloatAttr(std::string col, HGCalEntityRow &row)
constexpr int32_t cellU() const
get the cell #&#39;s in u,v or in x,y
void setHeader(HGCalEntityRow &header)
void buildFrom(std::string url)
builds the entity list from a file
constexpr HGCSiliconDetId moduleId() const
uint32_t getElectronicsId(bool zside, uint16_t fedid, uint16_t captureblock, uint16_t econdidx, int cellchip, int cellhalf, int cellseq)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Detector
Definition: DetId.h:24
constexpr int32_t cellV() const
col
Definition: cuy.py:1009
uint32_t getSiDetId(bool zside, int moduleplane, int moduleu, int modulev, int celltype, int celliu, int celliv)
std::map< HGCalEntityAttr, size_t > columnIndex_