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