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");
62 double refIdark =
cfg.getParameter<
edm::ParameterSet>(
"noise").getParameter<double>(
"referenceIdark");
87 const std::unordered_set<DetId>& validIds,
88 CLHEP::HepRandomEngine* engine) {
100 const std::unordered_set<DetId>& validIds,
101 CLHEP::HepRandomEngine* engine) {
108 for (
const auto&
id : validIds) {
109 chargeColl.fill(0.
f);
111 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
112 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
115 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
120 chargeColl[
i] = totalIniMIPs;
135 const std::unordered_set<DetId>& validIds,
136 CLHEP::HepRandomEngine* engine) {
138 constexpr
bool debug(
false);
158 : std::floor(vanillaADCThr / adcLsb));
163 for (
const auto&
id : validIds) {
164 chargeColl.fill(0.
f);
166 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
167 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
176 scaledPePerMip = opChar.
s;
177 tunedNoise = opChar.n;
178 gainIdx = opChar.gain;
179 thrADC = opChar.thrADC;
182 nTotalPixels = opChar.ntotalPE;
183 xTalk = opChar.xtalk;
187 float meanN =
std::pow(tunedNoise, 2);
189 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
194 const uint32_t npeS = std::floor(CLHEP::RandPoissonQ::shoot(engine, totalIniMIPs * scaledPePerMip) + 0.5);
197 const uint32_t npeN = std::floor(CLHEP::RandPoissonQ::shoot(engine, meanN) + 0.5);
200 const uint32_t npe = npeS + npeN;
203 uint32_t nPixel(npe);
226 if (
debug && totalIniMIPs > 0) {
227 LogDebug(
"HGCHEbackDigitizer") <<
"npeS: " << npeS <<
" npeN: " << npeN <<
" npe: " << npe
228 <<
" meanN: " << meanN <<
" noise_MIP_: " <<
noise_MIP_ 229 <<
" nPEperMIP_: " <<
nPEperMIP_ <<
" scaledPePerMip: " << scaledPePerMip
230 <<
" nPixel: " << nPixel;
231 LogDebug(
"HGCHEbackDigitizer") <<
"totalIniMIPs: " << totalIniMIPs <<
" totalMIPs: " << totalMIPs
236 chargeColl[
i] = totalMIPs;
247 this->
myFEelectronics_->runShaper(newDataFrame, chargeColl, toa, engine, thrADC, adcLsb, gainIdx, maxADC);
258 const std::unordered_set<DetId>& validIds,
259 CLHEP::HepRandomEngine* engine) {
261 constexpr
bool debug(
false);
270 for (
const auto&
id : validIds) {
271 chargeColl.fill(0.
f);
272 HGCSimHitDataAccumulator::iterator it = simData.find(
id);
273 HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second);
276 for (
size_t i = 0;
i < cell.
hit_info[0].size(); ++
i) {
281 const uint32_t npe = std::floor(CLHEP::RandPoissonQ::shoot(engine, totalIniMIPs *
nPEperMIP_));
291 nPixel = (uint32_t)
std::max(CLHEP::RandGaussQ::shoot(engine, (
double)nPixel,
sdPixels_), 0.);
294 float totalMIPs(0.
f), xtalk = 0.f;
303 chargeColl[
i] = totalMIPs;
308 <<
" keV -> " << totalIniMIPs <<
" raw-MIPs -> " << chargeColl[
i]
Log< level::Info, true > LogVerbatim
void runRealisticDigitizer(std::unique_ptr< HGCalDigiCollection > &digiColl, hgc::HGCSimHitDataAccumulator &simData, const CaloSubdetectorGeometry *theGeom, const std::unordered_set< DetId > &validIds, CLHEP::HepRandomEngine *engine)
~HGCHEbackDigitizer() override
T getParameter(std::string const &) const
void runEmptyDigitizer(std::unique_ptr< HGCalDigiCollection > &digiColl, hgc::HGCSimHitDataAccumulator &simData, const CaloSubdetectorGeometry *theGeom, const std::unordered_set< DetId > &validIds, CLHEP::HepRandomEngine *engine)
void setSipmMap(const std::string &)
void setGeometry(const CaloSubdetectorGeometry *)
void updateOutput(std::unique_ptr< DColl > &coll, const DFr &rawDataFrame)
prepares the output according to the number of time samples to produce
std::unordered_map< uint32_t, HGCCellInfo > HGCSimHitDataAccumulator
std::unique_ptr< HGCFEElectronics< DFr > > myFEelectronics_
void setReferenceCrossTalk(double xtalk)
std::array< HGCSimData_t, nSamples > HGCSimHitData
HGCHEbackDigitizer(const edm::ParameterSet &ps)
DetId::Detector det() const
std::array< double, GAINRANGE_N > getLSBPerGain()
std::array< HGCSimHitData, 2 > hit_info
bool thresholdFollowsMIP_
void addCellMetadata(HGCCellInfo &info, const HGCalGeometry *geom, const DetId &detid)
void setFluenceScaleFactor(double val)
void setReferenceDarkCurrent(double idark)
double scaleByDoseFactor_
derives from HGCalRadiation map to parse fluence/dose parameters, provides Sci-specific functions the...
void setDoseMap(const std::string &, const unsigned int)
void runDigitizer(std::unique_ptr< HGCalDigiCollection > &digiColl, hgc::HGCSimHitDataAccumulator &simData, const CaloSubdetectorGeometry *theGeom, const std::unordered_set< DetId > &validIds, CLHEP::HepRandomEngine *engine) override
double computeRadius(const HGCScintillatorDetId &)
bool ignoreAutoPedestalSubtraction()
void runCaliceLikeDigitizer(std::unique_ptr< HGCalDigiCollection > &digiColl, hgc::HGCSimHitDataAccumulator &simData, const CaloSubdetectorGeometry *theGeom, const std::unordered_set< DetId > &validIds, CLHEP::HepRandomEngine *engine)
SiPMonTileCharacteristics scaleByDose(const HGCScintillatorDetId &, const double, const int aimMIPtoADC=15, const GainRange_t gainPreChoice=GainRange_t::AUTO)
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::array< double, GAINRANGE_N > getMaxADCPerGain()
models the behavior of the front-end electronics
Power< A, B >::type pow(const A &a, const B &b)