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.2 2009/03/26 17:49:44 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 
94 
95 #define EMAP_NHBHECR 9
96 #define EMAP_NHFCR 3
97 #define EMAP_NHOCR 4
98 #define EMAP_NFBR 8
99 #define EMAP_NFCH 3
100 #define EMAP_NHTRS 3
101 #define EMAP_NHSETS 4
102 #define EMAP_NTOPBOT 2
103 #define EMAP_NHTRSHO 4
104 #define EMAP_NHSETSHO 3
105 
107 
108  /* HBHE crate numbering */
109  int hbhecrate[EMAP_NHBHECR]={0,1,4,5,10,11,14,15,17};
110  /* HF crate numbering */
111  int hfcrate[EMAP_NHFCR]={2,9,12};
112  /* HO crate numbering */
113  int hocrate[EMAP_NHOCR]={3,7,6,13};
114  /* HBHE FED numbering of DCCs */
115  int fedhbhenum[EMAP_NHBHECR][2]={{702,703},{704,705},{700,701},
116  {706,707},{716,717},{708,709},
117  {714,715},{710,711},{712,713}};
118  /* HF FED numbering of DCCs */
119  int fedhfnum[EMAP_NHFCR][2]={{718,719},{720,721},{722,723}};
120  /* HO FED numbering of DCCs */
121  int fedhonum[EMAP_NHOCR][2]={{724,725},{726,727},{728,729},{730,731}};
122  /* HBHE/HF htr slot offsets for set of three htrs */
123  int ihslot[EMAP_NHSETS]={2,5,13,16};
124  /* HO htr slot offsets for three sets of four htrs */
125  int ihslotho[EMAP_NHSETSHO][EMAP_NHTRSHO]={{2,3,4,5},{6,7,13,14},{15,16,17,18}};
126  /* iphi (lower) starting index for each HBHE crate */
127  int ihbhephis[EMAP_NHBHECR]={11,19,3,27,67,35,59,43,51};
128  /* iphi (lower) starting index for each HF crate */
129  int ihfphis[EMAP_NHFCR]={3,27,51};
130  /* iphi (lower) starting index for each HO crate */
131  int ihophis[EMAP_NHOCR]={71,17,35,53};
132  /* ihbheetadepth - unique HBHE {eta,depth} assignments per fiber and fiber channel */
133  int ihbheetadepth[EMAP_NHTRS][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2]={
134  {{{{11,1},{ 7,1},{ 3,1}}, /* htr 0 (HB) -bot(+top) */
135  {{ 5,1},{ 1,1},{ 9,1}},
136  {{11,1},{ 7,1},{ 3,1}},
137  {{ 5,1},{ 1,1},{ 9,1}},
138  {{10,1},{ 6,1},{ 2,1}},
139  {{ 8,1},{ 4,1},{12,1}},
140  {{10,1},{ 6,1},{ 2,1}},
141  {{ 8,1},{ 4,1},{12,1}}},
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  {{{{16,2},{15,2},{14,1}}, /* htr 1 (HBHE) -bot(+top) */
151  {{15,1},{13,1},{16,1}},
152  {{16,2},{15,2},{14,1}},
153  {{15,1},{13,1},{16,1}},
154  {{17,1},{16,3},{26,1}},
155  {{18,1},{18,2},{26,2}},
156  {{17,1},{16,3},{25,1}},
157  {{18,1},{18,2},{25,2}}},
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},{25,1}},
163  {{18,1},{18,2},{25,2}},
164  {{17,1},{16,3},{26,1}},
165  {{18,1},{18,2},{26,2}}}},
166  {{{{28,1},{28,2},{29,1}}, /* htr 2 (HE) -bot(+top) */
167  {{28,3},{24,2},{24,1}},
168  {{27,1},{27,2},{29,2}},
169  {{27,3},{23,2},{23,1}},
170  {{19,2},{20,1},{22,2}},
171  {{19,1},{20,2},{22,1}},
172  {{19,2},{20,1},{21,2}},
173  {{19,1},{20,2},{21,1}}},
174  {{{27,1},{27,2},{29,2}}, /* htr 2 (HE) +bot(-top) */
175  {{27,3},{23,2},{23,1}},
176  {{28,1},{28,2},{29,1}},
177  {{28,3},{24,2},{24,1}},
178  {{19,2},{20,1},{21,2}},
179  {{19,1},{20,2},{21,1}},
180  {{19,2},{20,1},{22,2}},
181  {{19,1},{20,2},{22,1}}}}
182  };
183  /* ihfetadepth - unique HF {eta,depth} assignments per fiber and fiber channel */
184  int ihfetadepth[EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2]={
185  {{{33,1},{31,1},{29,1}}, /* top */
186  {{32,1},{30,1},{34,1}},
187  {{33,2},{31,2},{29,2}},
188  {{32,2},{30,2},{34,2}},
189  {{34,2},{32,2},{30,2}},
190  {{31,2},{29,2},{33,2}},
191  {{34,1},{32,1},{30,1}},
192  {{31,1},{29,1},{33,1}}},
193  {{{41,1},{37,1},{35,1}}, /* bot */
194  {{38,1},{36,1},{39,1}},
195  {{41,2},{37,2},{35,2}},
196  {{38,2},{36,2},{39,2}},
197  {{40,2},{38,2},{36,2}},
198  {{37,2},{35,2},{39,2}},
199  {{40,1},{38,1},{36,1}},
200  {{37,1},{35,1},{39,1}}}
201  };
202  /* ihoetasidephi - unique HO {eta,side,phi} assignments per fiber and fiber channel */
203  int ihoetasidephi[EMAP_NHTRSHO][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][3]={
204  {{{{ 1,-1,0},{ 2,-1,0},{ 3,-1,0}}, /* htr 0 (HO) top */
205  {{ 1,-1,1},{ 2,-1,1},{ 3,-1,1}},
206  {{ 1,-1,2},{ 2,-1,2},{ 3,-1,2}},
207  {{ 1,-1,3},{ 2,-1,3},{ 3,-1,3}},
208  {{ 1,-1,4},{ 2,-1,4},{ 3,-1,4}},
209  {{ 1,-1,5},{ 2,-1,5},{ 3,-1,5}},
210  {{14, 1,0},{14, 1,1},{14, 1,2}},
211  {{14, 1,3},{14, 1,4},{14, 1,5}}},
212  {{{ 1, 1,0},{ 2, 1,0},{ 3, 1,0}}, /* htr 0 (HO) bot */
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  {{15, 1,0},{15, 1,1},{15, 1,2}},
219  {{15, 1,3},{15, 1,4},{15, 1,5}}}},
220  {{{{ 6, 1,0},{ 6, 1,1},{ 6, 1,2}}, /* htr 1 (HO) top */
221  {{ 6, 1,3},{ 6, 1,4},{ 6, 1,5}},
222  {{ 7, 1,0},{ 7, 1,1},{ 7, 1,2}},
223  {{ 7, 1,3},{ 7, 1,4},{ 7, 1,5}},
224  {{ 8, 1,0},{ 8, 1,1},{ 8, 1,2}},
225  {{ 8, 1,3},{ 8, 1,4},{ 8, 1,5}},
226  {{ 9, 1,0},{ 9, 1,1},{ 9, 1,2}},
227  {{ 9, 1,3},{ 9, 1,4},{ 9, 1,5}}},
228  {{{10, 1,0},{10, 1,1},{10, 1,2}}, /* htr 1 (HO) bot */
229  {{10, 1,3},{10, 1,4},{10, 1,5}},
230  {{11, 1,0},{11, 1,1},{11, 1,2}},
231  {{11, 1,3},{11, 1,4},{11, 1,5}},
232  {{12, 1,0},{12, 1,1},{12, 1,2}},
233  {{12, 1,3},{12, 1,4},{12, 1,5}},
234  {{13, 1,0},{13, 1,1},{13, 1,2}},
235  {{13, 1,3},{13, 1,4},{13, 1,5}}}},
236  {{{{ 4,-1,0},{ 4,-1,1},{ 0, 0,0}}, /* htr 2 (HO) top */
237  {{ 4,-1,2},{ 4,-1,3},{ 0, 0,0}},
238  {{ 4,-1,4},{ 4,-1,5},{ 0, 0,0}},
239  {{ 0, 0,0},{ 0, 0,0},{ 0, 0,0}},
240  {{ 5,-1,0},{ 5,-1,1},{ 5,-1,2}},
241  {{ 5,-1,3},{ 5,-1,4},{ 5,-1,5}},
242  {{14,-1,0},{14,-1,1},{14,-1,2}},
243  {{14,-1,3},{14,-1,4},{14,-1,5}}},
244  {{{ 4, 1,0},{ 4, 1,1},{ 0, 0,0}}, /* htr 2 (HO) bot */
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  {{15,-1,0},{15,-1,1},{15,-1,2}},
251  {{15,-1,3},{15,-1,4},{15,-1,5}}}},
252  {{{{ 6,-1,0},{ 6,-1,1},{ 6,-1,2}}, /* htr 3 (HO) top */
253  {{ 6,-1,3},{ 6,-1,4},{ 6,-1,5}},
254  {{ 7,-1,0},{ 7,-1,1},{ 7,-1,2}},
255  {{ 7,-1,3},{ 7,-1,4},{ 7,-1,5}},
256  {{ 8,-1,0},{ 8,-1,1},{ 8,-1,2}},
257  {{ 8,-1,3},{ 8,-1,4},{ 8,-1,5}},
258  {{ 9,-1,0},{ 9,-1,1},{ 9,-1,2}},
259  {{ 9,-1,3},{ 9,-1,4},{ 9,-1,5}}},
260  {{{10,-1,0},{10,-1,1},{10,-1,2}}, /* htr 3 (HO) bot */
261  {{10,-1,3},{10,-1,4},{10,-1,5}},
262  {{11,-1,0},{11,-1,1},{11,-1,2}},
263  {{11,-1,3},{11,-1,4},{11,-1,5}},
264  {{12,-1,0},{12,-1,1},{12,-1,2}},
265  {{12,-1,3},{12,-1,4},{12,-1,5}},
266  {{13,-1,0},{13,-1,1},{13,-1,2}},
267  {{13,-1,3},{13,-1,4},{13,-1,5}}}}
268  };
269  int ic,is,ih,itb,ifb,ifc,ifwtb,iphi_loc;
270  int iside,ieta,iphi,idepth,icrate,ihtr,ihtr_fi,ifi_ch,ispigot,idcc,idcc_sl,ifed;
271  std::string det;
272  std::string fpga;
273  // printf(" side eta phi depth det crate htr fpga htr_fi fi_ch spigo dcc dcc_sl fedid\n");
274  /* all HBHE crates */
275  for(ic=0; ic<EMAP_NHBHECR; ic++){
276  /* four sets of three htrs per crate */
277  for(is=0; is<EMAP_NHSETS; is++){
278  /* three htrs per set */
279  for(ih=0; ih<EMAP_NHTRS; ih++){
280  /* top and bottom */
281  for(itb=0; itb<EMAP_NTOPBOT; itb++){
282  /* eight fibers per HTR FPGA */
283  for(ifb=0; ifb<EMAP_NFBR; ifb++){
284  /* three channels per fiber */
285  for(ifc=0; ifc<EMAP_NFCH; ifc++){
286  icrate=hbhecrate[ic];
287  iside=is<EMAP_NHSETS/2?-1:1;
288  ifwtb=(is/2+itb+1)%2;
289  ieta=ihbheetadepth[ih][ifwtb][ifb][ifc][0];
290  idepth=ihbheetadepth[ih][ifwtb][ifb][ifc][1];
291  ihtr=ihslot[is]+ih;
292  det=((ieta>16||idepth>2)?("HE"):("HB"));
293  fpga=((itb%2)==1)?("bot"):("top");
294  ihtr_fi=ifb+1;
295  ifi_ch=ifc;
296  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;
297  ispigot=(is%2)*6+ih*2+itb;
298  idcc=is<EMAP_NHSETS/2?1:2;
299  idcc_sl=idcc==1?9:19;
300  ifed=fedhbhenum[ic][idcc-1];
302  CastorElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
303  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
304  HcalDetId hId((det=="HB")?(HcalBarrel):(HcalEndcap),ieta*iside,iphi,idepth);
305  emap.mapEId2chId(elId,hId);
306 
307  // 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);
308  }}}}}}
309  /* all HF crates */
310  for(ic=0; ic<EMAP_NHFCR; ic++){
311  /* four sets of three htrs per crate */
312  for(is=0; is<EMAP_NHSETS; is++){
313  /* three htrs per set */
314  for(ih=0; ih<EMAP_NHTRS; ih++){
315  /* top and bottom */
316  for(itb=0; itb<EMAP_NTOPBOT; itb++){
317  /* eight fibers per HTR FPGA */
318  for(ifb=0; ifb<EMAP_NFBR; ifb++){
319  /* three channels per fiber */
320  for(ifc=0; ifc<EMAP_NFCH; ifc++){
321  icrate=hfcrate[ic];
322  iside=is<EMAP_NHSETS/2?-1:1;
323  ieta=ihfetadepth[itb][ifb][ifc][0];
324  idepth=ihfetadepth[itb][ifb][ifc][1];
325  ihtr=ihslot[is]+ih;
326  det="HF";
327  fpga=((itb%2)==1)?("bot"):("top");
328  ihtr_fi=ifb+1;
329  ifi_ch=ifc;
330  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;
331  ispigot=(is%2)*6+ih*2+itb;
332  idcc=is<EMAP_NHSETS/2?1:2;
333  idcc_sl=idcc==1?9:19;
334  ifed=fedhfnum[ic][idcc-1];
335  CastorElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
336  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
337  HcalDetId hId(HcalForward,ieta*iside,iphi,idepth);
338  emap.mapEId2chId(elId,hId);
339  // 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);
340  }}}}}}
341  /* all HO crates */
342  for(ic=0; ic<EMAP_NHOCR; ic++){
343  /* three sets of four htrs per crate */
344  for(is=0; is<EMAP_NHSETSHO; is++){
345  /* four htrs per set */
346  for(ih=0; ih<EMAP_NHTRSHO; ih++){
347  /* top and bottom */
348  for(itb=0; itb<EMAP_NTOPBOT; itb++){
349  /* eight fibers per HTR FPGA */
350  for(ifb=0; ifb<EMAP_NFBR; ifb++){
351  /* three channels per fiber */
352  for(ifc=0; ifc<EMAP_NFCH; ifc++){
353  icrate=hocrate[ic];
354  idepth=1;
355  ieta=ihoetasidephi[ih][itb][ifb][ifc][0];
356  iside=ihoetasidephi[ih][itb][ifb][ifc][1];
357  iphi_loc=ihoetasidephi[ih][itb][ifb][ifc][2];
358  ihtr=ihslotho[is][ih];
359  det="HO";
360  fpga=((itb%2)==1)?("bot"):("top");
361  ihtr_fi=ifb+1;
362  ifi_ch=ifc;
363  iphi=(ihophis[ic]+is*6+iphi_loc-1)%72+1;
364  ispigot=ihtr<9?(ihtr-2)*2+itb:(ihtr-13)*2+itb;
365  idcc=ihtr<9?1:2;
366  idcc_sl=idcc==1?9:19;
367  ifed=fedhonum[ic][idcc-1];
368  CastorElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
369  elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
370  if (ieta==0) { // unmapped
372  } else {
373  HcalDetId hId(HcalOuter,ieta*iside,iphi,idepth+3); // HO is officially "depth=4"
374  emap.mapEId2chId(elId,hId);
375  }
376  // 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);
377  }}}}}}
378 
379 
380  emap.sort();
381 
382 }
CastorPedestalWidth makePedestalWidth(HcalGenericDetId fId)
static const HcalDetId Undefined
Definition: HcalDetId.h:66
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()
#define EMAP_NFBR
tuple result
Definition: query.py:137
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