CMS 3D CMS Logo

HGCalMappingTools.cc
Go to the documentation of this file.
2 #include <iostream>
3 #include <fstream>
4 #include <sstream>
5 
6 namespace hgcal {
7 
8  namespace mappingtools {
9 
10  //
13  std::ifstream file(url);
14 
15  //parse the lines to build the list of entities
16  size_t iline(0);
17  while (std::getline(file, line)) {
18  HGCalEntityRow row;
19  std::stringstream s;
20  s << line;
21  HGCalEntityAttr attr;
22  while (s >> attr)
23  row.push_back(attr);
24 
25  if (iline == 0)
26  setHeader(row);
27  else
28  addRow(row);
29  iline += 1;
30  }
31  }
32 
33  //
34  uint16_t getEcondErx(uint16_t chip, uint16_t half) { return chip * 2 + half; }
35 
36  //
37  uint32_t getElectronicsId(
38  bool zside, uint16_t fedid, uint16_t captureblock, uint16_t econdidx, int cellchip, int cellhalf, int cellseq) {
39  uint16_t econderx = getEcondErx(cellchip, cellhalf);
40 
41  return HGCalElectronicsId(zside, fedid, captureblock, econdidx, econderx, cellseq).raw();
42  }
43 
44  //
45  uint32_t getSiDetId(bool zside, int moduleplane, int moduleu, int modulev, int celltype, int celliu, int celliv) {
46  DetId::Detector det = moduleplane <= 26 ? DetId::Detector::HGCalEE : DetId::Detector::HGCalHSi;
47  int zp(zside ? 1 : -1);
48 
49  return HGCSiliconDetId(det, zp, celltype, moduleplane, moduleu, modulev, celliu, celliv).rawId();
50  }
51 
52  //
53  uint32_t getSiPMDetId(bool zside, int moduleplane, int modulev, int celltype, int celliu, int celliv) {
54  int layer = moduleplane - 25;
55  int type = 0; // depends on SiPM size to be updated with new geometry
56 
57  int ring = (zside ? celliu : (-1) * celliu);
58  int iphi = modulev * 8 + celliv + 1;
59 
60  return HGCScintillatorDetId(type, layer, ring, iphi, false, celltype).rawId();
61  }
62 
63  } // namespace mappingtools
64 } // namespace hgcal
uint32_t raw() const
void addRow(HGCalEntityRow &row)
std::vector< HGCalEntityAttr > HGCalEntityRow
int zside(DetId const &)
uint16_t getEcondErx(uint16_t chip, uint16_t half)
uint32_t getSiPMDetId(bool zside, int moduleplane, int modulev, int celltype, int celliu, int celliv)
wrapper for a 32b data word identifying a readout channel in the raw data The format is the following...
void setHeader(HGCalEntityRow &header)
void buildFrom(std::string url)
builds the entity list from a file
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
uint32_t getSiDetId(bool zside, int moduleplane, int moduleu, int modulev, int celltype, int celliu, int celliv)