test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalFrontEndId.cc
Go to the documentation of this file.
2 #include <iomanip>
3 #include <sstream>
4 #include <iostream>
5 #include <cstdlib>
6 
7 
8 HcalFrontEndId::HcalFrontEndId(const std::string& rbx,int rm,int pixel,int rmfiber,int fiberchannel,int qie,int adc)
9 {
11 
12  if (rbx.size()<5) return;
13  if (rm<1 || rm>5) return; //changed to 5 to incorporate CALIB channels which define RM = 5
14  if (pixel<0 || pixel>19) return;
15  if (rmfiber<1 || rmfiber>8) return;
16  if (fiberchannel<0 || fiberchannel>2) return;
17  if (qie<1 || qie>4) return;
18  if (adc<0 || adc>5) return;
19 
20  int num=-1;
21  if (!rbx.compare(0,3,"HBM" )) { num=0 + atoi(rbx.substr(3,2).c_str())-1; }
22  else if (!rbx.compare(0,3,"HBP" )) { num=18 + atoi(rbx.substr(3,2).c_str())-1; }
23  else if (!rbx.compare(0,3,"HEM" )) { num=18*2 + atoi(rbx.substr(3,2).c_str())-1; }
24  else if (!rbx.compare(0,3,"HEP" )) { num=18*3 + atoi(rbx.substr(3,2).c_str())-1; }
25  else if (!rbx.compare(0,4,"HO2M")) { num=18*4 + atoi(rbx.substr(4,2).c_str())-1; }
26  else if (!rbx.compare(0,4,"HO1M")) { num=18*4+12 + atoi(rbx.substr(4,2).c_str())-1; }
27  else if (!rbx.compare(0,3,"HO0" )) { num=18*4+12*2 + atoi(rbx.substr(3,2).c_str())-1; }
28  else if (!rbx.compare(0,4,"HO1P")) { num=18*4+12*3 + atoi(rbx.substr(4,2).c_str())-1; }
29  else if (!rbx.compare(0,4,"HO2P")) { num=18*4+12*4 + atoi(rbx.substr(4,2).c_str())-1; }
30  else if (!rbx.compare(0,3,"HFM" )) { num=18*4+12*5 + atoi(rbx.substr(3,2).c_str())-1; }
31  else if (!rbx.compare(0,3,"HFP" )) { num=18*4+12*6 + atoi(rbx.substr(3,2).c_str())-1; }
32  else return;
33 
34  hcalFrontEndId_|=((adc+1)&0x7);
35  hcalFrontEndId_|=((qie-1)&0x3)<<3;
36  hcalFrontEndId_|=(fiberchannel&0x3)<<5;
37  hcalFrontEndId_|=((rmfiber-1)&0x7)<<7;
38  hcalFrontEndId_|=(pixel&0x1F)<<10;
39  hcalFrontEndId_|=((rm-1)&0x7)<<15;
40  hcalFrontEndId_|=(num&0xFF)<<18;
41 }
42 
44 {
45 }
46 
48 {
49  std::string subdets[11]={"HBM","HBP","HEM","HEP","HO2M","HO1M","HO0","HO1P","HO2P","HFM","HFP"};
50 
51  int box=hcalFrontEndId_>>18;
52  int num=-1;
53  int subdet_index=-1;
54  if (box<18*4) {
55  num=box%18;
56  subdet_index=(box-num)/18;
57  }
58  else {
59  num=(box-18*4)%12;
60  subdet_index=4+(box-18*4-num)/12;
61  }
62  std::stringstream tempss;
63  tempss << std::setw(2) << std::setfill('0') << num+1;
64  return subdets[subdet_index]+tempss.str();
65 }
66 
67 std::ostream& operator<<(std::ostream& s,const HcalFrontEndId& id) {
68  return s << id.rbx() << id.rm() << '[' << id.rmFiber() << '/' << id.fiberChannel()
69  << "] pix=" << id.pixel()
70  << " qiecard=" << id.qieCard() << " adc=" << id.adc();
71 }
int adc(sample_type sample)
get the ADC sample (12 bits)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
std::string rbx() const
string rm
Definition: submit.py:76
char const * subdets[11]
uint32_t hcalFrontEndId_