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