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/DigiData.h>
0016 #include <DDDigi/DigiContainerProcessor.h>
0017
0018
0019 #include <iostream>
0020
0021
0022 namespace dd4hep {
0023
0024
0025 namespace digi {
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 class DigiIPMover : public DigiContainerProcessor {
0036 public:
0037
0038
0039 DigiIPMover(const DigiKernel& krnl, const std::string& nam)
0040 : DigiContainerProcessor(krnl, nam)
0041 {
0042 }
0043
0044
0045 template <typename DEPOSITS> std::size_t
0046 move_deposits(const char* tag, DEPOSITS& cont, const Position& delta, const predicate_t& predicate) const {
0047 info("%s+++ %-32s [%6ld] IP: x:%7.3f y:%7.3f z:%7.3f",
0048 tag, cont.name.c_str(), cont.size(), delta.X(), delta.Y(), delta.Z());
0049 for( auto& dep : cont ) {
0050 if( predicate(dep) ) {
0051 dep.second.position += delta;
0052 }
0053 }
0054 return cont.size();
0055 }
0056
0057
0058 template <typename PARTICLES> std::size_t
0059 move_particles(const char* tag, PARTICLES& cont, const Position& delta) const {
0060 info("%s+++ %-32s [%6ld] IP: x:%7.3f y:%7.3f z:%7.3f",
0061 tag, cont.name.c_str(), cont.size(), delta.X(), delta.Y(), delta.Z());
0062
0063 for( auto& p : cont )
0064 p.second.move_position(delta);
0065 return cont.size();
0066 }
0067
0068
0069 virtual void execute(DigiContext& context, work_t& work, const predicate_t& predicate) const override {
0070 const char* tag = context.event->id();
0071 Position delta = property("interaction_point").value<Position>();
0072 if ( auto* m = work.get_input<DepositMapping>() )
0073 move_deposits(tag, *m, delta, predicate);
0074 else if ( auto* v = work.get_input<DepositVector>() )
0075 move_deposits(tag, *v, delta, predicate);
0076 else if ( auto* p = work.get_input<ParticleMapping>() )
0077 move_particles(tag, *p, delta);
0078 else
0079 except("%s+++ Request to handle unknown data type: %s", tag, work.input_type_name().c_str());
0080 return;
0081 }
0082 };
0083 }
0084 }
0085
0086 #include <DDDigi/DigiFactories.h>
0087 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiIPMover)