3 #include "CLHEP/Random/RandPoissonQ.h"
4 #include "CLHEP/Random/RandGaussQ.h"
9 #include "vdt/vdtMath.h"
17 algo_ =
cfg.getParameter<uint32_t>(
"algo");
30 xTalk_ =
cfg.getParameter<
double>(
"xTalk");
41 const std::unordered_set<DetId>& validIds,
43 CLHEP::HepRandomEngine* engine) {
55 const std::unordered_set<DetId>& validIds,
56 CLHEP::HepRandomEngine* engine) {
63 for (
const auto&
id : validIds) {
66 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
67 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
70 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
75 chargeColl[
i] = totalIniMIPs;
90 const std::unordered_set<DetId>& validIds,
91 CLHEP::HepRandomEngine* engine) {
93 constexpr
bool debug(
false);
104 for (
const auto&
id : validIds) {
105 chargeColl.fill(0.
f);
107 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
108 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
113 float sipmFactor = 1.;
128 scaledPePerMip *= dosePair.first;
129 tunedNoise = dosePair.second;
135 scaledPePerMip *= sipmFactor;
136 tunedNoise *=
sqrt(sipmFactor);
141 float meanN =
std::pow(tunedNoise, 2);
143 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
148 const uint32_t npeS = std::floor(CLHEP::RandPoissonQ::shoot(engine, totalIniMIPs * scaledPePerMip) + 0.5);
151 const uint32_t npeN = std::floor(CLHEP::RandPoissonQ::shoot(engine, meanN) + 0.5);
154 const uint32_t npe = npeS + npeN;
157 float nTotalPixels =
nTotalPE_ * sipmFactor;
169 if (
debug && totalIniMIPs > 0) {
170 LogDebug(
"HGCHEbackDigitizer") <<
"npeS: " << npeS <<
" npeN: " << npeN <<
" npe: " << npe
171 <<
" meanN: " << meanN <<
" noise_MIP_: " <<
noise_MIP_
172 <<
" nPEperMIP_: " <<
nPEperMIP_ <<
" scaledPePerMip: " << scaledPePerMip
173 <<
" nPixel: " << nPixel;
174 LogDebug(
"HGCHEbackDigitizer") <<
"totalIniMIPs: " << totalIniMIPs <<
" totalMIPs: " << totalMIPs << std::endl;
178 chargeColl[
i] = totalMIPs;
191 : std::floor(adcThr / adcLsb));
193 this->
myFEelectronics_->runShaper(newDataFrame, chargeColl, toa, engine, thrADC);
204 const std::unordered_set<DetId>& validIds,
205 CLHEP::HepRandomEngine* engine) {
207 constexpr
bool debug(
false);
216 for (
const auto&
id : validIds) {
217 chargeColl.fill(0.
f);
218 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
219 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
222 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
227 const uint32_t npe = std::floor(CLHEP::RandPoissonQ::shoot(engine, totalIniMIPs *
nPEperMIP_));
237 nPixel = (uint32_t)
std::max(CLHEP::RandGaussQ::shoot(engine, (
double)nPixel,
sdPixels_), 0.);
240 float totalMIPs(0.
f), xtalk = 0.f;
249 chargeColl[
i] = totalMIPs;
254 <<
" keV -> " << totalIniMIPs <<
" raw-MIPs -> " << chargeColl[
i]