11 #include "CLHEP/Random/RandGauss.h" 19 theDefaultParameters_(
33 setHB_(
false), setHE_(
false), setHF_(
false), setHO_(
false),
34 setHBUpgrade_(
false), setHEUpgrade_(
false), setHFUpgrade_(
false),
35 useHBUpgrade_(
false), useHEUpgrade_(
false), useHOUpgrade_(
true),
36 useHFUpgrade_(
false), testHFQIE10_(
false), testHEPlan1_(
false)
75 if ((hid.
ieta() > -5) && (hid.
ieta() < 5)) index = 0;
79 if (hid.
depth() % 2 == 1) index = 0;
80 else if (hid.
depth() % 2 == 0) index = 1;
92 value0 += sipmpar.getDarkCurrent() * 25. / (1. - sipmchar->getCrossTalk(sipmpar.getType()));
94 float value [4] = {value0,value0,value0,value0};
96 for (
int i = 0;
i < 4;
i++) {
98 while (value [
i] <= 0.0
f)
100 value [
i] = value0 + (
float)CLHEP::RandGauss::shoot (0.0, width.
getWidth (
i) / 100.);
104 value[0], value[1], value[2], value[3]
111 float width2 = value*
value;
119 width2 += sipmpar.getDarkCurrent() * 25. /
std::pow(1 - sipmchar->getCrossTalk(sipmpar.getType()), 3) * sipmpar.getFCByPE();
123 for (
int i = 0;
i < 4;
i++) {
124 for (
int j = 0; j < 4; j++) {
135 float value [4] = {value0, value0, value0, value0};
137 for (
int i = 0;
i < 4;
i++) {
139 while (value [
i] <= 0.0
f) value [
i] = value0 + (
float)CLHEP::RandGauss::shoot (0.0, width.
getValue (
i));
162 for (
unsigned range = 0; range < 4; range++) {
163 for (
unsigned capid = 0; capid < 4; capid++) {
164 result.setOffset (capid, range, param.qieOffset(range));
165 result.setSlope (capid, range, param.qieSlope(range));
181 for (
int i = 0;
i < 64;
i++) { lowEdges[
i] = -1.5 +
i; }
182 result.setMinCharges (lowEdges);
197 float phase = -25.0f;
198 float Xphase = (phase + 32.0f) * 4.0
f;
200 int Iphase = Xphase; r1bit[3] = 8;
204 int pulseShapeID = hparam.
mcShape();
211 Xphase = (phase + 32.0f) * 4.0
f;
223 Xphase = (phase + 32.0f) * 4.0
f;
235 Xphase = (phase + 32.0f) * 4.0
f;
241 if (cell.
ieta() == 1 && cell.
iphi() == 1) pulseShapeID = 125;
250 Xphase = (phase + 32.0f) * 4.0
f;
263 Xphase = (phase + 32.0f) * 4.0
f;
273 for(
int k=0;
k<5;
k++) {
274 rshift[
k+1]=rshift[
k]+r1bit[
k];
277 int packingScheme = 1;
278 unsigned int param = pulseShapeID |
279 syncPhase<<rshift[1] |
280 (binOfMaximum << rshift[2]) |
281 (Iphase << rshift[3]) |
282 (timeSmearing << rshift[4] | packingScheme << 27);
295 int containmentCorrectionFlag = 0; p1bit[0]=1;
296 int containmentCorrectionPreSample = 0; p1bit[1]=1;
298 float Xphase = (phase + 32.0) * 4.0;
300 int Iphase = Xphase; p1bit[2]=8;
312 int LeakCorrectionID = 0; q2bit[1]=4;
314 int timeCorrectionID = 0; q2bit[3]=4;
317 int specialCaseID = 0; q2bit[6]=4;
318 int noiseFlaggingID = 0; q2bit[7]=4;
319 int pileupCleaningID = 0; q2bit[8]=4;
320 int packingScheme = 1; q2bit[9]=4;
326 containmentCorrectionFlag = 1;
327 containmentCorrectionPreSample = 0;
329 float Xphase = (phase + 32.0) * 4.0;
336 useLeakCorrection = 0;
337 LeakCorrectionID = 0;
338 correctForTimeslew = 1;
339 timeCorrectionID = 0;
344 pileupCleaningID = 0;
350 containmentCorrectionFlag = 1;
351 containmentCorrectionPreSample = 0;
353 float Xphase = (phase + 32.0) * 4.0;
360 useLeakCorrection = 0;
361 LeakCorrectionID = 0;
362 correctForTimeslew = 1;
363 timeCorrectionID = 0;
368 pileupCleaningID = 0;
373 containmentCorrectionFlag = 0;
374 containmentCorrectionPreSample = 0;
376 float Xphase = (phase + 32.0) * 4.0;
383 useLeakCorrection = 0;
384 LeakCorrectionID = 0;
385 correctForTimeslew = 0;
386 timeCorrectionID = 0;
391 pileupCleaningID = 0;
397 int p1shift[7]; p1shift[0] = 0;
398 for(
int k = 0;
k < 6;
k++) {
400 p1shift[j] = p1shift[
k] + p1bit[
k];
404 param1 = containmentCorrectionFlag |
405 (containmentCorrectionPreSample << p1shift[1]) |
406 (Iphase << p1shift[2]) |
407 (firstSample << p1shift[3]) |
408 (samplesToAdd << p1shift[4]) |
409 (pulseShapeID << p1shift[5]) ;
411 int q2shift[10]; q2shift[0] = 0;
412 for(
int k = 0;
k < 9;
k++) {
414 q2shift[j] = q2shift[
k] + q2bit[
k];
418 param2 = useLeakCorrection |
419 (LeakCorrectionID << q2shift[1]) |
420 (correctForTimeslew << q2shift[2]) |
421 (timeCorrectionID << q2shift[3]) |
422 (correctTiming << q2shift[4]) |
423 (firstAuxTS << q2shift[5]) |
424 (specialCaseID << q2shift[6]) |
425 (noiseFlaggingID << q2shift[7]) |
426 (pileupCleaningID << q2shift[8]) |
427 (packingScheme << q2shift[9]) ;
447 #define EMAP_NHBHECR 9 453 #define EMAP_NHSETS 4 454 #define EMAP_NTOPBOT 2 455 #define EMAP_NHTRSHO 4 456 #define EMAP_NHSETSHO 3 472 return std::make_unique<HcalDcsMap>(dcs_map_helper);
476 static const int kUTCAMask = 0x4000000;
477 static const int kLinearIndexMax = 0x7FFFF;
478 static const int kTriggerBitMask = 0x02000000;
480 uint32_t counterTrig = 0;
482 for(
const auto& fId : cells){
490 assert(counter < kLinearIndexMax);
498 assert(counterTrig < kLinearIndexMax);
499 uint32_t raw = counterTrig;
500 raw |= kUTCAMask | kTriggerBitMask;
505 return std::make_unique<HcalElectronicsMap>(emapHelper);
510 std::stringstream mystream;
512 for (
const auto& fId : cells) {
513 if (fId.isHcalDetId()) {
516 int ieta =
id.ietaAbs();
517 int iside =
id.zside();
518 int iphi =
id.iphi();
522 char sidesign = (iside == -1) ?
'M' :
'P';
524 det = detector[subdet];
525 irm = (iphi+1)%4 + 1;
527 if (ieta >= 21 && (irm == 1 || irm == 3))
528 iwedge = (iphi + 1 + irm + 1) / 4;
530 iwedge = (iphi + irm + 1) / 4;
531 if (iwedge > 18) iwedge -= 18;
532 sprintf (tempbuff,
"%s%c%2.2i%c",det.c_str(),sidesign,iwedge,
'\0');
533 mystream << tempbuff;
534 rbx = mystream.str();
538 det = detector[subdet];
540 if ((iside == 1 && ieta == 40) || (iside == -1 && ieta == 41)) {
541 irm = ((iphi + 1) / 2) % 36 + 1;
542 hfphi = ((iphi + 1) / 6) % 12 + 1;
544 irm = ( iphi + 1) / 2;
545 hfphi = (iphi - 1) / 6 + 1;
547 irm = (irm - 1) % 3 + 1;
548 sprintf (tempbuff,
"%s%c%2.2i%c",det.c_str(),sidesign,hfphi,
'\0');
549 mystream << tempbuff;
550 rbx = mystream.str();
554 det = detector[subdet];
555 int ring(0), sector(0);
556 if (ieta <= 4)
ring = 0;
557 else if (ieta >= 5 && ieta <= 10)
ring = 1;
559 for (
int i = -2;
i < iphi;
i+=6) sector++;
560 if (sector > 12) sector = 1;
561 irm = ((iphi+1)/2)%6 + 1;
562 if (
ring != 0 && sector % 2 != 0) sector++;
564 sprintf (tempbuff,
"%s%i%2.2d",det.c_str(),
ring,sector);
566 sprintf (tempbuff,
"%s%i%c%2.2d",det.c_str(),
ring,sidesign,sector);
567 mystream << tempbuff;
568 rbx = mystream.str();
574 return std::make_unique<HcalFrontEndMap>(emapHelper);
579 auto eta_depth_pair = std::make_pair(ieta,depth);
585 std::vector<int> segmentation;
588 int nLayersInDepth =
std::distance(std::lower_bound(segmentation.begin(),segmentation.end(),
depth),
589 std::upper_bound(segmentation.begin(),segmentation.end(),
depth));
591 return nLayersInDepth;
599 if(hid.
zside()==1 && (hid.
iphi()==63 || hid.
iphi()==64 || hid.
iphi()==65 || hid.
iphi()==66))
return true;
616 if(nLayersInDepth > 4) {
630 if(nLayersInDepth > 4) {
657 ps.getParameter<
int>(
"pixels"),
658 ps.getParameter<
double>(
"nonlin1"),
659 ps.getParameter<
double>(
"nonlin2"),
660 ps.getParameter<
double>(
"nonlin3"),
661 ps.getParameter<
double>(
"crosstalk"),
665 return std::make_unique<HcalSiPMCharacteristics>(sipmHelper);
672 uint32_t bitInfo = ((44 << 16) | 30);
680 tppar.
loadObject(0,0,0xFFFFFFFFFFFFFFFF,0,0,0);
const double pedestalWidth() const
HcalMCParam makeMCParam(HcalGenericDetId fId) const
HcalHardcodeParameters theHOParameters_
bool mapEId2chId(HcalElectronicsId fElectronicsId, DetId fId)
void getDepthSegmentation(const unsigned ring, std::vector< int > &readoutDepths, const bool flag=false) const
const HcalHardcodeParameters & getParameters(HcalGenericDetId fId) const
HcalCalibrationQIECoder makeCalibrationQIECoder(HcalGenericDetId fId) const
HcalSubdetector subdet() const
get the subdetector
bool loadObject(DetId fId, int rm, std::string rbx)
load a new entry
const int recoShape() const
std::vector< edm::ParameterSet > theSiPMCharacteristics_
int zside() const
get the z-side of the cell (1/-1)
std::unique_ptr< HcalElectronicsMap > makeHardcodeMap(const std::vector< HcalGenericDetId > &cells) const
constexpr uint32_t rawId() const
get the raw id
const int qieType() const
bool isHEPlan1(HcalGenericDetId fId) const
const int mcShape() const
float getValue(int fCapId) const
get value for capId = 0..3
HcalHardcodeParameters theDefaultParameters_
const double gainWidth(unsigned index) const
const double photoelectronsToAnalog() const
HcalTimingParam makeTimingParam(HcalGenericDetId fId) const
HcalRecoParam makeRecoParam(HcalGenericDetId fId) const
HcalHardcodeParameters theHEUpgradeParameters_
int depth() const
get the tower depth
void makeHardcodeFrontEndMap(HcalFrontEndMap &emap, const std::vector< HcalGenericDetId > &cells) const
HcalHardcodeParameters theHBUpgradeParameters_
HcalQIECoder makeQIECoder(HcalGenericDetId fId) const
std::unique_ptr< HcalDcsMap > makeHardcodeDcsMap() const
int ieta() const
get the cell ieta
HcalQIEShape makeQIEShape() const
void makeHardcodeTPParameters(HcalTPParameters &tppar) const
const int getGainIndex(HcalGenericDetId fId) const
bool mapGeomId2DcsId(HcalDetId fId, HcalDcsDetId fDcsId)
const double pedestal() const
bool mapEId2tId(HcalElectronicsId fElectronicsId, HcalTrigTowerDetId fTriggerId)
HcalHardcodeParameters theHBParameters_
int ietaAbs() const
get the absolute value of the cell ieta
HcalTPChannelParameter makeHardcodeTPChannelParameter(HcalGenericDetId fId) const
int iphi() const
get the cell iphi
HcalGainWidth makeGainWidth(HcalGenericDetId fId) const
std::unique_ptr< HcalSiPMCharacteristics > makeHardcodeSiPMCharacteristics() const
HcalGain makeGain(HcalGenericDetId fId, bool fSmear=false) const
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
bool loadObject(int type, int pixels, float parLin1, float parLin2, float parLin3, float crossTalk, int auxi1=0, float auxi2=0)
const double darkCurrent(unsigned index, double intlumi) const
void loadObject(int version, int adcCut, uint64_t tdcMask, uint32_t tbits, int auxi1, int auxi2)
HcalQIEType makeQIEType(HcalGenericDetId fId) const
const double gain(unsigned index) const
static std::atomic< unsigned int > counter
int getLayersInDepth(int ieta, int depth, const HcalTopology *topo)
HcalHardcodeParameters theHFParameters_
HcalPedestal makePedestal(HcalGenericDetId fId, bool fSmear, bool eff, const HcalTopology *topo, double intlumi)
HcalHardcodeParameters theHEParameters_
const int zsThreshold() const
HcalSiPMParameter makeHardcodeSiPMParameter(HcalGenericDetId fId, const HcalTopology *topo, double intlumi)
HcalGenericSubdetector genericSubdet() const
std::map< std::pair< int, int >, int > theLayersInDepths_
Readout chain identification for Hcal.
HcalHardcodeParameters theHFUpgradeParameters_
Power< A, B >::type pow(const A &a, const B &b)
HcalZSThreshold makeZSThreshold(HcalGenericDetId fId) const
HcalPedestalWidth makePedestalWidth(HcalGenericDetId fId, bool eff, const HcalTopology *topo, double intlumi)