Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21:49

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /*
0027  * =============================================================================
0028  *
0029  *       Filename:  CexmcParticleGun.hh
0030  *
0031  *    Description:  particle gun
0032  *
0033  *        Version:  1.0
0034  *        Created:  15.12.2009 00:41:16
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * =============================================================================
0042  */
0043 
0044 #ifndef CEXMC_PARTICLE_GUN_HH
0045 #define CEXMC_PARTICLE_GUN_HH
0046 
0047 #include <G4ParticleGun.hh>
0048 #include <G4ThreeVector.hh>
0049 #include "CexmcPhysicsManager.hh"
0050 #include "CexmcException.hh"
0051 
0052 class  CexmcParticleGunMessenger;
0053 
0054 
0055 class  CexmcParticleGun : public G4ParticleGun
0056 {
0057     public:
0058         explicit CexmcParticleGun( CexmcPhysicsManager *  physicsManager,
0059                                    G4int  nmbOfParticles = 1 );
0060 
0061         ~CexmcParticleGun();
0062 
0063     public:
0064         void  PrepareForNewEvent( void );
0065 
0066     public:
0067         const G4ThreeVector &  GetOrigPosition( void ) const;
0068 
0069         const G4ThreeVector &  GetOrigDirection( void ) const;
0070 
0071         G4double               GetOrigMomentumAmp( void ) const;
0072 
0073         void  SetOrigPosition( const G4ThreeVector &  position,
0074                                G4bool  fromMessenger = true );
0075 
0076         void  SetOrigDirection( const G4ThreeVector &  direction,
0077                                 G4bool  fromMessenger = true );
0078 
0079         void  SetOrigMomentumAmp( G4double  momentumAmp,
0080                                   G4bool  fromMessenger = true );
0081 
0082         void  SetBeamParticle( G4ParticleDefinition *  particleDefinition,
0083                                G4bool  fromMessenger = true );
0084 
0085     private:
0086         CexmcPhysicsManager *        physicsManager;
0087 
0088         G4ThreeVector                origPos;
0089 
0090         G4ThreeVector                origDir;
0091 
0092         G4double                     origMomentumAmp;
0093 
0094     private:
0095         CexmcParticleGunMessenger *  messenger;
0096 };
0097 
0098 
0099 inline void  CexmcParticleGun::PrepareForNewEvent( void )
0100 {
0101     /* this will prevent G4ParticleGun spam about kinetic energy redefinition */
0102     particle_energy = 0.0;
0103     particle_momentum = 0.0;
0104 }
0105 
0106 
0107 inline const G4ThreeVector &  CexmcParticleGun::GetOrigPosition( void ) const
0108 {
0109     return origPos;
0110 }
0111 
0112 
0113 inline const G4ThreeVector &  CexmcParticleGun::GetOrigDirection( void ) const
0114 {
0115     return origDir;
0116 }
0117 
0118 
0119 inline G4double  CexmcParticleGun::GetOrigMomentumAmp( void ) const
0120 {
0121     return origMomentumAmp;
0122 }
0123 
0124 
0125 inline void  CexmcParticleGun::SetOrigPosition(
0126                     const G4ThreeVector &  position, G4bool  fromMessenger )
0127 {
0128     if ( fromMessenger )
0129         ThrowExceptionIfProjectIsRead( CexmcCmdIsNotAllowed );
0130 
0131     origPos = position;
0132 }
0133 
0134 
0135 inline void  CexmcParticleGun::SetOrigDirection(
0136                     const G4ThreeVector &  direction, G4bool  fromMessenger )
0137 {
0138     if ( fromMessenger )
0139         ThrowExceptionIfProjectIsRead( CexmcCmdIsNotAllowed );
0140 
0141     origDir = direction;
0142 
0143     physicsManager->SetMaxIL( direction );
0144 }
0145 
0146 
0147 inline void  CexmcParticleGun::SetOrigMomentumAmp( G4double  momentumAmp,
0148                                                    G4bool  fromMessenger )
0149 {
0150     if ( fromMessenger )
0151         ThrowExceptionIfProjectIsRead( CexmcCmdIsNotAllowed );
0152 
0153     origMomentumAmp = momentumAmp;
0154 }
0155 
0156 
0157 inline void  CexmcParticleGun::SetBeamParticle(
0158             G4ParticleDefinition *  particleDefinition, G4bool  fromMessenger )
0159 {
0160     if ( fromMessenger )
0161         ThrowExceptionIfProjectIsRead( CexmcCmdIsNotAllowed );
0162 
0163     SetParticleDefinition( particleDefinition );
0164 }
0165 
0166 
0167 #endif
0168