00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00029
00030
00031
00032
00033
00035
00036 #include "G4AdjointSteppingAction.hh"
00037 #include "G4Track.hh"
00038 #include "G4PhysicalVolumeStore.hh"
00039 #include "G4AffineTransform.hh"
00040 #include "G4AdjointCrossSurfChecker.hh"
00042
00043 G4AdjointSteppingAction::G4AdjointSteppingAction()
00044 : ext_sourceEMax(0.), start_event(false),
00045 did_adj_part_reach_ext_source(false), last_ekin(0.), last_weight(0.),
00046 prim_weight(0.), last_part_def(0), theUserAdjointSteppingAction(0)
00047 {
00048 theG4AdjointCrossSurfChecker = G4AdjointCrossSurfChecker::GetInstance();
00049 }
00051
00052 G4AdjointSteppingAction::~G4AdjointSteppingAction()
00053 {;}
00054
00056
00057 void G4AdjointSteppingAction::UserSteppingAction(const G4Step* aStep)
00058 {
00059
00060
00061 if (theUserAdjointSteppingAction) theUserAdjointSteppingAction->UserSteppingAction(aStep);
00062
00063 G4Track* aTrack =aStep->GetTrack();
00064 G4double nb_nuc=1.;
00065 G4ParticleDefinition* thePartDef = aTrack->GetDefinition();
00066
00067 if (thePartDef->GetParticleType() == "adjoint_nucleus"){
00068 nb_nuc=double(thePartDef->GetBaryonNumber());
00069 }
00070
00071
00072 if(aTrack->GetKineticEnergy() >= ext_sourceEMax*nb_nuc){
00073 aTrack->SetTrackStatus(fStopAndKill);
00074 did_adj_part_reach_ext_source=false;
00075 return;
00076 }
00077
00078 G4double weight_factor = aTrack->GetWeight()/prim_weight;
00079
00080 if ( (weight_factor>0 && weight_factor<=0) || weight_factor<= 1e-290 || weight_factor>1.e200)
00081 {
00082
00083 aTrack->SetTrackStatus(fStopAndKill);
00084 did_adj_part_reach_ext_source=false;
00085 return;
00086 }
00087
00088
00089
00090
00091
00092 G4String surface_name;
00093 G4double cos_to_surface;
00094 G4bool GoingIn;
00095 G4ThreeVector crossing_pos;
00096 if (theG4AdjointCrossSurfChecker->CrossingOneOfTheRegisteredSurface(aStep, surface_name, crossing_pos, cos_to_surface, GoingIn) ){
00097
00098
00099
00100 if (surface_name == "ExternalSource") {
00101
00102 did_adj_part_reach_ext_source=true;
00103 aTrack->SetTrackStatus(fStopAndKill);
00104
00105 last_momentum =aTrack->GetMomentum();
00106 last_ekin=aTrack->GetKineticEnergy();
00107 last_weight = aTrack->GetWeight();
00108 last_part_def = aTrack->GetDefinition();
00109 last_pos = crossing_pos;
00110 return;
00111 }
00112 else if (surface_name == "AdjointSource" && GoingIn) {
00113 did_adj_part_reach_ext_source=false;
00114 aTrack->SetTrackStatus(fStopAndKill);
00115 return;
00116 }
00117 }
00118
00119 if (aStep->GetPostStepPoint()->GetStepStatus() == fWorldBoundary) {
00120 did_adj_part_reach_ext_source=true;
00121 last_momentum =aTrack->GetMomentum();
00122 last_ekin=aTrack->GetKineticEnergy();
00123 last_weight = aTrack->GetWeight();
00124 last_part_def = aTrack->GetDefinition();
00125 last_pos = crossing_pos;
00126 return;
00127
00128 }
00129
00130 }
00131