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 // G4AdjointSteppingAction
0027 //
0028 // Class description:
0029 //
0030 // Stepping action used in the adjoint simulation.
0031 // It is responsible to stop the adjoint tracking phase when:
0032 // a) The adjoint track reaches the external surface.
0033 // b) The being tracked adjoint dynamic particle get an energy higher than
0034 //    the maximum energy of the external source.
0035 // c) The adjoint track enters the volume delimited by the adjoint source.
0036 // In the case a) the info (energy,weight,...) of the adjoint dynamic particle
0037 // associated to the track when crossing the external source is registered and
0038 // in the next event a forward primary is generated.
0039 // In the other cases b) and c) the next generated fwd particle is killed
0040 // before being tracked and the next tracking of an adjoint particle is
0041 // started directly.
0042 
0043 // Author: L. Desorgher, SpaceIT GmbH
0044 // Contract: ESA contract 21435/08/NL/AT
0045 // Customer: ESA/ESTEC
0046 // History:
0047 // - 15/01/2007 L.Desorgher, created.
0048 // - 04/11/2009 L.Desorgher, added possibility to use user stepping action.
0049 // - 20/11/2009 L.Desorgher, corrected stop of adjoint particles tracking
0050 //                           when reentering the adjoint source.
0051 //---------------------------------------------------------------------
0052 #ifndef G4AdjointSteppingAction_hh
0053 #define G4AdjointSteppingAction_hh 1
0054 
0055 #include "G4ThreeVector.hh"
0056 #include "G4UserSteppingAction.hh"
0057 #include "globals.hh"
0058 
0059 class G4AdjointCrossSurfChecker;
0060 class G4ParticleDefinition;
0061 
0062 class G4AdjointSteppingAction : public G4UserSteppingAction
0063 {
0064  public:
0065   G4AdjointSteppingAction();
0066   ~G4AdjointSteppingAction() override = default;
0067 
0068   void UserSteppingAction(const G4Step*) override;
0069 
0070   inline void SetExtSourceEMax(G4double Emax) { ext_sourceEMax = Emax; }
0071   inline void SetStartEvent(G4bool aBool) { start_event = aBool; }
0072   inline G4bool GetDidAdjParticleReachTheExtSource() { return did_adj_part_reach_ext_source; }
0073   inline G4ThreeVector GetLastMomentum() { return last_momentum; }
0074   inline G4ThreeVector GetLastPosition() { return last_pos; }
0075   inline G4double GetLastEkin() { return last_ekin; }
0076   inline G4double GetLastWeight() { return last_weight; }
0077   inline void SetPrimWeight(G4double weight) { prim_weight = weight; }
0078   inline G4ParticleDefinition* GetLastPartDef() { return last_part_def; }
0079   inline void SetUserAdjointSteppingAction(G4UserSteppingAction* anAction)
0080   {
0081     theUserAdjointSteppingAction = anAction;
0082   }
0083   inline void SetUserForwardSteppingAction(G4UserSteppingAction* anAction)
0084   {
0085     theUserFwdSteppingAction = anAction;
0086   }
0087   inline void SetAdjointTrackingMode(G4bool aBool) { is_adjoint_tracking_mode = aBool; }
0088   inline void ResetDidOneAdjPartReachExtSourceDuringEvent()
0089   {
0090     did_one_adj_part_reach_ext_source_during_event = false;
0091   }
0092   inline void SetAdjointGeantinoTrackingMode(G4bool aBool)
0093   {
0094     is_adjoint_geantino_tracking_mode = aBool;
0095   }
0096 
0097  private:
0098   G4double ext_sourceEMax = 0.0;
0099   G4AdjointCrossSurfChecker* theG4AdjointCrossSurfChecker = nullptr;
0100 
0101   G4ThreeVector last_momentum, last_pos;
0102   G4double last_ekin = 0.0;
0103   G4double last_weight = 0.0;
0104   G4double prim_weight = 1.0;
0105   G4ParticleDefinition* last_part_def = nullptr;
0106   G4UserSteppingAction* theUserAdjointSteppingAction = nullptr;
0107   G4UserSteppingAction* theUserFwdSteppingAction = nullptr;
0108 
0109   G4bool start_event = false;
0110   G4bool did_adj_part_reach_ext_source = false;
0111   G4bool did_one_adj_part_reach_ext_source_during_event = false;
0112   G4bool is_adjoint_tracking_mode = false;
0113   G4bool is_adjoint_geantino_tracking_mode = false;
0114 };
0115 
0116 #endif