8 #include "CLHEP/Random/RandPoissonQ.h"
9 #include "CLHEP/Random/RandGaussQ.h"
10 #include "vdt/vdtMath.h"
18 void runDigitizer(std::unique_ptr<HGCalDigiCollection>&
digiColl,
21 const std::unordered_set<DetId>& validIds,
22 CLHEP::HepRandomEngine* engine)
override;
30 float nPEperMIP_, nTotalPE_,
xTalk_, sdPixels_;
34 void runEmptyDigitizer(std::unique_ptr<HGCalDigiCollection>&
digiColl,
37 const std::unordered_set<DetId>& validIds,
38 CLHEP::HepRandomEngine* engine);
40 void runRealisticDigitizer(std::unique_ptr<HGCalDigiCollection>&
digiColl,
43 const std::unordered_set<DetId>& validIds,
44 CLHEP::HepRandomEngine* engine);
46 void runCaliceLikeDigitizer(std::unique_ptr<HGCalDigiCollection>&
digiColl,
49 const std::unordered_set<DetId>& validIds,
50 CLHEP::HepRandomEngine* engine);
55 algo_ =
cfg.getParameter<uint32_t>(
"algo");
70 xTalk_ =
cfg.getParameter<
double>(
"xTalk");
82 const std::unordered_set<DetId>& validIds,
83 CLHEP::HepRandomEngine* engine) {
95 const std::unordered_set<DetId>& validIds,
96 CLHEP::HepRandomEngine* engine) {
103 for (
const auto&
id : validIds) {
104 chargeColl.fill(0.
f);
106 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
107 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
110 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
115 chargeColl[
i] = totalIniMIPs;
130 const std::unordered_set<DetId>& validIds,
131 CLHEP::HepRandomEngine* engine) {
133 constexpr
bool debug(
false);
144 for (
const auto&
id : validIds) {
145 chargeColl.fill(0.
f);
147 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
148 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
153 float sipmFactor = 1.;
168 scaledPePerMip *= dosePair.first;
169 tunedNoise = dosePair.second;
175 scaledPePerMip *= sipmFactor;
176 tunedNoise *=
sqrt(sipmFactor);
181 float meanN =
std::pow(tunedNoise, 2);
183 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
188 const uint32_t npeS = std::floor(CLHEP::RandPoissonQ::shoot(engine, totalIniMIPs * scaledPePerMip) + 0.5);
191 const uint32_t npeN = std::floor(CLHEP::RandPoissonQ::shoot(engine, meanN) + 0.5);
194 const uint32_t npe = npeS + npeN;
197 float nTotalPixels =
nTotalPE_ * sipmFactor;
209 if (
debug && totalIniMIPs > 0) {
210 LogDebug(
"HGCHEbackDigitizer") <<
"npeS: " << npeS <<
" npeN: " << npeN <<
" npe: " << npe
211 <<
" meanN: " << meanN <<
" noise_MIP_: " <<
noise_MIP_
212 <<
" nPEperMIP_: " <<
nPEperMIP_ <<
" scaledPePerMip: " << scaledPePerMip
213 <<
" nPixel: " << nPixel;
214 LogDebug(
"HGCHEbackDigitizer") <<
"totalIniMIPs: " << totalIniMIPs <<
" totalMIPs: " << totalMIPs << std::endl;
218 chargeColl[
i] = totalMIPs;
231 : std::floor(adcThr / adcLsb));
233 this->
myFEelectronics_->runShaper(newDataFrame, chargeColl, toa, engine, thrADC);
244 const std::unordered_set<DetId>& validIds,
245 CLHEP::HepRandomEngine* engine) {
247 constexpr
bool debug(
false);
256 for (
const auto&
id : validIds) {
257 chargeColl.fill(0.
f);
258 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
259 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
262 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
267 const uint32_t npe = std::floor(CLHEP::RandPoissonQ::shoot(engine, totalIniMIPs *
nPEperMIP_));
277 nPixel = (uint32_t)
std::max(CLHEP::RandGaussQ::shoot(engine, (
double)nPixel,
sdPixels_), 0.);
280 float totalMIPs(0.
f), xtalk = 0.f;
289 chargeColl[
i] = totalMIPs;
294 <<
" keV -> " << totalIniMIPs <<
" raw-MIPs -> " << chargeColl[
i]