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