File indexing completed on 2025-01-18 09:57:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #ifndef G4AdjointTrackingAction_hh
0038 #define G4AdjointTrackingAction_hh 1
0039
0040 #include "G4ThreeVector.hh"
0041 #include "G4UserTrackingAction.hh"
0042 #include "globals.hh"
0043
0044 #include <vector>
0045
0046 class G4AdjointSteppingAction;
0047 class G4Track;
0048 class G4ParticleDefinition;
0049
0050 class G4AdjointTrackingAction : public G4UserTrackingAction
0051 {
0052 public:
0053 G4AdjointTrackingAction(G4AdjointSteppingAction* anAction);
0054 ~G4AdjointTrackingAction() override = default;
0055
0056 void PreUserTrackingAction(const G4Track*) override;
0057 void PostUserTrackingAction(const G4Track*) override;
0058 void RegisterAtEndOfAdjointTrack();
0059 void ClearEndOfAdjointTrackInfoVectors();
0060
0061 inline void SetUserForwardTrackingAction(G4UserTrackingAction* anAction)
0062 {
0063 theUserFwdTrackingAction = anAction;
0064 }
0065 inline G4ThreeVector GetPositionAtEndOfLastAdjointTrack(std::size_t i = 0)
0066 {
0067 return last_pos_vec[i];
0068 }
0069 inline G4ThreeVector GetDirectionAtEndOfLastAdjointTrack(std::size_t i = 0)
0070 {
0071 return last_direction_vec[i];
0072 }
0073 inline G4double GetEkinAtEndOfLastAdjointTrack(std::size_t i = 0) { return last_ekin_vec[i]; }
0074 inline G4double GetEkinNucAtEndOfLastAdjointTrack(std::size_t i = 0)
0075 {
0076 return last_ekin_nuc_vec[i];
0077 }
0078 inline G4double GetWeightAtEndOfLastAdjointTrack(std::size_t i = 0) { return last_weight_vec[i]; }
0079 inline G4double GetCosthAtEndOfLastAdjointTrack(std::size_t i = 0) { return last_cos_th_vec[i]; }
0080 inline const G4String& GetFwdParticleNameAtEndOfLastAdjointTrack() { return last_fwd_part_name; }
0081 inline G4int GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(std::size_t i = 0)
0082 {
0083 return last_fwd_part_PDGEncoding_vec[i];
0084 }
0085 inline G4bool GetIsAdjointTrackingMode() { return is_adjoint_tracking_mode; }
0086 inline G4int GetLastFwdParticleIndex(std::size_t i = 0) { return last_fwd_part_index_vec[i]; }
0087 inline std::size_t GetNbOfAdointTracksReachingTheExternalSurface() { return last_pos_vec.size(); }
0088 inline void SetListOfPrimaryFwdParticles(std::vector<G4ParticleDefinition*>* aListOfParticles)
0089 {
0090 pListOfPrimaryFwdParticles = aListOfParticles;
0091 }
0092
0093 private:
0094 G4AdjointSteppingAction* theAdjointSteppingAction = nullptr;
0095 G4UserTrackingAction* theUserFwdTrackingAction = nullptr;
0096 G4bool is_adjoint_tracking_mode = false;
0097
0098
0099
0100 G4ThreeVector last_pos;
0101 G4ThreeVector last_direction;
0102 G4double last_ekin = 0.0, last_ekin_nuc = 0.0;
0103
0104 G4double last_cos_th = 0.0;
0105 G4String last_fwd_part_name;
0106 G4int last_fwd_part_PDGEncoding = 0;
0107 G4double last_weight = 0.0;
0108 G4int last_fwd_part_index = 0;
0109 std::vector<G4ParticleDefinition*>* pListOfPrimaryFwdParticles = nullptr;
0110
0111 std::vector<G4ThreeVector> last_pos_vec;
0112 std::vector<G4ThreeVector> last_direction_vec;
0113 std::vector<G4double> last_ekin_vec;
0114 std::vector<G4double> last_ekin_nuc_vec;
0115 std::vector<G4double> last_cos_th_vec;
0116 std::vector<G4double> last_weight_vec;
0117 std::vector<G4int> last_fwd_part_PDGEncoding_vec;
0118 std::vector<G4int> last_fwd_part_index_vec;
0119 };
0120
0121 #endif