File indexing completed on 2025-01-31 09:21:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
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
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