Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:24

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 #ifndef DDG4_GEANT4PARTICLEGENERATOR_H
0014 #define DDG4_GEANT4PARTICLEGENERATOR_H
0015 
0016 // Framework include files
0017 #include <DDG4/Geant4GeneratorAction.h>
0018 #include <Math/Vector3D.h>
0019 
0020 // Forward declarations
0021 class G4ParticleDefinition;
0022 
0023 /// Namespace for the AIDA detector description toolkit
0024 namespace dd4hep {
0025 
0026   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0027   namespace sim {
0028 
0029     // Forward declarations
0030     class Geant4PrimaryInteraction;
0031 
0032     /// Generate particles isotrop in space around origine (0,0,0)
0033     /**
0034      *  \author  M.Frank
0035      *  \version 1.0
0036      *  \ingroup DD4HEP_SIMULATION
0037      */
0038     class Geant4ParticleGenerator: public Geant4GeneratorAction {
0039     public:
0040     protected:
0041       /// Property: Shooting direction of the gun
0042       ROOT::Math::XYZVector m_direction;
0043       /// Property: Position of the gun in space
0044       ROOT::Math::XYZVector m_position;
0045       /// Property: Particle name
0046       std::string m_particleName;
0047       /// Pointer to geant4 particle definition
0048       G4ParticleDefinition* m_particle;
0049       /// Property: Fixed momentum value, overwrites momentumMin and momentumMax if set
0050       double m_energy;
0051       /// Property: Minimal momentum value
0052       double m_momentumMin;
0053       /// Property: Maximal momentum value
0054       double m_momentumMax;
0055       /// Property: Desired multiplicity of the particles to be shot
0056       int m_multiplicity;
0057       /// Property: User mask passed to all particles in the generated interaction
0058       int m_mask;
0059       
0060       /// Particle modification. Caller presets defaults to: (multiplicity=m_multiplicity)
0061       virtual void getParticleMultiplicity(int& multiplicity) const;
0062 
0063       /// Particle's vertex modification. Caller presets defaults to: (multiplicity=m_multiplicity)
0064       virtual void getVertexPosition(ROOT::Math::XYZVector& position) const;
0065 
0066       /// Particle modification. Caller presets defaults to: ( direction = m_direction, momentum = m_energy)
0067       /** Use this function to implement isotrop guns, multiple guns etc. 
0068           User must return a UNIT vector, which gets scaled with momentum.
0069       */
0070       virtual void getParticleDirection(int num, ROOT::Math::XYZVector& direction, double& momentum) const;
0071       /// Uniform particle momentum
0072       void getParticleMomentumUniform(double& momentum) const;
0073 
0074       /// Print single particle interaction identified by its mask
0075       virtual void printInteraction(int mask)  const;
0076       /// Print single particle interaction identified by its reference
0077       virtual void printInteraction(Geant4PrimaryInteraction* inter)  const;
0078     
0079 
0080     public:
0081       /// Standard constructor
0082       Geant4ParticleGenerator(Geant4Context* context, const std::string& name);
0083       /// Default destructor
0084       virtual ~Geant4ParticleGenerator();
0085       /// Callback to generate primary particles
0086       virtual void operator()(G4Event* event);
0087     };
0088   }    // End namespace sim
0089 }      // End namespace dd4hep
0090 #endif // DDG4_GEANT4PARTICLEGENERATOR_H