File indexing completed on 2026-03-31 07:49:53
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 "RunAction.hh"
0033
0034 #include "G4Event.hh"
0035
0036
0037
0038 EventAction::EventAction(RunAction* RA) : fRunAction(RA) {}
0039
0040
0041
0042 void EventAction::BeginOfEventAction(const G4Event*)
0043 {
0044
0045 fEdepPrimary = fEdepSecondary = 0.;
0046 }
0047
0048
0049
0050 void EventAction::SumEnergyDeposited(G4int trackID, G4double edep)
0051 {
0052 if (trackID == 1)
0053 fEdepPrimary += edep;
0054 else
0055 fEdepSecondary += edep;
0056 }
0057
0058
0059
0060 void EventAction::SumEnergyTransfered(const G4VProcess* process, G4double energy)
0061 {
0062 G4String procName = process->GetProcessName();
0063 std::map<G4String, G4double>::iterator it = fEnergyTransfered.find(procName);
0064 if (it == fEnergyTransfered.end()) {
0065 fEnergyTransfered[procName] = energy;
0066 }
0067 else {
0068 fEnergyTransfered[procName] += energy;
0069 }
0070
0071 G4int subtype = process->GetProcessSubType();
0072 fProcessSubType[procName] = subtype;
0073 }
0074
0075
0076
0077 void EventAction::EndOfEventAction(const G4Event*)
0078 {
0079 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0080
0081 G4double EtransferedTotal = 0.;
0082 std::map<G4String, G4double>::iterator it;
0083 for (it = fEnergyTransfered.begin(); it != fEnergyTransfered.end(); it++) {
0084 G4String procName = it->first;
0085 G4double energy = it->second;
0086 fRunAction->EnergyTransferedByProcess(procName, energy);
0087 EtransferedTotal += energy;
0088
0089 G4int ih = 0;
0090 if (fProcessSubType[procName] == 2)
0091 ih = 3;
0092 else if (fProcessSubType[procName] == 3)
0093 ih = 4;
0094 else if (fProcessSubType[procName] == 4)
0095 ih = 5;
0096 if (ih > 0) analysisManager->FillH1(ih, energy);
0097 }
0098
0099 fRunAction->EnergyDeposited(fEdepPrimary, fEdepSecondary);
0100 if (EtransferedTotal > 0.) fRunAction->EnergyTransfered(EtransferedTotal);
0101 G4double energyLostTotal = fEdepPrimary + EtransferedTotal;
0102 fRunAction->TotalEnergyLost(energyLostTotal);
0103 G4double energyDepositTotal = fEdepPrimary + fEdepSecondary;
0104 fRunAction->TotalEnergyDeposit(energyDepositTotal);
0105
0106 analysisManager->FillH1(2, fEdepPrimary);
0107 analysisManager->FillH1(6, EtransferedTotal);
0108 analysisManager->FillH1(7, energyLostTotal);
0109 analysisManager->FillH1(9, fEdepSecondary);
0110 analysisManager->FillH1(10, energyDepositTotal);
0111
0112 fEnergyTransfered.clear();
0113 fProcessSubType.clear();
0114 }
0115
0116