Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:26

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 /** \addtogroup Geant4PhysicsConstructor
0015  *
0016  * @{
0017  * \package Geant4Optical PhotonPhysics
0018  *
0019  * \brief PhysicsConstructor for Optical Photon physics
0020 
0021  This plugin allows to enable Optical Photon physics in the physics list
0022 
0023  *
0024  * @}
0025  */
0026 #ifndef DDG4_GEANT4OPTICALPHOTONPHYSICS_H
0027 #define DDG4_GEANT4OPTICALPHOTONPHYSICS_H 1
0028 
0029 // Framework include files
0030 #include <DDG4/Geant4PhysicsList.h>
0031 
0032 /// Geant4 include files
0033 #include <G4OpAbsorption.hh>
0034 #include <G4OpRayleigh.hh>
0035 #include <G4OpMieHG.hh>
0036 #include <G4OpBoundaryProcess.hh>
0037 #include <G4ParticleDefinition.hh>
0038 #include <G4ParticleTypes.hh>
0039 #include <G4ParticleTable.hh>
0040 #include <G4ProcessManager.hh>
0041 #include <G4Version.hh>
0042 
0043 #if G4VERSION_NUMBER >= 1070
0044 #include <G4OpticalParameters.hh>
0045 #endif
0046 
0047 /// Namespace for the AIDA detector description toolkit
0048 namespace dd4hep {
0049 
0050   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0051   namespace sim {
0052 
0053     /// Geant4 physics list action to enable OpticalPhoton physics
0054     /**
0055      *  \author  M.Frank
0056      *  \version 1.0
0057      *  \ingroup DD4HEP_SIMULATION
0058      */
0059     class Geant4OpticalPhotonPhysics : public Geant4PhysicsList    {
0060     public:
0061       /// Default constructor
0062       Geant4OpticalPhotonPhysics() = delete;
0063       /// Copy constructor
0064       Geant4OpticalPhotonPhysics(const Geant4OpticalPhotonPhysics&) = delete;
0065       /// Initializing constructor
0066       Geant4OpticalPhotonPhysics(Geant4Context* ctxt, const std::string& nam)
0067         : Geant4PhysicsList(ctxt, nam)
0068       {
0069         declareProperty("VerboseLevel", m_verbosity = 0);
0070         declareProperty("BoundaryInvokeSD", m_boundaryInvokeSD = false);
0071       }
0072       /// Default destructor
0073       virtual ~Geant4OpticalPhotonPhysics() = default;
0074       /// Callback to construct processes (uses the G4 particle table)
0075       virtual void constructProcesses(G4VUserPhysicsList* physics_list)   { 
0076         this->Geant4PhysicsList::constructProcesses(physics_list);
0077         info("+++ Constructing optical_photon processes:");
0078         info("+++              G4OpAbsorption G4OpRayleigh G4OpMieHG G4OpBoundaryProcess");
0079         G4ParticleTable*      table = G4ParticleTable::GetParticleTable();
0080         G4ParticleDefinition* particle = table->FindParticle("opticalphoton");
0081         if (0 == particle) {
0082           except("++ Cannot resolve 'opticalphoton' particle definition!");
0083         }
0084 
0085         G4OpBoundaryProcess*  fBoundaryProcess           = new G4OpBoundaryProcess();
0086         G4OpAbsorption*       fAbsorptionProcess         = new G4OpAbsorption();
0087         G4OpRayleigh*         fRayleighScatteringProcess = new G4OpRayleigh();
0088         G4OpMieHG*            fMieHGScatteringProcess    = new G4OpMieHG();
0089 
0090 #if G4VERSION_NUMBER >= 1070
0091         G4OpticalParameters* params = G4OpticalParameters::Instance();
0092         params->SetAbsorptionVerboseLevel(m_verbosity);
0093         params->SetRayleighVerboseLevel(m_verbosity);
0094         params->SetMieVerboseLevel(m_verbosity);
0095         params->SetBoundaryVerboseLevel(m_verbosity);
0096         params->SetBoundaryInvokeSD(m_boundaryInvokeSD);
0097 #else
0098         fAbsorptionProcess->SetVerboseLevel(m_verbosity);
0099         fRayleighScatteringProcess->SetVerboseLevel(m_verbosity);
0100         fMieHGScatteringProcess->SetVerboseLevel(m_verbosity);
0101         fBoundaryProcess->SetVerboseLevel(m_verbosity);
0102 #if G4VERSION_NUMBER >= 1000
0103         fBoundaryProcess->SetInvokeSD(m_boundaryInvokeSD);
0104 #endif
0105 #endif
0106         G4ProcessManager* pmanager = particle->GetProcessManager();
0107         pmanager->AddDiscreteProcess(fAbsorptionProcess);
0108         pmanager->AddDiscreteProcess(fRayleighScatteringProcess);
0109         pmanager->AddDiscreteProcess(fMieHGScatteringProcess);
0110         pmanager->AddDiscreteProcess(fBoundaryProcess);
0111       }
0112     private:
0113       int         m_verbosity;
0114       bool        m_boundaryInvokeSD;
0115     };
0116   }
0117 }
0118 #endif   // DDG4_GEANT4OPTICALPHOTONPHYSICS_H
0119 
0120 #include <DDG4/Factories.h>
0121 using namespace dd4hep::sim;
0122 DECLARE_GEANT4ACTION(Geant4OpticalPhotonPhysics)