File indexing completed on 2024-05-04 04:04:31
0001 #include "Geometry/HGCalMapping/interface/HGCalMappingTools.h"
0002 #include <iostream>
0003 #include <fstream>
0004 #include <sstream>
0005
0006 namespace hgcal {
0007
0008 namespace mappingtools {
0009
0010
0011 void HGCalEntityList::buildFrom(std::string url) {
0012 std::string line;
0013 std::ifstream file(url);
0014
0015
0016 size_t iline(0);
0017 while (std::getline(file, line)) {
0018 HGCalEntityRow row;
0019 std::stringstream s;
0020 s << line;
0021 HGCalEntityAttr attr;
0022 while (s >> attr)
0023 row.push_back(attr);
0024
0025 if (iline == 0)
0026 setHeader(row);
0027 else
0028 addRow(row);
0029 iline += 1;
0030 }
0031 }
0032
0033
0034 uint16_t getEcondErx(uint16_t chip, uint16_t half) { return chip * 2 + half; }
0035
0036
0037 uint32_t getElectronicsId(
0038 bool zside, uint16_t fedid, uint16_t captureblock, uint16_t econdidx, int cellchip, int cellhalf, int cellseq) {
0039 uint16_t econderx = getEcondErx(cellchip, cellhalf);
0040
0041 return HGCalElectronicsId(zside, fedid, captureblock, econdidx, econderx, cellseq).raw();
0042 }
0043
0044
0045 uint32_t getSiDetId(bool zside, int moduleplane, int moduleu, int modulev, int celltype, int celliu, int celliv) {
0046 DetId::Detector det = moduleplane <= 26 ? DetId::Detector::HGCalEE : DetId::Detector::HGCalHSi;
0047 int zp(zside ? 1 : -1);
0048
0049 return HGCSiliconDetId(det, zp, celltype, moduleplane, moduleu, modulev, celliu, celliv).rawId();
0050 }
0051
0052
0053 uint32_t getSiPMDetId(bool zside, int moduleplane, int modulev, int celltype, int celliu, int celliv) {
0054 int layer = moduleplane - 25;
0055 int type = 0;
0056
0057 int ring = (zside ? celliu : (-1) * celliu);
0058 int iphi = modulev * 8 + celliv + 1;
0059
0060 return HGCScintillatorDetId(type, layer, ring, iphi, false, celltype).rawId();
0061 }
0062
0063 }
0064 }