File indexing completed on 2026-05-16 07:41:49
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 "DetectorConstruction.hh"
0033 #include "G4Run.hh"
0034 #include "G4AnalysisManager.hh"
0035
0036 #include <vector>
0037 typedef std::vector<G4double> MyVector;
0038
0039
0040
0041 class DetectorConstruction;
0042 class PrimaryGeneratorAction;
0043
0044
0045
0046 class Run : public G4Run
0047 {
0048 public:
0049 Run(DetectorConstruction*, PrimaryGeneratorAction*);
0050 ~Run() override = default;
0051
0052 void Merge(const G4Run*) override;
0053
0054 void InitializePerEvent();
0055 void FillPerEvent();
0056
0057 inline void FillPerTrack(G4double, G4double);
0058 inline void FillPerStep(G4double, G4int, G4int);
0059
0060 inline void AddStep(G4double q);
0061
0062 void EndOfRun(G4double edep, G4double rms, G4double& limit);
0063
0064 inline void SetVerbose(G4int val) { fVerbose = val; };
0065
0066 private:
0067 void Reset();
0068
0069 DetectorConstruction* fDet = nullptr;
0070 PrimaryGeneratorAction* fKin = nullptr;
0071
0072 G4int f_nLbin = kMaxBin;
0073 MyVector f_dEdL;
0074 MyVector fSumELongit;
0075 MyVector fSumE2Longit;
0076 MyVector fSumELongitCumul;
0077 MyVector fSumE2LongitCumul;
0078
0079 G4int f_nRbin = kMaxBin;
0080 MyVector f_dEdR;
0081 MyVector fSumERadial;
0082 MyVector fSumE2Radial;
0083 MyVector fSumERadialCumul;
0084 MyVector fSumE2RadialCumul;
0085
0086 G4double fChargTrLength = 0.;
0087 G4double fSumChargTrLength = 0.;
0088 G4double fSum2ChargTrLength = 0.;
0089
0090 G4double fNeutrTrLength = 0.;
0091 G4double fSumNeutrTrLength = 0.;
0092 G4double fSum2NeutrTrLength = 0.;
0093
0094 G4double fChargedStep = 0.;
0095 G4double fNeutralStep = 0.;
0096
0097 G4int fVerbose = 0;
0098 };
0099
0100
0101
0102 inline void Run::FillPerTrack(G4double charge, G4double trkLength)
0103 {
0104 if (charge != 0.)
0105 fChargTrLength += trkLength;
0106 else
0107 fNeutrTrLength += trkLength;
0108 }
0109
0110
0111
0112 inline void Run::FillPerStep(G4double dEstep, G4int Lbin, G4int Rbin)
0113 {
0114 f_dEdL[Lbin] += dEstep;
0115 f_dEdR[Rbin] += dEstep;
0116 }
0117
0118
0119
0120 inline void Run::AddStep(G4double q)
0121 {
0122 if (q == 0.0) {
0123 fNeutralStep += 1.0;
0124 }
0125 else {
0126 fChargedStep += 1.0;
0127 }
0128 }
0129
0130
0131
0132 #endif