CMS 3D CMS Logo

HcalFrontEndId.cc
Go to the documentation of this file.
2 #include <iomanip>
3 #include <sstream>
4 #include <iostream>
5 #include <cstdlib>
6 
8  const std::string& rbx, int rm, int pixel, int rmfiber, int fiberchannel, int qie, int adc) {
9  hcalFrontEndId_ = 0;
10 
11  if (rbx.size() < 5)
12  return;
13  if (rm < 1 || rm > 5)
14  return; //changed to 5 to incorporate CALIB channels which define RM = 5
15  if (pixel < 0 || pixel > 19)
16  return;
17  if (rmfiber < 1 || rmfiber > 8)
18  return;
19  if (fiberchannel < 0 || fiberchannel > 2)
20  return;
21  if (qie < 1 || qie > 4)
22  return;
23  if (adc < 0 || adc > 5)
24  return;
25 
26  int num = -1;
27  if (!rbx.compare(0, 3, "HBM")) {
28  num = 0 + atoi(rbx.substr(3, 2).c_str()) - 1;
29  } else if (!rbx.compare(0, 3, "HBP")) {
30  num = 18 + atoi(rbx.substr(3, 2).c_str()) - 1;
31  } else if (!rbx.compare(0, 3, "HEM")) {
32  num = 18 * 2 + atoi(rbx.substr(3, 2).c_str()) - 1;
33  } else if (!rbx.compare(0, 3, "HEP")) {
34  num = 18 * 3 + atoi(rbx.substr(3, 2).c_str()) - 1;
35  } else if (!rbx.compare(0, 4, "HO2M")) {
36  num = 18 * 4 + atoi(rbx.substr(4, 2).c_str()) - 1;
37  } else if (!rbx.compare(0, 4, "HO1M")) {
38  num = 18 * 4 + 12 + atoi(rbx.substr(4, 2).c_str()) - 1;
39  } else if (!rbx.compare(0, 3, "HO0")) {
40  num = 18 * 4 + 12 * 2 + atoi(rbx.substr(3, 2).c_str()) - 1;
41  } else if (!rbx.compare(0, 4, "HO1P")) {
42  num = 18 * 4 + 12 * 3 + atoi(rbx.substr(4, 2).c_str()) - 1;
43  } else if (!rbx.compare(0, 4, "HO2P")) {
44  num = 18 * 4 + 12 * 4 + atoi(rbx.substr(4, 2).c_str()) - 1;
45  } else if (!rbx.compare(0, 3, "HFM")) {
46  num = 18 * 4 + 12 * 5 + atoi(rbx.substr(3, 2).c_str()) - 1;
47  } else if (!rbx.compare(0, 3, "HFP")) {
48  num = 18 * 4 + 12 * 6 + atoi(rbx.substr(3, 2).c_str()) - 1;
49  } else
50  return;
51 
52  hcalFrontEndId_ |= ((adc + 1) & 0x7);
53  hcalFrontEndId_ |= ((qie - 1) & 0x3) << 3;
54  hcalFrontEndId_ |= (fiberchannel & 0x3) << 5;
55  hcalFrontEndId_ |= ((rmfiber - 1) & 0x7) << 7;
56  hcalFrontEndId_ |= (pixel & 0x1F) << 10;
57  hcalFrontEndId_ |= ((rm - 1) & 0x7) << 15;
58  hcalFrontEndId_ |= (num & 0xFF) << 18;
59 }
60 
62 
64  std::string subdets[11] = {"HBM", "HBP", "HEM", "HEP", "HO2M", "HO1M", "HO0", "HO1P", "HO2P", "HFM", "HFP"};
65 
66  int box = hcalFrontEndId_ >> 18;
67  int num = -1;
68  int subdet_index = -1;
69  if (box < 18 * 4) {
70  num = box % 18;
71  subdet_index = (box - num) / 18;
72  } else {
73  num = (box - 18 * 4) % 12;
74  subdet_index = 4 + (box - 18 * 4 - num) / 12;
75  }
76  std::stringstream tempss;
77  tempss << std::setw(2) << std::setfill('0') << num + 1;
78  return subdets[subdet_index] + tempss.str();
79 }
80 
81 std::ostream& operator<<(std::ostream& s, const HcalFrontEndId& id) {
82  return s << id.rbx() << id.rm() << '[' << id.rmFiber() << '/' << id.fiberChannel() << "] pix=" << id.pixel()
83  << " qiecard=" << id.qieCard() << " adc=" << id.adc();
84 }
HcalFrontEndId::rm
int rm() const
Definition: HcalFrontEndId.h:26
gpuClustering::adc
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Definition: gpuClusterChargeCut.h:20
fireworks::subdets
static const std::string subdets[7]
Definition: TrackUtils.cc:60
muonClassificationByHits_cfi.pixel
pixel
Definition: muonClassificationByHits_cfi.py:9
HcalFrontEndId::~HcalFrontEndId
~HcalFrontEndId()
Definition: HcalFrontEndId.cc:61
HcalFrontEndId.h
alignCSCRings.s
s
Definition: alignCSCRings.py:92
HcalFrontEndId::pixel
int pixel() const
Definition: HcalFrontEndId.h:27
HcalFrontEndId
Definition: HcalFrontEndId.h:8
submit.rm
rm
Definition: submit.py:77
HcalFrontEndId::hcalFrontEndId_
uint32_t hcalFrontEndId_
Definition: HcalFrontEndId.h:38
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
operator<<
std::ostream & operator<<(std::ostream &s, const HcalFrontEndId &id)
Definition: HcalFrontEndId.cc:81
HcalFrontEndId::HcalFrontEndId
HcalFrontEndId()
Definition: HcalFrontEndId.h:10
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
HcalFrontEndId::rbx
std::string rbx() const
Definition: HcalFrontEndId.cc:63
HcalFrontEndId::adc
int adc() const
Definition: HcalFrontEndId.h:31