Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-10 08:06:17

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 GetCubicVolumeScoringTrackerShell() const { return fCubicVolumeScoringTrackerShell; }
0074     G4double GetCubicVolumeScoringEmCaloShell() const { return fCubicVolumeScoringEmCaloShell; }
0075     G4double GetCubicVolumeScoringHadCaloShell() const { return fCubicVolumeScoringHadCaloShell; }
0076     // Needed to get the fluence from the sum of step lengths
0077 
0078     static const G4int fkNumberScoringShells = 3;  // tracker, emCalo, hadCalo
0079     static const G4int fkNumberKinematicRegions = 3;  // all, below 20 MeV, above 20 MeV
0080     static const G4int fkNumberScoringPositions = 2;  // forward, backward (hemisphere, w.r.t.
0081                                                       // the primary particle direction)
0082     static const G4int fkNumberParticleTypes = 11;  // all, e, gamma, mu, nu, pi, n, p, ions,
0083                                                     // other-mesons, other-baryons
0084     static const G4int fkNumberCombinations = fkNumberScoringShells * fkNumberKinematicRegions
0085                                               * fkNumberScoringPositions * fkNumberParticleTypes;
0086     static const std::array<G4String, fkNumberScoringShells> fkArrayScoringShellNames;
0087     static const std::array<G4String, fkNumberKinematicRegions> fkArrayKinematicRegionNames;
0088     static const std::array<G4String, fkNumberScoringPositions> fkArrayScoringPositionNames;
0089     static const std::array<G4String, fkNumberParticleTypes> fkArrayParticleTypeNames;
0090     static G4int GetIndex(const G4int iScoringShell, const G4int iKinematicRegion,
0091                           const G4int iScoringPosition, const G4int iParticleType);
0092 
0093   private:
0094     Run* fRunPtr;  // Pointer to the Run object
0095     G4int fPrimaryParticleId;
0096     G4double fPrimaryParticleEnergy;
0097     G4ThreeVector fPrimaryParticleDirection;
0098     G4String fTrackerMaterialName;
0099     G4String fEmCaloMaterialName;
0100     G4String fHadCaloMaterialName;
0101     G4bool fIsFirstStepOfTheEvent;
0102     G4bool fIsFirstStepInTracker;
0103     G4bool fIsFirstStepInScoringTrackerShell;
0104     G4double fCubicVolumeScoringTrackerShell;
0105     G4bool fIsFirstStepInEmCalo;
0106     G4bool fIsFirstStepInScoringEmCaloShell;
0107     G4double fCubicVolumeScoringEmCaloShell;
0108     G4bool fIsFirstStepInHadCalo;
0109     G4bool fIsFirstStepInScoringHadCaloShell;
0110     G4double fCubicVolumeScoringHadCaloShell;
0111 
0112     std::array<G4double, fkNumberCombinations> fArraySumStepLengths;
0113     // Array to collect the sum of step lengths in the scoring shells for the whole run,
0114     // according to the various cases (scoring shell, kinematical region, scoring position
0115     // and particle type).
0116     // Note that the fluence in a scoring volume is defined as sum of step lengths
0117     // in that scoring volume divided by the cubic-volume of that scoring volume.
0118 };
0119 
0120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0121 
0122 #endif