File indexing completed on 2025-02-23 09:20:10
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 "G4HumanPhantomEventAction.hh"
0030 #include "G4HumanPhantomHit.hh"
0031 #include "G4Event.hh"
0032 #include "G4EventManager.hh"
0033 #include "G4ios.hh"
0034 #include "G4SDManager.hh"
0035 #include "G4UnitsTable.hh"
0036 #include "G4HumanPhantomRunAction.hh"
0037 #include "G4RunManager.hh"
0038
0039 G4HumanPhantomEventAction::G4HumanPhantomEventAction():
0040 fHitCollectionID(-1)
0041 {
0042
0043 }
0044
0045 void G4HumanPhantomEventAction::BeginOfEventAction(const G4Event*)
0046 {
0047 fEnergyTotal["logicalHead"]=0.;
0048 fEnergyTotal["logicalTrunk"]=0.;
0049 fEnergyTotal["logicalLeftLeg"]=0.;
0050 fEnergyTotal["logicalRightLeg"]=0.;
0051 fEnergyTotal["logicalSkull"]=0.;
0052 fEnergyTotal["logicalLeftArmBone"]=0.;
0053 fEnergyTotal["logicalRightArmBone"]=0.;
0054 fEnergyTotal["logicalUpperSpine"]=0.;
0055 fEnergyTotal["logicalMiddleLowerSpine"]=0.;
0056 fEnergyTotal["logicalPelvis"]=0.;
0057 fEnergyTotal["logicalRibCage"]=0.;
0058 fEnergyTotal["logicalLeftClavicle"]=0.;
0059 fEnergyTotal["logicalRightClavicle"]=0.;
0060 fEnergyTotal["logicalLeftLegBone"]=0.;
0061 fEnergyTotal["logicalRightLegBone"]=0.;
0062 fEnergyTotal["logicalLeftScapula"]=0.;
0063 fEnergyTotal["logicalRightScapula"]=0.;
0064 fEnergyTotal["logicalHeart"]=0.;
0065 fEnergyTotal["logicalThyroid"]=0.;
0066 fEnergyTotal["logicalThymus"]=0.;
0067 fEnergyTotal["logicalMaleGenitalia"]=0.;
0068 fEnergyTotal["logicalBrain"]=0.;
0069 fEnergyTotal["logicalStomach"]=0.;
0070 fEnergyTotal["logicalUpperLargeIntestine"]=0.;
0071 fEnergyTotal["logicalLowerLargeIntestine"]=0.;
0072 fEnergyTotal["logicalSmallIntestine"]=0;
0073 fEnergyTotal["logicalSpleen"]=0.;
0074 fEnergyTotal["logicalPancreas"]=0.;
0075 fEnergyTotal["logicalLeftKidney"]=0.;
0076 fEnergyTotal["logicalRightKidney"]=0.;
0077 fEnergyTotal["logicalUrinaryBladder"]=0.;
0078 fEnergyTotal["logicalUterus"]=0.;
0079 fEnergyTotal["logicalLeftLung"]=0.;
0080 fEnergyTotal["logicalRightLung"]=0.;
0081 fEnergyTotal["logicalLeftOvary"]=0.;
0082 fEnergyTotal["logicalRightOvary"]=0.;
0083 fEnergyTotal["logicalLeftTeste"]=0;
0084 fEnergyTotal["logicalRightTeste"]=0;
0085 fEnergyTotal["logicalLeftBreast"]=0.;
0086 fEnergyTotal["logicalRightBreast"]=0.;
0087 fEnergyTotal["logicalLeftAdrenal"]=0.;
0088 fEnergyTotal["logicalRightAdrenal"]=0.;
0089
0090 G4SDManager * SDman = G4SDManager::GetSDMpointer();
0091
0092 if (fHitCollectionID==-1) {
0093 fHitCollectionID = SDman->GetCollectionID("HumanPhantomCollection");
0094 }
0095 }
0096
0097 void G4HumanPhantomEventAction::EndOfEventAction(const G4Event* evt)
0098 {
0099
0100 G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
0101
0102 G4HumanPhantomHitsCollection* HC = nullptr;
0103
0104 if (HCE)
0105 HC = (G4HumanPhantomHitsCollection*)(HCE->GetHC(fHitCollectionID));
0106
0107 if (HC)
0108 {
0109 G4int hitNumber = HC->entries();
0110 G4double edep =0;
0111 G4String bodyPart;
0112 for (G4int i=0;i<hitNumber;i++)
0113 {
0114 edep = (*HC)[i]->GetEdep();
0115 bodyPart = (*HC)[i]->GetBodyPartID();
0116 Fill(bodyPart, edep);
0117
0118 }
0119 }
0120
0121 totalEventEnergyDeposit();
0122 }
0123
0124 void G4HumanPhantomEventAction:: Fill(G4String bName,
0125 G4double energyDeposit)
0126
0127 {
0128 fEnergyTotal[bName] += energyDeposit;
0129 }
0130
0131 void G4HumanPhantomEventAction::totalEventEnergyDeposit()
0132 {
0133
0134 G4RunManager* runManager = G4RunManager::GetRunManager();
0135 auto* pointerRun = (G4HumanPhantomRunAction*)(runManager->GetUserRunAction());
0136
0137 std::map<std::string,G4double>::iterator i = fEnergyTotal.begin();
0138 std::map<std::string,G4double>::iterator end = fEnergyTotal.end();
0139
0140 while(i!=end)
0141 {
0142
0143 G4String bodypart = i->first;
0144 G4double energyDep = i->second;
0145
0146 if(energyDep != 0.)
0147 {
0148 pointerRun->Fill(bodypart, energyDep);
0149 }
0150 i++;
0151 }
0152
0153 }