Warning, file /geant4/examples/advanced/hadrontherapy/src/HadrontherapyEventAction.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 "G4SystemOfUnits.hh"
0030 #include "G4Event.hh"
0031 #include "G4EventManager.hh"
0032 #include "G4HCofThisEvent.hh"
0033 #include "G4VHitsCollection.hh"
0034 #include "G4SDManager.hh"
0035 #include "G4VVisManager.hh"
0036
0037 #include "HadrontherapyEventAction.hh"
0038 #include "HadrontherapyDetectorHit.hh"
0039 #include "HadrontherapyDetectorSD.hh"
0040 #include "HadrontherapyDetectorConstruction.hh"
0041 #include "HadrontherapyMatrix.hh"
0042 #include "HadrontherapyEventActionMessenger.hh"
0043
0044
0045 HadrontherapyEventAction::HadrontherapyEventAction() :
0046 drawFlag("all" ),printModulo(10), pointerEventMessenger(0)
0047 {
0048 hitsCollectionID = -1;
0049 pointerEventMessenger = new HadrontherapyEventActionMessenger(this);
0050 }
0051
0052
0053 HadrontherapyEventAction::~HadrontherapyEventAction()
0054 {
0055 delete pointerEventMessenger;
0056 }
0057
0058
0059 void HadrontherapyEventAction::BeginOfEventAction(const G4Event*)
0060 {
0061 G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
0062 if(hitsCollectionID == -1)
0063 hitsCollectionID = pSDManager -> GetCollectionID("HadrontherapyDetectorHitsCollection");
0064 }
0065
0066
0067 void HadrontherapyEventAction::EndOfEventAction(const G4Event* evt)
0068 {
0069 if(hitsCollectionID < 0)
0070 return;
0071 G4HCofThisEvent* HCE = evt -> GetHCofThisEvent();
0072
0073
0074 HadrontherapyMatrix* matrix = HadrontherapyMatrix::GetInstance();
0075 if (matrix) matrix -> ClearHitTrack();
0076
0077 if(HCE)
0078 {
0079 HadrontherapyDetectorHitsCollection* CHC = (HadrontherapyDetectorHitsCollection*)(HCE -> GetHC(hitsCollectionID));
0080 if(CHC)
0081 {
0082 if(matrix)
0083 {
0084
0085
0086
0087 size_t HitCount = CHC -> entries();
0088 for (size_t h=0; h<HitCount; h++)
0089 {
0090 G4int i = ((*CHC)[h]) -> GetXID();
0091 G4int j = ((*CHC)[h]) -> GetYID();
0092 G4int k = ((*CHC)[h]) -> GetZID();
0093 G4double energyDeposit = ((*CHC)[h]) -> GetEdep();
0094 matrix -> Fill(i, j, k, energyDeposit/MeV);
0095 }
0096 }
0097 }
0098 }
0099 }