CMS 3D CMS Logo

HcalMappingEntry.cc
Go to the documentation of this file.
4 
6 
7 #include <iostream>
8 #include <fstream>
9 #include <sstream>
10 #include <cstdio>
11 #include <string>
12 #include <cstring>
13 
14 using namespace std;
15 
16 //class HBHEHFLogicalMapEntry
17 
19  int in_htr_fi,
20  int in_spig,
21  int in_fed,
22  int in_cr,
23  int in_htr,
24  std::string in_s_fpga,
25  std::string in_s_det,
26  int in_sid,
27  int in_et,
28  int in_ph,
29  int in_dep,
30  int in_dph,
31  int in_wed,
32  int in_rm,
33  int in_rm_fi,
34  int in_pix,
35  int in_qie,
36  int in_adc,
37  int in_slb,
38  int in_rctcra,
39  int in_rctcar,
40  int in_rctcon,
41  std::string in_s_rbx,
42  std::string in_s_slb,
43  std::string in_s_slb2,
44  std::string in_s_slnam,
45  std::string in_s_rctnam) {
46  int mytopbot;
47  (in_s_fpga == "bot") ? mytopbot = 0 : mytopbot = 1;
48 
49  mydphi_ = in_dph;
50  mywedge_ = in_wed;
51  myslb_ = in_slb;
52  myrctcra_ = in_rctcra;
53  myrctcar_ = in_rctcar;
54  myrctcon_ = in_rctcon;
55 
56  // string data members
57  myslbin_ = in_s_slb;
58  myslbin2_ = in_s_slb2;
59  myslnam_ = in_s_slnam;
60  myrctnam_ = in_s_rctnam;
61 
62  // create the hcal electronics id
63  HcalElectronicsId heid(in_fi_ch, in_htr_fi, in_spig, in_fed - 700);
64  heid.setHTR(in_cr, in_htr, mytopbot);
65  // create the hcal detector id
66  HcalSubdetector mysubdet = HcalEmpty;
67  if (in_s_det == "HB")
68  mysubdet = HcalBarrel;
69  else if (in_s_det == "HE")
70  mysubdet = HcalEndcap;
71  else if (in_s_det == "HF")
72  mysubdet = HcalForward;
73 
74  HcalDetId hdid(mysubdet, in_sid * in_et, in_ph, in_dep);
75 
76  HcalFrontEndId hrbx(in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc);
77 
78  // store the different ids
79  hcalEID_ = heid.rawId();
80  hcalDetID_ = hdid.rawId();
81  hcalFrontEndID_ = hrbx.rawId();
82 }
83 
85  static char myline[512];
86 
87  HcalElectronicsId hcaleid(hcalEID_);
88  HcalDetId hcaldid(hcalDetID_);
89  HcalGenericDetId hcalgenid(hcalDetID_);
90  HcalFrontEndId rbxid(hcalFrontEndID_);
91 
92  int mydcc_sl = 0;
93  int mydcc = 0;
94  if ((hcaleid.dccid() % 2) == 1) {
95  mydcc_sl = 20;
96  mydcc = 2;
97  } else {
98  mydcc_sl = 10;
99  mydcc = 1;
100  }
101 
102  string myfpga = "";
103  string mydet = "";
104  HcalSubdetector mysubdet = hcaldid.subdet();
105  (mysubdet == 1)
106  ? mydet = "HB"
107  : ((mysubdet == 2) ? mydet = "HE"
108  : ((mysubdet == 3) ? mydet = "HO" : ((mysubdet == 4) ? mydet = "HF" : mydet = "invalid")));
109 
110  (hcaleid.htrTopBottom() == 0) ? myfpga = "bot" : myfpga = "top";
111 
112  sprintf(myline,
113  "%1d %6d %6d %6d %6d %6d %6s %7s %6d %6d %6d",
114  0,
115  hcaldid.zside(),
116  hcaldid.ietaAbs(),
117  hcaldid.iphi(),
118  mydphi_,
119  hcaldid.depth(),
120  mydet.c_str(),
121  rbxid.rbx().c_str(),
122  mywedge_,
123  rbxid.rm(),
124  rbxid.pixel());
125  sprintf(myline + strlen(myline),
126  "%6d %6d %6d %6d %6d %6d %6s",
127  rbxid.qieCard(),
128  rbxid.adc(),
129  rbxid.rmFiber(),
130  hcaleid.fiberChanId(),
131  hcaleid.readoutVMECrateId(),
132  hcaleid.htrSlot(),
133  myfpga.c_str());
134  sprintf(myline + strlen(myline),
135  "%8d %7d %6d %6d %6d %6s",
136  hcaleid.fiberIndex(),
137  mydcc_sl,
138  hcaleid.spigot(),
139  mydcc,
140  myslb_,
141  myslbin_.c_str());
142  sprintf(myline + strlen(myline),
143  "%8s %15s %6d %6d %6d %20s %6d\n",
144  myslbin2_.c_str(),
145  myslnam_.c_str(),
146  myrctcra_,
147  myrctcar_,
148  myrctcon_,
149  myrctnam_.c_str(),
150  hcaleid.dccid() + 700);
151 
152  return myline;
153 }
154 
155 // class HOHXLogicalMapEntry
156 
158  int in_htr_fi,
159  int in_spig,
160  int in_fed,
161  int in_cr,
162  int in_htr,
163  std::string in_s_fpga,
164  std::string in_s_det,
165  int in_sid,
166  int in_et,
167  int in_ph,
168  int in_dep,
169  int in_dph,
170  int in_sec,
171  int in_rm,
172  int in_rm_fi,
173  int in_pix,
174  int in_qie,
175  int in_adc,
176  std::string in_s_rbx,
177  std::string in_s_let) {
178  int mytopbot;
179  (in_s_fpga == "bot") ? mytopbot = 0 : mytopbot = 1;
180 
181  mydphi_ = in_dph;
182  mysector_ = in_sec;
183  // string data members
184  myletter_ = in_s_let;
185 
186  // create the hcal electronics id
187  HcalElectronicsId heid(in_fi_ch, in_htr_fi, in_spig, in_fed - 700);
188  heid.setHTR(in_cr, in_htr, mytopbot);
189 
190  if (in_s_det == "HO") {
191  //create the hcal det id in the case of regular HO channel
192  HcalDetId hdid(HcalOuter, in_sid * in_et, in_ph, in_dep);
193  hcalDetID_ = hdid.rawId();
194  } else {
195  //create the calib det id in the case of HO cross talk channels
196  HcalCalibDetId hdid(in_sid * in_et, in_ph);
197  hcalDetID_ = hdid.rawId();
198  }
199 
200  HcalFrontEndId hrbx(in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc);
201 
202  // store the different ids
203  hcalEID_ = heid.rawId();
204  hcalFrontEndID_ = hrbx.rawId();
205 }
206 
208  static char myline[512];
209 
210  HcalElectronicsId hcaleid(hcalEID_);
211  HcalGenericDetId hcalgenid(hcalDetID_);
212  HcalFrontEndId rbxid(hcalFrontEndID_);
213 
214  int mydcc_sl = 0;
215  int mydcc = 0;
216  if ((hcaleid.dccid() % 2) == 1) {
217  mydcc_sl = 20;
218  mydcc = 2;
219  } else {
220  mydcc_sl = 10;
221  mydcc = 1;
222  }
223 
224  string myfpga = "";
225  string mydet = "";
226  int mydepth = 0;
227  int myside = -2;
228  int myeta = 0;
229  int myphi = -1;
230  if (hcalgenid.isHcalCalibDetId()) {
231  HcalCalibDetId hcalcompid(hcalDetID_);
232  mydet = "HOX";
233  mydepth = 4;
234  myside = hcalcompid.zside();
235  myeta = hcalcompid.ieta() * myside;
236  myphi = hcalcompid.iphi();
237  } else if (hcalgenid.isHcalDetId()) {
238  HcalDetId hcalcompid(hcalDetID_);
239  HcalSubdetector mysubdet = hcalcompid.subdet();
240  (mysubdet == HcalBarrel)
241  ? mydet = "HB"
242  : ((mysubdet == HcalEndcap)
243  ? mydet = "HE"
244  : ((mysubdet == HcalOuter) ? mydet = "HO"
245  : ((mysubdet == HcalForward) ? mydet = "HF" : mydet = "invalid")));
246  mydepth = hcalcompid.depth();
247  myside = hcalcompid.zside();
248  myeta = hcalcompid.ietaAbs();
249  myphi = hcalcompid.iphi();
250  }
251 
252  (hcaleid.htrTopBottom() == 0) ? myfpga = "bot" : myfpga = "top";
253 
254  sprintf(myline,
255  "%1d %6d %6d %6d %6d %6d %6s %7s %6d %6d %6d",
256  0,
257  myside,
258  myeta,
259  myphi,
260  mydphi_,
261  mydepth,
262  mydet.c_str(),
263  rbxid.rbx().c_str(),
264  mysector_,
265  rbxid.rm(),
266  rbxid.pixel());
267  sprintf(myline + strlen(myline),
268  "%6d %6d %6d %6d %8s %6d %6d %6s",
269  rbxid.qieCard(),
270  rbxid.adc(),
271  rbxid.rmFiber(),
272  hcaleid.fiberChanId(),
273  myletter_.c_str(),
274  hcaleid.readoutVMECrateId(),
275  hcaleid.htrSlot(),
276  myfpga.c_str());
277  sprintf(myline + strlen(myline),
278  "%8d %7d %6d %6d %6d\n",
279  hcaleid.fiberIndex(),
280  mydcc_sl,
281  hcaleid.spigot(),
282  mydcc,
283  hcaleid.dccid() + 700);
284 
285  return myline;
286 }
287 
288 // class CalibLogicalMapEntry
289 
291  int in_htr_fi,
292  int in_spig,
293  int in_fed,
294  int in_cr,
295  int in_htr,
296  std::string in_s_fpga,
297  std::string in_s_det,
298  int in_et,
299  int in_ph,
300  int in_ch_ty,
301  int in_sid,
302  int in_dph,
303  std::string in_s_rbx,
304  int in_wed,
305  int in_rm_fi,
306  std::string in_s_subdet) {
307  int mytopbot;
308  (in_s_fpga == "bot") ? mytopbot = 0 : mytopbot = 1;
309 
310  myside_ = in_sid;
311  mydphi_ = in_dph;
312  mywedge_ = in_wed;
313  // string data members
314  mycalibsubdet_ = in_s_subdet;
315 
316  //create the hcal electronics id
317  HcalElectronicsId heid(in_fi_ch, in_htr_fi, in_spig, in_fed - 700);
318  heid.setHTR(in_cr, in_htr, mytopbot);
319 
320  //create the hcal det id for a calibration unit channel
321  HcalSubdetector mysubdet = HcalEmpty;
322  if (in_s_det == "HB")
323  mysubdet = HcalBarrel;
324  else if (in_s_det == "HE")
325  mysubdet = HcalEndcap;
326  else if (in_s_det == "HO")
327  mysubdet = HcalOuter;
328  else if (in_s_det == "HF")
329  mysubdet = HcalForward;
330 
331  HcalCalibDetId hcalibdid(mysubdet, in_et, in_ph, in_ch_ty);
332 
333  int in_rm, in_pix, in_qie, in_adc;
334  //CM RM in HF is 4 rather than 5
335  if (in_s_det == "HF")
336  in_rm = 4;
337  else
338  in_rm = 5;
339 
340  in_pix = 0;
341  in_qie = 1;
342  in_adc = in_fi_ch + (3 * (in_rm_fi - 1));
343 
344  HcalFrontEndId hrbx(in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc);
345 
346  //store the different ids
347  hcalEID_ = heid.rawId();
348  hcalCalibDetID_ = hcalibdid.rawId();
349  hcalFrontEndID_ = hrbx.rawId();
350 }
351 
353  static char myline[512];
354 
355  HcalElectronicsId hcaleid(hcalEID_);
356  HcalCalibDetId hcalcalibid(hcalCalibDetID_);
357  HcalGenericDetId hcalgenid(hcalCalibDetID_);
358  HcalFrontEndId rbxid(hcalFrontEndID_);
359 
360  int mydcc_sl = 0;
361  int mydcc = 0;
362  if ((hcaleid.dccid() % 2) == 1) {
363  mydcc_sl = 20;
364  mydcc = 2;
365  } else {
366  mydcc_sl = 10;
367  mydcc = 1;
368  }
369 
370  string myfpga = "";
371  string mydet = "";
372  HcalSubdetector mysubdet = hcalcalibid.hcalSubdet();
373  (mysubdet == HcalBarrel)
374  ? mydet = "HB"
375  : ((mysubdet == HcalEndcap)
376  ? mydet = "HE"
377  : ((mysubdet == HcalOuter) ? mydet = "HO"
378  : ((mysubdet == HcalForward) ? mydet = "HF" : mydet = "invalid")));
379  (hcaleid.htrTopBottom() == 0) ? myfpga = "bot" : myfpga = "top";
380 
381  sprintf(myline,
382  "%1d %6d %6d %6d %6d %6s %7s",
383  0,
384  myside_,
385  hcalcalibid.ieta(),
386  hcalcalibid.iphi(),
387  mydphi_,
388  mydet.c_str(),
389  rbxid.rbx().c_str());
390  sprintf(myline + strlen(myline),
391  "%8d %6d %6d %6d %6d %4d %5s",
392  mywedge_,
393  rbxid.rm(),
394  rbxid.rmFiber(),
395  hcaleid.fiberChanId(),
396  hcaleid.readoutVMECrateId(),
397  hcaleid.htrSlot(),
398  myfpga.c_str());
399  sprintf(myline + strlen(myline),
400  "%8d %7d %6d %4d %6d %8d %9s\n",
401  hcaleid.fiberIndex(),
402  mydcc_sl,
403  hcaleid.spigot(),
404  mydcc,
405  hcaleid.dccid() + 700,
406  hcalcalibid.cboxChannel(),
407  mycalibsubdet_.c_str());
408 
409  return myline;
410 }
411 
412 // class ZDCLogicalMapEntry
413 
415  int in_htr_fi,
416  int in_spigot,
417  int in_fed,
418  int in_cr,
419  int in_htr,
420  std::string in_s_fpga,
421  std::string in_s_det,
422  int in_sid,
423  int in_dep,
424  int in_x,
425  int in_y,
426  int in_dx,
427  int in_det_ch,
428  int in_cab,
429  int in_rm,
430  int in_qie,
431  int in_adc,
432  int in_rm_fi) {
433  int mytopbot;
434  (in_s_fpga == "bot") ? mytopbot = 0 : mytopbot = 1;
435 
436  myx_ = in_x;
437  myy_ = in_y;
438  mydx_ = in_dx;
439  mycable_ = in_cab;
440  myrm_ = in_rm;
441  myqie_ = in_qie;
442  myadc_ = in_adc;
443  myrm_fi_ = in_rm_fi;
444 
445  // create the hcal electronics id
446  HcalElectronicsId heid(in_fi_ch, in_htr_fi, in_spigot, in_fed - 700);
447  heid.setHTR(in_cr, in_htr, mytopbot);
448 
449  //create the hcal det id
450  bool myzdccheck;
451  HcalZDCDetId::Section myzdcsec;
452  if (in_s_det == "ZDC_EM")
453  myzdcsec = HcalZDCDetId::EM;
454  else if (in_s_det == "ZDC_HAD")
455  myzdcsec = HcalZDCDetId::HAD;
456  else if (in_s_det == "ZDC_LUM")
457  myzdcsec = HcalZDCDetId::LUM;
458  else if (in_s_det == "ZDC_RPD")
459  myzdcsec = HcalZDCDetId::RPD;
460  else
461  myzdcsec = HcalZDCDetId::Unknown;
462 
463  (in_sid > 0) ? myzdccheck = true : myzdccheck = false;
464  HcalZDCDetId hzdcdid(myzdcsec, myzdccheck, in_det_ch);
465 
466  // store the different ids
467  hcalEID_ = heid.rawId();
468  hcalZDCDetID_ = hzdcdid.rawId();
469 }
470 
472  static char myline[512];
473 
474  HcalElectronicsId hcaleid(hcalEID_);
475  HcalZDCDetId hcalzdcid(hcalZDCDetID_);
476  HcalGenericDetId hcalgenid(hcalZDCDetID_);
477 
478  int mydcc_sl = -1;
479  int mydcc = -1;
480  if ((hcaleid.dccid() % 2) == 1) {
481  mydcc_sl = 20;
482  mydcc = 2;
483  } else {
484  mydcc_sl = 10;
485  mydcc = 1;
486  }
487 
488  string myfpga = "";
489  string mydet = "ZDC_";
490  HcalZDCDetId::Section myzdcsec = hcalzdcid.section();
491 
492  if (myzdcsec == 0)
493  mydet += "Unknown";
494  else if (myzdcsec == 1)
495  mydet += "EM";
496  else if (myzdcsec == 2)
497  mydet += "HAD";
498  else if (myzdcsec == 3)
499  mydet += "LUM";
500  else
501  mydet += "RPD";
502 
503  (hcaleid.htrTopBottom() == 0) ? myfpga = "bot" : myfpga = "top";
504 
505  sprintf(myline,
506  "%1d %5d %2d %2d %3d %6d %7s %7d",
507  0,
508  hcalzdcid.zside(),
509  myx_,
510  myy_,
511  mydx_,
512  hcalzdcid.depth(),
513  mydet.c_str(),
514  hcalzdcid.channel());
515  sprintf(myline + strlen(myline),
516  "%7d %3d %4d %4d %6d %6d %6d",
517  mycable_,
518  myrm_,
519  myqie_,
520  myadc_,
521  myrm_fi_,
522  hcaleid.fiberChanId(),
523  hcaleid.readoutVMECrateId());
524  sprintf(myline + strlen(myline),
525  "%5d %5s %7d %7d %6d %4d %6d\n",
526  hcaleid.htrSlot(),
527  myfpga.c_str(),
528  hcaleid.fiberIndex(),
529  mydcc_sl,
530  hcaleid.spigot(),
531  mydcc,
532  hcaleid.dccid() + 700);
533 
534  return myline;
535 }
536 
537 // class HTLogicalMapEntry
538 
540  int in_ph,
541  int in_sid,
542  int in_dph,
543  int in_dep,
544  std::string in_s_chDet,
545  int in_wed,
546  int in_cr,
547  int in_htr,
548  int in_tb,
549  int in_spig,
550  int in_slb,
551  std::string in_s_slb,
552  std::string in_s_slb2,
553  int in_ndat,
554  std::string in_s_slnam,
555  int in_rctcra,
556  int in_rctcar,
557  int in_rctcon,
558  std::string in_s_rctnam,
559  int in_fed) {
560  myside_ = in_sid;
561  mydphi_ = in_dph;
562  mydepth_ = in_dep;
563  mywedge_ = in_wed;
564  myrctcra_ = in_rctcra;
565  myrctcar_ = in_rctcar;
566  myrctcon_ = in_rctcon;
567 
568  // string data members
569  mydet_ = in_s_chDet;
570  myslbin_ = in_s_slb;
571  myslbin2_ = in_s_slb2;
572  myslnam_ = in_s_slnam;
573  myrctnam_ = in_s_rctnam;
574 
575  // necessary since LMap code makes top = 0, bottom = 1, but det ids have top = 1, bottom = 0
576  int top = 1;
577  in_tb == 1 ? top = 0 : top = 1;
578  //create an hcal electronics id for the trigger tower, idea copied from CalibCalorimetry/HcalAlgos/src/HcalDBASCIIIO.cc
579  HcalElectronicsId hteid(in_ndat, in_slb, in_spig, in_fed - 700, in_cr, in_htr, top);
580  //HcalElectronicsId hteid( slbCh, slb, spigot, dcc, crate, slot, top );
581 
582  //create the hcal trigger tower det id
583  HcalTrigTowerDetId htrigdid(in_et, in_ph);
584 
585  // store the different ids
586  hcalTrigEID_ = hteid.rawId();
587  hcalTrigDetID_ = htrigdid.rawId();
588 }
589 
591  static char myline[512];
592  HcalElectronicsId hcaltrigeid(hcalTrigEID_);
593  HcalTrigTowerDetId hcaltrigid(hcalTrigDetID_);
594  HcalGenericDetId hcalgenid(hcalTrigDetID_);
595 
596  int mydcc_sl = 0;
597  int mydcc = 0;
598  if ((hcaltrigeid.dccid() % 2) == 1) {
599  mydcc_sl = 20;
600  mydcc = 2;
601  } else {
602  mydcc_sl = 10;
603  mydcc = 1;
604  }
605 
606  string myfpga = "";
607  (hcaltrigeid.htrTopBottom() == 0) ? myfpga = "bot" : myfpga = "top";
608 
609  sprintf(myline,
610  "%1d %5d %4d %4d %5d %6d %4s %7d %6d ",
611  0,
612  myside_,
613  hcaltrigid.ieta(),
614  hcaltrigid.iphi(),
615  mydphi_,
616  mydepth_,
617  mydet_.c_str(),
618  mywedge_,
619  hcaltrigeid.readoutVMECrateId());
620  sprintf(myline + strlen(myline),
621  "%4d %5s %7d %6d %4d %4d %6s %7s %5d ",
622  hcaltrigeid.htrSlot(),
623  myfpga.c_str(),
624  mydcc_sl,
625  hcaltrigeid.spigot(),
626  mydcc,
627  hcaltrigeid.slbSiteNumber(),
628  myslbin_.c_str(),
629  myslbin2_.c_str(),
630  hcaltrigeid.slbChannelIndex());
631  sprintf(myline + strlen(myline),
632  "%13s %7d %7d %7d %17s %6d\n",
633  myslnam_.c_str(),
634  myrctcra_,
635  myrctcar_,
636  myrctcon_,
637  myrctnam_.c_str(),
638  hcaltrigeid.dccid() + 700);
639 
640  return myline;
641 }
constexpr int slbSiteNumber() const
get the SLB site number (valid only for VME trigger-chain ids)
constexpr void setHTR(int crate, int slot, int tb)
int cboxChannel() const
get the calibration box channel (if relevant)
constexpr int readoutVMECrateId() const
get the readout VME crate number
int rm() const
int qieCard() const
constexpr int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:141
Section section() const
get the section
Definition: HcalZDCDetId.cc:44
constexpr int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:148
constexpr int htrSlot() const
get the htr slot
int ieta() const
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
int iphi() const
get the tower iphi
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
bool isHcalDetId() const
constexpr int fiberIndex() const
get the fiber index. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zer...
int iphi() const
get the low-edge iphi (if relevant)
int pixel() const
std::string rbx() const
HcalSubdetector
Definition: HcalAssistant.h:31
int zside() const
get the sign of ieta (+/-1)
int depth() const
get the depth (1 for EM, channel + 1 for HAD, 2 for RPD, not sure yet for LUM, leave as default) ...
Definition: HcalZDCDetId.cc:51
int ieta() const
get the tower ieta
bool isHcalCalibDetId() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
constexpr int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
constexpr uint32_t rawId() const
int rmFiber() const
constexpr int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
constexpr int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
constexpr int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
uint32_t rawId() const
constexpr int slbChannelIndex() const
get the SLB channel index (valid only for VME trigger-chain ids)
int adc() const
Readout chain identification for Hcal.
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:39
int channel() const
get the channel
Definition: HcalZDCDetId.cc:63
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164