File indexing completed on 2025-01-31 09:21:50
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_PHYSICS_LIST_HH
0045 #define CEXMC_PHYSICS_LIST_HH
0046
0047 #include <Randomize.hh>
0048 #include <G4Track.hh>
0049 #include <G4StepPoint.hh>
0050 #include <G4ThreeVector.hh>
0051 #include <G4AffineTransform.hh>
0052 #include "CexmcPhysicsManager.hh"
0053 #include "CexmcProductionModel.hh"
0054 #include "CexmcIncidentParticleTrackInfo.hh"
0055 #include "CexmcSetup.hh"
0056 #include "CexmcException.hh"
0057 #include "CexmcCommon.hh"
0058
0059
0060 template < typename BasePhysics, template < typename > class StudiedPhysics,
0061 typename ProductionModel >
0062 class CexmcPhysicsList : public BasePhysics, public CexmcPhysicsManager
0063 {
0064 public:
0065 CexmcPhysicsList();
0066
0067 public:
0068 CexmcProductionModel * GetProductionModel( void );
0069
0070 G4bool IsStudiedProcessAllowed( void ) const;
0071
0072 void ResampleTrackLengthInTarget( const G4Track * track,
0073 const G4StepPoint * stepPoint );
0074
0075 void SetupConstructionHook( const CexmcSetup * setup );
0076
0077 protected:
0078 void CalculateBasicMaxIL( const G4ThreeVector & direction );
0079
0080 private:
0081 StudiedPhysics< ProductionModel > * studiedPhysics;
0082
0083 G4VSolid * targetSolid;
0084
0085 G4AffineTransform targetTransform;
0086 };
0087
0088
0089 template < typename BasePhysics, template < typename > class StudiedPhysics,
0090 typename ProductionModel >
0091 CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0092 CexmcPhysicsList() : studiedPhysics( NULL ), targetSolid( NULL )
0093 {
0094 studiedPhysics = new StudiedPhysics< ProductionModel >( this );
0095 this->RegisterPhysics( studiedPhysics );
0096 }
0097
0098
0099 template < typename BasePhysics, template < typename > class StudiedPhysics,
0100 typename ProductionModel >
0101 CexmcProductionModel *
0102 CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0103 GetProductionModel( void )
0104 {
0105 return studiedPhysics->GetProductionModel();
0106 }
0107
0108
0109 template < typename BasePhysics, template < typename > class StudiedPhysics,
0110 typename ProductionModel >
0111 G4bool CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0112 IsStudiedProcessAllowed( void ) const
0113 {
0114 return numberOfTriggeredStudiedInteractions == 0;
0115 }
0116
0117
0118 template < typename BasePhysics, template < typename > class StudiedPhysics,
0119 typename ProductionModel >
0120 void CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0121 ResampleTrackLengthInTarget( const G4Track * track,
0122 const G4StepPoint * stepPoint )
0123 {
0124
0125
0126
0127
0128
0129 CexmcIncidentParticleTrackInfo * trackInfo(
0130 static_cast< CexmcIncidentParticleTrackInfo * >(
0131 track->GetUserInformation() ) );
0132
0133 if ( ! trackInfo )
0134 return;
0135
0136 G4ThreeVector position;
0137 G4ThreeVector direction;
0138
0139 if ( stepPoint )
0140 {
0141 position = targetTransform.TransformPoint( stepPoint->GetPosition() );
0142 direction = targetTransform.TransformAxis(
0143 stepPoint->GetMomentumDirection() );
0144 }
0145 else
0146 {
0147 position = targetTransform.TransformPoint( track->GetPosition() );
0148 direction = targetTransform.TransformAxis(
0149 track->GetMomentumDirection() );
0150 }
0151
0152 G4double distanceInTarget( targetSolid->DistanceToOut( position,
0153 direction ) );
0154 trackInfo->ResetCurrentTrackLengthInTarget();
0155 trackInfo->SetFinalTrackLengthInTarget( G4UniformRand() *
0156 std::max( distanceInTarget, proposedMaxIL ) );
0157 trackInfo->SetNeedsTrackLengthResampling( false );
0158 }
0159
0160
0161 template < typename BasePhysics, template < typename > class StudiedPhysics,
0162 typename ProductionModel >
0163 void CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0164 CalculateBasicMaxIL( const G4ThreeVector & direction )
0165 {
0166
0167
0168 basicMaxIL = targetSolid->DistanceToOut( G4ThreeVector(),
0169 targetTransform.TransformAxis( direction ) ) * 2;
0170 }
0171
0172
0173 template < typename BasePhysics, template < typename > class StudiedPhysics,
0174 typename ProductionModel >
0175 void CexmcPhysicsList< BasePhysics, StudiedPhysics, ProductionModel >::
0176 SetupConstructionHook( const CexmcSetup * setup )
0177 {
0178 targetSolid = setup->GetVolume( CexmcSetup::Target )->GetSolid();
0179 targetTransform = setup->GetTargetTransform().Inverse();
0180 }
0181
0182
0183 #endif
0184