File indexing completed on 2026-04-20 07:52:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifndef Run_h
0030 #define Run_h 1
0031
0032 #include "G4Electron.hh"
0033 #include "G4Gamma.hh"
0034 #include "G4Positron.hh"
0035 #include "G4Run.hh"
0036 #include "globals.hh"
0037
0038 class DetectorConstruction;
0039 class G4ParticleDefinition;
0040
0041
0042
0043 class Run : public G4Run
0044 {
0045 public:
0046 Run(DetectorConstruction*);
0047 ~Run() override = default;
0048
0049 void SetPrimary(G4ParticleDefinition* particle, G4double energy);
0050
0051 void AddEnergy(G4double edep)
0052 {
0053 fEnergyDeposit += edep;
0054 fEnergyDeposit2 += edep * edep;
0055 };
0056
0057 void AddTrakLenCharg(G4double length)
0058 {
0059 fTrakLenCharged += length;
0060 fTrakLenCharged2 += length * length;
0061 };
0062
0063 void AddTrakLenNeutr(G4double length)
0064 {
0065 fTrakLenNeutral += length;
0066 fTrakLenNeutral2 += length * length;
0067 };
0068
0069 void AddMscProjTheta(G4double theta)
0070 {
0071 if (std::abs(theta) <= fMscThetaCentral) {
0072 fMscEntryCentral++;
0073 fMscProjecTheta += theta;
0074 fMscProjecTheta2 += theta * theta;
0075 }
0076 };
0077
0078 void CountStepsCharg(G4int nSteps)
0079 {
0080 fNbStepsCharged += nSteps;
0081 fNbStepsCharged2 += nSteps * nSteps;
0082 };
0083
0084 void CountStepsNeutr(G4int nSteps)
0085 {
0086 fNbStepsNeutral += nSteps;
0087 fNbStepsNeutral2 += nSteps * nSteps;
0088 };
0089
0090 void CountParticles(G4ParticleDefinition* part)
0091 {
0092 if (part == G4Gamma::Gamma())
0093 ++fNbGamma;
0094 else if (part == G4Electron::Electron())
0095 ++fNbElect;
0096 else if (part == G4Positron::Positron())
0097 ++fNbPosit;
0098 };
0099
0100 void CountTransmit(G4int flag)
0101 {
0102 if (flag == 1)
0103 ++fTransmit[0];
0104 else if (flag == 2) {
0105 ++fTransmit[0];
0106 ++fTransmit[1];
0107 }
0108 };
0109
0110 void CountReflect(G4int flag)
0111 {
0112 if (flag == 1)
0113 ++fReflect[0];
0114 else if (flag == 2) {
0115 ++fReflect[0];
0116 ++fReflect[1];
0117 }
0118 };
0119
0120 void AddEnergyLeak(G4double eleak, G4int index)
0121 {
0122 fEnergyLeak[index] += eleak;
0123 fEnergyLeak2[index] += eleak * eleak;
0124 };
0125
0126 G4double ComputeMscHighland();
0127
0128 void CountGammaProcesses(G4int* type)
0129 {
0130 for (G4int i = 0; i < 4; ++i) {
0131 fTypes[i] += type[i];
0132 }
0133 }
0134
0135 void Merge(const G4Run*) override;
0136
0137 void EndOfRun();
0138
0139 private:
0140 DetectorConstruction* fDetector = nullptr;
0141 G4ParticleDefinition* fParticle = nullptr;
0142 G4double fEkin = 0.;
0143
0144 G4double fEnergyDeposit = 0., fEnergyDeposit2 = 0.;
0145 G4double fTrakLenCharged = 0., fTrakLenCharged2 = 0.;
0146 G4double fTrakLenNeutral = 0., fTrakLenNeutral2 = 0.;
0147 G4double fNbStepsCharged = 0., fNbStepsCharged2 = 0.;
0148 G4double fNbStepsNeutral = 0., fNbStepsNeutral2 = 0.;
0149 G4double fMscProjecTheta = 0., fMscProjecTheta2 = 0.;
0150 G4double fMscThetaCentral = 0.;
0151
0152 G4int fNbGamma = 0, fNbElect = 0, fNbPosit = 0;
0153 G4int fTransmit[2] = {0, 0}, fReflect[2] = {0, 0};
0154 G4int fMscEntryCentral = 0;
0155 G4int fTypes[4] = {0, 0, 0, 0};
0156
0157 G4double fEnergyLeak[2] = {0, 0}, fEnergyLeak2[2] = {0, 0};
0158 };
0159
0160
0161
0162 #endif