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/DigiData.h>
0016 #include <DDDigi/DigiEventAction.h>
0017
0018
0019 #include <cmath>
0020
0021
0022 namespace dd4hep {
0023
0024 namespace digi {
0025
0026 class DigiIPCreate : public DigiEventAction {
0027 Position m_offset_ip;
0028 Position m_sigma_ip;
0029 mutable Position m_interaction_point;
0030
0031 public:
0032
0033 DigiIPCreate(const DigiKernel& krnl, const std::string& nam)
0034 : DigiEventAction(krnl, nam)
0035 {
0036 declareProperty("offset_ip", m_offset_ip);
0037 declareProperty("sigma_ip", m_sigma_ip);
0038 declareProperty("interaction_point", m_interaction_point);
0039 }
0040
0041
0042 virtual void execute(DigiContext& context) const override final {
0043 auto& rndm = context.randomGenerator();
0044 double theta = rndm.uniform(0.0, M_PI);
0045 double phi = rndm.uniform(0.0, 2.0*M_PI);
0046 double radius = rndm.uniform(0.0, 1.0);
0047 radius = std::sqrt( -std::log(radius) );
0048
0049 double st = std::sin(theta);
0050 double xx = radius * st * std::cos(phi) * m_sigma_ip.X() + m_offset_ip.X();
0051 double yy = radius * st * std::sin(phi) * m_sigma_ip.Y() + m_offset_ip.Y();
0052 double zz = radius * std::cos(theta) * m_sigma_ip.Z() + m_offset_ip.Z();
0053 m_interaction_point = Position(xx, yy, zz);
0054 }
0055 };
0056 }
0057 }
0058
0059 #include <DDDigi/DigiFactories.h>
0060 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiIPCreate)