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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/Layer/src/TrackingAction.cc (Version 11.3.0) and /examples/extended/hadronic/ParticleFluence/Layer/src/TrackingAction.cc (Version 9.3)


  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 TrackingAction.cc                       
 27 /// \brief Implementation of the TrackingActio    
 28 //                                                
 29 //                                                
 30                                                   
 31 //....oooOO0OOooo........oooOO0OOooo........oo    
 32 //....oooOO0OOooo........oooOO0OOooo........oo    
 33                                                   
 34 #include "TrackingAction.hh"                      
 35                                                   
 36 #include "Run.hh"                                 
 37                                                   
 38 #include "G4IonTable.hh"                          
 39 #include "G4ParticleDefinition.hh"                
 40 #include "G4ParticleTypes.hh"                     
 41 #include "G4Step.hh"                              
 42 #include "G4StepPoint.hh"                         
 43 #include "G4SystemOfUnits.hh"                     
 44 #include "G4Track.hh"                             
 45                                                   
 46 const std::array<G4String, TrackingAction::fkN    
 47   TrackingAction::fkArrayScoringVolumeNames =     
 48                                                   
 49 const std::array<G4String, TrackingAction::fkN    
 50   TrackingAction::fkArrayKinematicRegionNames     
 51                                                   
 52 const std::array<G4String, TrackingAction::fkN    
 53   TrackingAction::fkArrayParticleTypeNames = {    
 54                                                   
 55                                                   
 56                                                   
 57 //....oooOO0OOooo........oooOO0OOooo........oo    
 58                                                   
 59 G4int TrackingAction::GetIndex(const G4int iSc    
 60                                const G4int iPa    
 61 {                                                 
 62   G4int index = -1;                               
 63   if (iScoringVolume >= 0 && iScoringVolume <     
 64       && iKinematicRegion < fkNumberKinematicR    
 65       && iParticleType < fkNumberParticleTypes    
 66   {                                               
 67     index = iScoringVolume * fkNumberKinematic    
 68             + iKinematicRegion * fkNumberParti    
 69   }                                               
 70   return index;                                   
 71 }                                                 
 72                                                   
 73 //....oooOO0OOooo........oooOO0OOooo........oo    
 74                                                   
 75 TrackingAction::TrackingAction() : G4UserTrack    
 76 {                                                 
 77   Initialize();                                   
 78 }                                                 
 79                                                   
 80 //....oooOO0OOooo........oooOO0OOooo........oo    
 81                                                   
 82 void TrackingAction::Initialize()                 
 83 {                                                 
 84   // Initialization needed at the beginning of    
 85   fArrayMultiplicities.fill(0);                   
 86   fArraySumKineticEnergies.fill(0.0);             
 87 }                                                 
 88                                                   
 89 //....oooOO0OOooo........oooOO0OOooo........oo    
 90                                                   
 91 void TrackingAction::PreUserTrackingAction(con    
 92 {                                                 
 93   // This method is called not only once when     
 94   // but also each time it is resumed, in the     
 95   // as it happens in the case of neutrons wit    
 96   // To be sure that we collect information ab    
 97   // we require that the current step be the f    
 98   if (aTrack == nullptr || aTrack->GetCurrentS    
 99       || aTrack->GetLogicalVolumeAtVertex() ==    
100       || aTrack->GetLogicalVolumeAtVertex()->G    
101     return;                                       
102   G4int iScoringVolume = 0;                       
103   // Three kinematical regions:  [0] : any val    
104   G4int iKinematicRegion = aTrack->GetKineticE    
105   G4int absPdg = std::abs(aTrack->GetDefinitio    
106   G4int iParticleType = -1;                       
107   if (absPdg == 11)                               
108     iParticleType = 1;  // electron (and posit    
109   else if (absPdg == 22)                          
110     iParticleType = 2;  // gamma                  
111   else if (absPdg == 13)                          
112     iParticleType = 3;  // muons (mu- and mu+)    
113   else if (absPdg == 12 || absPdg == 14 || abs    
114     iParticleType = 4;                            
115   // neutrinos (and anti-neutrinos), all flavo    
116   else if (absPdg == 111 || absPdg == 211)        
117     iParticleType = 5;  // (charged) pions        
118   else if (absPdg == 2112)                        
119     iParticleType = 6;  // neutron (and anti-n    
120   else if (absPdg == 2212)                        
121     iParticleType = 7;  // proton  (and anti-p    
122   else if (G4IonTable::IsIon(aTrack->GetDefini    
123            || G4IonTable::IsAntiIon(aTrack->Ge    
124     iParticleType = 8;                            
125   // ions (and anti-ions)                         
126   else if (absPdg < 1000)                         
127     iParticleType = 9;  // other mesons (e.g.     
128   // (Note: this works in most cases, but not     
129   else if (absPdg > 1000)                         
130     iParticleType = 10;  // other baryons (e.g    
131                          // anti-hyperons, etc    
132   // Consider the specific case : scoring volu    
133   G4int index = GetIndex(iScoringVolume, iKine    
134   ++fArrayMultiplicities[index];                  
135   fArraySumKineticEnergies[index] += aTrack->G    
136   // Consider the "all" particle case, with th    
137   index = GetIndex(iScoringVolume, iKinematicR    
138   ++fArrayMultiplicities[index];                  
139   fArraySumKineticEnergies[index] += aTrack->G    
140   // Consider the "any" kinematic region case,    
141   index = GetIndex(iScoringVolume, 0, iParticl    
142   ++fArrayMultiplicities[index];                  
143   fArraySumKineticEnergies[index] += aTrack->G    
144   // Consider the "any" kinematic region and "    
145   index = GetIndex(iScoringVolume, 0, 0);         
146   ++fArrayMultiplicities[index];                  
147   fArraySumKineticEnergies[index] += aTrack->G    
148   if (fRunPtr) {                                  
149     fRunPtr->SetTrackingArray1(fArrayMultiplic    
150     fRunPtr->SetTrackingArray2(fArraySumKineti    
151   }                                               
152 }                                                 
153                                                   
154 //....oooOO0OOooo........oooOO0OOooo........oo    
155                                                   
156 void TrackingAction::PostUserTrackingAction(co    
157                                                   
158 //....oooOO0OOooo........oooOO0OOooo........oo    
159