Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4AdjointSteppingAction.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id$
27//
28/////////////////////////////////////////////////////////////////////////////
29// Class Name: G4AdjointSteppingAction
30// Author: L. Desorgher
31// Organisation: SpaceIT GmbH
32// Contract: ESA contract 21435/08/NL/AT
33// Customer: ESA/ESTEC
34/////////////////////////////////////////////////////////////////////////////
35
37#include "G4Track.hh"
39#include "G4AffineTransform.hh"
41////////////////////////////////////////////////////////////////////////////////////////////////
42//
44 : ext_sourceEMax(0.), start_event(false),
45 did_adj_part_reach_ext_source(false), last_ekin(0.), last_weight(0.),
46 prim_weight(0.), last_part_def(0), theUserAdjointSteppingAction(0)
47{
48 theG4AdjointCrossSurfChecker = G4AdjointCrossSurfChecker::GetInstance();
49}
50////////////////////////////////////////////////////////////////////////////////////////////////
51//
53{;}
54
55////////////////////////////////////////////////////////////////////////////////////////////////
56//
58{
59 //Apply first the user adjoint stepping action
60 //---------------------------
61 if (theUserAdjointSteppingAction) theUserAdjointSteppingAction->UserSteppingAction(aStep);
62
63 G4Track* aTrack =aStep->GetTrack();
64 G4double nb_nuc=1.;
65 G4ParticleDefinition* thePartDef = aTrack->GetDefinition();
66
67 if (thePartDef->GetParticleType() == "adjoint_nucleus"){
68 nb_nuc=double(thePartDef->GetBaryonNumber());
69 }
70 //Kill conditions for adjoint particles reaching the maximum energy
71 //-----------------------------------------------------------------
72 if(aTrack->GetKineticEnergy() >= ext_sourceEMax*nb_nuc){
74 did_adj_part_reach_ext_source=false;
75 return;
76 }
77
78 G4double weight_factor = aTrack->GetWeight()/prim_weight;
79
80 if ( (weight_factor>0 && weight_factor<=0) || weight_factor<= 1e-290 || weight_factor>1.e200)
81 {
82 //std::cout<<"Weight_factor problem! Value = "<<weight_factor<<std::endl;
84 did_adj_part_reach_ext_source=false;
85 return;
86 }
87
88
89 //Kill conditions for surface crossing
90 //--------------------------------------
91
92 G4String surface_name;
93 G4double cos_to_surface;
94 G4bool GoingIn;
95 G4ThreeVector crossing_pos;
96 if (theG4AdjointCrossSurfChecker->CrossingOneOfTheRegisteredSurface(aStep, surface_name, crossing_pos, cos_to_surface, GoingIn) ){
97
98 //G4cout<<"Test_step11"<<std::endl;
99 //G4cout<<surface_name<<std::endl;
100 if (surface_name == "ExternalSource") {
101 //Registering still needed
102 did_adj_part_reach_ext_source=true;
104 //now register the adjoint particles reaching the external surface
105 last_momentum =aTrack->GetMomentum();
106 last_ekin=aTrack->GetKineticEnergy();
107 last_weight = aTrack->GetWeight();
108 last_part_def = aTrack->GetDefinition();
109 last_pos = crossing_pos;
110 return;
111 }
112 else if (surface_name == "AdjointSource" && GoingIn) {
113 did_adj_part_reach_ext_source=false;
115 return;
116 }
117 }
118 //Check for reaching out of world
119 if (aStep->GetPostStepPoint()->GetStepStatus() == fWorldBoundary) {
120 did_adj_part_reach_ext_source=true;
121 last_momentum =aTrack->GetMomentum();
122 last_ekin=aTrack->GetKineticEnergy();
123 last_weight = aTrack->GetWeight();
124 last_part_def = aTrack->GetDefinition();
125 last_pos = crossing_pos;
126 return;
127
128 }
129
130}
131
@ fWorldBoundary
Definition: G4StepStatus.hh:52
@ fStopAndKill
double G4double
Definition: G4Types.hh:64
bool G4bool
Definition: G4Types.hh:67
G4bool CrossingOneOfTheRegisteredSurface(const G4Step *aStep, G4String &surface_name, G4ThreeVector &crossing_pos, G4double &cos_to_surface, G4bool &GoingIn)
static G4AdjointCrossSurfChecker * GetInstance()
void UserSteppingAction(const G4Step *)
const G4String & GetParticleType() const
G4StepStatus GetStepStatus() const
Definition: G4Step.hh:78
G4Track * GetTrack() const
G4StepPoint * GetPostStepPoint() const
void SetTrackStatus(const G4TrackStatus aTrackStatus)
G4double GetWeight() const
G4ThreeVector GetMomentum() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
virtual void UserSteppingAction(const G4Step *)