test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorDbHardcode.cc
Go to the documentation of this file.
1 //
2 // F.Ratnikov (UMd), Dec 14, 2005
3 // Adapted for Castor by L. Mundim
4 //
5 #include <vector>
6 #include <string>
7 
8 #include "CLHEP/Random/RandGauss.h"
11 
12 
15  float value0 = fId.genericSubdet() == HcalGenericDetId::HcalGenForward ? 11. : 4.; // fC
16  float value [4] = {value0, value0, value0, value0};
17  if (fSmear) {
18  for (int i = 0; i < 4; i++) {
19  value [i] = CLHEP::RandGauss::shoot (value0, width.getWidth (i) / 100.); // ignore correlations, assume 10K pedestal run
20  while (value [i] <= 0) value [i] = CLHEP::RandGauss::shoot (value0, width.getWidth (i));
21  }
22  }
23  CastorPedestal result (fId.rawId (),
24  value[0], value[1], value[2], value[3]
25  );
26  return result;
27 }
28 
30  float value = 0;
31  /*
32  if (fId.genericSubdet() == HcalGenericDetId::HcalGenBarrel ||
33  fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) value = 0.7;
34  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) value = 0.9;
35  else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) value = 2.5;
36  */
37  // everything in fC
39  for (int i = 0; i < 4; i++) {
40  double width = value;
41  for (int j = 0; j < 4; j++) {
42  result.setSigma (i, j, i == j ? width * width : 0);
43  }
44  }
45  return result;
46 }
47 
50  float value0 = 0;
51  if (fId.genericSubdet() != HcalGenericDetId::HcalGenForward) value0 = 0.177; // GeV/fC
52  else {
53  if (HcalDetId(fId).depth() == 1) value0 = 0.2146;
54  else if (HcalDetId(fId).depth() == 2) value0 = 0.3375;
55  }
56  float value [4] = {value0, value0, value0, value0};
57  if (fSmear) for (int i = 0; i < 4; i++) value [i] = CLHEP::RandGauss::shoot (value0, width.getValue (i));
58  CastorGain result (fId.rawId (), value[0], value[1], value[2], value[3]);
59  return result;
60 }
61 
63  float value = 0;
65  return result;
66 }
67 
69  CastorQIECoder result (fId.rawId ());
70  float offset = 0;
71  float slope = fId.genericSubdet () == HcalGenericDetId::HcalGenForward ? 0.36 : 0.92; // ADC/fC
72  for (unsigned range = 0; range < 4; range++) {
73  for (unsigned capid = 0; capid < 4; capid++) {
74  result.setOffset (capid, range, offset);
75  result.setSlope (capid, range, slope);
76  }
77  }
78  return result;
79 }
80 
83  float lowEdges [32];
84  for (int i = 0; i < 32; i++) lowEdges[i] = -1.5 + i*0.35;
85  result.setMinCharges (lowEdges);
86  return result;
87 }
88 
90  return CastorQIEShape ();
91 }
92 
94  CastorRecoParam result(fId.rawId(), 4, 2);
95  return result;
96 }
97 
100  return result;
101 }
102 
103 #define EMAP_NHBHECR 9
104 #define EMAP_NHFCR 3
105 #define EMAP_NHOCR 4
106 #define EMAP_NFBR 8
107 #define EMAP_NFCH 3
108 #define EMAP_NHTRS 3
109 #define EMAP_NHSETS 4
110 #define EMAP_NTOPBOT 2
111 #define EMAP_NHTRSHO 4
112 #define EMAP_NHSETSHO 3
113 
115 
116  /* HBHE crate numbering */
117  int hbhecrate[EMAP_NHBHECR]={0,1,4,5,10,11,14,15,17};
118  /* HF crate numbering */
119  int hfcrate[EMAP_NHFCR]={2,9,12};
120  /* HO crate numbering */
121  int hocrate[EMAP_NHOCR]={3,7,6,13};
122  /* HBHE FED numbering of DCCs */
123  int fedhbhenum[EMAP_NHBHECR][2]={{702,703},{704,705},{700,701},
124  {706,707},{716,717},{708,709},
125  {714,715},{710,711},{712,713}};
126  /* HF FED numbering of DCCs */
127  int fedhfnum[EMAP_NHFCR][2]={{718,719},{720,721},{722,723}};
128  /* HO FED numbering of DCCs */
129  int fedhonum[EMAP_NHOCR][2]={{724,725},{726,727},{728,729},{730,731}};
130  /* HBHE/HF htr slot offsets for set of three htrs */
131  int ihslot[EMAP_NHSETS]={2,5,13,16};
132  /* HO htr slot offsets for three sets of four htrs */
133  int ihslotho[EMAP_NHSETSHO][EMAP_NHTRSHO]={{2,3,4,5},{6,7,13,14},{15,16,17,18}};
134  /* iphi (lower) starting index for each HBHE crate */
135  int ihbhephis[EMAP_NHBHECR]={11,19,3,27,67,35,59,43,51};
136  /* iphi (lower) starting index for each HF crate */
137  int ihfphis[EMAP_NHFCR]={3,27,51};
138  /* iphi (lower) starting index for each HO crate */
139  int ihophis[EMAP_NHOCR]={71,17,35,53};
140  /* ihbheetadepth - unique HBHE {eta,depth} assignments per fiber and fiber channel */
141  int ihbheetadepth[EMAP_NHTRS][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2]={
142  {{{{11,1},{ 7,1},{ 3,1}}, /* htr 0 (HB) -bot(+top) */
143  {{ 5,1},{ 1,1},{ 9,1}},
144  {{11,1},{ 7,1},{ 3,1}},
145  {{ 5,1},{ 1,1},{ 9,1}},
146  {{10,1},{ 6,1},{ 2,1}},
147  {{ 8,1},{ 4,1},{12,1}},
148  {{10,1},{ 6,1},{ 2,1}},
149  {{ 8,1},{ 4,1},{12,1}}},
150  {{{11,1},{ 7,1},{ 3,1}}, /* htr 0 (HB) +bot(-top) */
151  {{ 5,1},{ 1,1},{ 9,1}},
152  {{11,1},{ 7,1},{ 3,1}},
153  {{ 5,1},{ 1,1},{ 9,1}},
154  {{10,1},{ 6,1},{ 2,1}},
155  {{ 8,1},{ 4,1},{12,1}},
156  {{10,1},{ 6,1},{ 2,1}},
157  {{ 8,1},{ 4,1},{12,1}}}},
158  {{{{16,2},{15,2},{14,1}}, /* htr 1 (HBHE) -bot(+top) */
159  {{15,1},{13,1},{16,1}},
160  {{16,2},{15,2},{14,1}},
161  {{15,1},{13,1},{16,1}},
162  {{17,1},{16,3},{26,1}},
163  {{18,1},{18,2},{26,2}},
164  {{17,1},{16,3},{25,1}},
165  {{18,1},{18,2},{25,2}}},
166  {{{16,2},{15,2},{14,1}}, /* htr 1 (HBHE) +bot(-top) */
167  {{15,1},{13,1},{16,1}},
168  {{16,2},{15,2},{14,1}},
169  {{15,1},{13,1},{16,1}},
170  {{17,1},{16,3},{25,1}},
171  {{18,1},{18,2},{25,2}},
172  {{17,1},{16,3},{26,1}},
173  {{18,1},{18,2},{26,2}}}},
174  {{{{28,1},{28,2},{29,1}}, /* htr 2 (HE) -bot(+top) */
175  {{28,3},{24,2},{24,1}},
176  {{27,1},{27,2},{29,2}},
177  {{27,3},{23,2},{23,1}},
178  {{19,2},{20,1},{22,2}},
179  {{19,1},{20,2},{22,1}},
180  {{19,2},{20,1},{21,2}},
181  {{19,1},{20,2},{21,1}}},
182  {{{27,1},{27,2},{29,2}}, /* htr 2 (HE) +bot(-top) */
183  {{27,3},{23,2},{23,1}},
184  {{28,1},{28,2},{29,1}},
185  {{28,3},{24,2},{24,1}},
186  {{19,2},{20,1},{21,2}},
187  {{19,1},{20,2},{21,1}},
188  {{19,2},{20,1},{22,2}},
189  {{19,1},{20,2},{22,1}}}}
190  };
191  /* ihfetadepth - unique HF {eta,depth} assignments per fiber and fiber channel */
192  int ihfetadepth[EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2]={
193  {{{33,1},{31,1},{29,1}}, /* top */
194  {{32,1},{30,1},{34,1}},
195  {{33,2},{31,2},{29,2}},
196  {{32,2},{30,2},{34,2}},
197  {{34,2},{32,2},{30,2}},
198  {{31,2},{29,2},{33,2}},
199  {{34,1},{32,1},{30,1}},
200  {{31,1},{29,1},{33,1}}},
201  {{{41,1},{37,1},{35,1}}, /* bot */
202  {{38,1},{36,1},{39,1}},
203  {{41,2},{37,2},{35,2}},
204  {{38,2},{36,2},{39,2}},
205  {{40,2},{38,2},{36,2}},
206  {{37,2},{35,2},{39,2}},
207  {{40,1},{38,1},{36,1}},
208  {{37,1},{35,1},{39,1}}}
209  };
210  /* ihoetasidephi - unique HO {eta,side,phi} assignments per fiber and fiber channel */
211  int ihoetasidephi[EMAP_NHTRSHO][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][3]={
212  {{{{ 1,-1,0},{ 2,-1,0},{ 3,-1,0}}, /* htr 0 (HO) top */
213  {{ 1,-1,1},{ 2,-1,1},{ 3,-1,1}},
214  {{ 1,-1,2},{ 2,-1,2},{ 3,-1,2}},
215  {{ 1,-1,3},{ 2,-1,3},{ 3,-1,3}},
216  {{ 1,-1,4},{ 2,-1,4},{ 3,-1,4}},
217  {{ 1,-1,5},{ 2,-1,5},{ 3,-1,5}},
218  {{14, 1,0},{14, 1,1},{14, 1,2}},
219  {{14, 1,3},{14, 1,4},{14, 1,5}}},
220  {{{ 1, 1,0},{ 2, 1,0},{ 3, 1,0}}, /* htr 0 (HO) bot */
221  {{ 1, 1,1},{ 2, 1,1},{ 3, 1,1}},
222  {{ 1, 1,2},{ 2, 1,2},{ 3, 1,2}},
223  {{ 1, 1,3},{ 2, 1,3},{ 3, 1,3}},
224  {{ 1, 1,4},{ 2, 1,4},{ 3, 1,4}},
225  {{ 1, 1,5},{ 2, 1,5},{ 3, 1,5}},
226  {{15, 1,0},{15, 1,1},{15, 1,2}},
227  {{15, 1,3},{15, 1,4},{15, 1,5}}}},
228  {{{{ 6, 1,0},{ 6, 1,1},{ 6, 1,2}}, /* htr 1 (HO) top */
229  {{ 6, 1,3},{ 6, 1,4},{ 6, 1,5}},
230  {{ 7, 1,0},{ 7, 1,1},{ 7, 1,2}},
231  {{ 7, 1,3},{ 7, 1,4},{ 7, 1,5}},
232  {{ 8, 1,0},{ 8, 1,1},{ 8, 1,2}},
233  {{ 8, 1,3},{ 8, 1,4},{ 8, 1,5}},
234  {{ 9, 1,0},{ 9, 1,1},{ 9, 1,2}},
235  {{ 9, 1,3},{ 9, 1,4},{ 9, 1,5}}},
236  {{{10, 1,0},{10, 1,1},{10, 1,2}}, /* htr 1 (HO) bot */
237  {{10, 1,3},{10, 1,4},{10, 1,5}},
238  {{11, 1,0},{11, 1,1},{11, 1,2}},
239  {{11, 1,3},{11, 1,4},{11, 1,5}},
240  {{12, 1,0},{12, 1,1},{12, 1,2}},
241  {{12, 1,3},{12, 1,4},{12, 1,5}},
242  {{13, 1,0},{13, 1,1},{13, 1,2}},
243  {{13, 1,3},{13, 1,4},{13, 1,5}}}},
244  {{{{ 4,-1,0},{ 4,-1,1},{ 0, 0,0}}, /* htr 2 (HO) top */
245  {{ 4,-1,2},{ 4,-1,3},{ 0, 0,0}},
246  {{ 4,-1,4},{ 4,-1,5},{ 0, 0,0}},
247  {{ 0, 0,0},{ 0, 0,0},{ 0, 0,0}},
248  {{ 5,-1,0},{ 5,-1,1},{ 5,-1,2}},
249  {{ 5,-1,3},{ 5,-1,4},{ 5,-1,5}},
250  {{14,-1,0},{14,-1,1},{14,-1,2}},
251  {{14,-1,3},{14,-1,4},{14,-1,5}}},
252  {{{ 4, 1,0},{ 4, 1,1},{ 0, 0,0}}, /* htr 2 (HO) bot */
253  {{ 4, 1,2},{ 4, 1,3},{ 0, 0,0}},
254  {{ 4, 1,4},{ 4, 1,5},{ 0, 0,0}},
255  {{ 0, 0,0},{ 0, 0,0},{ 0, 0,0}},
256  {{ 5, 1,0},{ 5, 1,1},{ 5, 1,2}},
257  {{ 5, 1,3},{ 5, 1,4},{ 5, 1,5}},
258  {{15,-1,0},{15,-1,1},{15,-1,2}},
259  {{15,-1,3},{15,-1,4},{15,-1,5}}}},
260  {{{{ 6,-1,0},{ 6,-1,1},{ 6,-1,2}}, /* htr 3 (HO) top */
261  {{ 6,-1,3},{ 6,-1,4},{ 6,-1,5}},
262  {{ 7,-1,0},{ 7,-1,1},{ 7,-1,2}},
263  {{ 7,-1,3},{ 7,-1,4},{ 7,-1,5}},
264  {{ 8,-1,0},{ 8,-1,1},{ 8,-1,2}},
265  {{ 8,-1,3},{ 8,-1,4},{ 8,-1,5}},
266  {{ 9,-1,0},{ 9,-1,1},{ 9,-1,2}},
267  {{ 9,-1,3},{ 9,-1,4},{ 9,-1,5}}},
268  {{{10,-1,0},{10,-1,1},{10,-1,2}}, /* htr 3 (HO) bot */
269  {{10,-1,3},{10,-1,4},{10,-1,5}},
270  {{11,-1,0},{11,-1,1},{11,-1,2}},
271  {{11,-1,3},{11,-1,4},{11,-1,5}},
272  {{12,-1,0},{12,-1,1},{12,-1,2}},
273  {{12,-1,3},{12,-1,4},{12,-1,5}},
274  {{13,-1,0},{13,-1,1},{13,-1,2}},
275  {{13,-1,3},{13,-1,4},{13,-1,5}}}}
276  };
277  int ic,is,ih,itb,ifb,ifc,ifwtb,iphi_loc;
278  int iside,ieta,iphi,idepth,icrate,ihtr,ihtr_fi,ifi_ch,ispigot,idcc,/*idcc_sl,*/ifed;
279  std::string det;
280  std::string fpga;
281  // printf(" side eta phi depth det crate htr fpga htr_fi fi_ch spigo dcc dcc_sl fedid\n");
282  /* all HBHE crates */
283  for(ic=0; ic<EMAP_NHBHECR; ic++){
284  /* four sets of three htrs per crate */
285  for(is=0; is<EMAP_NHSETS; is++){
286  /* three htrs per set */
287  for(ih=0; ih<EMAP_NHTRS; ih++){
288  /* top and bottom */
289  for(itb=0; itb<EMAP_NTOPBOT; itb++){
290  /* eight fibers per HTR FPGA */
291  for(ifb=0; ifb<EMAP_NFBR; ifb++){
292  /* three channels per fiber */
293  for(ifc=0; ifc<EMAP_NFCH; ifc++){
294  icrate=hbhecrate[ic];
295  iside=is<EMAP_NHSETS/2?-1:1;
296  ifwtb=(is/2+itb+1)%2;
297  ieta=ihbheetadepth[ih][ifwtb][ifb][ifc][0];
298  idepth=ihbheetadepth[ih][ifwtb][ifb][ifc][1];
299  ihtr=ihslot[is]+ih;
300  det=((ieta>16||idepth>2)?("HE"):("HB"));
301  fpga=((itb%2)==1)?("bot"):("top");
302  ihtr_fi=ifb+1;
303  ifi_ch=ifc;
304  iphi=(ieta>20)?(ihbhephis[ic]+(is%2)*4+itb*2-1)%72+1:(ihbhephis[ic]+(is%2)*4+itb*2+(ifb/2+is/2+1)%2-1)%72+1;
305  ispigot=(is%2)*6+ih*2+itb;
306  idcc=is<EMAP_NHSETS/2?1:2;
307  //idcc_sl=idcc==1?9:19;
308  ifed=fedhbhenum[ic][idcc-1];
310  CastorElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
311  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
312  HcalDetId hId((det=="HB")?(HcalBarrel):(HcalEndcap),ieta*iside,iphi,idepth);
313  emap.mapEId2chId(elId,hId);
314 
315  // printf(" %9d %9d %9d %9d %9s %9d %9d %9s %9d %9d %9d %9d %9d %9d\n",iside,ieta,iphi,idepth,&det,icrate,ihtr,&fpga,ihtr_fi,ifi_ch,ispigot,idcc,idcc_sl,ifed);
316  }}}}}}
317  /* all HF crates */
318  for(ic=0; ic<EMAP_NHFCR; ic++){
319  /* four sets of three htrs per crate */
320  for(is=0; is<EMAP_NHSETS; is++){
321  /* three htrs per set */
322  for(ih=0; ih<EMAP_NHTRS; ih++){
323  /* top and bottom */
324  for(itb=0; itb<EMAP_NTOPBOT; itb++){
325  /* eight fibers per HTR FPGA */
326  for(ifb=0; ifb<EMAP_NFBR; ifb++){
327  /* three channels per fiber */
328  for(ifc=0; ifc<EMAP_NFCH; ifc++){
329  icrate=hfcrate[ic];
330  iside=is<EMAP_NHSETS/2?-1:1;
331  ieta=ihfetadepth[itb][ifb][ifc][0];
332  idepth=ihfetadepth[itb][ifb][ifc][1];
333  ihtr=ihslot[is]+ih;
334  det="HF";
335  fpga=((itb%2)==1)?("bot"):("top");
336  ihtr_fi=ifb+1;
337  ifi_ch=ifc;
338  iphi=(ieta>39)?(ihfphis[ic]+(is%2)*12+ih*4-3)%72+1:(ihfphis[ic]+(is%2)*12+ih*4+(ifb/4)*2-1)%72+1;
339  ispigot=(is%2)*6+ih*2+itb;
340  idcc=is<EMAP_NHSETS/2?1:2;
341  //idcc_sl=idcc==1?9:19;
342  ifed=fedhfnum[ic][idcc-1];
343  CastorElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
344  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
345  HcalDetId hId(HcalForward,ieta*iside,iphi,idepth);
346  emap.mapEId2chId(elId,hId);
347  // printf(" %9d %9d %9d %9d %9s %9d %9d %9s %9d %9d %9d %9d %9d %9d\n",iside,ieta,iphi,idepth,&det,icrate,ihtr,&fpga,ihtr_fi,ifi_ch,ispigot,idcc,idcc_sl,ifed);
348  }}}}}}
349  /* all HO crates */
350  for(ic=0; ic<EMAP_NHOCR; ic++){
351  /* three sets of four htrs per crate */
352  for(is=0; is<EMAP_NHSETSHO; is++){
353  /* four htrs per set */
354  for(ih=0; ih<EMAP_NHTRSHO; ih++){
355  /* top and bottom */
356  for(itb=0; itb<EMAP_NTOPBOT; itb++){
357  /* eight fibers per HTR FPGA */
358  for(ifb=0; ifb<EMAP_NFBR; ifb++){
359  /* three channels per fiber */
360  for(ifc=0; ifc<EMAP_NFCH; ifc++){
361  icrate=hocrate[ic];
362  idepth=1;
363  ieta=ihoetasidephi[ih][itb][ifb][ifc][0];
364  iside=ihoetasidephi[ih][itb][ifb][ifc][1];
365  iphi_loc=ihoetasidephi[ih][itb][ifb][ifc][2];
366  ihtr=ihslotho[is][ih];
367  det="HO";
368  fpga=((itb%2)==1)?("bot"):("top");
369  ihtr_fi=ifb+1;
370  ifi_ch=ifc;
371  iphi=(ihophis[ic]+is*6+iphi_loc-1)%72+1;
372  ispigot=ihtr<9?(ihtr-2)*2+itb:(ihtr-13)*2+itb;
373  idcc=ihtr<9?1:2;
374  //idcc_sl=idcc==1?9:19;
375  ifed=fedhonum[ic][idcc-1];
376  CastorElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
377  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
378  if (ieta==0) { // unmapped
380  } else {
381  HcalDetId hId(HcalOuter,ieta*iside,iphi,4); // HO is officially "depth=4"
382  emap.mapEId2chId(elId,hId);
383  }
384  // printf(" %9d %9d %9d %9d %9s %9d %9d %9s %9d %9d %9d %9d %9d %9d\n",iside,ieta,iphi,idepth,&det,icrate,ihtr,&fpga,ihtr_fi,ifi_ch,ispigot,idcc,idcc_sl,ifed);
385  }}}}}}
386 
387 
388  emap.sort();
389 
390 }
CastorPedestalWidth makePedestalWidth(HcalGenericDetId fId)
static const HcalDetId Undefined
Definition: HcalDetId.h:80
int i
Definition: DBlmapReader.cc:9
CastorQIECoder makeQIECoder(HcalGenericDetId fId)
#define EMAP_NHSETSHO
#define EMAP_NHTRSHO
void makeHardcodeMap(CastorElectronicsMap &emap)
static const double slope[3]
#define EMAP_NHTRS
void setHTR(int crate, int slot, int tb)
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
float getValue(int fCapId) const
get value for capId = 0..3
tuple result
Definition: mps_fire.py:83
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
#define EMAP_NFCH
int depth() const
get the tower depth
Definition: HcalDetId.cc:106
CastorQIEShape makeQIEShape()
CastorRecoParam makeRecoParam(HcalGenericDetId fId)
#define EMAP_NFBR
CastorSaturationCorr makeSaturationCorr(HcalGenericDetId fId)
int j
Definition: DBlmapReader.cc:9
#define EMAP_NHFCR
CastorGainWidth makeGainWidth(HcalGenericDetId fId)
Definition: DetId.h:18
CastorPedestal makePedestal(HcalGenericDetId fId, bool fSmear=false)
CastorGain makeGain(HcalGenericDetId fId, bool fSmear=false)
#define EMAP_NHSETS
#define EMAP_NHOCR
bool mapEId2chId(CastorElectronicsId fElectronicsId, DetId fId)
Readout chain identification for Castor Bits for the readout chain : some names need change! [31:26] ...
#define EMAP_NTOPBOT
CastorCalibrationQIECoder makeCalibrationQIECoder(HcalGenericDetId fId)
HcalGenericSubdetector genericSubdet() const
#define EMAP_NHBHECR