File indexing completed on 2025-01-31 09:21:53
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 #include "CexmcRunManager.hh"
0045 #include "CexmcProductionModel.hh"
0046 #include "CexmcProductionModelMessenger.hh"
0047
0048
0049 CexmcProductionModel::CexmcProductionModel( const G4String & name_,
0050 G4bool fermiMotionIsOn_ ) :
0051 name( name_ ), fermiMotionIsOn( fermiMotionIsOn_ ),
0052 incidentParticle( NULL ), nucleusParticle( NULL ), outputParticle( NULL ),
0053 nucleusOutputParticle( NULL ), messenger( NULL )
0054 {
0055 angularRanges.push_back( CexmcAngularRange( 1.0, -1.0, 0 ) );
0056 messenger = new CexmcProductionModelMessenger( this );
0057 }
0058
0059
0060 CexmcProductionModel::~CexmcProductionModel()
0061 {
0062 delete messenger;
0063 }
0064
0065
0066 void CexmcProductionModel::SetAngularRange( G4double top, G4double bottom,
0067 G4int nmbOfDivs )
0068 {
0069 if ( ! IsValidCandidateForAngularRange( top, bottom, nmbOfDivs ) )
0070 throw CexmcException( CexmcInvalidAngularRange );
0071
0072 if ( ! IsGoodCandidateForAngularRange( top, bottom ) )
0073 throw CexmcException( CexmcBadAngularRange );
0074
0075 angularRanges.clear();
0076 G4double curBottom( top );
0077 for ( int i( 0 ); i < nmbOfDivs; ++i )
0078 {
0079 G4double binWidth( ( top - bottom ) / nmbOfDivs );
0080 G4double curTop( curBottom );
0081 curBottom -= binWidth;
0082 angularRanges.push_back( CexmcAngularRange( curTop, curBottom, i ) );
0083 }
0084 #ifdef CEXMC_USE_ROOT
0085 CexmcHistoManager::Instance()->SetupARHistos( angularRanges );
0086 #endif
0087 }
0088
0089
0090 void CexmcProductionModel::AddAngularRange( G4double top, G4double bottom,
0091 G4int nmbOfDivs )
0092 {
0093 if ( ! IsValidCandidateForAngularRange( top, bottom, nmbOfDivs ) )
0094 throw CexmcException( CexmcInvalidAngularRange );
0095
0096 if ( ! IsGoodCandidateForAngularRange( top, bottom ) )
0097 throw CexmcException( CexmcBadAngularRange );
0098
0099 G4int curIndex( angularRanges.size() );
0100 G4double curBottom( top );
0101 for ( int i( 0 ); i < nmbOfDivs; ++i )
0102 {
0103 G4double binWidth( ( top - bottom ) / nmbOfDivs );
0104 G4double curTop( curBottom );
0105 curBottom -= binWidth;
0106 CexmcAngularRange aRange( curTop, curBottom, curIndex + i );
0107 angularRanges.push_back( aRange );
0108 #ifdef CEXMC_USE_ROOT
0109 CexmcHistoManager::Instance()->AddARHistos( aRange );
0110 #endif
0111 }
0112 }
0113
0114
0115 void CexmcProductionModel::SetTriggeredAngularRanges( G4double opCosThetaSCM )
0116 {
0117 triggeredAngularRanges.clear();
0118
0119 for ( CexmcAngularRangeList::iterator k( angularRanges.begin() );
0120 k != angularRanges.end(); ++k )
0121 {
0122 if ( opCosThetaSCM <= k->top && opCosThetaSCM > k->bottom )
0123 triggeredAngularRanges.push_back( CexmcAngularRange(
0124 k->top, k->bottom, k->index ) );
0125 }
0126 }
0127
0128
0129 void CexmcProductionModel::FermiMotionStatusChangeHook( void )
0130 {
0131 }
0132
0133
0134 G4bool CexmcProductionModel::IsGoodCandidateForAngularRange( G4double top,
0135 G4double bottom ) const
0136 {
0137 CexmcRunManager * runManager( static_cast< CexmcRunManager * >(
0138 G4RunManager::GetRunManager() ) );
0139
0140 if ( ! runManager->ProjectIsRead() )
0141 return true;
0142
0143 CexmcAngularRangeList normalizedARanges;
0144 GetNormalizedAngularRange( angularRangesRef, normalizedARanges );
0145
0146 for ( CexmcAngularRangeList::iterator k( normalizedARanges.begin() );
0147 k != normalizedARanges.end(); ++k )
0148 {
0149 if ( top <= k->top && bottom >= k->bottom )
0150 return true;
0151 }
0152
0153 return false;
0154 }
0155