File indexing completed on 2025-04-10 08:06:17
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
0034 #include "Run.hh"
0035
0036 #include "G4Run.hh"
0037 #include "G4RunManager.hh"
0038 #include "G4SystemOfUnits.hh"
0039
0040
0041
0042 Run::Run()
0043 : G4Run(),
0044 fNumEvents(0),
0045 fPrimaryParticleId(0),
0046 fPrimaryParticleEnergy(0.0),
0047 fPrimaryParticleDirection(G4ThreeVector(0.0, 0.0, 0.0)),
0048 fTrackerMaterialName(""),
0049 fEmCaloMaterialName(""),
0050 fHadCaloMaterialName(""),
0051 fCubicVolumeScoringTrackerShell(1.0),
0052 fCubicVolumeScoringEmCaloShell(1.0),
0053 fCubicVolumeScoringHadCaloShell(1.0)
0054 {
0055 fSteppingArray.fill(0.0);
0056 fTrackingArray1.fill(0);
0057 fTrackingArray2.fill(0.0);
0058 }
0059
0060
0061
0062 void Run::RecordEvent(const G4Event* anEvent)
0063 {
0064
0065
0066 G4int nEvt = anEvent->GetEventID();
0067 if (nEvt % 10 == 0) G4cout << " Event#=" << nEvt << G4endl;
0068 G4Run::RecordEvent(anEvent);
0069 }
0070
0071
0072
0073 void Run::Merge(const G4Run* aRun)
0074 {
0075
0076
0077 const Run* localRun = static_cast<const Run*>(aRun);
0078 fPrimaryParticleId = localRun->GetPrimaryParticleId();
0079 fPrimaryParticleEnergy = localRun->GetPrimaryParticleEnergy();
0080 fPrimaryParticleDirection = localRun->GetPrimaryParticleDirection();
0081 fTrackerMaterialName = localRun->GetTrackerMaterialName();
0082 fEmCaloMaterialName = localRun->GetEmCaloMaterialName();
0083 fHadCaloMaterialName = localRun->GetHadCaloMaterialName();
0084 fCubicVolumeScoringTrackerShell = localRun->GetCubicVolumeScoringTrackerShell();
0085 fCubicVolumeScoringEmCaloShell = localRun->GetCubicVolumeScoringEmCaloShell();
0086 fCubicVolumeScoringHadCaloShell = localRun->GetCubicVolumeScoringHadCaloShell();
0087 fNumEvents += localRun->GetNumberOfEvent();
0088 for (G4int i = 0; i < SteppingAction::fkNumberCombinations; ++i) {
0089 fSteppingArray[i] += localRun->GetSteppingArray()[i];
0090 }
0091 for (G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i) {
0092 fTrackingArray1[i] += localRun->GetTrackingArray1()[i];
0093 fTrackingArray2[i] += localRun->GetTrackingArray2()[i];
0094 }
0095 G4Run::Merge(aRun);
0096 }
0097
0098
0099
0100 void Run::PrintInfo() const
0101 {
0102
0103
0104 const G4double floatingNumberOfEvents =
0105 std::max(1.0, fNumEvents > 0 ? fNumEvents * 1.0 : GetNumberOfEvent() * 1.0);
0106
0107
0108 const G4double conversionFactor = CLHEP::cm * CLHEP::cm;
0109 const G4double factorTracker =
0110 conversionFactor / (0.5 * fCubicVolumeScoringTrackerShell * floatingNumberOfEvents);
0111 const G4double factorEmCalo =
0112 conversionFactor / (0.5 * fCubicVolumeScoringEmCaloShell * floatingNumberOfEvents);
0113 const G4double factorHadCalo =
0114 conversionFactor / (0.5 * fCubicVolumeScoringHadCaloShell * floatingNumberOfEvents);
0115 G4cout << std::setprecision(6) << G4endl << G4endl
0116 << " =============== Run::PrintInfo() =============== \t RunID = " << GetRunID()
0117 << G4endl << " Primary particle PDG code = " << fPrimaryParticleId << G4endl
0118 << " Primary particle kinetic energy = " << fPrimaryParticleEnergy / CLHEP::GeV << " GeV"
0119 << G4endl << " Primary particle direction = " << fPrimaryParticleDirection << G4endl
0120 << " Tracker material = " << fTrackerMaterialName << G4endl
0121 << " EmCalo material = " << fEmCaloMaterialName << G4endl
0122 << " HadCalo material = " << fHadCaloMaterialName << G4endl
0123 << " Cubic-volume scoring tracker shell = " << fCubicVolumeScoringTrackerShell << " mm^3"
0124 << G4endl << " Cubic-volume scoring emCalo shell = " << fCubicVolumeScoringEmCaloShell
0125 << " mm^3" << G4endl
0126 << " Cubic-volume scoring hadCalo shell = " << fCubicVolumeScoringHadCaloShell << " mm^3"
0127 << G4endl << " Number of events = " << floatingNumberOfEvents << G4endl
0128 << " Conversion factor: fluence from mm^-2 to cm^-2 = " << conversionFactor << G4endl
0129 << " Particle fluence in unit of cm^-2 :" << G4endl;
0130 for (G4int i = 0; i < SteppingAction::fkNumberScoringShells; ++i) {
0131 G4double factor = factorTracker;
0132 if (i == 1)
0133 factor = factorEmCalo;
0134 else if (i == 2)
0135 factor = factorHadCalo;
0136 for (G4int j = 0; j < SteppingAction::fkNumberKinematicRegions; ++j) {
0137 for (G4int k = 0; k < SteppingAction::fkNumberScoringPositions; ++k) {
0138 for (G4int ll = 0; ll < SteppingAction::fkNumberParticleTypes; ++ll) {
0139 G4int index = SteppingAction::GetIndex(i, j, k, ll);
0140
0141
0142 G4cout << " case=" << std::setw(3) << index << " " << std::setw(12)
0143 << SteppingAction::fkArrayScoringShellNames[i] << " " << std::setw(12)
0144 << SteppingAction::fkArrayKinematicRegionNames[j] << " " << std::setw(12)
0145 << SteppingAction::fkArrayScoringPositionNames[k] << " " << std::setw(12)
0146 << SteppingAction::fkArrayParticleTypeNames[ll] << " " << std::setw(8)
0147 << factor * fSteppingArray[index] << G4endl;
0148 }
0149 }
0150 }
0151 }
0152 G4cout << " ------------------------------------------------------------- " << G4endl
0153 << " Extra information: particle production \t \t <N> <E_kin> <Sum_Ekin> [MeV]"
0154 << G4endl;
0155 const G4double normalization = 1.0 / floatingNumberOfEvents;
0156 for (G4int i = 0; i < TrackingAction::fkNumberScoringVolumes; ++i) {
0157 for (G4int j = 0; j < TrackingAction::fkNumberKinematicRegions; ++j) {
0158 for (G4int k = 0; k < TrackingAction::fkNumberParticleTypes; ++k) {
0159 G4int index = TrackingAction::GetIndex(i, j, k);
0160
0161 G4cout << " case=" << std::setw(3) << index << " " << std::setw(12)
0162 << TrackingAction::fkArrayScoringVolumeNames[i] << " " << std::setw(12)
0163 << TrackingAction::fkArrayKinematicRegionNames[j] << " " << std::setw(12)
0164 << TrackingAction::fkArrayParticleTypeNames[k] << " " << std::setw(8)
0165 << normalization * fTrackingArray1[index] << " " << std::setw(8)
0166 << (fTrackingArray1[index] > 0 ? fTrackingArray2[index] / fTrackingArray1[index]
0167 : 0.0)
0168 << " " << std::setw(8) << normalization * fTrackingArray2[index] << G4endl;
0169 }
0170 }
0171 }
0172 G4cout << " ============================================================= " << G4endl << G4endl;
0173 }
0174
0175
0176
0177 void Run::SetSteppingArray(
0178 const std::array<G4double, SteppingAction::fkNumberCombinations>& inputArray)
0179 {
0180 for (G4int i = 0; i < SteppingAction::fkNumberCombinations; ++i) {
0181 fSteppingArray[i] = inputArray[i];
0182 }
0183 }
0184
0185
0186
0187 void Run::SetTrackingArray1(
0188 const std::array<G4long, TrackingAction::fkNumberCombinations>& inputArray)
0189 {
0190 for (G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i) {
0191 fTrackingArray1[i] = inputArray[i];
0192 }
0193 }
0194
0195
0196
0197 void Run::SetTrackingArray2(
0198 const std::array<G4double, TrackingAction::fkNumberCombinations>& inputArray)
0199 {
0200 for (G4int i = 0; i < TrackingAction::fkNumberCombinations; ++i) {
0201 fTrackingArray2[i] = inputArray[i];
0202 }
0203 }
0204
0205