Geant4 Cross Reference |
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 // G4AdjointSteppingAction 27 // 28 // Class description: 29 // 30 // Stepping action used in the adjoint simulation. 31 // It is responsible to stop the adjoint tracking phase when: 32 // a) The adjoint track reaches the external surface. 33 // b) The being tracked adjoint dynamic particle get an energy higher than 34 // the maximum energy of the external source. 35 // c) The adjoint track enters the volume delimited by the adjoint source. 36 // In the case a) the info (energy,weight,...) of the adjoint dynamic particle 37 // associated to the track when crossing the external source is registered and 38 // in the next event a forward primary is generated. 39 // In the other cases b) and c) the next generated fwd particle is killed 40 // before being tracked and the next tracking of an adjoint particle is 41 // started directly. 42 43 // Author: L. Desorgher, SpaceIT GmbH 44 // Contract: ESA contract 21435/08/NL/AT 45 // Customer: ESA/ESTEC 46 // History: 47 // - 15/01/2007 L.Desorgher, created. 48 // - 04/11/2009 L.Desorgher, added possibility to use user stepping action. 49 // - 20/11/2009 L.Desorgher, corrected stop of adjoint particles tracking 50 // when reentering the adjoint source. 51 //--------------------------------------------------------------------- 52 #ifndef G4AdjointSteppingAction_hh 53 #define G4AdjointSteppingAction_hh 1 54 55 #include "G4ThreeVector.hh" 56 #include "G4UserSteppingAction.hh" 57 #include "globals.hh" 58 59 class G4AdjointCrossSurfChecker; 60 class G4ParticleDefinition; 61 62 class G4AdjointSteppingAction : public G4UserSteppingAction 63 { 64 public: 65 G4AdjointSteppingAction(); 66 ~G4AdjointSteppingAction() override = default; 67 68 void UserSteppingAction(const G4Step*) override; 69 70 inline void SetExtSourceEMax(G4double Emax) { ext_sourceEMax = Emax; } 71 inline void SetStartEvent(G4bool aBool) { start_event = aBool; } 72 inline G4bool GetDidAdjParticleReachTheExtSource() { return did_adj_part_reach_ext_source; } 73 inline G4ThreeVector GetLastMomentum() { return last_momentum; } 74 inline G4ThreeVector GetLastPosition() { return last_pos; } 75 inline G4double GetLastEkin() { return last_ekin; } 76 inline G4double GetLastWeight() { return last_weight; } 77 inline void SetPrimWeight(G4double weight) { prim_weight = weight; } 78 inline G4ParticleDefinition* GetLastPartDef() { return last_part_def; } 79 inline void SetUserAdjointSteppingAction(G4UserSteppingAction* anAction) 80 { 81 theUserAdjointSteppingAction = anAction; 82 } 83 inline void SetUserForwardSteppingAction(G4UserSteppingAction* anAction) 84 { 85 theUserFwdSteppingAction = anAction; 86 } 87 inline void SetAdjointTrackingMode(G4bool aBool) { is_adjoint_tracking_mode = aBool; } 88 inline void ResetDidOneAdjPartReachExtSourceDuringEvent() 89 { 90 did_one_adj_part_reach_ext_source_during_event = false; 91 } 92 inline void SetAdjointGeantinoTrackingMode(G4bool aBool) 93 { 94 is_adjoint_geantino_tracking_mode = aBool; 95 } 96 97 private: 98 G4double ext_sourceEMax = 0.0; 99 G4AdjointCrossSurfChecker* theG4AdjointCrossSurfChecker = nullptr; 100 101 G4ThreeVector last_momentum, last_pos; 102 G4double last_ekin = 0.0; 103 G4double last_weight = 0.0; 104 G4double prim_weight = 1.0; 105 G4ParticleDefinition* last_part_def = nullptr; 106 G4UserSteppingAction* theUserAdjointSteppingAction = nullptr; 107 G4UserSteppingAction* theUserFwdSteppingAction = nullptr; 108 109 G4bool start_event = false; 110 G4bool did_adj_part_reach_ext_source = false; 111 G4bool did_one_adj_part_reach_ext_source_during_event = false; 112 G4bool is_adjoint_tracking_mode = false; 113 G4bool is_adjoint_geantino_tracking_mode = false; 114 }; 115 116 #endif 117