File indexing completed on 2026-09-19 08:38:15
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
0035
0036
0037
0038
0039
0040 #include "EventAction.hh"
0041
0042 #include "EventActionMessenger.hh"
0043
0044 #include "G4AnalysisManager.hh"
0045 #include "G4Event.hh"
0046 #include "G4SystemOfUnits.hh"
0047 #include "G4UnitsTable.hh"
0048 #include "Randomize.hh"
0049
0050 #include <algorithm>
0051
0052
0053
0054 EventAction::EventAction() : G4UserEventAction()
0055 {
0056
0057
0058 fThresEdepForSSB = 8.22 * eV;
0059 fThresDistForDSB = 10;
0060 fTotalEnergyDeposit = 0;
0061
0062
0063
0064 fpEventMessenger = new EventActionMessenger(this);
0065 }
0066
0067
0068
0069 EventAction::~EventAction()
0070 {
0071 delete fpEventMessenger;
0072 }
0073
0074
0075
0076 void EventAction::BeginOfEventAction(const G4Event*)
0077 {
0078
0079
0080 fTotalEnergyDeposit = 0.;
0081 fEdepStrand1.clear();
0082 fEdepStrand2.clear();
0083 }
0084
0085
0086
0087 void EventAction::EndOfEventAction(const G4Event*)
0088 {
0089
0090
0091 G4int sb[2] = {0, 0};
0092 ComputeStrandBreaks(sb);
0093
0094
0095 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0096
0097 if (fTotalEnergyDeposit > 0.) {
0098 analysisManager->FillH1(1, fTotalEnergyDeposit);
0099 }
0100 if (sb[0] > 0) {
0101 analysisManager->FillH1(2, sb[0]);
0102 }
0103 if (sb[1] > 0) {
0104 analysisManager->FillH1(3, sb[1]);
0105 }
0106 }
0107
0108
0109
0110 void EventAction::ComputeStrandBreaks(G4int* sb)
0111 {
0112
0113
0114 G4int ssb1 = 0;
0115 G4int ssb2 = 0;
0116 G4int dsb = 0;
0117
0118
0119 G4int nucl1;
0120 G4int nucl2;
0121 G4double edep1;
0122 G4double edep2;
0123
0124
0125
0126 while (!fEdepStrand1.empty()) {
0127 nucl1 = fEdepStrand1.begin()->first;
0128 edep1 = fEdepStrand1.begin()->second;
0129 fEdepStrand1.erase(fEdepStrand1.begin());
0130
0131
0132
0133 if (edep1 >= fThresEdepForSSB / eV) {
0134 ssb1++;
0135 }
0136
0137
0138
0139 if (!fEdepStrand2.empty()) {
0140 do {
0141 nucl2 = fEdepStrand2.begin()->first;
0142 edep2 = fEdepStrand2.begin()->second;
0143 if (edep2 >= fThresEdepForSSB / eV) {
0144 ssb2++;
0145 }
0146 fEdepStrand2.erase(fEdepStrand2.begin());
0147 } while (((nucl1 - nucl2) > fThresDistForDSB) && (!fEdepStrand2.empty()));
0148
0149
0150
0151 if (nucl2 - nucl1 > fThresDistForDSB) {
0152 fEdepStrand2[nucl2] = edep2;
0153 if (edep2 >= fThresEdepForSSB / eV) {
0154 ssb2--;
0155 }
0156 }
0157
0158
0159
0160 if (std::abs(nucl2 - nucl1) <= fThresDistForDSB) {
0161 if ((edep2 >= fThresEdepForSSB / eV) && (edep1 >= fThresEdepForSSB / eV)) {
0162 ssb1--;
0163 ssb2--;
0164 dsb++;
0165 }
0166 }
0167 }
0168 }
0169
0170
0171
0172 while (!fEdepStrand1.empty()) {
0173 nucl1 = fEdepStrand1.begin()->first;
0174 edep1 = fEdepStrand1.begin()->second;
0175 if (edep1 >= fThresEdepForSSB / eV) {
0176 ssb1++;
0177 }
0178 fEdepStrand1.erase(fEdepStrand1.begin());
0179 }
0180
0181 while (!fEdepStrand2.empty()) {
0182 nucl2 = fEdepStrand2.begin()->first;
0183 edep2 = fEdepStrand2.begin()->second;
0184 if (edep2 >= fThresEdepForSSB / eV) {
0185 ssb2++;
0186 }
0187 fEdepStrand2.erase(fEdepStrand2.begin());
0188 }
0189
0190 sb[0] = ssb1 + ssb2;
0191 sb[1] = dsb;
0192 }