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3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/biasing/generic/src/G4BOptnForceCommonTruncatedExp.cc (Version 11.3.0) and /processes/biasing/generic/src/G4BOptnForceCommonTruncatedExp.cc (Version 8.0.p1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 // G4BOptnForceCommonTruncatedExp                 
 27 // -------------------------------------------    
 28 #include "G4BOptnForceCommonTruncatedExp.hh"      
 29 #include "G4ILawCommonTruncatedExp.hh"            
 30 #include "G4ILawForceFreeFlight.hh"               
 31 #include "G4TransportationManager.hh"             
 32                                                   
 33 #include "Randomize.hh"                           
 34 #include "G4BiasingProcessInterface.hh"           
 35                                                   
 36 G4BOptnForceCommonTruncatedExp::                  
 37 G4BOptnForceCommonTruncatedExp(const G4String&    
 38   : G4VBiasingOperation(name)                     
 39 {                                                 
 40   fCommonTruncatedExpLaw = new G4ILawCommonTru    
 41   fForceFreeFlightLaw    = new G4ILawForceFree    
 42 }                                                 
 43                                                   
 44 G4BOptnForceCommonTruncatedExp::~G4BOptnForceC    
 45 {                                                 
 46   delete fCommonTruncatedExpLaw;                  
 47   delete fForceFreeFlightLaw;                     
 48 }                                                 
 49                                                   
 50 const G4VBiasingInteractionLaw* G4BOptnForceCo    
 51 ProvideOccurenceBiasingInteractionLaw( const G    
 52                                        G4Force    
 53 {                                                 
 54   if ( callingProcess->GetWrappedProcess() ==     
 55   {                                               
 56     proposeForceCondition = Forced;               
 57     return fCommonTruncatedExpLaw;                
 58   }                                               
 59   else                                            
 60   {                                               
 61     proposeForceCondition = Forced;               
 62     return fForceFreeFlightLaw;                   
 63   }                                               
 64 }                                                 
 65                                                   
 66 G4GPILSelection G4BOptnForceCommonTruncatedExp    
 67 ProposeGPILSelection( const G4GPILSelection )     
 68 {                                                 
 69   return NotCandidateForSelection;                
 70 }                                                 
 71                                                   
 72 G4VParticleChange* G4BOptnForceCommonTruncated    
 73 ApplyFinalStateBiasing( const G4BiasingProcess    
 74                         const G4Track* track,     
 75                         const G4Step* step,       
 76                               G4bool& forceFin    
 77 {                                                 
 78   if ( callingProcess->GetWrappedProcess() !=     
 79   {                                               
 80     forceFinalState = true;                       
 81     fDummyParticleChange.Initialize( *track );    
 82     return &fDummyParticleChange;                 
 83   }                                               
 84   if ( fInteractionOccured )                      
 85   {                                               
 86     forceFinalState = true;                       
 87     fDummyParticleChange.Initialize( *track );    
 88     return &fDummyParticleChange;                 
 89   }                                               
 90                                                   
 91   // -- checks if process won the GPIL race:      
 92   G4double processGPIL = callingProcess->GetPo    
 93                        < callingProcess->GetAl    
 94                        ? callingProcess->GetPo    
 95                        : callingProcess->GetAl    
 96   if ( processGPIL <= step->GetStepLength() )     
 97   {                                               
 98     // -- if process won, wrapped process prod    
 99     // -- In this case, the weight for occurre    
100     // -- by the callingProcess, at exit of pr    
101     // -- selected by "forceFinalState = false    
102     forceFinalState     = false;                  
103     fInteractionOccured = true;                   
104     return callingProcess->GetWrappedProcess()    
105   }                                               
106   else                                            
107   {                                               
108     forceFinalState = true;                       
109     fDummyParticleChange.Initialize( *track );    
110     return &fDummyParticleChange;                 
111   }                                               
112 }                                                 
113                                                   
114 void G4BOptnForceCommonTruncatedExp::             
115 AddCrossSection( const G4VProcess* process, G4    
116 {                                                 
117   fTotalCrossSection      += crossSection;        
118   fCrossSections[process]  = crossSection;        
119   fNumberOfSharing         = fCrossSections.si    
120 }                                                 
121                                                   
122 void G4BOptnForceCommonTruncatedExp::Initializ    
123 {                                                 
124   fCrossSections.clear();                         
125   fTotalCrossSection  = 0.0;                      
126   fNumberOfSharing    = 0;                        
127   fProcessToApply     = 0;                        
128   fInteractionOccured = false;                    
129   fInitialMomentum    = track->GetMomentum();     
130                                                   
131   G4VSolid* currentSolid = track->GetVolume()-    
132   G4ThreeVector  localPosition = (G4Transporta    
133                                   GetNavigator    
134                                   GetGlobalToL    
135   G4ThreeVector localDirection = (G4Transporta    
136                                   GetNavigator    
137                                   GetGlobalToL    
138   fMaximumDistance = currentSolid->DistanceToO    
139   if ( fMaximumDistance <= DBL_MIN ) { fMaximu    
140   fCommonTruncatedExpLaw->SetMaximumDistance(     
141 }                                                 
142                                                   
143 void G4BOptnForceCommonTruncatedExp::UpdateFor    
144 {                                                 
145   fCrossSections.clear();                         
146   fTotalCrossSection  = 0.0;                      
147   fNumberOfSharing    = 0;                        
148   fProcessToApply     = 0;                        
149                                                   
150   fCommonTruncatedExpLaw->UpdateForStep( step-    
151   fMaximumDistance = fCommonTruncatedExpLaw->G    
152 }                                                 
153                                                   
154 void G4BOptnForceCommonTruncatedExp::Sample()     
155 {                                                 
156   fCommonTruncatedExpLaw->SetForceCrossSection    
157   fCommonTruncatedExpLaw->Sample();               
158   ChooseProcessToApply();                         
159   fCommonTruncatedExpLaw->SetSelectedProcessXS    
160 }                                                 
161                                                   
162 void G4BOptnForceCommonTruncatedExp::ChoosePro    
163 {                                                 
164   G4double sigmaRand   = G4UniformRand() * fTo    
165   G4double sigmaSelect = 0.0;                     
166   for ( auto it = fCrossSections.cbegin(); it     
167   {                                               
168     sigmaSelect += (*it).second;                  
169     if ( sigmaRand <= sigmaSelect )               
170     {                                             
171       fProcessToApply = (*it).first;              
172       break;                                      
173     }                                             
174   }                                               
175 }                                                 
176