Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-06 08:08:02

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