00001
00002
00003
00004
00005 #include <vector>
00006 #include <string>
00007
00008 #include "CLHEP/Random/RandGauss.h"
00009 #include "CalibCalorimetry/HcalAlgos/interface/HcalDbHardcode.h"
00010
00011
00012 HcalPedestal HcalDbHardcode::makePedestal (HcalGenericDetId fId, bool fSmear) {
00013 HcalPedestalWidth width = makePedestalWidth (fId);
00014 float value0 = fId.genericSubdet() == HcalGenericDetId::HcalGenForward ? 11. : 4.;
00015 float value [4] = {value0, value0, value0, value0};
00016 if (fSmear) {
00017 for (int i = 0; i < 4; i++) {
00018 value [i] = RandGauss::shoot (value0, width.getWidth (i) / 100.);
00019 while (value [i] <= 0) value [i] = RandGauss::shoot (value0, width.getWidth (i));
00020 }
00021 }
00022 HcalPedestal result (fId.rawId (),
00023 value[0], value[1], value[2], value[3]
00024 );
00025 return result;
00026 }
00027
00028 HcalPedestalWidth HcalDbHardcode::makePedestalWidth (HcalGenericDetId fId) {
00029 float value = 0;
00030 if (fId.genericSubdet() == HcalGenericDetId::HcalGenBarrel ||
00031 fId.genericSubdet() == HcalGenericDetId::HcalGenOuter) value = 0.7;
00032 else if (fId.genericSubdet() == HcalGenericDetId::HcalGenEndcap) value = 0.9;
00033 else if (fId.genericSubdet() == HcalGenericDetId::HcalGenForward) value = 2.5;
00034 HcalPedestalWidth result (fId.rawId ());
00035 for (int i = 0; i < 4; i++) {
00036 double width = value;
00037 for (int j = 0; j <= i; j++) {
00038 result.setSigma (i, j, i == j ? width * width : 0);
00039 }
00040 }
00041 return result;
00042 }
00043
00044 HcalGain HcalDbHardcode::makeGain (HcalGenericDetId fId, bool fSmear) {
00045 HcalGainWidth width = makeGainWidth (fId);
00046 float value0 = 0;
00047 if (fId.genericSubdet() != HcalGenericDetId::HcalGenForward) value0 = 0.177;
00048 else {
00049 if (HcalDetId(fId).depth() == 1) value0 = 0.2146;
00050 else if (HcalDetId(fId).depth() == 2) value0 = 0.3375;
00051 }
00052 float value [4] = {value0, value0, value0, value0};
00053 if (fSmear) for (int i = 0; i < 4; i++) value [i] = RandGauss::shoot (value0, width.getValue (i));
00054 HcalGain result (fId.rawId (), value[0], value[1], value[2], value[3]);
00055 return result;
00056 }
00057
00058 HcalGainWidth HcalDbHardcode::makeGainWidth (HcalGenericDetId fId) {
00059 float value = 0;
00060 HcalGainWidth result (fId.rawId (), value, value, value, value);
00061 return result;
00062 }
00063
00064 HcalQIECoder HcalDbHardcode::makeQIECoder (HcalGenericDetId fId) {
00065 HcalQIECoder result (fId.rawId ());
00066 float offset = 0;
00067 float slope = fId.genericSubdet () == HcalGenericDetId::HcalGenForward ? 0.36 : 0.92;
00068 for (unsigned range = 0; range < 4; range++) {
00069 for (unsigned capid = 0; capid < 4; capid++) {
00070 result.setOffset (capid, range, offset);
00071 result.setSlope (capid, range, slope);
00072 }
00073 }
00074 return result;
00075 }
00076
00077 HcalCalibrationQIECoder HcalDbHardcode::makeCalibrationQIECoder (HcalGenericDetId fId) {
00078 HcalCalibrationQIECoder result (fId.rawId ());
00079 float lowEdges [32];
00080 for (int i = 0; i < 32; i++) lowEdges[i] = -1.5 + i*0.35;
00081 result.setMinCharges (lowEdges);
00082 return result;
00083 }
00084
00085 HcalQIEShape HcalDbHardcode::makeQIEShape () {
00086 return HcalQIEShape ();
00087 }
00088
00089
00090 #define EMAP_NHBHECR 9
00091 #define EMAP_NHFCR 3
00092 #define EMAP_NHOCR 4
00093 #define EMAP_NFBR 8
00094 #define EMAP_NFCH 3
00095 #define EMAP_NHTRS 3
00096 #define EMAP_NHSETS 4
00097 #define EMAP_NTOPBOT 2
00098 #define EMAP_NHTRSHO 4
00099 #define EMAP_NHSETSHO 3
00100
00101 void HcalDbHardcode::makeHardcodeMap(HcalElectronicsMap& emap) {
00102
00103
00104 int hbhecrate[EMAP_NHBHECR]={0,1,4,5,10,11,14,15,17};
00105
00106 int hfcrate[EMAP_NHFCR]={2,9,12};
00107
00108 int hocrate[EMAP_NHOCR]={3,7,6,13};
00109
00110 int fedhbhenum[EMAP_NHBHECR][2]={{702,703},{704,705},{700,701},
00111 {706,707},{716,717},{708,709},
00112 {714,715},{710,711},{712,713}};
00113
00114 int fedhfnum[EMAP_NHFCR][2]={{718,719},{720,721},{722,723}};
00115
00116 int fedhonum[EMAP_NHOCR][2]={{724,725},{726,727},{728,729},{730,731}};
00117
00118 int ihslot[EMAP_NHSETS]={2,5,13,16};
00119
00120 int ihslotho[EMAP_NHSETSHO][EMAP_NHTRSHO]={{2,3,4,5},{6,7,13,14},{15,16,17,18}};
00121
00122 int ihbhephis[EMAP_NHBHECR]={11,19,3,27,67,35,59,43,51};
00123
00124 int ihfphis[EMAP_NHFCR]={3,27,51};
00125
00126 int ihophis[EMAP_NHOCR]={71,17,35,53};
00127
00128 int ihbheetadepth[EMAP_NHTRS][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2]={
00129 {{{{11,1},{ 7,1},{ 3,1}},
00130 {{ 5,1},{ 1,1},{ 9,1}},
00131 {{11,1},{ 7,1},{ 3,1}},
00132 {{ 5,1},{ 1,1},{ 9,1}},
00133 {{10,1},{ 6,1},{ 2,1}},
00134 {{ 8,1},{ 4,1},{12,1}},
00135 {{10,1},{ 6,1},{ 2,1}},
00136 {{ 8,1},{ 4,1},{12,1}}},
00137 {{{11,1},{ 7,1},{ 3,1}},
00138 {{ 5,1},{ 1,1},{ 9,1}},
00139 {{11,1},{ 7,1},{ 3,1}},
00140 {{ 5,1},{ 1,1},{ 9,1}},
00141 {{10,1},{ 6,1},{ 2,1}},
00142 {{ 8,1},{ 4,1},{12,1}},
00143 {{10,1},{ 6,1},{ 2,1}},
00144 {{ 8,1},{ 4,1},{12,1}}}},
00145 {{{{16,2},{15,2},{14,1}},
00146 {{15,1},{13,1},{16,1}},
00147 {{16,2},{15,2},{14,1}},
00148 {{15,1},{13,1},{16,1}},
00149 {{17,1},{16,3},{26,1}},
00150 {{18,1},{18,2},{26,2}},
00151 {{17,1},{16,3},{25,1}},
00152 {{18,1},{18,2},{25,2}}},
00153 {{{16,2},{15,2},{14,1}},
00154 {{15,1},{13,1},{16,1}},
00155 {{16,2},{15,2},{14,1}},
00156 {{15,1},{13,1},{16,1}},
00157 {{17,1},{16,3},{25,1}},
00158 {{18,1},{18,2},{25,2}},
00159 {{17,1},{16,3},{26,1}},
00160 {{18,1},{18,2},{26,2}}}},
00161 {{{{28,1},{28,2},{29,1}},
00162 {{28,3},{24,2},{24,1}},
00163 {{27,1},{27,2},{29,2}},
00164 {{27,3},{23,2},{23,1}},
00165 {{19,2},{20,1},{22,2}},
00166 {{19,1},{20,2},{22,1}},
00167 {{19,2},{20,1},{21,2}},
00168 {{19,1},{20,2},{21,1}}},
00169 {{{27,1},{27,2},{29,2}},
00170 {{27,3},{23,2},{23,1}},
00171 {{28,1},{28,2},{29,1}},
00172 {{28,3},{24,2},{24,1}},
00173 {{19,2},{20,1},{21,2}},
00174 {{19,1},{20,2},{21,1}},
00175 {{19,2},{20,1},{22,2}},
00176 {{19,1},{20,2},{22,1}}}}
00177 };
00178
00179 int ihfetadepth[EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][2]={
00180 {{{33,1},{31,1},{29,1}},
00181 {{32,1},{30,1},{34,1}},
00182 {{33,2},{31,2},{29,2}},
00183 {{32,2},{30,2},{34,2}},
00184 {{34,2},{32,2},{30,2}},
00185 {{31,2},{29,2},{33,2}},
00186 {{34,1},{32,1},{30,1}},
00187 {{31,1},{29,1},{33,1}}},
00188 {{{41,1},{37,1},{35,1}},
00189 {{38,1},{36,1},{39,1}},
00190 {{41,2},{37,2},{35,2}},
00191 {{38,2},{36,2},{39,2}},
00192 {{40,2},{38,2},{36,2}},
00193 {{37,2},{35,2},{39,2}},
00194 {{40,1},{38,1},{36,1}},
00195 {{37,1},{35,1},{39,1}}}
00196 };
00197
00198 int ihoetasidephi[EMAP_NHTRSHO][EMAP_NTOPBOT][EMAP_NFBR][EMAP_NFCH][3]={
00199 {{{{ 1,-1,0},{ 2,-1,0},{ 3,-1,0}},
00200 {{ 1,-1,1},{ 2,-1,1},{ 3,-1,1}},
00201 {{ 1,-1,2},{ 2,-1,2},{ 3,-1,2}},
00202 {{ 1,-1,3},{ 2,-1,3},{ 3,-1,3}},
00203 {{ 1,-1,4},{ 2,-1,4},{ 3,-1,4}},
00204 {{ 1,-1,5},{ 2,-1,5},{ 3,-1,5}},
00205 {{14, 1,0},{14, 1,1},{14, 1,2}},
00206 {{14, 1,3},{14, 1,4},{14, 1,5}}},
00207 {{{ 1, 1,0},{ 2, 1,0},{ 3, 1,0}},
00208 {{ 1, 1,1},{ 2, 1,1},{ 3, 1,1}},
00209 {{ 1, 1,2},{ 2, 1,2},{ 3, 1,2}},
00210 {{ 1, 1,3},{ 2, 1,3},{ 3, 1,3}},
00211 {{ 1, 1,4},{ 2, 1,4},{ 3, 1,4}},
00212 {{ 1, 1,5},{ 2, 1,5},{ 3, 1,5}},
00213 {{15, 1,0},{15, 1,1},{15, 1,2}},
00214 {{15, 1,3},{15, 1,4},{15, 1,5}}}},
00215 {{{{ 6, 1,0},{ 6, 1,1},{ 6, 1,2}},
00216 {{ 6, 1,3},{ 6, 1,4},{ 6, 1,5}},
00217 {{ 7, 1,0},{ 7, 1,1},{ 7, 1,2}},
00218 {{ 7, 1,3},{ 7, 1,4},{ 7, 1,5}},
00219 {{ 8, 1,0},{ 8, 1,1},{ 8, 1,2}},
00220 {{ 8, 1,3},{ 8, 1,4},{ 8, 1,5}},
00221 {{ 9, 1,0},{ 9, 1,1},{ 9, 1,2}},
00222 {{ 9, 1,3},{ 9, 1,4},{ 9, 1,5}}},
00223 {{{10, 1,0},{10, 1,1},{10, 1,2}},
00224 {{10, 1,3},{10, 1,4},{10, 1,5}},
00225 {{11, 1,0},{11, 1,1},{11, 1,2}},
00226 {{11, 1,3},{11, 1,4},{11, 1,5}},
00227 {{12, 1,0},{12, 1,1},{12, 1,2}},
00228 {{12, 1,3},{12, 1,4},{12, 1,5}},
00229 {{13, 1,0},{13, 1,1},{13, 1,2}},
00230 {{13, 1,3},{13, 1,4},{13, 1,5}}}},
00231 {{{{ 4,-1,0},{ 4,-1,1},{ 0, 0,0}},
00232 {{ 4,-1,2},{ 4,-1,3},{ 0, 0,0}},
00233 {{ 4,-1,4},{ 4,-1,5},{ 0, 0,0}},
00234 {{ 0, 0,0},{ 0, 0,0},{ 0, 0,0}},
00235 {{ 5,-1,0},{ 5,-1,1},{ 5,-1,2}},
00236 {{ 5,-1,3},{ 5,-1,4},{ 5,-1,5}},
00237 {{14,-1,0},{14,-1,1},{14,-1,2}},
00238 {{14,-1,3},{14,-1,4},{14,-1,5}}},
00239 {{{ 4, 1,0},{ 4, 1,1},{ 0, 0,0}},
00240 {{ 4, 1,2},{ 4, 1,3},{ 0, 0,0}},
00241 {{ 4, 1,4},{ 4, 1,5},{ 0, 0,0}},
00242 {{ 0, 0,0},{ 0, 0,0},{ 0, 0,0}},
00243 {{ 5, 1,0},{ 5, 1,1},{ 5, 1,2}},
00244 {{ 5, 1,3},{ 5, 1,4},{ 5, 1,5}},
00245 {{15,-1,0},{15,-1,1},{15,-1,2}},
00246 {{15,-1,3},{15,-1,4},{15,-1,5}}}},
00247 {{{{ 6,-1,0},{ 6,-1,1},{ 6,-1,2}},
00248 {{ 6,-1,3},{ 6,-1,4},{ 6,-1,5}},
00249 {{ 7,-1,0},{ 7,-1,1},{ 7,-1,2}},
00250 {{ 7,-1,3},{ 7,-1,4},{ 7,-1,5}},
00251 {{ 8,-1,0},{ 8,-1,1},{ 8,-1,2}},
00252 {{ 8,-1,3},{ 8,-1,4},{ 8,-1,5}},
00253 {{ 9,-1,0},{ 9,-1,1},{ 9,-1,2}},
00254 {{ 9,-1,3},{ 9,-1,4},{ 9,-1,5}}},
00255 {{{10,-1,0},{10,-1,1},{10,-1,2}},
00256 {{10,-1,3},{10,-1,4},{10,-1,5}},
00257 {{11,-1,0},{11,-1,1},{11,-1,2}},
00258 {{11,-1,3},{11,-1,4},{11,-1,5}},
00259 {{12,-1,0},{12,-1,1},{12,-1,2}},
00260 {{12,-1,3},{12,-1,4},{12,-1,5}},
00261 {{13,-1,0},{13,-1,1},{13,-1,2}},
00262 {{13,-1,3},{13,-1,4},{13,-1,5}}}}
00263 };
00264 int ic,is,ih,itb,ifb,ifc,ifwtb,iphi_loc;
00265 int iside,ieta,iphi,idepth,icrate,ihtr,ihtr_fi,ifi_ch,ispigot,idcc,idcc_sl,ifed;
00266 std::string det;
00267 std::string fpga;
00268
00269
00270 for(ic=0; ic<EMAP_NHBHECR; ic++){
00271
00272 for(is=0; is<EMAP_NHSETS; is++){
00273
00274 for(ih=0; ih<EMAP_NHTRS; ih++){
00275
00276 for(itb=0; itb<EMAP_NTOPBOT; itb++){
00277
00278 for(ifb=0; ifb<EMAP_NFBR; ifb++){
00279
00280 for(ifc=0; ifc<EMAP_NFCH; ifc++){
00281 icrate=hbhecrate[ic];
00282 iside=is<EMAP_NHSETS/2?-1:1;
00283 ifwtb=(is/2+itb+1)%2;
00284 ieta=ihbheetadepth[ih][ifwtb][ifb][ifc][0];
00285 idepth=ihbheetadepth[ih][ifwtb][ifb][ifc][1];
00286 ihtr=ihslot[is]+ih;
00287 det=((ieta>16||idepth>2)?("HE"):("HB"));
00288 fpga=((itb%2)==1)?("bot"):("top");
00289 ihtr_fi=ifb+1;
00290 ifi_ch=ifc;
00291 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;
00292 ispigot=(is%2)*6+ih*2+itb;
00293 idcc=is<EMAP_NHSETS/2?1:2;
00294 idcc_sl=idcc==1?9:19;
00295 ifed=fedhbhenum[ic][idcc-1];
00297 HcalElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
00298 elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
00299 HcalDetId hId((det=="HB")?(HcalBarrel):(HcalEndcap),ieta*iside,iphi,idepth);
00300 emap.mapEId2chId(elId,hId);
00301
00302
00303 }}}}}}
00304
00305 for(ic=0; ic<EMAP_NHFCR; ic++){
00306
00307 for(is=0; is<EMAP_NHSETS; is++){
00308
00309 for(ih=0; ih<EMAP_NHTRS; ih++){
00310
00311 for(itb=0; itb<EMAP_NTOPBOT; itb++){
00312
00313 for(ifb=0; ifb<EMAP_NFBR; ifb++){
00314
00315 for(ifc=0; ifc<EMAP_NFCH; ifc++){
00316 icrate=hfcrate[ic];
00317 iside=is<EMAP_NHSETS/2?-1:1;
00318 ieta=ihfetadepth[itb][ifb][ifc][0];
00319 idepth=ihfetadepth[itb][ifb][ifc][1];
00320 ihtr=ihslot[is]+ih;
00321 det="HF";
00322 fpga=((itb%2)==1)?("bot"):("top");
00323 ihtr_fi=ifb+1;
00324 ifi_ch=ifc;
00325 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;
00326 ispigot=(is%2)*6+ih*2+itb;
00327 idcc=is<EMAP_NHSETS/2?1:2;
00328 idcc_sl=idcc==1?9:19;
00329 ifed=fedhfnum[ic][idcc-1];
00330 HcalElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
00331 elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
00332 HcalDetId hId(HcalForward,ieta*iside,iphi,idepth);
00333 emap.mapEId2chId(elId,hId);
00334
00335 }}}}}}
00336
00337 for(ic=0; ic<EMAP_NHOCR; ic++){
00338
00339 for(is=0; is<EMAP_NHSETSHO; is++){
00340
00341 for(ih=0; ih<EMAP_NHTRSHO; ih++){
00342
00343 for(itb=0; itb<EMAP_NTOPBOT; itb++){
00344
00345 for(ifb=0; ifb<EMAP_NFBR; ifb++){
00346
00347 for(ifc=0; ifc<EMAP_NFCH; ifc++){
00348 icrate=hocrate[ic];
00349 idepth=1;
00350 ieta=ihoetasidephi[ih][itb][ifb][ifc][0];
00351 iside=ihoetasidephi[ih][itb][ifb][ifc][1];
00352 iphi_loc=ihoetasidephi[ih][itb][ifb][ifc][2];
00353 ihtr=ihslotho[is][ih];
00354 det="HO";
00355 fpga=((itb%2)==1)?("bot"):("top");
00356 ihtr_fi=ifb+1;
00357 ifi_ch=ifc;
00358 iphi=(ihophis[ic]+is*6+iphi_loc-1)%72+1;
00359 ispigot=ihtr<9?(ihtr-2)*2+itb:(ihtr-13)*2+itb;
00360 idcc=ihtr<9?1:2;
00361 idcc_sl=idcc==1?9:19;
00362 ifed=fedhonum[ic][idcc-1];
00363 HcalElectronicsId elId(ifi_ch, ihtr_fi, ispigot, ifed-700);
00364 elId.setHTR(icrate, ihtr, (fpga=="top")?(1):(0));
00365 if (ieta==0) {
00366 emap.mapEId2chId(elId,DetId(HcalDetId::Undefined));
00367 } else {
00368 HcalDetId hId(HcalOuter,ieta*iside,iphi,idepth+3);
00369 emap.mapEId2chId(elId,hId);
00370 }
00371
00372 }}}}}}
00373
00374
00375 emap.sort();
00376
00377 }