ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4AdjointSteppingAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4AdjointSteppingAction.cc
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 //
28 // Class Name: G4AdjointSteppingAction
29 // Author: L. Desorgher
30 // Organisation: SpaceIT GmbH
31 // Contract: ESA contract 21435/08/NL/AT
32 // Customer: ESA/ESTEC
34 
36 #include "G4Track.hh"
37 #include "G4PhysicalVolumeStore.hh"
38 #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(1.), last_part_def(0), theUserAdjointSteppingAction(0),
47  theUserFwdSteppingAction(0)
48 {
50 }
52 //
54 {;}
55 
57 //
59 {
60  G4Track* aTrack =aStep->GetTrack();
61  //G4cout<<"Ste weight "<<<<std:.endl;
62  //forward tracking mode
66  return;
67  }
70  return;
71  }
72  //Apply first the user adjoint stepping action
73  //---------------------------
76 
77 
78  G4double nb_nuc=1.;
79  G4ParticleDefinition* thePartDef = aTrack->GetDefinition();
80 
81  if (thePartDef->GetParticleType() == "adjoint_nucleus"){
82  nb_nuc=double(thePartDef->GetBaryonNumber());
83  }
84  //Kill conditions for adjoint particles reaching the maximum energy
85  //-----------------------------------------------------------------
86  if(aTrack->GetKineticEnergy() >= ext_sourceEMax*nb_nuc){
89  return;
90  }
91  //G4cout<<"Weight adjoint "<<aTrack->GetWeight()<<std::endl;
92  /*G4double weight_factor = aTrack->GetWeight()/prim_weight;
93  if ( (weight_factor>0 && weight_factor<=0) || weight_factor<= 1e-290 || weight_factor>1.e200)
94  {
95  //std::cout<<"Weight_factor problem! Value = "<<weight_factor<<std::endl;
96  aTrack->SetTrackStatus(fStopAndKill);
97  did_adj_part_reach_ext_source=false;
98  //G4cout<<thePartDef->GetParticleName()<<std::endl;
99  return;
100  }
101  */
102 
103 
104  //Kill conditions for surface crossing
105  //--------------------------------------
106 
107  G4String surface_name;
108  G4double cos_to_surface;
109  G4bool GoingIn;
110  G4ThreeVector crossing_pos;
111  if (theG4AdjointCrossSurfChecker->CrossingOneOfTheRegisteredSurface(aStep, surface_name, crossing_pos, cos_to_surface, GoingIn) ){
112 
113  //G4cout<<"Test_step11"<<std::endl;
114  if (surface_name == "ExternalSource") {
115  //Registering still needed
118  aTrack->SetTrackStatus(fStopAndKill);
119  //now register the adjoint particles reaching the external surface
120  last_momentum =aTrack->GetMomentum();
121  last_ekin=aTrack->GetKineticEnergy();
122  last_weight = aTrack->GetWeight();
123  last_part_def = aTrack->GetDefinition();
124  last_pos = crossing_pos;
125  return;
126  }
127  else if (surface_name == "AdjointSource" && GoingIn) {
129  aTrack->SetTrackStatus(fStopAndKill);
130  return;
131  }
132  }
133  //Check for reaching out of world
134  //G4cout<<aStep->GetPostStepPoint()->GetStepStatus()<<std::endl;
135  if (aStep->GetPostStepPoint()->GetStepStatus() == fWorldBoundary) {
138  last_momentum =aTrack->GetMomentum();
139  last_ekin=aTrack->GetKineticEnergy();
140  last_weight = aTrack->GetWeight();
141  last_part_def = aTrack->GetDefinition();
142  last_pos = crossing_pos;
143  return;
144  }
145 }
146