Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-16 08:07:05

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 SteppingAction.hh
0027 /// \brief Definition of the SteppingAction class
0028 //
0029 //
0030 
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 #ifndef SteppingAction_H
0035 #define SteppingAction_H 1
0036 
0037 #include "G4ThreeVector.hh"
0038 #include "G4UserSteppingAction.hh"
0039 #include "globals.hh"
0040 
0041 #include <array>
0042 
0043 class Run;
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 
0047 class SteppingAction : public G4UserSteppingAction
0048 {
0049   public:
0050     SteppingAction();
0051     ~SteppingAction() override = default;
0052 
0053     void UserSteppingAction(const G4Step*) override;
0054     // This is the main method where the step lengths of particles inside
0055     // the scoring shell are collected, and then the corresponding fluences
0056     // are filled up in the Run object where they are stored (and then
0057     // printed out at the end of the Run).
0058     // (For simplicity and brevity, we avoid histograms and compute instead
0059     //  some statistics ourself, which will be print-out at the end of the run.)
0060 
0061     void Initialize();
0062     // This method is called by RunAction::BeginOfRunAction for the
0063     // initialization of the stepping-action at the beginning of each Run.
0064     // This is necessary because different runs can have different primary particle
0065     // types, kinetic energies, and detector configurations.
0066 
0067     void SetRunPointer(Run* inputValue = nullptr) { fRunPtr = inputValue; }
0068     // This method is called by RunAction::BeginOfRunAction for providing to the
0069     // stepping-action the pointer to the run object at the beginning of each Run.
0070     // This pointer is then used to pass the information collected by the stepping-action
0071     // to the run object.
0072 
0073     G4double GetCubicVolumeScoringShell() const { return fCubicVolumeScoringShell; }
0074     // The cubic-volume of the scoring shell is needed to get the fluence from the
0075     // sum of step lengths inside that scoring shell.
0076 
0077     static const G4int fkNumberKinematicRegions = 3;  // all, below 20 MeV, above 20 MeV
0078     static const G4int fkNumberScoringPositions = 2;  // forward, backward (hemisphere with
0079                                                       // respect to the primary particle direction)
0080     static const G4int fkNumberParticleTypes = 11;  // all, e, gamma, mu, nu, pi, n, p, ions,
0081                                                     // other-mesons, other-baryons
0082     static const G4int fkNumberCombinations =
0083       fkNumberKinematicRegions * fkNumberScoringPositions * fkNumberParticleTypes;
0084     static const std::array<G4String, fkNumberKinematicRegions> fkArrayKinematicRegionNames;
0085     static const std::array<G4String, fkNumberScoringPositions> fkArrayScoringPositionNames;
0086     static const std::array<G4String, fkNumberParticleTypes> fkArrayParticleTypeNames;
0087     static G4int GetIndex(const G4int iKinematicRegion, const G4int iScoringPosition,
0088                           const G4int iParticleType);
0089 
0090   private:
0091     Run* fRunPtr;  // Pointer to the Run object
0092     G4int fPrimaryParticleId;
0093     G4double fPrimaryParticleEnergy;
0094     G4ThreeVector fPrimaryParticleDirection;
0095     G4String fTargetMaterialName;
0096     G4bool fIsFirstStepOfTheEvent;
0097     G4bool fIsFirstStepInTarget;
0098     G4bool fIsFirstStepInScoringShell;
0099     G4double fCubicVolumeScoringShell;
0100 
0101     std::array<G4double, fkNumberCombinations> fArraySumStepLengths;
0102     // Array to collect the sum of step lengths in the scoring shell for the whole run,
0103     // according to the various cases (kinematical region, scoring position and particle type).
0104     // Note that the fluence in a scoring volume is defined as sum of step lengths
0105     // in that scoring volume divided by the cubic-volume of that scoring volume.
0106 };
0107 
0108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0109 
0110 #endif