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/InstanceCount.h>
0017 #include <DD4hep/DD4hepUnits.h>
0018
0019
0020
0021
0022 namespace dd4hep {
0023
0024
0025 namespace digi {
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 class DigiDepositRecalibEnergy : public DigiDepositsProcessor {
0036 protected:
0037
0038 std::vector<double> m_polynomial { };
0039
0040 double m_e0 { 0e0 };
0041
0042 public:
0043
0044 DigiDepositRecalibEnergy(const DigiKernel& krnl, const std::string& nam)
0045 : DigiDepositsProcessor(krnl, nam)
0046 {
0047 declareProperty("e0", m_e0);
0048 declareProperty("parameters" , m_polynomial);
0049 DEPOSIT_PROCESSOR_BIND_HANDLERS(DigiDepositRecalibEnergy::recalibrate_deposit_energy);
0050 }
0051
0052
0053 template <typename T> void
0054 recalibrate_deposit_energy(DigiContext& context, T& cont, work_t& , const predicate_t& predicate) const {
0055 std::size_t updated = 0UL;
0056 for( auto& dep : cont ) {
0057 if ( predicate(dep) ) {
0058 double deposit = dep.second.deposit;
0059 double delta_E = deposit - m_e0;
0060 double fac = 1e0;
0061 for( double param : m_polynomial ) {
0062 deposit += param * fac;
0063 fac *= delta_E;
0064 }
0065 if ( m_monitor ) m_monitor->energy_shift(dep, delta_E);
0066 dep.second.deposit = deposit;
0067 dep.second.flag |= EnergyDeposit::RECALIBRATED;
0068 ++updated;
0069 }
0070 }
0071 info("%s+++ %-32s Recalibrating: updated %6ld out of %6ld entries from mask: %04X",
0072 context.event->id(), cont.name.c_str(), updated, cont.size(), cont.key.mask());
0073 }
0074 };
0075 }
0076 }
0077
0078 #include <DDDigi/DigiFactories.h>
0079 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiDepositRecalibEnergy)