File indexing completed on 2025-01-30 09:17:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DDDigi/DigiContext.h>
0016 #include <DDDigi/DigiContainerProcessor.h>
0017
0018
0019 namespace dd4hep {
0020
0021
0022 namespace digi {
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 class DigiSegmentDepositExtractor : public DigiContainerProcessor {
0035 public:
0036
0037 DigiSegmentDepositExtractor(const DigiKernel& kernel, const std::string& nam)
0038 : DigiContainerProcessor(kernel, nam) {}
0039
0040 template <typename T> void copy_deposits(const T& cont, work_t& work, const predicate_t& predicate) const {
0041 DepositVector deposits(cont.name, work.environ.output.mask, cont.data_type);
0042 for( const auto& dep : cont ) {
0043 if( predicate(dep) ) {
0044 CellID cell = dep.first;
0045 EnergyDeposit depo = dep.second;
0046 deposits.emplace(cell, std::move(depo));
0047 }
0048 }
0049 work.environ.output.data.put(deposits.key, std::move(deposits));
0050 }
0051
0052 virtual void execute(DigiContext&, work_t& work, const predicate_t& predicate) const override final {
0053 if ( const auto* m = work.get_input<DepositMapping>() )
0054 copy_deposits(*m, work, predicate);
0055 else if ( const auto* v = work.get_input<DepositVector>() )
0056 copy_deposits(*v, work, predicate);
0057 else
0058 except("Request to handle unknown data type: %s", work.input_type_name().c_str());
0059 }
0060 };
0061 }
0062 }
0063
0064 #include <DDDigi/DigiFactories.h>
0065 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiSegmentDepositExtractor)