CMS 3D CMS Logo

PixelROCName.cc
Go to the documentation of this file.
1 //
2 // This class stores the name and related
3 // hardware mapings for a ROC
4 //
5 
7 #include <string>
8 #include <iostream>
9 #include <sstream>
10 #include <cctype>
11 #include <cassert>
12 #include <cstdlib>
13 
14 using namespace std;
15 using namespace pos;
16 
17 PixelROCName::PixelROCName() : id_(0) {}
18 
20 
21 void PixelROCName::setIdFPix(char np, char LR, int disk, int blade, int panel, int plaquet, int roc) {
22  std::string mthn = "[PixelROCName::setIdFPix()]\t\t\t\t ";
23  id_ = 0;
24 
25  //std::cout << __LINE__ << "]\t" << mthn << "subdet: " << subdet << std::endl;
26  //std::cout << __LINE__ << "]\t" << mthn << "np : " << np << std::endl;
27  //std::cout << __LINE__ << "]\t" << mthn << "LR : " << LR << std::endl;
28  //std::cout << __LINE__ << "]\t" << mthn << "disk : " << disk << std::endl;
29 
30  assert(roc >= 0 && roc < 10);
31 
32  if (np == 'p')
33  id_ = (id_ | 0x40000000);
34  //std::cout<< __LINE__ << "]\t" << mthn <<"2 id_="<<std::hex<<id_<<std::dec<<std::endl;
35  if (LR == 'I')
36  id_ = (id_ | 0x20000000);
37  //std::cout<< __LINE__ << "]\t" << mthn <<"3 id_="<<std::hex<<id_<<std::dec<<std::endl;
38  id_ = (id_ | (disk << 12));
39  //std::cout<< __LINE__ << "]\t" << mthn <<"4 id_="<<std::hex<<id_<<std::dec<<std::endl;
40  id_ = (id_ | (blade << 7));
41  //std::cout<< __LINE__ << "]\t" << mthn <<"5 id_="<<std::hex<<id_<<std::dec<<std::endl;
42  id_ = (id_ | ((panel - 1) << 6));
43  //std::cout<< __LINE__ << "]\t" << mthn <<"6 id_="<<std::hex<<id_<<std::dec<<std::endl;
44  id_ = (id_ | ((plaquet - 1) << 4));
45  //std::cout<< __LINE__ << "]\t" << mthn <<"7 id_="<<std::hex<<id_<<std::dec<<std::endl;
46  id_ = (id_ | roc);
47 
48  //std::cout<< __LINE__ << "]\t" << mthn <<"final id_="<<std::hex<<id_<<std::dec<<std::endl;
49 }
50 
51 void PixelROCName::setIdBPix(char np, char LR, int sec, int layer, int ladder, char HF, int module, int roc) {
52  id_ = 0;
53 
54  //std::cout<< __LINE__ << "]\t" << mthn <<"BPix ladder:"<<ladder<<std::endl;
55  //std::cout<< __LINE__ << "]\t" << mthn <<"np : " << np << std::endl;
56  //std::cout<< __LINE__ << "]\t" << mthn <<"LR : " << LR << std::endl;
57  //std::cout<< __LINE__ << "]\t" << mthn <<"disk: " << disk << std::endl;
58 
59  assert(roc >= 0 && roc < 16);
60 
61  id_ = 0x80000000;
62 
63  if (np == 'p')
64  id_ = (id_ | 0x40000000);
65  //std::cout<< __LINE__ << "]\t" << mthn <<"2 id_="<<std::hex<<id_<<std::dec<<std::endl;
66  if (LR == 'I')
67  id_ = (id_ | 0x20000000);
68  //std::cout<< __LINE__ << "]\t" << mthn <<"3 id_="<<std::hex<<id_<<std::dec<<std::endl;
69  id_ = (id_ | ((sec - 1) << 14));
70  //std::cout<< __LINE__ << "]\t" << mthn <<"4 id_="<<std::hex<<id_<<std::dec<<std::endl;
71  if (HF == 'F')
72  id_ = (id_ | 0x00000800);
73 
74  id_ = (id_ | (layer << 12));
75  //std::cout<< __LINE__ << "]\t" << mthn <<"5 id_="<<std::hex<<id_<<std::dec<<std::endl;
76  id_ = (id_ | (ladder << 6));
77  //std::cout<< __LINE__ << "]\t" << mthn <<"6 id_="<<std::hex<<id_<<std::dec<<std::endl;
78  id_ = (id_ | ((module - 1) << 4));
79  //std::cout<< __LINE__ << "]\t" << mthn <<"7 id_="<<std::hex<<id_<<std::dec<<std::endl;
80  id_ = (id_ | roc);
81 
82  //std::cout<< __LINE__ << "]\t" << mthn <<"final id_="<<std::hex<<id_<<std::dec<<std::endl;
83 }
84 
85 void PixelROCName::check(bool check, const string& name) {
86  static std::string mthn = "[PixelROCName::check()]\t\t\t\t ";
87 
88  if (check)
89  return;
90 
91  cout << __LINE__ << "]\t" << mthn << "ERROR tried to parse string:'" << name;
92  cout << "' as a ROC name. Will terminate." << endl;
93 
94  ::abort();
95 }
96 
98  //
99  // The name should be on the format
100  //
101  // FPix_BpR_D1_BLD1_PNL1_PLQ1_ROC1
102  //
103 
104  // std::cout << "[PixelROCName::parsename()]\t\tROC name:"<<name<<std::endl;
105 
106  check(name[0] == 'F' || name[0] == 'B', name);
107 
108  if (name[0] == 'F') {
109  check(name[0] == 'F', name);
110  check(name[1] == 'P', name);
111  check(name[2] == 'i', name);
112  check(name[3] == 'x', name);
113  check(name[4] == '_', name);
114  check(name[5] == 'B', name);
115  check((name[6] == 'm') || (name[6] == 'p'), name);
116  char np = name[6];
117  check((name[7] == 'I') || (name[7] == 'O'), name);
118  char LR = name[7];
119  check(name[8] == '_', name);
120  check(name[9] == 'D', name);
121  char digit[2] = {0, 0};
122  digit[0] = name[10];
123  int disk = atoi(digit);
124  check(name[11] == '_', name);
125  check(name[12] == 'B', name);
126  check(name[13] == 'L', name);
127  check(name[14] == 'D', name);
128  check(std::isdigit(name[15]), name);
129  digit[0] = name[15];
130  int bld = atoi(digit);
131  unsigned int offset = 0;
132  if (std::isdigit(name[16])) {
133  digit[0] = name[16];
134  bld = 10 * bld + atoi(digit);
135  offset++;
136  }
137  check(name[16 + offset] == '_', name);
138  check(name[17 + offset] == 'P', name);
139  check(name[18 + offset] == 'N', name);
140  check(name[19 + offset] == 'L', name);
141  check(std::isdigit(name[20 + offset]), name);
142  digit[0] = name[20 + offset];
143  int pnl = atoi(digit);
144  check(name[21 + offset] == '_', name);
145  check(name[22 + offset] == 'P', name);
146  check(name[23 + offset] == 'L', name);
147  check(name[24 + offset] == 'Q', name);
148  check(std::isdigit(name[25 + offset]), name);
149  digit[0] = name[25 + offset];
150  int plq = atoi(digit);
151  check(name[26 + offset] == '_', name);
152  check(name[27 + offset] == 'R', name);
153  check(name[28 + offset] == 'O', name);
154  check(name[29 + offset] == 'C', name);
155  check(std::isdigit(name[30 + offset]), name);
156  digit[0] = name[30 + offset];
157  int roc = atoi(digit);
158  if (name.size() == 32 + offset) {
159  digit[0] = name[31 + offset];
160  roc = roc * 10 + atoi(digit);
161  }
162 
163  setIdFPix(np, LR, disk, bld, pnl, plq, roc);
164  } else {
165  check(name[0] == 'B', name);
166  check(name[1] == 'P', name);
167  check(name[2] == 'i', name);
168  check(name[3] == 'x', name);
169  check(name[4] == '_', name);
170  check(name[5] == 'B', name);
171  check((name[6] == 'm') || (name[6] == 'p'), name);
172  char np = name[6];
173  check((name[7] == 'I') || (name[7] == 'O'), name);
174  char LR = name[7];
175  check(name[8] == '_', name);
176  check(name[9] == 'S', name);
177  check(name[10] == 'E', name);
178  check(name[11] == 'C', name);
179  char digit[2] = {0, 0};
180  digit[0] = name[12];
181  int sec = atoi(digit);
182  check(name[13] == '_', name);
183  check(name[14] == 'L', name);
184  check(name[15] == 'Y', name);
185  check(name[16] == 'R', name);
186  check(std::isdigit(name[17]), name);
187  digit[0] = name[17];
188  int layer = atoi(digit);
189  check(name[18] == '_', name);
190  check(name[19] == 'L', name);
191  check(name[20] == 'D', name);
192  check(name[21] == 'R', name);
193  check(std::isdigit(name[22]), name);
194  digit[0] = name[22];
195  int ladder = atoi(digit);
196  unsigned int offset = 0;
197  if (std::isdigit(name[23])) {
198  offset++;
199  digit[0] = name[22 + offset];
200  ladder = 10 * ladder + atoi(digit);
201  }
202  check(name[23 + offset] == 'H' || name[23 + offset] == 'F', name);
203  char HF = name[23 + offset];
204  check(name[24 + offset] == '_', name);
205  check(name[25 + offset] == 'M', name);
206  check(name[26 + offset] == 'O', name);
207  check(name[27 + offset] == 'D', name);
208  check(std::isdigit(name[28 + offset]), name);
209  digit[0] = name[28 + offset];
210  int module = atoi(digit);
211  check(name[29 + offset] == '_', name);
212  check(name[30 + offset] == 'R', name);
213  check(name[31 + offset] == 'O', name);
214  check(name[32 + offset] == 'C', name);
215  check(std::isdigit(name[33 + offset]), name);
216  digit[0] = name[33 + offset];
217  int roc = atoi(digit);
218  if (name.size() == 35 + offset) {
219  digit[0] = name[34 + offset];
220  roc = roc * 10 + atoi(digit);
221  }
222 
223  setIdBPix(np, LR, sec, layer, ladder, HF, module, roc);
224  }
225 }
226 
227 PixelROCName::PixelROCName(std::ifstream& s) {
229 
230  s >> tmp;
231 
232  parsename(tmp);
233 }
234 
236  std::string s;
237 
238  std::ostringstream s1;
239 
240  if (detsub() == 'F') {
241  s1 << "FPix";
242  s1 << "_B";
243  s1 << mp();
244  s1 << IO();
245  s1 << "_D";
246  s1 << disk();
247  s1 << "_BLD";
248  s1 << blade();
249  s1 << "_PNL";
250  s1 << panel();
251  s1 << "_PLQ";
252  s1 << plaquet();
253  s1 << "_ROC";
254  s1 << roc();
255 
256  assert(roc() >= 0 && roc() <= 10);
257  } else {
258  s1 << "BPix";
259  s1 << "_B";
260  s1 << mp();
261  s1 << IO();
262  s1 << "_SEC";
263  s1 << sec();
264  s1 << "_LYR";
265  s1 << layer();
266  s1 << "_LDR";
267  s1 << ladder();
268  s1 << HF();
269  s1 << "_MOD";
270  s1 << module();
271  s1 << "_ROC";
272  s1 << roc();
273 
274  assert(roc() >= 0 && roc() <= 15);
275  }
276 
277  s = s1.str();
278 
279  return s;
280 }
281 
282 std::ostream& pos::operator<<(std::ostream& s, const PixelROCName& pixelroc) {
283  // FPix_BpR_D1_BLD1_PNL1_PLQ1_ROC1
284 
285  s << pixelroc.rocname();
286 
287  return s;
288 }
289 
291  id_ = aROC.id_;
292 
293  return *this;
294 }
pos::PixelROCName::parsename
void parsename(std::string name)
Definition: PixelROCName.cc:97
pos::PixelROCName::rocname
std::string rocname() const
Definition: PixelROCName.cc:235
pos::PixelROCName::setIdBPix
void setIdBPix(char np, char LR, int sec, int layer, int ladder, char HF, int module, int roc)
Definition: PixelROCName.cc:51
pos::PixelROCName::PixelROCName
PixelROCName()
Definition: PixelROCName.cc:17
pos::PixelROCName::disk
int disk() const
Definition: PixelROCName.h:39
pos::PixelROCName::layer
int layer() const
Definition: PixelROCName.h:61
pos::PixelROCName::ladder
int ladder() const
Definition: PixelROCName.h:65
pos::PixelROCName::roc
int roc() const
Definition: PixelROCName.h:36
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
np
int np
Definition: AMPTWrapper.h:43
PixelROCName.h
This class stores the name and related hardware mappings for a ROC.
cms::cuda::assert
assert(be >=bs)
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
pos::PixelROCName::IO
char IO() const
Definition: PixelROCName.h:35
alignCSCRings.s
s
Definition: alignCSCRings.py:92
pos::PixelROCName::check
void check(bool check, const std::string &name)
Definition: PixelROCName.cc:85
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
pos::PixelROCName::plaquet
int plaquet() const
Definition: PixelROCName.h:51
pos::PixelROCName::panel
int panel() const
Definition: PixelROCName.h:47
pos::PixelROCName::id_
unsigned int id_
Definition: PixelROCName.h:122
pos::PixelROCName::mp
char mp() const
Definition: PixelROCName.h:34
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
pos::PixelROCName::module
int module() const
Definition: PixelROCName.h:73
pos::operator<<
std::ostream & operator<<(std::ostream &s, const PixelCalibConfiguration &calib)
Definition: PixelCalibConfiguration.cc:1325
pos::PixelROCName
This class implements..
Definition: PixelROCName.h:23
pos::PixelROCName::blade
int blade() const
Definition: PixelROCName.h:43
pos::PixelROCName::setIdFPix
void setIdFPix(char np, char LR, int disk, int blade, int panel, int plaquet, int roc)
Definition: PixelROCName.cc:21
fileinputsource_cfi.sec
sec
Definition: fileinputsource_cfi.py:87
pos::PixelROCName::operator=
const PixelROCName & operator=(const PixelROCName &aROC)
Definition: PixelROCName.cc:290
std
Definition: JetResolutionObject.h:76
pos::PixelROCName::detsub
char detsub() const
Definition: PixelROCName.h:33
PVValHelper::ladder
Definition: PVValidationHelpers.h:72
pos::PixelROCName::HF
char HF() const
Definition: PixelROCName.h:69
PixelMapPlotter.roc
roc
Definition: PixelMapPlotter.py:498
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
pos::PixelROCName::sec
int sec() const
Definition: PixelROCName.h:57
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
DigiToRawDM_cff.HF
HF
Definition: DigiToRawDM_cff.py:22