Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 08:32:06

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 "CLHEP/Units/SystemOfUnits.h"
0033 
0034 #include "G4ThreeVector.hh"
0035 #include "G4UserSteppingAction.hh"
0036 #include "globals.hh"
0037 
0038 class Run;
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 class SteppingAction : public G4UserSteppingAction
0043 {
0044   public:
0045     SteppingAction();
0046     virtual ~SteppingAction();
0047 
0048     // This is the main method where the properties of the primary particle,
0049     // at the beginning and when it decays, are collected or computed, and
0050     // then filled up in the Run object where they are stored (and then
0051     // printed out at the end of the Run).
0052     // (For simplicity and brevity, we avoid histograms and compute instead
0053     //  some statistics ourself, which will be print-out at the end of the run.)
0054     virtual void UserSteppingAction(const G4Step*) override;
0055 
0056     // This method is called by RunAction::BeginOfRunAction for the
0057     // initialization of the stepping-action at the beginning of each Run.
0058     // This is necessary because different runs can have different primary particle
0059     // types, kinetic energies, starting positions and/or directions, as well as
0060     // different detector configurations.
0061     void Initialize();
0062 
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 provide information on the primary decays
0066     // by calling accessor methods of the Run object.
0067     void SetRunPointer(Run* inputValue = nullptr) { fRunPtr = inputValue; }
0068 
0069   private:
0070     G4bool IsPreassignedDecayEnabled() const { return fIsPreassignedDecayEnabled; }
0071     G4bool IsBoostToLabEnabled() const { return fIsBoostToLabEnabled; }
0072     G4double ToleranceEPviolations() const { return fToleranceEPviolations; }
0073     G4double ToleranceDeltaDecayRadius() const { return fToleranceDeltaDecayRadius; }
0074 
0075     // Decide whether you want to preassign a decay to the primary particle, if it is unstable.
0076     // Normally, the preassigned decay is set by a Monte Carlo Event Generator.
0077     // Here, instead, just for testing, we use the Geant4 decay table, selecting randomly
0078     // one of the decay channels defined in Geant4 for this primary particle.
0079     // Here we have two choices: either to set the decay products directly as returned from the
0080     // decay channel, i.e in the parent particle rest frame; or to boost them in lab frame.
0081     // Both cases should provide the same result, because internally Geant4 knows whether
0082     // the reference frame is at test ( E_total = mass of the parent, decaying particle)
0083     // or the laboratory frame.
0084     const G4bool fIsPreassignedDecayEnabled = true;  //***LOOKHERE***
0085     const G4bool fIsBoostToLabEnabled = true;  //***LOOKHERE***
0086 
0087     // Energy-momentum violations are tolerated if smaller than this value
0088     G4double fToleranceEPviolations;
0089 
0090     // Differences between the MC-true decay radius and the real decay radius are tolerated
0091     // if smaller than this value
0092     const G4double fToleranceDeltaDecayRadius = 1.0 * CLHEP::micrometer;
0093 
0094     Run* fRunPtr;  // Pointer to the Run object
0095 
0096     // Information regarding the primary particle at the beginning of its tracking
0097     G4int fPrimaryParticleId;
0098     G4double fPrimaryParticleInitialKineticEnergy;
0099     G4double fPrimaryParticleInitialTotalEnergy;
0100     G4double fPrimaryParticleInitialMomentum;
0101     G4double fPrimaryParticleInitialBeta;  // Lorentz beta
0102     G4double fPrimaryParticleInitialGamma;  // Lorentz gamma
0103     G4ThreeVector fPrimaryParticleInitial3Momentum;
0104     G4ThreeVector fPrimaryParticleInitialPosition;
0105 
0106     // Discrepancies between alternative, but equivalent ways to compute kinematical properties
0107     // of the primary particle, due to limited numerical accuracy.
0108     G4double fMaxEkin_deltaMax;
0109     G4double fMaxEtot_deltaMax;
0110     G4double fMaxP_deltaMax;
0111     G4double fMaxPdir_deltaMax;
0112     G4double fMaxMass_deltaMax1;
0113     G4double fMaxMass_deltaMax2;
0114     G4double fMaxMass_deltaMax3;
0115     G4double fMeanMass_deltaMax3;
0116     G4double fMaxBeta_deltaMax1;
0117     G4double fMaxBeta_deltaMax2;
0118     G4double fMaxGamma_deltaMax1;
0119     G4double fMaxGamma_deltaMax2;
0120     G4double fMaxGamma_deltaMax3;
0121     G4double fMaxT_proper_deltaMax;
0122     G4double fMaxT_lab_deltaMax;
0123     G4double fMaxMc_truth_rPos_deltaMax;
0124     G4double fMeanMc_truth_rPos_deltaMax;
0125 
0126     // Properties of the primary particle at the moment of its decay
0127     G4double fMeanDeltaR_primaryDecay;
0128     G4double fMinDeltaR_primaryDecay;
0129     G4double fMaxDeltaR_primaryDecay;
0130     G4double fMeanR_primaryDecay;
0131     G4double fMinR_primaryDecay;
0132     G4double fMaxR_primaryDecay;
0133     G4double fMeanX_primaryDecay;
0134     G4double fMinX_primaryDecay;
0135     G4double fMaxX_primaryDecay;
0136     G4double fMeanY_primaryDecay;
0137     G4double fMinY_primaryDecay;
0138     G4double fMaxY_primaryDecay;
0139     G4double fMeanZ_primaryDecay;
0140     G4double fMinZ_primaryDecay;
0141     G4double fMaxZ_primaryDecay;
0142     G4double fMeanDeltaAngle_primaryDecay;
0143     G4double fMinDeltaAngle_primaryDecay;
0144     G4double fMaxDeltaAngle_primaryDecay;
0145     G4double fMeanDeltaEkin_primaryDecay;
0146     G4double fMinDeltaEkin_primaryDecay;
0147     G4double fMaxDeltaEkin_primaryDecay;
0148     G4double fMeanEkin_primaryDecay;
0149     G4double fMinEkin_primaryDecay;
0150     G4double fMaxEkin_primaryDecay;
0151     G4double fMeanPx_primaryDecay;
0152     G4double fMinPx_primaryDecay;
0153     G4double fMaxPx_primaryDecay;
0154     G4double fMeanPy_primaryDecay;
0155     G4double fMinPy_primaryDecay;
0156     G4double fMaxPy_primaryDecay;
0157     G4double fMeanPz_primaryDecay;
0158     G4double fMinPz_primaryDecay;
0159     G4double fMaxPz_primaryDecay;
0160 
0161     // Conceptually wrong ways to estimate the "MC-truth" decay radius and the decay radius
0162     // (nevertheless useful to estimate the expected potential errors that users might do)
0163     G4double fMinUnderestimated_mc_truth_rPos_delta;
0164     G4double fMaxOverestimated_mc_truth_rPos_delta;
0165     G4double fMeanUnderestimated_mc_truth_rPos_delta;
0166     G4double fMeanOverestimated_mc_truth_rPos_delta;
0167     G4double fMinUnderestimated_rDeltaPos;
0168     G4double fMaxOverestimated_rDeltaPos;
0169     G4double fMeanUnderestimated_rDeltaPos;
0170     G4double fMeanOverestimated_rDeltaPos;
0171 
0172     // Max error due to the use of  float  instead of  double
0173     G4double fMaxFloat_rDeltaPos_deltaMax;
0174 
0175     // Energy-momentum violation in the decay of the primary particle, computed as difference
0176     // between the sum of its daughters and the parent (at the moment of its decay)
0177     G4double fMeanViolationE_primaryDecay;
0178     G4double fMinViolationE_primaryDecay;
0179     G4double fMaxViolationE_primaryDecay;
0180     G4double fMeanViolationPx_primaryDecay;
0181     G4double fMinViolationPx_primaryDecay;
0182     G4double fMaxViolationPx_primaryDecay;
0183     G4double fMeanViolationPy_primaryDecay;
0184     G4double fMinViolationPy_primaryDecay;
0185     G4double fMaxViolationPy_primaryDecay;
0186     G4double fMeanViolationPz_primaryDecay;
0187     G4double fMinViolationPz_primaryDecay;
0188     G4double fMaxViolationPz_primaryDecay;
0189 };
0190 
0191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0192 
0193 #endif