10 #include "CLHEP/Random/RandGauss.h"
17 : theDefaultParameters_(3.0,0.5,{0.2,0.2},{0.0,0.0},0,{0.0,0.0,0.0,0.0},{0.9,0.9,0.9,0.9},125,105,0.0,{0.0}),
18 setHB_(
false), setHE_(
false), setHF_(
false), setHO_(
false),
19 setHBUpgrade_(
false), setHEUpgrade_(
false), setHFUpgrade_(
false),
20 useHBUpgrade_(
false), useHEUpgrade_(
false), useHOUpgrade_(
true),
21 useHFUpgrade_(
false), testHFQIE10_(
false)
59 if ((hid.ieta() > -5) && (hid.ieta() < 5)) index = 0;
63 if (hid.depth() % 2 == 1) index = 0;
64 else if (hid.depth() % 2 == 0) index = 1;
72 float value [4] = {value0,value0,value0,value0};
74 for (
int i = 0;
i < 4;
i++) {
76 while (value [
i] <= 0.0
f)
78 value [
i] = value0 + (float)CLHEP::RandGauss::shoot (0.0, width.
getWidth (
i) / 100.);
82 value[0], value[1], value[2], value[3]
92 float width2 = value*
value;
93 for (
int i = 0;
i < 4;
i++) {
94 for (
int j = 0;
j < 4;
j++) {
105 float value [4] = {value0, value0, value0, value0};
107 for (
int i = 0;
i < 4;
i++) {
109 while (value [
i] <= 0.0
f) value [
i] = value0 + (float)CLHEP::RandGauss::shoot (0.0, width.
getValue (
i));
126 for (
unsigned range = 0; range < 4; range++) {
127 for (
unsigned capid = 0; capid < 4; capid++) {
128 result.setOffset (capid, range, param.qieOffset(range));
129 result.setSlope (capid, range, param.qieSlope(range));
145 for (
int i = 0;
i < 64;
i++) { lowEdges[
i] = -1.5 +
i; }
146 result.setMinCharges (lowEdges);
162 int syncPhase = 0; r1bit[1] = 1;
164 float phase = -25.0f;
165 float Xphase = (phase + 32.0f) * 4.0
f;
167 int Iphase = Xphase; r1bit[3] = 8;
168 int timeSmearing = 0; r1bit[4] = 1;
171 int pulseShapeID = hparam.mcShape();
178 Xphase = (phase + 32.0f) * 4.0
f;
190 Xphase = (phase + 32.0f) * 4.0
f;
202 Xphase = (phase + 32.0f) * 4.0
f;
208 if (cell.
ieta() == 1 && cell.
iphi() == 1) pulseShapeID = 125;
217 Xphase = (phase + 32.0f) * 4.0
f;
230 Xphase = (phase + 32.0f) * 4.0
f;
240 for(
int k=0;
k<5;
k++) {
241 rshift[
k+1]=rshift[
k]+r1bit[
k];
244 int packingScheme = 1;
245 unsigned int param = pulseShapeID |
246 syncPhase<<rshift[1] |
247 (binOfMaximum << rshift[2]) |
248 (Iphase << rshift[3]) |
249 (timeSmearing << rshift[4] | packingScheme << 27);
262 int containmentCorrectionFlag = 0; p1bit[0]=1;
263 int containmentCorrectionPreSample = 0; p1bit[1]=1;
265 float Xphase = (phase + 32.0) * 4.0;
267 int Iphase = Xphase; p1bit[2]=8;
274 int pulseShapeID = hparam.recoShape();
279 int LeakCorrectionID = 0; q2bit[1]=4;
281 int timeCorrectionID = 0; q2bit[3]=4;
284 int specialCaseID = 0; q2bit[6]=4;
285 int noiseFlaggingID = 0; q2bit[7]=4;
286 int pileupCleaningID = 0; q2bit[8]=4;
287 int packingScheme = 1; q2bit[9]=4;
293 containmentCorrectionFlag = 1;
294 containmentCorrectionPreSample = 0;
296 float Xphase = (phase + 32.0) * 4.0;
303 useLeakCorrection = 0;
304 LeakCorrectionID = 0;
305 correctForTimeslew = 1;
306 timeCorrectionID = 0;
311 pileupCleaningID = 0;
317 containmentCorrectionFlag = 1;
318 containmentCorrectionPreSample = 0;
320 float Xphase = (phase + 32.0) * 4.0;
327 useLeakCorrection = 0;
328 LeakCorrectionID = 0;
329 correctForTimeslew = 1;
330 timeCorrectionID = 0;
335 pileupCleaningID = 0;
340 containmentCorrectionFlag = 0;
341 containmentCorrectionPreSample = 0;
343 float Xphase = (phase + 32.0) * 4.0;
350 useLeakCorrection = 0;
351 LeakCorrectionID = 0;
352 correctForTimeslew = 0;
353 timeCorrectionID = 0;
358 pileupCleaningID = 0;
364 int p1shift[7]; p1shift[0] = 0;
365 for(
int k = 0;
k < 6;
k++) {
367 p1shift[
j] = p1shift[
k] + p1bit[
k];
371 param1 = containmentCorrectionFlag |
372 (containmentCorrectionPreSample << p1shift[1]) |
373 (Iphase << p1shift[2]) |
374 (firstSample << p1shift[3]) |
375 (samplesToAdd << p1shift[4]) |
376 (pulseShapeID << p1shift[5]) ;
378 int q2shift[10]; q2shift[0] = 0;
379 for(
int k = 0;
k < 9;
k++) {
381 q2shift[
j] = q2shift[
k] + q2bit[
k];
385 param2 = useLeakCorrection |
386 (LeakCorrectionID << q2shift[1]) |
387 (correctForTimeslew << q2shift[2]) |
388 (timeCorrectionID << q2shift[3]) |
389 (correctTiming << q2shift[4]) |
390 (firstAuxTS << q2shift[5]) |
391 (specialCaseID << q2shift[6]) |
392 (noiseFlaggingID << q2shift[7]) |
393 (pileupCleaningID << q2shift[8]) |
394 (packingScheme << q2shift[9]) ;
414 #define EMAP_NHBHECR 9
420 #define EMAP_NHSETS 4
421 #define EMAP_NTOPBOT 2
422 #define EMAP_NHTRSHO 4
423 #define EMAP_NHSETSHO 3
441 static const int kUTCAMask = 0x4000000;
442 static const int kLinearIndexMax = 0x7FFFF;
443 static const int kTriggerBitMask = 0x02000000;
445 uint32_t counterTrig = 0;
446 for(
const auto& fId : cells){
454 assert(counter < kLinearIndexMax);
462 assert(counterTrig < kLinearIndexMax);
463 uint32_t raw = counterTrig;
464 raw |= kUTCAMask | kTriggerBitMask;
474 std::stringstream mystream;
475 std::string detector[5] = {
"XX",
"HB",
"HE",
"HO",
"HF"};
476 for (
const auto& fId : cells) {
480 int ieta =
id.ietaAbs();
481 int iside =
id.zside();
482 int iphi =
id.iphi();
486 char sidesign = (iside == -1) ?
'M' :
'P';
488 det = detector[subdet];
489 irm = (iphi+1)%4 + 1;
491 if (ieta >= 21 && (irm == 1 || irm == 3))
492 iwedge = (iphi + 1 + irm + 1) / 4;
494 iwedge = (iphi + irm + 1) / 4;
495 if (iwedge > 18) iwedge -= 18;
496 sprintf (tempbuff,
"%s%c%2.2i%c",det.c_str(),sidesign,iwedge,
'\0');
497 mystream << tempbuff;
498 rbx = mystream.str();
502 det = detector[subdet];
504 if ((iside == 1 && ieta == 40) || (iside == -1 && ieta == 41)) {
505 irm = ((iphi + 1) / 2) % 36 + 1;
506 hfphi = ((iphi + 1) / 6) % 12 + 1;
508 irm = ( iphi + 1) / 2;
509 hfphi = (iphi - 1) / 6 + 1;
511 irm = (irm - 1) % 3 + 1;
512 sprintf (tempbuff,
"%s%c%2.2i%c",det.c_str(),sidesign,hfphi,
'\0');
513 mystream << tempbuff;
514 rbx = mystream.str();
518 det = detector[subdet];
519 int ring(0), sector(0);
520 if (ieta <= 4)
ring = 0;
521 else if (ieta >= 5 && ieta <= 10)
ring = 1;
523 for (
int i = -2;
i < iphi;
i+=6) sector++;
524 if (sector > 12) sector = 1;
525 irm = ((iphi+1)/2)%6 + 1;
526 if (
ring != 0 && sector % 2 != 0) sector++;
528 sprintf (tempbuff,
"%s%i%2.2d",det.c_str(),
ring,sector);
530 sprintf (tempbuff,
"%s%i%c%2.2d",det.c_str(),
ring,sidesign,sector);
531 mystream << tempbuff;
532 rbx = mystream.str();
543 auto eta_depth_pair = std::make_pair(ieta,depth);
546 return nLayers->second;
549 std::vector<int> segmentation;
552 int nLayersInDepth =
std::distance(std::lower_bound(segmentation.begin(),segmentation.end(),
depth),
553 std::upper_bound(segmentation.begin(),segmentation.end(),
depth));
555 return nLayersInDepth;
570 if(nLayersInDepth > 4) {
581 if(nLayersInDepth > 4) {
604 ps.getParameter<
int>(
"pixels"),
605 ps.getParameter<
double>(
"nonlin1"),
606 ps.getParameter<
double>(
"nonlin2"),
607 ps.getParameter<
double>(
"nonlin3"),
608 ps.getParameter<
double>(
"crosstalk"),
618 uint32_t bitInfo = ((44 << 16) | 30);
626 tppar.
loadObject(0,0,0xFFFFFFFFFFFFFFFF,0,0,0);
const double pedestalWidth() const
HcalGainWidth makeGainWidth(HcalGenericDetId fId)
HcalHardcodeParameters theHOParameters_
HcalSubdetector subdet() const
get the subdetector
HcalSiPMParameter makeHardcodeSiPMParameter(HcalGenericDetId fId, const HcalTopology *topo)
bool mapGeomId2DcsId(HcalDetId fId, HcalDcsDetId fDcsId)
std::vector< edm::ParameterSet > theSiPMCharacteristics_
HcalRecoParam makeRecoParam(HcalGenericDetId fId)
HcalQIECoder makeQIECoder(HcalGenericDetId fId)
const int qieType() const
bool mapEId2tId(HcalElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
HcalMCParam makeMCParam(HcalGenericDetId fId)
void makeHardcodeSiPMCharacteristics(HcalSiPMCharacteristics &sipm)
float getValue(int fCapId) const
get value for capId = 0..3
HcalHardcodeParameters theDefaultParameters_
const double gainWidth(unsigned index) const
HcalCalibrationQIECoder makeCalibrationQIECoder(HcalGenericDetId fId)
const double photoelectronsToAnalog() const
HcalPedestalWidth makePedestalWidth(HcalGenericDetId fId)
uint32_t rawId() const
get the raw id
const HcalHardcodeParameters & getParameters(HcalGenericDetId fId)
HcalHardcodeParameters theHEUpgradeParameters_
void makeHardcodeFrontEndMap(HcalFrontEndMap &emap, const std::vector< HcalGenericDetId > &cells)
HcalTPChannelParameter makeHardcodeTPChannelParameter(HcalGenericDetId fId)
void makeHardcodeMap(HcalElectronicsMap &emap, const std::vector< HcalGenericDetId > &cells)
HcalPedestal makePedestal(HcalGenericDetId fId, bool fSmear=false)
HcalHardcodeParameters theHBUpgradeParameters_
bool loadObject(int type, int pixels, float parLin1, float parLin2, float parLin3, float crossTalk, int auxi1=0, float auxi2=0)
HcalTimingParam makeTimingParam(HcalGenericDetId fId)
HcalQIEType makeQIEType(HcalGenericDetId fId)
int ieta() const
get the cell ieta
HcalQIEShape makeQIEShape()
void makeHardcodeDcsMap(HcalDcsMap &dcs_map)
const double pedestal() const
HcalHardcodeParameters theHBParameters_
const double darkCurrent(unsigned index) const
bool mapEId2chId(HcalElectronicsId fElectronicsId, DetId fId)
int iphi() const
get the cell iphi
void getDepthSegmentation(unsigned ring, std::vector< int > &readoutDepths) const
void makeHardcodeTPParameters(HcalTPParameters &tppar)
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
void loadObject(int version, int adcCut, uint64_t tdcMask, uint32_t tbits, int auxi1, int auxi2)
const double gain(unsigned index) const
bool loadObject(DetId fId, int rm, std::string rbx)
load a new entry
static std::atomic< unsigned int > counter
int getLayersInDepth(int ieta, int depth, const HcalTopology *topo)
HcalHardcodeParameters theHFParameters_
HcalGain makeGain(HcalGenericDetId fId, bool fSmear=false)
const int getGainIndex(HcalGenericDetId fId)
HcalHardcodeParameters theHEParameters_
HcalGenericSubdetector genericSubdet() const
std::map< std::pair< int, int >, int > theLayersInDepths_
Readout chain identification for Hcal.
HcalHardcodeParameters theHFUpgradeParameters_