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