Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 08:32:31

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 /// \file TrackingManagerHelper.hh
0027 /// \brief Definition of the TrackingManagerHelper class
0028 
0029 /// \class TrackingManagerHelper
0030 ///
0031 /// Class description:
0032 ///
0033 /// Helper class for reducing the effort required to implement a custom tracking
0034 /// manager. It implements a stepping loop that calls user actions as the generic
0035 /// tracking and stepping managers do, and it implements navigation for charged
0036 /// particles in energy-preserving fields and for neutral particles.
0037 ///
0038 /// Original author: Jonas Hahnfeld, 2021
0039 
0040 #ifndef TrackingManagerHelper_hh
0041 #define TrackingManagerHelper_hh 1
0042 
0043 #include "G4TrackVector.hh"
0044 #include "globals.hh"
0045 
0046 class G4Step;
0047 class G4Track;
0048 
0049 class TrackingManagerHelper
0050 {
0051   public:
0052     class Physics
0053     {
0054       public:
0055         virtual void StartTracking(G4Track*) {}
0056         virtual void EndTracking() {}
0057 
0058         // Combines AlongStep and PostStep; the implementation needs to remember
0059         // the right value to pass as previousStepSize to G4VProcess.
0060         virtual G4double GetPhysicalInteractionLength(const G4Track& track) = 0;
0061 
0062         // This method is called for every step after navigation. The updated
0063         // position is stored in the G4Step's post-step point. Any particle change
0064         // should be applied directly to the step, UpdateTrack() will be called
0065         // automatically after this method returns. If secondaries should be given
0066         // back to the G4EventManager, put them into the container passed as the
0067         // last argument.
0068         virtual void AlongStepDoIt(G4Track& track, G4Step& step, G4TrackVector& secondaries) = 0;
0069 
0070         // This method is called unless the track has been killed during this step.
0071         // If secondaries should be given back to the G4EventManager, put them into
0072         // the container passed as the last argument.
0073         virtual void PostStepDoIt(G4Track& track, G4Step& step, G4TrackVector& secondaries) = 0;
0074 
0075         virtual bool HasAtRestProcesses() { return false; }
0076 
0077         // This method is called when a track is stopped, but still alive. If
0078         // secondaries should be given back to the G4EventManager, put them into
0079         // the container passed as the last argument.
0080         virtual void AtRestDoIt(G4Track& track, G4Step& step, G4TrackVector& secondaries)
0081         {
0082           (void)track;
0083           (void)step;
0084           (void)secondaries;
0085         }
0086     };
0087 
0088     class Navigation
0089     {
0090       public:
0091         virtual G4double MakeStep(G4Track& track, G4Step& step, G4double physicalStep) = 0;
0092 
0093         virtual void FinishStep(G4Track& track, G4Step& step) = 0;
0094     };
0095 
0096     template<typename PhysicsImpl, typename NavigationImpl>
0097     static void TrackParticle(G4Track* aTrack, PhysicsImpl& physics, NavigationImpl& navigation);
0098 
0099     template<typename PhysicsImpl>
0100     static void TrackChargedParticle(G4Track* aTrack, PhysicsImpl& physics);
0101 
0102     template<typename PhysicsImpl>
0103     static void TrackNeutralParticle(G4Track* aTrack, PhysicsImpl& physics);
0104 };
0105 
0106 #include "TrackingManagerHelper.icc"
0107 
0108 #endif