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 
17 //class HBHEHFLogicalMapEntry
18 
20  int in_fi_ch, int in_htr_fi, int in_spig, int in_fed, int in_cr, int in_htr, std::string in_s_fpga,
21  std::string in_s_det, int in_sid, int in_et, int in_ph, int in_dep,
22  int in_dph, int in_wed, int in_rm, int in_rm_fi, int in_pix, int in_qie, int in_adc,
23  int in_slb, int in_rctcra, int in_rctcar, int in_rctcon,
24  std::string in_s_rbx, std::string in_s_slb, std::string in_s_slb2, std::string in_s_slnam, std::string in_s_rctnam
25  )
26 {
27  int mytopbot;
28  (in_s_fpga=="bot") ? mytopbot = 0 : mytopbot = 1;
29 
30  mydphi_ = in_dph;
31  mywedge_ = in_wed;
32  myslb_ = in_slb;
33  myrctcra_ = in_rctcra;
34  myrctcar_ = in_rctcar;
35  myrctcon_ = in_rctcon;
36 
37  // string data members
38  myslbin_ = in_s_slb;
39  myslbin2_ = in_s_slb2;
40  myslnam_ = in_s_slnam;
41  myrctnam_ = in_s_rctnam;
42 
43  // create the hcal electronics id
44  HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spig, in_fed - 700 );
45  heid.setHTR( in_cr, in_htr, mytopbot );
46  // create the hcal detector id
47  HcalSubdetector mysubdet = HcalEmpty;
48  if (in_s_det=="HB") mysubdet = HcalBarrel;
49  else if (in_s_det=="HE") mysubdet = HcalEndcap;
50  else if (in_s_det=="HF") mysubdet = HcalForward;
51 
52  HcalDetId hdid( mysubdet, in_sid*in_et, in_ph, in_dep );
53 
54  HcalFrontEndId hrbx( in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc );
55 
56  // store the different ids
57  hcalEID_ = heid.rawId();
58  hcalDetID_ = hdid.rawId();
59  hcalFrontEndID_ = hrbx.rawId();
60 }
61 
63 
64  static char myline[512];
65 
66  HcalElectronicsId hcaleid(hcalEID_);
67  HcalDetId hcaldid(hcalDetID_);
68  HcalGenericDetId hcalgenid(hcalDetID_);
69  HcalFrontEndId rbxid(hcalFrontEndID_);
70 
71  int mydcc_sl = 0;
72  int mydcc = 0;
73  if ((hcaleid.dccid()%2)==1) {
74  mydcc_sl = 20;
75  mydcc = 2;
76  }
77  else {
78  mydcc_sl = 10;
79  mydcc = 1;
80  }
81 
82  string myfpga = "";
83  string mydet = "";
84  HcalSubdetector mysubdet = hcaldid.subdet();
85  (mysubdet==1) ? mydet = "HB" :
86  ((mysubdet==2) ? mydet = "HE" :
87  ((mysubdet==3) ? mydet = "HO" :
88  ((mysubdet==4) ? mydet = "HF" :
89  mydet = "invalid")));
90 
91  ( hcaleid.htrTopBottom()==0 ) ? myfpga = "bot" : myfpga = "top";
92 
93  sprintf(myline,"%1d %6d %6d %6d %6d %6d %6s %7s %6d %6d %6d",0,hcaldid.zside(),hcaldid.ietaAbs(),hcaldid.iphi(),mydphi_,hcaldid.depth(),mydet.c_str(),rbxid.rbx().c_str(),mywedge_,rbxid.rm(),rbxid.pixel());
94  sprintf(myline+strlen(myline),"%6d %6d %6d %6d %6d %6d %6s",rbxid.qieCard(),rbxid.adc(),rbxid.rmFiber(),hcaleid.fiberChanId(),hcaleid.readoutVMECrateId(),hcaleid.htrSlot(),myfpga.c_str());
95  sprintf(myline+strlen(myline),"%8d %7d %6d %6d %6d %6s",hcaleid.fiberIndex(),mydcc_sl,hcaleid.spigot(),mydcc,myslb_,myslbin_.c_str());
96  sprintf(myline+strlen(myline),"%8s %15s %6d %6d %6d %20s %6d\n",myslbin2_.c_str(),myslnam_.c_str(),myrctcra_,myrctcar_,myrctcon_,myrctnam_.c_str(),hcaleid.dccid()+700);
97 
98  return myline;
99 }
100 
101 
102 // class HOHXLogicalMapEntry
103 
105  int in_fi_ch, int in_htr_fi, int in_spig, int in_fed, int in_cr, int in_htr, std::string in_s_fpga,
106  std::string in_s_det, int in_sid, int in_et, int in_ph, int in_dep,
107  int in_dph, int in_sec, int in_rm, int in_rm_fi, int in_pix, int in_qie, int in_adc,
108  std::string in_s_rbx, std::string in_s_let
109  )
110 {
111  int mytopbot;
112  (in_s_fpga=="bot") ? mytopbot = 0 : mytopbot = 1;
113 
114  mydphi_ = in_dph;
115  mysector_ = in_sec;
116  // string data members
117  myletter_ = in_s_let;
118 
119  // create the hcal electronics id
120  HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spig, in_fed - 700 );
121  heid.setHTR( in_cr, in_htr, mytopbot );
122 
123  if (in_s_det=="HO") {
124  //create the hcal det id in the case of regular HO channel
125  HcalDetId hdid( HcalOuter, in_sid*in_et, in_ph, in_dep );
126  hcalDetID_ = hdid.rawId();
127  }
128  else {
129  //create the calib det id in the case of HO cross talk channels
130  HcalCalibDetId hdid( in_sid*in_et, in_ph );
131  hcalDetID_ = hdid.rawId();
132  }
133 
134  HcalFrontEndId hrbx( in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc );
135 
136  // store the different ids
137  hcalEID_ = heid.rawId();
138  hcalFrontEndID_ = hrbx.rawId();
139 
140 }
141 
143 
144  static char myline[512];
145 
146  HcalElectronicsId hcaleid(hcalEID_);
147  HcalGenericDetId hcalgenid(hcalDetID_);
148  HcalFrontEndId rbxid(hcalFrontEndID_);
149 
150  int mydcc_sl = 0;
151  int mydcc = 0;
152  if ((hcaleid.dccid()%2)==1) {
153  mydcc_sl = 20;
154  mydcc = 2;
155  }
156  else {
157  mydcc_sl = 10;
158  mydcc = 1;
159  }
160 
161  string myfpga = "";
162  string mydet = "";
163  int mydepth = 0;
164  int myside = -2;
165  int myeta = 0;
166  int myphi = -1;
167  if ( hcalgenid.isHcalCalibDetId() ) {
168  HcalCalibDetId hcalcompid(hcalDetID_);
169  mydet = "HOX";
170  mydepth = 4;
171  myside = hcalcompid.zside();
172  myeta = hcalcompid.ieta()*myside;
173  myphi = hcalcompid.iphi();
174  }
175  else if ( hcalgenid.isHcalDetId() ) {
176  HcalDetId hcalcompid(hcalDetID_);
177  HcalSubdetector mysubdet = hcalcompid.subdet();
178  (mysubdet==HcalBarrel) ? mydet = "HB" :
179  ((mysubdet==HcalEndcap) ? mydet = "HE" :
180  ((mysubdet==HcalOuter) ? mydet = "HO" :
181  ((mysubdet==HcalForward) ? mydet = "HF" :
182  mydet = "invalid")));
183  mydepth = hcalcompid.depth();
184  myside = hcalcompid.zside();
185  myeta = hcalcompid.ietaAbs();
186  myphi = hcalcompid.iphi();
187  }
188 
189  ( hcaleid.htrTopBottom()==0 ) ? myfpga = "bot" : myfpga = "top";
190 
191  sprintf(myline,"%1d %6d %6d %6d %6d %6d %6s %7s %6d %6d %6d",0,myside,myeta,myphi,mydphi_,mydepth,mydet.c_str(),rbxid.rbx().c_str(),mysector_,rbxid.rm(),rbxid.pixel());
192  sprintf(myline+strlen(myline),"%6d %6d %6d %6d %8s %6d %6d %6s",rbxid.qieCard(),rbxid.adc(),rbxid.rmFiber(),hcaleid.fiberChanId(),myletter_.c_str(),hcaleid.readoutVMECrateId(),hcaleid.htrSlot(),myfpga.c_str());
193  sprintf(myline+strlen(myline),"%8d %7d %6d %6d %6d\n",hcaleid.fiberIndex(),mydcc_sl,hcaleid.spigot(),mydcc,hcaleid.dccid()+700);
194 
195  return myline;
196 }
197 
198 
199 // class CalibLogicalMapEntry
200 
202  int in_fi_ch, int in_htr_fi, int in_spig, int in_fed, int in_cr, int in_htr, std::string in_s_fpga,
203  std::string in_s_det, int in_et, int in_ph, int in_ch_ty,
204  int in_sid, int in_dph, std::string in_s_rbx, int in_wed, int in_rm_fi,
205  std::string in_s_subdet
206  )
207 {
208  int mytopbot;
209  (in_s_fpga=="bot") ? mytopbot = 0 : mytopbot = 1;
210 
211  myside_ = in_sid;
212  mydphi_ = in_dph;
213  mywedge_ = in_wed;
214  // string data members
215  mycalibsubdet_ = in_s_subdet;
216 
217  //create the hcal electronics id
218  HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spig, in_fed - 700 );
219  heid.setHTR( in_cr, in_htr, mytopbot );
220 
221  //create the hcal det id for a calibration unit channel
222  HcalSubdetector mysubdet = HcalEmpty;
223  if (in_s_det=="HB") mysubdet = HcalBarrel;
224  else if (in_s_det=="HE") mysubdet = HcalEndcap;
225  else if (in_s_det=="HO") mysubdet = HcalOuter;
226  else if (in_s_det=="HF") mysubdet = HcalForward;
227 
228  HcalCalibDetId hcalibdid( mysubdet, in_et, in_ph, in_ch_ty );
229 
230  int in_rm, in_pix, in_qie, in_adc;
231  //CM RM in HF is 4 rather than 5
232  if (in_s_det=="HF")
233  in_rm = 4;
234  else
235  in_rm = 5;
236 
237  in_pix = 0;
238  in_qie = 1;
239  in_adc = in_fi_ch + ( 3 * ( in_rm_fi - 1 ) );
240 
241  HcalFrontEndId hrbx( in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc );
242 
243  //store the different ids
244  hcalEID_ = heid.rawId();
245  hcalCalibDetID_ = hcalibdid.rawId();
246  hcalFrontEndID_ = hrbx.rawId();
247 }
248 
250 
251  static char myline[512];
252 
253  HcalElectronicsId hcaleid(hcalEID_);
254  HcalCalibDetId hcalcalibid(hcalCalibDetID_);
255  HcalGenericDetId hcalgenid(hcalCalibDetID_);
256  HcalFrontEndId rbxid(hcalFrontEndID_);
257 
258  int mydcc_sl = 0;
259  int mydcc = 0;
260  if ((hcaleid.dccid()%2)==1) {
261  mydcc_sl = 20;
262  mydcc = 2;
263  }
264  else {
265  mydcc_sl = 10;
266  mydcc = 1;
267  }
268 
269  string myfpga = "";
270  string mydet = "";
271  HcalSubdetector mysubdet = hcalcalibid.hcalSubdet();
272  (mysubdet==HcalBarrel) ? mydet = "HB" :
273  ((mysubdet==HcalEndcap) ? mydet = "HE" :
274  ((mysubdet==HcalOuter) ? mydet = "HO" :
275  ((mysubdet==HcalForward) ? mydet = "HF" :
276  mydet = "invalid")));
277  (hcaleid.htrTopBottom()==0) ? myfpga = "bot" : myfpga = "top";
278 
279  sprintf(myline,"%1d %6d %6d %6d %6d %6s %7s",0,myside_,hcalcalibid.ieta(),hcalcalibid.iphi(),mydphi_,mydet.c_str(),rbxid.rbx().c_str());
280  sprintf(myline+strlen(myline),"%8d %6d %6d %6d %6d %4d %5s",mywedge_,rbxid.rm(),rbxid.rmFiber(),hcaleid.fiberChanId(),hcaleid.readoutVMECrateId(),hcaleid.htrSlot(),myfpga.c_str());
281  sprintf(myline+strlen(myline),"%8d %7d %6d %4d %6d %8d %9s\n",hcaleid.fiberIndex(),mydcc_sl,hcaleid.spigot(),mydcc,hcaleid.dccid()+700, hcalcalibid.cboxChannel(), mycalibsubdet_.c_str());
282 
283  return myline;
284 }
285 
286 
287 // class ZDCLogicalMapEntry
288 
290  int in_fi_ch, int in_htr_fi, int in_spigot, int in_fed, int in_cr, int in_htr, std::string in_s_fpga,
291  std::string in_s_det, int in_sid, int in_dep,
292  int in_x, int in_y, int in_dx, int in_det_ch, int in_cab, int in_rm, int in_qie,
293  int in_adc, int in_rm_fi
294  )
295 {
296  int mytopbot;
297  (in_s_fpga=="bot") ? mytopbot = 0 : mytopbot = 1;
298 
299  myx_ = in_x;
300  myy_ = in_y;
301  mydx_ = in_dx;
302  mycable_ = in_cab;
303  myrm_ = in_rm;
304  myqie_ = in_qie;
305  myadc_ = in_adc;
306  myrm_fi_ = in_rm_fi;
307 
308  // create the hcal electronics id
309  HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spigot, in_fed - 700 );
310  heid.setHTR( in_cr, in_htr, mytopbot );
311 
312  //create the hcal det id
313  bool myzdccheck;
314  HcalZDCDetId::Section myzdcsec;
315  if (in_s_det=="ZDC_EM") myzdcsec = HcalZDCDetId::EM;
316  else if (in_s_det=="ZDC_HAD") myzdcsec = HcalZDCDetId::HAD;
317  else if (in_s_det=="ZDC_LUM") myzdcsec = HcalZDCDetId::LUM;
318  else if (in_s_det=="ZDC_RPD") myzdcsec = HcalZDCDetId::RPD;
319  else myzdcsec = HcalZDCDetId::Unknown;
320 
321  (in_sid > 0) ? myzdccheck = true : myzdccheck = false;
322  HcalZDCDetId hzdcdid( myzdcsec, myzdccheck, in_det_ch );
323 
324  // store the different ids
325  hcalEID_ = heid.rawId();
326  hcalZDCDetID_ = hzdcdid.rawId();
327 
328 }
329 
331 
332  static char myline[512];
333 
334  HcalElectronicsId hcaleid(hcalEID_);
335  HcalZDCDetId hcalzdcid(hcalZDCDetID_);
336  HcalGenericDetId hcalgenid(hcalZDCDetID_);
337 
338  int mydcc_sl = -1;
339  int mydcc = -1;
340  if ((hcaleid.dccid()%2)==1) {
341  mydcc_sl = 20;
342  mydcc = 2;
343  }
344  else {
345  mydcc_sl = 10;
346  mydcc = 1;
347  }
348 
349  string myfpga ="";
350  string mydet ="ZDC_";
351  HcalZDCDetId::Section myzdcsec = hcalzdcid.section();
352 
353  if (myzdcsec==0) mydet += "Unknown";
354  else if (myzdcsec==1) mydet += "EM";
355  else if (myzdcsec==2) mydet += "HAD";
356  else if (myzdcsec==3) mydet += "LUM";
357  else mydet += "RPD";
358 
359  (hcaleid.htrTopBottom()==0) ? myfpga = "bot" : myfpga = "top";
360 
361  sprintf(myline,"%1d %5d %2d %2d %3d %6d %7s %7d",0,hcalzdcid.zside(),myx_,myy_,mydx_,hcalzdcid.depth(),mydet.c_str(),hcalzdcid.channel());
362  sprintf(myline+strlen(myline),"%7d %3d %4d %4d %6d %6d %6d",mycable_,myrm_,myqie_,myadc_,myrm_fi_,hcaleid.fiberChanId(),hcaleid.readoutVMECrateId());
363  sprintf(myline+strlen(myline),"%5d %5s %7d %7d %6d %4d %6d\n",hcaleid.htrSlot(),myfpga.c_str(),hcaleid.fiberIndex(),mydcc_sl,hcaleid.spigot(),mydcc,hcaleid.dccid()+700);
364 
365  return myline;
366 }
367 
368 
369 // class HTLogicalMapEntry
370 
372  int in_et, int in_ph,
373  int in_sid, int in_dph, int in_dep, std::string in_s_chDet, int in_wed, int in_cr, int in_htr, int in_tb,
374  int in_spig, int in_slb, std::string in_s_slb, std::string in_s_slb2, int in_ndat,
375  std::string in_s_slnam, int in_rctcra, int in_rctcar, int in_rctcon, std::string in_s_rctnam, int in_fed
376  )
377 {
378  myside_ = in_sid;
379  mydphi_ = in_dph;
380  mydepth_ = in_dep;
381  mywedge_ = in_wed;
382  myrctcra_ = in_rctcra;
383  myrctcar_ = in_rctcar;
384  myrctcon_ = in_rctcon;
385 
386  // string data members
387  mydet_ = in_s_chDet;
388  myslbin_ = in_s_slb;
389  myslbin2_ = in_s_slb2;
390  myslnam_ = in_s_slnam;
391  myrctnam_ = in_s_rctnam;
392 
393  // necessary since LMap code makes top = 0, bottom = 1, but det ids have top = 1, bottom = 0
394  int top = 1;
395  in_tb == 1 ? top = 0 : top = 1;
396  //create an hcal electronics id for the trigger tower, idea copied from CalibCalorimetry/HcalAlgos/src/HcalDBASCIIIO.cc
397  HcalElectronicsId hteid( in_ndat, in_slb, in_spig, in_fed - 700, in_cr, in_htr, top );
398  //HcalElectronicsId hteid( slbCh, slb, spigot, dcc, crate, slot, top );
399 
400  //create the hcal trigger tower det id
401  HcalTrigTowerDetId htrigdid( in_et, in_ph );
402 
403  // store the different ids
404  hcalTrigEID_ = hteid.rawId();
405  hcalTrigDetID_ = htrigdid.rawId();
406 
407 }
408 
410  static char myline[512];
411  HcalElectronicsId hcaltrigeid(hcalTrigEID_);
412  HcalTrigTowerDetId hcaltrigid(hcalTrigDetID_);
413  HcalGenericDetId hcalgenid(hcalTrigDetID_);
414 
415  int mydcc_sl = 0;
416  int mydcc = 0;
417  if ((hcaltrigeid.dccid()%2)==1) {
418  mydcc_sl = 20;
419  mydcc = 2;
420  }
421  else {
422  mydcc_sl = 10;
423  mydcc = 1;
424  }
425 
426  string myfpga ="";
427  ( hcaltrigeid.htrTopBottom()==0 ) ? myfpga = "bot" : myfpga = "top";
428 
429  sprintf(myline,"%1d %5d %4d %4d %5d %6d %4s %7d %6d ",0,myside_,hcaltrigid.ieta(),hcaltrigid.iphi(),mydphi_,mydepth_,mydet_.c_str(),mywedge_,hcaltrigeid.readoutVMECrateId());
430  sprintf(myline+strlen(myline),"%4d %5s %7d %6d %4d %4d %6s %7s %5d ",hcaltrigeid.htrSlot(),myfpga.c_str(),mydcc_sl,hcaltrigeid.spigot(),mydcc,hcaltrigeid.slbSiteNumber(),myslbin_.c_str(),myslbin2_.c_str(),hcaltrigeid.slbChannelIndex());
431  sprintf(myline+strlen(myline),"%13s %7d %7d %7d %17s %6d\n",myslnam_.c_str(),myrctcra_,myrctcar_,myrctcon_,myrctnam_.c_str(),hcaltrigeid.dccid()+700);
432 
433  return myline;
434 }
435 
constexpr uint32_t rawId() const
constexpr void setHTR(int crate, int slot, int tb)
int pixel() const
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:146
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:149
uint32_t rawId() const
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:39
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
constexpr int slbChannelIndex() const
get the SLB channel index (valid only for VME trigger-chain ids)
constexpr int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
int ieta() const
get the tower ieta
int ieta() const
get the rbx name (if relevant)
std::string rbx() const
constexpr int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom), valid for VME
int depth() const
get the tower depth
Definition: HcalDetId.h:166
int rm() const
constexpr int htrSlot() const
get the htr slot
HcalSubdetector
Definition: HcalAssistant.h:31
constexpr int readoutVMECrateId() const
get the readout VME crate number
constexpr int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
bool isHcalDetId() const
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:154
int iphi() const
get the low-edge iphi (if relevant)
int iphi() const
get the cell iphi
Definition: HcalDetId.h:161
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 zside() const
get the sign of ieta (+/-1)
int adc() const
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:54
int channel() const
get the channel
Definition: HcalZDCDetId.cc:62
Section section() const
get the section
Definition: HcalZDCDetId.cc:47
int cboxChannel() const
get the calibration box channel (if relevant)
bool isHcalCalibDetId() const
constexpr int slbSiteNumber() const
get the SLB site number (valid only for VME trigger-chain ids)
constexpr int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
int rmFiber() const
int qieCard() const
Readout chain identification for Hcal.
int iphi() const
get the tower iphi