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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/extended/hadronic/ParticleFluence/Sphere/src/SteppingAction.cc (Version 11.3.0) and /examples/extended/hadronic/ParticleFluence/Sphere/src/SteppingAction.cc (Version 6.2)


  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 /// \file SteppingAction.cc                       
 27 /// \brief Implementation of the SteppingActio    
 28 //                                                
 29 //                                                
 30                                                   
 31 //....oooOO0OOooo........oooOO0OOooo........oo    
 32 //....oooOO0OOooo........oooOO0OOooo........oo    
 33                                                   
 34 #include "SteppingAction.hh"                      
 35                                                   
 36 #include "Run.hh"                                 
 37                                                   
 38 #include "G4IonTable.hh"                          
 39 #include "G4LossTableManager.hh"                  
 40 #include "G4ParticleDefinition.hh"                
 41 #include "G4ParticleTypes.hh"                     
 42 #include "G4Step.hh"                              
 43 #include "G4StepPoint.hh"                         
 44 #include "G4SystemOfUnits.hh"                     
 45 #include "G4TouchableHistory.hh"                  
 46 #include "G4Track.hh"                             
 47 #include "G4VPhysicalVolume.hh"                   
 48 #include "G4VSolid.hh"                            
 49 #include "G4VTouchable.hh"                        
 50                                                   
 51 const std::array<G4String, SteppingAction::fkN    
 52   SteppingAction::fkArrayKinematicRegionNames     
 53                                                   
 54 const std::array<G4String, SteppingAction::fkN    
 55   SteppingAction::fkArrayScoringPositionNames     
 56                                                   
 57 const std::array<G4String, SteppingAction::fkN    
 58   SteppingAction::fkArrayParticleTypeNames = {    
 59                                                   
 60                                                   
 61                                                   
 62 //....oooOO0OOooo........oooOO0OOooo........oo    
 63                                                   
 64 G4int SteppingAction::GetIndex(const G4int iKi    
 65                                const G4int iPa    
 66 {                                                 
 67   G4int index = -1;                               
 68   if (iKinematicRegion >= 0 && iKinematicRegio    
 69       && iScoringPosition < fkNumberScoringPos    
 70       && iParticleType < fkNumberParticleTypes    
 71   {                                               
 72     index = iKinematicRegion * fkNumberScoring    
 73             + iScoringPosition * fkNumberParti    
 74   }                                               
 75   if (index < 0 || index >= fkNumberCombinatio    
 76     G4cerr << "SteppingAction::GetIndex : WRON    
 77     index = 0;                                    
 78   }                                               
 79   return index;                                   
 80 }                                                 
 81                                                   
 82 //....oooOO0OOooo........oooOO0OOooo........oo    
 83                                                   
 84 SteppingAction::SteppingAction() : G4UserStepp    
 85 {                                                 
 86   Initialize();                                   
 87 }                                                 
 88                                                   
 89 //....oooOO0OOooo........oooOO0OOooo........oo    
 90                                                   
 91 void SteppingAction::Initialize()                 
 92 {                                                 
 93   // Initialization needed at the beginning of    
 94   fPrimaryParticleId = 0;                         
 95   fPrimaryParticleEnergy = 0.0;                   
 96   fPrimaryParticleDirection = G4ThreeVector(0.    
 97   fTargetMaterialName = "";                       
 98   fIsFirstStepOfTheEvent = true;                  
 99   fIsFirstStepInTarget = true;                    
100   fIsFirstStepInScoringShell = true;              
101   fCubicVolumeScoringShell = 1.0;                 
102   for (G4int i = 0; i < fkNumberCombinations;     
103     fArraySumStepLengths[i] = 0.0;                
104   }                                               
105   /*                                              
106   for ( G4int i = 0; i < fkNumberCombinations;    
107   G4cout << " fkNumberCombinations=" << fkNumb    
108   for ( G4int i = 0; i < fkNumberKinematicRegi    
109     for ( G4int j = 0; j < fkNumberScoringPosi    
110       for ( G4int k = 0; k < fkNumberParticleT    
111         G4int index = GetIndex( i, j, k );        
112         G4cout << "(i, j, k)=(" << i << ", " <    
113         if ( fArraySumStepLengths[ index ] < 1    
114         else                                      
115         G4cout << G4endl;                         
116       }                                           
117     }                                             
118   }                                               
119   for ( G4int i = 0; i < fkNumberCombinations;    
120     if ( fArraySumStepLengths[i] > 999.0 ) G4c    
121   }                                               
122   */                                              
123 }                                                 
124                                                   
125 //....oooOO0OOooo........oooOO0OOooo........oo    
126                                                   
127 void SteppingAction::UserSteppingAction(const     
128 {                                                 
129   // Get information on the primary particle      
130   if (fIsFirstStepOfTheEvent) {                   
131     if (theStep->GetTrack()->GetParentID() ==     
132       fPrimaryParticleId = theStep->GetTrack()    
133       fPrimaryParticleEnergy = theStep->GetPre    
134       fPrimaryParticleDirection = theStep->Get    
135       if (fRunPtr) {                              
136         fRunPtr->SetPrimaryParticleId(fPrimary    
137         fRunPtr->SetPrimaryParticleEnergy(fPri    
138         fRunPtr->SetPrimaryParticleDirection(f    
139       }                                           
140       fIsFirstStepOfTheEvent = false;             
141     }                                             
142   }                                               
143   // Get information on the target material       
144   if (fIsFirstStepInTarget                        
145       && theStep->GetPreStepPoint()->GetPhysic    
146   {                                               
147     fTargetMaterialName = theStep->GetPreStepP    
148     if (fRunPtr) fRunPtr->SetTargetMaterialNam    
149     fIsFirstStepInTarget = false;                 
150   }                                               
151   // Get information on step lengths in the sc    
152   if (theStep->GetPreStepPoint()->GetPhysicalV    
153     if (fIsFirstStepInScoringShell) {             
154       fCubicVolumeScoringShell =                  
155         theStep->GetTrack()->GetVolume()->GetL    
156       if (fRunPtr) fRunPtr->SetCubicVolumeScor    
157       fIsFirstStepInScoringShell = false;         
158     }                                             
159     G4double stepLength = theStep->GetTrack()-    
160     G4int absPdg = theStep->GetTrack()->GetDef    
161                      ? 0                          
162                      : std::abs(theStep->GetTr    
163     /*                                            
164     G4cout << theStep->GetTrack()->GetDefiniti    
165            << "  Ekin[MeV]=" << theStep->GetPr    
166            << "  r[mm]=" << theStep->GetTrack(    
167            << "  z[mm]=" << theStep->GetTrack(    
168            << "  " << theStep->GetTrack()->Get    
169            << "  " << theStep->GetTrack()->Get    
170            << "  L[mm]=" << stepLength << "  "    
171            << ( fPrimaryParticleDirection.dot(    
172                 ? "forward" : "backward" ) <<     
173     */                                            
174     // Three kinematical regions:  [0] : any v    
175     G4int iKinematicRegion = theStep->GetPreSt    
176     // Two scoring positions:  [0] : forward h    
177     // (with respect to the primary particle i    
178     G4int iScoringPosition =                      
179       fPrimaryParticleDirection.dot(theStep->G    
180     G4int iParticleType = -1;                     
181     if (absPdg == 11)                             
182       iParticleType = 1;  // electron (and pos    
183     else if (absPdg == 22)                        
184       iParticleType = 2;  // gamma                
185     else if (absPdg == 13)                        
186       iParticleType = 3;  // muons (mu- and mu    
187     else if (absPdg == 12 || absPdg == 14 || a    
188       iParticleType = 4;  // neutrinos (and       
189                           // anti-neutrinos),     
190     else if (absPdg == 111 || absPdg == 211)      
191       iParticleType = 5;  // (charged) pions      
192     else if (absPdg == 2112)                      
193       iParticleType = 6;  // neutron (and anti    
194     else if (absPdg == 2212)                      
195       iParticleType = 7;  // proton  (and anti    
196     else if (G4IonTable::IsIon(theStep->GetTra    
197              G4IonTable::IsAntiIon(theStep->Ge    
198       iParticleType = 8;                          
199     else if (absPdg < 1000)                       
200       iParticleType = 9;  // other mesons (e.g    
201                           // in most cases, bu    
202     else if (absPdg > 1000)                       
203       iParticleType = 10;  // other baryons (e    
204                            // etc.)               
205     // Consider the specific case : kinematic     
206     G4int index = GetIndex(iKinematicRegion, i    
207     fArraySumStepLengths[index] += stepLength;    
208     // Consider the "all" particle case, with     
209     index = GetIndex(iKinematicRegion, iScorin    
210     fArraySumStepLengths[index] += stepLength;    
211     // Consider the "any" kinematic region cas    
212     index = GetIndex(0, iScoringPosition, iPar    
213     fArraySumStepLengths[index] += stepLength;    
214     // Consider the "any" kinematic region and    
215     index = GetIndex(0, iScoringPosition, 0);     
216     fArraySumStepLengths[index] += stepLength;    
217     if (fRunPtr) fRunPtr->SetSteppingArray(fAr    
218   }                                               
219 }                                                 
220                                                   
221 //....oooOO0OOooo........oooOO0OOooo........oo    
222