source: trunk/source/tracking/src/G4AdjointSteppingAction.cc@ 1341

Last change on this file since 1341 was 1340, checked in by garnier, 15 years ago

update ti head

File size: 4.9 KB
Line 
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: G4AdjointSteppingAction.cc,v 1.4 2010/07/19 13:41:21 gcosmo Exp $
27// GEANT4 tag $Name: tracking-V09-03-08 $
28//
29/////////////////////////////////////////////////////////////////////////////
30// Class Name: G4AdjointSteppingAction
31// Author: L. Desorgher
32// Organisation: SpaceIT GmbH
33// Contract: ESA contract 21435/08/NL/AT
34// Customer: ESA/ESTEC
35/////////////////////////////////////////////////////////////////////////////
36
37#include "G4AdjointSteppingAction.hh"
38#include "G4Track.hh"
39#include "G4PhysicalVolumeStore.hh"
40#include "G4AffineTransform.hh"
41#include "G4AdjointCrossSurfChecker.hh"
42////////////////////////////////////////////////////////////////////////////////////////////////
43//
44G4AdjointSteppingAction::G4AdjointSteppingAction()
45 : ext_sourceEMax(0.), start_event(false),
46 did_adj_part_reach_ext_source(false), last_ekin(0.), last_weight(0.),
47 prim_weight(0.), last_part_def(0), theUserAdjointSteppingAction(0)
48{
49 theG4AdjointCrossSurfChecker = G4AdjointCrossSurfChecker::GetInstance();
50}
51////////////////////////////////////////////////////////////////////////////////////////////////
52//
53G4AdjointSteppingAction::~G4AdjointSteppingAction()
54{;}
55
56////////////////////////////////////////////////////////////////////////////////////////////////
57//
58void G4AdjointSteppingAction::UserSteppingAction(const G4Step* aStep)
59{
60 //Apply first the user adjoint stepping action
61 //---------------------------
62 if (theUserAdjointSteppingAction) theUserAdjointSteppingAction->UserSteppingAction(aStep);
63
64 G4Track* aTrack =aStep->GetTrack();
65 G4double nb_nuc=1.;
66 G4ParticleDefinition* thePartDef = aTrack->GetDefinition();
67
68 if (thePartDef->GetParticleType() == "adjoint_nucleus"){
69 nb_nuc=double(thePartDef->GetBaryonNumber());
70 }
71 //Kill conditions for adjoint particles reaching the maximum energy
72 //-----------------------------------------------------------------
73 if(aTrack->GetKineticEnergy() >= ext_sourceEMax*nb_nuc){
74 aTrack->SetTrackStatus(fStopAndKill);
75 did_adj_part_reach_ext_source=false;
76 return;
77 }
78
79 G4double weight_factor = aTrack->GetWeight()/prim_weight;
80
81 if ( (weight_factor>0 && weight_factor<=0) || weight_factor<= 1e-290 || weight_factor>1.e200)
82 {
83 //std::cout<<"Weight_factor problem! Value = "<<weight_factor<<std::endl;
84 aTrack->SetTrackStatus(fStopAndKill);
85 did_adj_part_reach_ext_source=false;
86 return;
87 }
88
89
90 //Kill conditions for surface crossing
91 //--------------------------------------
92
93 G4String surface_name;
94 G4double cos_to_surface;
95 G4bool GoingIn;
96 G4ThreeVector crossing_pos;
97 if (theG4AdjointCrossSurfChecker->CrossingOneOfTheRegisteredSurface(aStep, surface_name, crossing_pos, cos_to_surface, GoingIn) ){
98
99 //G4cout<<"Test_step11"<<std::endl;
100 //G4cout<<surface_name<<std::endl;
101 if (surface_name == "ExternalSource") {
102 //Registering still needed
103 did_adj_part_reach_ext_source=true;
104 aTrack->SetTrackStatus(fStopAndKill);
105 //now register the adjoint particles reaching the external surface
106 last_momentum =aTrack->GetMomentum();
107 last_ekin=aTrack->GetKineticEnergy();
108 last_weight = aTrack->GetWeight();
109 last_part_def = aTrack->GetDefinition();
110 last_pos = crossing_pos;
111 return;
112 }
113 else if (surface_name == "AdjointSource" && GoingIn) {
114 did_adj_part_reach_ext_source=false;
115 aTrack->SetTrackStatus(fStopAndKill);
116 return;
117 }
118 }
119}
120
Note: See TracBrowser for help on using the repository browser.