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p3 ] [ 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 /examples/advanced/ChargeExchangeMC/src/CexmcHadronicProcess.cc (Version 11.3.0) and /examples/advanced/ChargeExchangeMC/src/CexmcHadronicProcess.cc (Version 9.2.p3)


  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 /*                                                
 27  * ===========================================    
 28  *                                                
 29  *       Filename:  CexmcHadronicProcess.cc       
 30  *                                                
 31  *    Description:  hadronic process with prod    
 32  *                                                
 33  *        Version:  1.0                           
 34  *        Created:  31.10.2009 23:54:38           
 35  *       Revision:  none                          
 36  *       Compiler:  gcc                           
 37  *                                                
 38  *         Author:  Alexey Radkov (),             
 39  *        Company:  PNPI                          
 40  *                                                
 41  * ===========================================    
 42  */                                               
 43                                                   
 44 #include <G4ParticleChange.hh>                    
 45 #include <G4ParticleDefinition.hh>                
 46 #include <G4HadronicInteraction.hh>               
 47 #include <G4Track.hh>                             
 48 #include <G4Step.hh>                              
 49 #include <G4Element.hh>                           
 50 #include <G4StableIsotopes.hh>                    
 51 #include <G4TrackStatus.hh>                       
 52 #include "CexmcHadronicProcess.hh"                
 53 #include "CexmcProductionModel.hh"                
 54 #include "CexmcIncidentParticleTrackInfo.hh"      
 55 #include "CexmcException.hh"                      
 56                                                   
 57                                                   
 58 CexmcHadronicProcess::CexmcHadronicProcess( co    
 59     G4HadronicProcess( name ), productionModel    
 60     theTotalResult( NULL ), isInitialized( fal    
 61 {                                                 
 62     theTotalResult = new G4ParticleChange();      
 63     SetIntegral(false);                           
 64 }                                                 
 65                                                   
 66                                                   
 67 CexmcHadronicProcess::~CexmcHadronicProcess()     
 68 {                                                 
 69     delete theTotalResult;                        
 70 }                                                 
 71                                                   
 72                                                   
 73 void  CexmcHadronicProcess::RegisterProduction    
 74                                                   
 75 {                                                 
 76     productionModel = model;                      
 77                                                   
 78     interaction = dynamic_cast< G4HadronicInte    
 79                                                   
 80     if ( ! interaction )                          
 81         throw CexmcException( CexmcIncompatibl    
 82                                                   
 83     G4HadronicProcess::RegisterMe( interaction    
 84 }                                                 
 85                                                   
 86                                                   
 87 void  CexmcHadronicProcess::CalculateTargetNuc    
 88                                                   
 89 {                                                 
 90     G4int  numberOfElements( material->GetNumb    
 91     if ( numberOfElements > 1 )                   
 92     {                                             
 93         G4cout << CEXMC_LINE_START "WARNING: N    
 94                   "material is more than 1.\n     
 95                   "element will be chosen for     
 96     }                                             
 97                                                   
 98     const G4Element *  element( material->GetE    
 99     G4double           ZZ( element->GetZ() );     
100     G4int              Z( G4int( ZZ + 0.5 ) );    
101                                                   
102     G4StableIsotopes  stableIsotopes;             
103     G4int             index( stableIsotopes.Ge    
104     G4double          AA( stableIsotopes.GetIs    
105                                                   
106     targetNucleus.SetParameters( AA, ZZ );        
107 }                                                 
108                                                   
109                                                   
110 void  CexmcHadronicProcess::FillTotalResult( G    
111                                              c    
112 {                                                 
113     G4int  numberOfSecondaries( hadFinalState-    
114                                                   
115     theTotalResult->Clear();                      
116     theTotalResult->Initialize( track );          
117     theTotalResult->SetSecondaryWeightByProces    
118     theTotalResult->ProposeLocalEnergyDeposit(    
119                                     hadFinalSt    
120     theTotalResult->SetNumberOfSecondaries( nu    
121     theTotalResult->ProposeEnergy( hadFinalSta    
122     theTotalResult->ProposeTrackStatus( fAlive    
123     if ( hadFinalState->GetStatusChange() == s    
124         theTotalResult->ProposeTrackStatus( fS    
125                                                   
126     for ( G4int  i( 0 ); i < numberOfSecondari    
127     {                                             
128         G4double   time( hadFinalState->GetSec    
129         if ( time < 0 )                           
130             time = track.GetGlobalTime();         
131                                                   
132         G4Track *  newTrack( new G4Track(         
133                              hadFinalState->Ge    
134                              time, track.GetPo    
135                                                   
136         G4double   newWeight( track.GetWeight(    
137                               hadFinalState->G    
138         newTrack->SetWeight( newWeight );         
139         newTrack->SetTouchableHandle( track.Ge    
140         theTotalResult->AddSecondary( newTrack    
141     }                                             
142                                                   
143     hadFinalState->Clear();                       
144 }                                                 
145                                                   
146                                                   
147 G4VParticleChange *  CexmcHadronicProcess::Pos    
148                                                   
149 {                                                 
150     G4TrackStatus  trackStatus( track.GetTrack    
151                                                   
152     if ( trackStatus != fAlive && trackStatus     
153     {                                             
154         theTotalResult->Clear();                  
155         theTotalResult->Initialize( track );      
156                                                   
157         return theTotalResult;                    
158     }                                             
159                                                   
160     /* NB: the target nucleus is chosen only o    
161      * have same Z and A, practically the firs    
162      * element in elements vector will be chos    
163      * the user to choose simple single-elemen    
164      * example liquid hydrogen. On the other h    
165      * only needed if user decides to turn Fer    
166      * simplification should not be very harmf    
167     if ( ! isInitialized )                        
168     {                                             
169         CalculateTargetNucleus( track.GetMater    
170         isInitialized = true;                     
171     }                                             
172                                                   
173     G4HadProjectile    projectile( track );       
174     G4HadFinalState *  result( interaction->Ap    
175                                                   
176     FillTotalResult( result, track );             
177                                                   
178     if ( theTotalResult->GetTrackStatus() != f    
179     {                                             
180         CexmcTrackInfo *  trackInfo( static_ca    
181                                                   
182                                                   
183         if ( trackInfo &&                         
184              trackInfo->GetTypeInfo() == Cexmc    
185         {                                         
186             CexmcIncidentParticleTrackInfo *      
187                 static_cast< CexmcIncidentPart    
188             theTrackInfo->SetNeedsTrackLengthR    
189         }                                         
190     }                                             
191                                                   
192     return theTotalResult;                        
193 }                                                 
194                                                   
195                                                   
196 G4bool  CexmcHadronicProcess::IsApplicable(       
197                                         const     
198 {                                                 
199     if ( ! productionModel )                      
200         return false;                             
201                                                   
202     G4ParticleDefinition *  incidentParticle(     
203                                     production    
204                                                   
205     if ( ! incidentParticle )                     
206         return false;                             
207                                                   
208     return particle == *incidentParticle;         
209 }                                                 
210                                                   
211