Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:52

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4AdjointTrackingAction
0027 //
0028 // Class description:
0029 //
0030 // This class represents actions taken place at the start/end point
0031 // of processing one track during an adjoint simulation
0032 
0033 // Author: L. Desorgher, SpaceIT GmbH
0034 // Contract: ESA contract 21435/08/NL/AT
0035 // Customer: ESA/ESTEC
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   // Adjoint particle information on the external surface
0099   // ----------------------------------------------------
0100   G4ThreeVector last_pos;
0101   G4ThreeVector last_direction;
0102   G4double last_ekin = 0.0, last_ekin_nuc = 0.0;
0103   // last_ekin_nuc=last_ekin/nuc, nuc is 1 if not a nucleus
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