File indexing completed on 2026-06-15 07:54:06
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 #include "EventAction.hh"
0030
0031 #include "HistoManager.hh"
0032 #include "Run.hh"
0033
0034 #include "G4Event.hh"
0035 #include "G4RunManager.hh"
0036 #include "G4UnitsTable.hh"
0037
0038
0039
0040 void EventAction::BeginOfEventAction(const G4Event*)
0041 {
0042 fEdep1 = fEdep2 = fWeight1 = fWeight2 = 0.;
0043 fTime0 = -1 * s;
0044 }
0045
0046
0047
0048 void EventAction::AddEdep(G4int iVol, G4double edep, G4double time, G4double weight)
0049 {
0050
0051 if (fTime0 < 0.) fTime0 = time;
0052
0053
0054 const G4double TimeWindow(1 * microsecond);
0055 if (std::fabs(time - fTime0) > TimeWindow) return;
0056
0057 if (iVol == 1) {
0058 fEdep1 += edep;
0059 fWeight1 += edep * weight;
0060 }
0061 if (iVol == 2) {
0062 fEdep2 += edep;
0063 fWeight2 += edep * weight;
0064 }
0065 }
0066
0067
0068
0069 void EventAction::EndOfEventAction(const G4Event*)
0070 {
0071 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0072
0073 G4double Etot = fEdep1 + fEdep2;
0074 G4double Wtot = (fWeight1 + fWeight2) / Etot;
0075
0076
0077
0078 if (fEdep1 > 0.) {
0079 fWeight1 /= fEdep1;
0080 analysisManager->FillH1(0, fEdep1, fWeight1);
0081 }
0082
0083
0084
0085 if (fEdep2 > 0.) {
0086 fWeight2 /= fEdep2;
0087 analysisManager->FillH1(1, fEdep2, fWeight2);
0088 }
0089
0090
0091
0092 analysisManager->FillH1(2, Etot, Wtot);
0093
0094
0095 const G4double Threshold1(10 * keV), Threshold2(10 * keV);
0096
0097
0098
0099 G4bool coincidence = ((fEdep1 >= Threshold1) && (fEdep2 >= Threshold2));
0100 G4bool anti_coincidence1 = ((fEdep1 >= Threshold1) && (fEdep2 < Threshold2));
0101 G4bool anti_coincidence2 = ((fEdep1 < Threshold1) && (fEdep2 >= Threshold2));
0102
0103 if (coincidence) analysisManager->FillH1(3, fEdep2, fWeight2);
0104 if (anti_coincidence1) analysisManager->FillH1(4, fEdep1, fWeight1);
0105 if (anti_coincidence2) analysisManager->FillH1(5, fEdep2, fWeight2);
0106
0107
0108
0109 Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0110
0111 run->AddEdep(fEdep1, fEdep2);
0112 }
0113
0114