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 = 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 myzdcsec = HcalZDCDetId::Unknown;
319 
320  (in_sid > 0) ? myzdccheck = true : myzdccheck = false;
321  HcalZDCDetId hzdcdid( myzdcsec, myzdccheck, in_det_ch );
322 
323  // store the different ids
324  hcalEID_ = heid.rawId();
325  hcalZDCDetID_ = hzdcdid.rawId();
326 
327 }
328 
330 
331  static char myline[512];
332 
333  HcalElectronicsId hcaleid(hcalEID_);
334  HcalZDCDetId hcalzdcid(hcalZDCDetID_);
335  HcalGenericDetId hcalgenid(hcalZDCDetID_);
336 
337  int mydcc_sl = -1;
338  int mydcc = -1;
339  if ((hcaleid.dccid()%2)==1) {
340  mydcc_sl = 20;
341  mydcc = 2;
342  }
343  else {
344  mydcc_sl = 10;
345  mydcc = 1;
346  }
347 
348  string myfpga ="";
349  string mydet ="ZDC_";
350  HcalZDCDetId::Section myzdcsec = hcalzdcid.section();
351 
352  if (myzdcsec==0) mydet += "Unknown";
353  else if (myzdcsec==1) mydet += "EM";
354  else if (myzdcsec==2) mydet += "HAD";
355  else mydet += "LUM";
356 
357  (hcaleid.htrTopBottom()==0) ? myfpga = "bot" : myfpga = "top";
358 
359  sprintf(myline,"%1d %5d %2d %2d %3d %6d %7s %7d",0,hcalzdcid.zside(),myx_,myy_,mydx_,hcalzdcid.depth(),mydet.c_str(),hcalzdcid.channel());
360  sprintf(myline+strlen(myline),"%7d %3d %4d %4d %6d %6d %6d",mycable_,myrm_,myqie_,myadc_,myrm_fi_,hcaleid.fiberChanId(),hcaleid.readoutVMECrateId());
361  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);
362 
363  return myline;
364 }
365 
366 
367 // class HTLogicalMapEntry
368 
370  int in_et, int in_ph,
371  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,
372  int in_spig, int in_slb, std::string in_s_slb, std::string in_s_slb2, int in_ndat,
373  std::string in_s_slnam, int in_rctcra, int in_rctcar, int in_rctcon, std::string in_s_rctnam, int in_fed
374  )
375 {
376  myside_ = in_sid;
377  mydphi_ = in_dph;
378  mydepth_ = in_dep;
379  mywedge_ = in_wed;
380  myrctcra_ = in_rctcra;
381  myrctcar_ = in_rctcar;
382  myrctcon_ = in_rctcon;
383 
384  // string data members
385  mydet_ = in_s_chDet;
386  myslbin_ = in_s_slb;
387  myslbin2_ = in_s_slb2;
388  myslnam_ = in_s_slnam;
389  myrctnam_ = in_s_rctnam;
390 
391  // necessary since LMap code makes top = 0, bottom = 1, but det ids have top = 1, bottom = 0
392  int top = 1;
393  in_tb == 1 ? top = 0 : top = 1;
394  //create an hcal electronics id for the trigger tower, idea copied from CalibCalorimetry/HcalAlgos/src/HcalDBASCIIIO.cc
395  HcalElectronicsId hteid( in_ndat, in_slb, in_spig, in_fed - 700, in_cr, in_htr, top );
396  //HcalElectronicsId hteid( slbCh, slb, spigot, dcc, crate, slot, top );
397 
398  //create the hcal trigger tower det id
399  HcalTrigTowerDetId htrigdid( in_et, in_ph );
400 
401  // store the different ids
402  hcalTrigEID_ = hteid.rawId();
403  hcalTrigDetID_ = htrigdid.rawId();
404 
405 }
406 
408  static char myline[512];
409  HcalElectronicsId hcaltrigeid(hcalTrigEID_);
410  HcalTrigTowerDetId hcaltrigid(hcalTrigDetID_);
411  HcalGenericDetId hcalgenid(hcalTrigDetID_);
412 
413  int mydcc_sl = 0;
414  int mydcc = 0;
415  if ((hcaltrigeid.dccid()%2)==1) {
416  mydcc_sl = 20;
417  mydcc = 2;
418  }
419  else {
420  mydcc_sl = 10;
421  mydcc = 1;
422  }
423 
424  string myfpga ="";
425  ( hcaltrigeid.htrTopBottom()==0 ) ? myfpga = "bot" : myfpga = "top";
426 
427  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());
428  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());
429  sprintf(myline+strlen(myline),"%13s %7d %7d %7d %17s %6d\n",myslnam_.c_str(),myrctcra_,myrctcar_,myrctcon_,myrctnam_.c_str(),hcaltrigeid.dccid()+700);
430 
431  return myline;
432 }
433 
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:30
uint32_t rawId() const
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:32
uint32_t rawId() const
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:34
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:43
int depth() const
get the tower depth
Definition: HcalDetId.h:40
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:31
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:36
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:34
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:38
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:38
int channel() const
get the channel
Definition: HcalZDCDetId.h:40
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