CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalMappingEntry.cc
Go to the documentation of this file.
4 
6 
7 #include <iostream>
8 #include <fstream>
9 #include <sstream>
10 #include <stdio.h>
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 = 19;
75  mydcc = 2;
76  }
77  else {
78  mydcc_sl = 9;
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 = 19;
154  mydcc = 2;
155  }
156  else {
157  mydcc_sl = 9;
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  in_rm = 5;
232  in_pix = 0;
233  in_qie = 1;
234  in_adc = in_fi_ch + ( 3 * ( in_rm_fi - 1 ) );
235 
236  HcalFrontEndId hrbx( in_s_rbx, in_rm, in_pix, in_rm_fi, in_fi_ch, in_qie, in_adc );
237 
238  //store the different ids
239  hcalEID_ = heid.rawId();
240  hcalCalibDetID_ = hcalibdid.rawId();
241  hcalFrontEndID_ = hrbx.rawId();
242 }
243 
245 
246  static char myline[512];
247 
248  HcalElectronicsId hcaleid(hcalEID_);
249  HcalCalibDetId hcalcalibid(hcalCalibDetID_);
250  HcalGenericDetId hcalgenid(hcalCalibDetID_);
251  HcalFrontEndId rbxid(hcalFrontEndID_);
252 
253  int mydcc_sl = 0;
254  int mydcc = 0;
255  if ((hcaleid.dccid()%2)==1) {
256  mydcc_sl = 19;
257  mydcc = 2;
258  }
259  else {
260  mydcc_sl = 9;
261  mydcc = 1;
262  }
263 
264  string myfpga = "";
265  string mydet = "";
266  HcalSubdetector mysubdet = hcalcalibid.hcalSubdet();
267  (mysubdet==HcalBarrel) ? mydet = "HB" :
268  ((mysubdet==HcalEndcap) ? mydet = "HE" :
269  ((mysubdet==HcalOuter) ? mydet = "HO" :
270  ((mysubdet==HcalForward) ? mydet = "HF" :
271  mydet = "invalid")));
272  (hcaleid.htrTopBottom()==0) ? myfpga = "bot" : myfpga = "top";
273 
274  sprintf(myline,"%1d %6d %6d %6d %6d %6s %7s",0,myside_,hcalcalibid.ieta(),hcalcalibid.iphi(),mydphi_,mydet.c_str(),rbxid.rbx().c_str());
275  sprintf(myline+strlen(myline),"%8d %6d %6d %6d %4d %5s",mywedge_,rbxid.rmFiber(),hcaleid.fiberChanId(),hcaleid.readoutVMECrateId(),hcaleid.htrSlot(),myfpga.c_str());
276  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());
277 
278  return myline;
279 }
280 
281 
282 // class ZDCLogicalMapEntry
283 
285  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,
286  std::string in_s_det, int in_sid, int in_dep,
287  int in_x, int in_y, int in_dx, int in_det_ch, int in_cab, int in_rm, int in_qie,
288  int in_adc, int in_rm_fi
289  )
290 {
291  int mytopbot;
292  (in_s_fpga=="bot") ? mytopbot = 0 : mytopbot = 1;
293 
294  myx_ = in_x;
295  myy_ = in_y;
296  mydx_ = in_dx;
297  mycable_ = in_cab;
298  myrm_ = in_rm;
299  myqie_ = in_qie;
300  myadc_ = in_adc;
301  myrm_fi_ = in_rm_fi;
302 
303  // create the hcal electronics id
304  HcalElectronicsId heid( in_fi_ch, in_htr_fi, in_spigot, in_fed - 700 );
305  heid.setHTR( in_cr, in_htr, mytopbot );
306 
307  //create the hcal det id
308  bool myzdccheck;
309  HcalZDCDetId::Section myzdcsec;
310  if (in_s_det=="ZDC_EM") myzdcsec = HcalZDCDetId::EM;
311  else if (in_s_det=="ZDC_HAD") myzdcsec = HcalZDCDetId::HAD;
312  else if (in_s_det=="ZDC_LUM") myzdcsec = HcalZDCDetId::LUM;
313  else myzdcsec = HcalZDCDetId::Unknown;
314 
315  (in_sid > 0) ? myzdccheck = true : myzdccheck = false;
316  HcalZDCDetId hzdcdid( myzdcsec, myzdccheck, in_det_ch );
317 
318  // store the different ids
319  hcalEID_ = heid.rawId();
320  hcalZDCDetID_ = hzdcdid.rawId();
321 
322 }
323 
325 
326  static char myline[512];
327 
328  HcalElectronicsId hcaleid(hcalEID_);
329  HcalZDCDetId hcalzdcid(hcalZDCDetID_);
330  HcalGenericDetId hcalgenid(hcalZDCDetID_);
331 
332  int mydcc_sl = -1;
333  int mydcc = -1;
334  if ((hcaleid.dccid()%2)==1) {
335  mydcc_sl = 19;
336  mydcc = 2;
337  }
338  else {
339  mydcc_sl = 9;
340  mydcc = 1;
341  }
342 
343  string myfpga ="";
344  string mydet ="ZDC_";
345  HcalZDCDetId::Section myzdcsec = hcalzdcid.section();
346 
347  if (myzdcsec==0) mydet += "Unknown";
348  else if (myzdcsec==1) mydet += "EM";
349  else if (myzdcsec==2) mydet += "HAD";
350  else mydet += "LUM";
351 
352  (hcaleid.htrTopBottom()==0) ? myfpga = "bot" : myfpga = "top";
353 
354  sprintf(myline,"%1d %5d %2d %2d %3d %6d %7s %7d",0,hcalzdcid.zside(),myx_,myy_,mydx_,hcalzdcid.depth(),mydet.c_str(),hcalzdcid.channel());
355  sprintf(myline+strlen(myline),"%7d %3d %4d %4d %6d %6d %6d",mycable_,myrm_,myqie_,myadc_,myrm_fi_,hcaleid.fiberChanId(),hcaleid.readoutVMECrateId());
356  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);
357 
358  return myline;
359 }
360 
361 
362 // class HTLogicalMapEntry
363 
365  int in_et, int in_ph,
366  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,
367  int in_spig, int in_slb, std::string in_s_slb, std::string in_s_slb2, int in_ndat,
368  std::string in_s_slnam, int in_rctcra, int in_rctcar, int in_rctcon, std::string in_s_rctnam, int in_fed
369  )
370 {
371  myside_ = in_sid;
372  mydphi_ = in_dph;
373  mydepth_ = in_dep;
374  mywedge_ = in_wed;
375  myrctcra_ = in_rctcra;
376  myrctcar_ = in_rctcar;
377  myrctcon_ = in_rctcon;
378 
379  // string data members
380  mydet_ = in_s_chDet;
381  myslbin_ = in_s_slb;
382  myslbin2_ = in_s_slb2;
383  myslnam_ = in_s_slnam;
384  myrctnam_ = in_s_rctnam;
385 
386  // necessary since LMap code makes top = 0, bottom = 1, but det ids have top = 1, bottom = 0
387  int top = 1;
388  in_tb == 1 ? top = 0 : top = 1;
389  //create an hcal electronics id for the trigger tower, idea copied from CalibCalorimetry/HcalAlgos/src/HcalDBASCIIIO.cc
390  HcalElectronicsId hteid( in_ndat, in_slb, in_spig, in_fed - 700, in_cr, in_htr, top );
391  //HcalElectronicsId hteid( slbCh, slb, spigot, dcc, crate, slot, top );
392 
393  //create the hcal trigger tower det id
394  HcalTrigTowerDetId htrigdid( in_et, in_ph );
395 
396  // store the different ids
397  hcalTrigEID_ = hteid.rawId();
398  hcalTrigDetID_ = htrigdid.rawId();
399 
400 }
401 
403  static char myline[512];
404  HcalElectronicsId hcaltrigeid(hcalTrigEID_);
405  HcalTrigTowerDetId hcaltrigid(hcalTrigDetID_);
406  HcalGenericDetId hcalgenid(hcalTrigDetID_);
407 
408  int mydcc_sl = 0;
409  int mydcc = 0;
410  if ((hcaltrigeid.dccid()%2)==1) {
411  mydcc_sl = 19;
412  mydcc = 2;
413  }
414  else {
415  mydcc_sl = 9;
416  mydcc = 1;
417  }
418 
419  string myfpga ="";
420  ( hcaltrigeid.htrTopBottom()==0 ) ? myfpga = "bot" : myfpga = "top";
421 
422  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());
423  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());
424  sprintf(myline+strlen(myline),"%13s %7d %7d %7d %17s %6d\n",myslnam_.c_str(),myrctcra_,myrctcar_,myrctcon_,myrctnam_.c_str(),hcaltrigeid.dccid()+700);
425 
426  return myline;
427 }
int fiberIndex() const
get the fiber index [1-8] (which of eight fibers carried by a spigot) (valid only for non-trigger-cha...
int pixel() const
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:32
uint32_t rawId() const
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:34
uint32_t rawId() const
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:36
int htrSlot() const
get the htr slot
int ieta() const
get the tower ieta
int ieta() const
get the rbx name (if relevant)
int readoutVMECrateId() const
get the readout VME crate number
std::string rbx() const
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
int depth() const
get the tower depth
Definition: HcalDetId.h:42
int htrTopBottom() const
get the htr top/bottom (1=top/0=bottom)
int rm() const
int dccid() const
get the (Hcal local) DCC id
HcalSubdetector
Definition: HcalAssistant.h:32
int fiberChanId() const
get the fiber channel id (which of three channels on a readout fiber) (valid only for non-trigger-cha...
Section section() const
get the section
Definition: HcalZDCDetId.h:38
bool isHcalDetId() const
int spigot() const
get the spigot (input number on DCC)
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:36
int iphi() const
get the low-edge iphi (if relevant)
int slbChannelIndex() const
get the SLB channel index (valid only for trigger-chain ids)
int iphi() const
get the cell iphi
Definition: HcalDetId.h:40
int zside() const
get the sign of ieta (+/-1)
void setHTR(int crate, int slot, int tb)
int adc() const
int depth() const
get the depth (1 for EM, channel + 1 for HAD, not sure yet for LUM, leave as default) ...
Definition: HcalZDCDetId.h:40
int channel() const
get the channel
Definition: HcalZDCDetId.h:42
int cboxChannel() const
get the calibration box channel (if relevant)
int slbSiteNumber() const
get the SLB site number (valid only for trigger-chain ids)
bool isHcalCalibDetId() const
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
int rmFiber() const
int qieCard() const
Readout chain identification for Hcal [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
int iphi() const
get the tower iphi