00001
00002
00003
00004
00005
00006 #include "EventAction.hh"
00007
00008 #include "RunAction.hh"
00009
00010 #include "G4Event.hh"
00011 #include "G4UnitsTable.hh"
00012
00013 #include "G4SDManager.hh"
00014 #include "G4RunManager.hh"
00015 #include "AstroHitCollection.hh"
00016 #include "DetectorConstruction.hh"
00017
00018
00019
00020 EventAction::EventAction(RunAction* run)
00021 :m_runAction(run), m_printModulo(5000)
00022 {}
00023
00024
00025
00026 EventAction::~EventAction()
00027 {}
00028
00029
00030
00031 void EventAction::BeginOfEventAction(const G4Event* evt)
00032 {
00033 G4int evtNb = evt->GetEventID();
00034
00035
00036 if (evtNb%m_printModulo == 0)
00037 G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
00038
00039
00040 m_edepPerEvent = 0.;
00041 }
00042
00043
00044
00045 void EventAction::EndOfEventAction(const G4Event *event)
00046 {
00047
00048
00049 if (m_edepPerEvent > 0.) {
00050 m_runAction->SumEvents(m_edepPerEvent);
00051 }
00052
00053
00054
00055
00056
00057
00058 G4SDManager* SDmanager = G4SDManager::GetSDMpointer();
00059 G4int astronautCollectionID = SDmanager->GetCollectionID("AstronautCollection");
00060 AstroHitCollection* astroCollection(0);
00061
00062 if (astronautCollectionID>=0) astroCollection = (AstroHitCollection*)(event->GetHCofThisEvent()->GetHC(astronautCollectionID));
00063 else G4cout << "Collection `AstronautCollection' not found !!!!" << G4endl;
00064
00065
00066
00067
00068
00069
00070 if (event->GetEventID() < 5)
00071 {
00072 G4cout << "Event::EndOfEventAction(...) for event # " << event->GetEventID() << " : " << G4endl;
00073
00074 DetectorConstruction* detector = (DetectorConstruction*)(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
00075 G4double mass = detector->GetAstronaut()->GetLogicalVolume()->GetMass();
00076 if (astroCollection)
00077 {
00078
00079 G4cout << " - number of hits : " << astroCollection->entries() << G4endl;
00080 if (astroCollection->entries()) G4cout << " - hit list : " << G4endl;
00081 else G4cout << " - hit list : (empty)" << G4endl;
00082 for (G4int i=0; i<astroCollection->entries(); i++)
00083 {
00084 AstroHit* hit = (*astroCollection)[i];
00085 G4cout << " k = " << hit->GetSlice() << " dose (gray) = " << hit->GetEnergy()/mass/gray << G4endl;
00086 }
00087 }
00088 }
00089
00090
00091
00092
00093 if (astroCollection)
00094 {
00095 for (G4int i=0; i<astroCollection->entries(); i++)
00096 {
00097 AstroHit* hit = (*astroCollection)[i];
00098 m_runAction->SumDepthDoseSD(hit->GetSlice(),
00099 hit->GetEnergy());
00100 }
00101 }
00102 }
00103
00104
00105
00106