3 #include "CLHEP/Random/RandPoissonQ.h"
4 #include "CLHEP/Random/RandGaussQ.h"
9 #include "vdt/vdtMath.h"
17 algo_ =
cfg.getParameter<uint32_t>(
"algo");
31 xTalk_ =
cfg.getParameter<
double>(
"xTalk");
43 const std::unordered_set<DetId>& validIds,
45 CLHEP::HepRandomEngine* engine) {
57 const std::unordered_set<DetId>& validIds,
58 CLHEP::HepRandomEngine* engine) {
65 for (
const auto&
id : validIds) {
68 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
69 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
72 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
77 chargeColl[
i] = totalIniMIPs;
92 const std::unordered_set<DetId>& validIds,
93 CLHEP::HepRandomEngine* engine) {
95 constexpr
bool debug(
false);
106 for (
const auto&
id : validIds) {
107 chargeColl.fill(0.
f);
109 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
110 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
115 float sipmFactor = 1.;
130 scaledPePerMip *= dosePair.first;
131 tunedNoise = dosePair.second;
137 scaledPePerMip *= sipmFactor;
138 tunedNoise *=
sqrt(sipmFactor);
143 float meanN =
std::pow(tunedNoise, 2);
145 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
150 const uint32_t npeS = std::floor(CLHEP::RandPoissonQ::shoot(engine, totalIniMIPs * scaledPePerMip) + 0.5);
153 const uint32_t npeN = std::floor(CLHEP::RandPoissonQ::shoot(engine, meanN) + 0.5);
156 const uint32_t npe = npeS + npeN;
159 float nTotalPixels =
nTotalPE_ * sipmFactor;
171 if (
debug && totalIniMIPs > 0) {
172 LogDebug(
"HGCHEbackDigitizer") <<
"npeS: " << npeS <<
" npeN: " << npeN <<
" npe: " << npe
173 <<
" meanN: " << meanN <<
" noise_MIP_: " <<
noise_MIP_
174 <<
" nPEperMIP_: " <<
nPEperMIP_ <<
" scaledPePerMip: " << scaledPePerMip
175 <<
" nPixel: " << nPixel;
176 LogDebug(
"HGCHEbackDigitizer") <<
"totalIniMIPs: " << totalIniMIPs <<
" totalMIPs: " << totalMIPs << std::endl;
180 chargeColl[
i] = totalMIPs;
193 : std::floor(adcThr / adcLsb));
195 this->
myFEelectronics_->runShaper(newDataFrame, chargeColl, toa, engine, thrADC);
206 const std::unordered_set<DetId>& validIds,
207 CLHEP::HepRandomEngine* engine) {
209 constexpr
bool debug(
false);
218 for (
const auto&
id : validIds) {
219 chargeColl.fill(0.
f);
220 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
221 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
224 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
229 const uint32_t npe = std::floor(CLHEP::RandPoissonQ::shoot(engine, totalIniMIPs *
nPEperMIP_));
239 nPixel = (uint32_t)
std::max(CLHEP::RandGaussQ::shoot(engine, (
double)nPixel,
sdPixels_), 0.);
242 float totalMIPs(0.
f), xtalk = 0.f;
251 chargeColl[
i] = totalMIPs;
256 <<
" keV -> " << totalIniMIPs <<
" raw-MIPs -> " << chargeColl[
i]