File indexing completed on 2025-01-18 09:14:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DDDigi/DigiContainerProcessor.h>
0016 #include <DD4hep/DD4hepUnits.h>
0017
0018
0019 #include <limits>
0020
0021
0022 namespace dd4hep {
0023
0024
0025 namespace digi {
0026
0027
0028
0029
0030
0031
0032
0033
0034 class DigiDepositNoiseOnSignal : public DigiDepositsProcessor {
0035 protected:
0036
0037 double m_mean { 0e0 };
0038
0039 double m_sigma { 0e0 };
0040
0041 public:
0042
0043 template <typename T> void
0044 create_noise(DigiContext& context, T& cont, work_t& , const predicate_t& predicate) const {
0045 auto& random = context.randomGenerator();
0046 std::size_t updated = 0UL;
0047 for( auto& dep : cont ) {
0048 if ( predicate(dep) ) {
0049 int flag = EnergyDeposit::DEPOSIT_NOISE;
0050 double delta_E = random.gaussian(m_mean, m_sigma);
0051 if ( m_monitor ) m_monitor->energy_shift(dep, delta_E);
0052 dep.second.deposit += delta_E;
0053 dep.second.flag |= flag;
0054 ++updated;
0055 }
0056 }
0057 info("%s+++ %-32s Noise on signal: %6ld entries, updated %6ld entries. mask: %04X",
0058 context.event->id(), cont.name.c_str(), cont.size(), updated, cont.key.mask());
0059 }
0060
0061
0062 DigiDepositNoiseOnSignal(const DigiKernel& krnl, const std::string& nam)
0063 : DigiDepositsProcessor(krnl, nam)
0064 {
0065 declareProperty("mean", m_mean);
0066 declareProperty("sigma", m_sigma);
0067 DEPOSIT_PROCESSOR_BIND_HANDLERS(DigiDepositNoiseOnSignal::create_noise);
0068 }
0069 };
0070 }
0071 }
0072
0073 #include <DDDigi/DigiFactories.h>
0074 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiDepositNoiseOnSignal)