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
0017
0018 #include <limits>
0019
0020
0021 namespace dd4hep {
0022
0023
0024 namespace digi {
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 class DigiDepositWeightedPosition : public DigiDepositsProcessor {
0038 protected:
0039
0040 double m_cutoff { -std::numeric_limits<double>::epsilon() };
0041
0042 public:
0043
0044 template <typename T> void
0045 create_deposits(context_t& context, const T& cont, work_t& work, const predicate_t& predicate) const {
0046 Key key(cont.name, work.environ.output.mask);
0047 DepositMapping m(cont.name, work.environ.output.mask, cont.data_type );
0048 std::size_t dropped = 0UL, updated = 0UL, added = 0UL;
0049 for( const auto& dep : cont ) {
0050 if ( predicate(dep) ) {
0051 const EnergyDeposit& depo = dep.second;
0052 if ( depo.deposit >= m_cutoff ) {
0053 CellID cell = dep.first;
0054 auto iter = m.data.find(cell);
0055 if ( iter == m.data.end() )
0056 m.data.emplace(dep.first, depo), ++added;
0057 else
0058 iter->second.update_deposit_weighted(depo), ++updated;
0059 continue;
0060 }
0061 ++dropped;
0062 }
0063 }
0064 info("%s+++ %-32s added %6ld updated %6ld dropped %6ld entries (now: %6ld) from mask: %04X to mask: %04X",
0065 context.event->id(), cont.name.c_str(), added, updated, dropped, m.size(), cont.key.mask(), m.key.mask());
0066 work.environ.output.data.put(m.key, std::move(m));
0067 }
0068
0069
0070 DigiDepositWeightedPosition(const DigiKernel& krnl, const std::string& nam)
0071 : DigiDepositsProcessor(krnl, nam)
0072 {
0073 declareProperty("deposit_cutoff", m_cutoff);
0074 DEPOSIT_PROCESSOR_BIND_HANDLERS(DigiDepositWeightedPosition::create_deposits);
0075 }
0076 };
0077 }
0078 }
0079
0080 #include <DDDigi/DigiFactories.h>
0081 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiDepositWeightedPosition)