Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:06

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 
0014 // Framework include files
0015 #include <DDDigi/DigiData.h>
0016 #include <DDDigi/DigiEventAction.h>
0017 
0018 /// C/C++ include files
0019 #include <cmath>
0020 
0021 /// Namespace for the AIDA detector description toolkit
0022 namespace dd4hep {
0023   /// Namespace for the Digitization part of the AIDA detector description toolkit
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       /// Standard constructor
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       /// Main functional callback
0042       virtual void execute(DigiContext& context)   const  override final  {
0043         auto& rndm = context.randomGenerator();
0044         double theta  = rndm.uniform(0.0, M_PI);       // theta  = [0,pi]
0045         double phi    = rndm.uniform(0.0, 2.0*M_PI);   // phi    = [0,2*pi] 
0046         double radius = rndm.uniform(0.0, 1.0);        // radius = [0,1]
0047         radius = std::sqrt( -std::log(radius) );       // radius in a gaussian distribution
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   }    // End namespace digi
0057 }      // End namespace dd4hep
0058 
0059 #include <DDDigi/DigiFactories.h>
0060 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiIPCreate)