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 #include "G4THitsMap.hh"
00019
00020
00021
00022 EventAction::EventAction(RunAction* run)
00023 :m_runAction(run), m_printModulo(5000)
00024 {}
00025
00026
00027
00028 EventAction::~EventAction()
00029 {}
00030
00031
00032
00033 void EventAction::BeginOfEventAction(const G4Event* evt)
00034 {
00035 G4int evtNb = evt->GetEventID();
00036
00037
00038 if (evtNb%m_printModulo == 0)
00039 G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
00040
00041
00042 m_edepPerEvent = 0.;
00043 }
00044
00045
00046
00047 void EventAction::EndOfEventAction(const G4Event *event)
00048 {
00049
00050
00051 if (m_edepPerEvent > 0.) {
00052 m_runAction->SumEvents(m_edepPerEvent);
00053 }
00054
00055
00056
00057
00058
00059
00060 G4SDManager* SDmanager = G4SDManager::GetSDMpointer();
00061 G4int astronautCollectionID = SDmanager->GetCollectionID("AstronautCollection");
00062 AstroHitCollection* astroCollection(0);
00063
00064 if (astronautCollectionID>=0) astroCollection = (AstroHitCollection*)(event->GetHCofThisEvent()->GetHC(astronautCollectionID));
00065 else G4cout << "Collection `AstronautCollection' not found !!!!" << G4endl;
00066
00067
00068
00069
00070
00071
00072 if (event->GetEventID() < 5)
00073 {
00074 G4cout << "Event::EndOfEventAction(...) for event # " << event->GetEventID() << " : " << G4endl;
00075
00076 DetectorConstruction* detector = (DetectorConstruction*)(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
00077 G4double mass = detector->GetAstronaut()->GetLogicalVolume()->GetMass();
00078 if (astroCollection)
00079 {
00080
00081 G4cout << " - number of hits : " << astroCollection->entries() << G4endl;
00082 if (astroCollection->entries()) G4cout << " - hit list : " << G4endl;
00083 else G4cout << " - hit list : (empty)" << G4endl;
00084 for (G4int i=0; i<astroCollection->entries(); i++)
00085 {
00086 AstroHit* hit = (*astroCollection)[i];
00087 G4cout << " k = " << hit->GetSlice()
00088 << " , dose (gray) = " << hit->GetEnergy()/mass/gray
00089 << " , nb protons : " << hit->GetNbProton()
00090 << " , <eKin>(MeV) = " << hit->GetProtonMeanEkin()/MeV << G4endl;
00091 }
00092 }
00093 }
00094
00095
00096
00097
00098 if (astroCollection)
00099 {
00100 for (G4int i=0; i<astroCollection->entries(); i++)
00101 {
00102 AstroHit* hit = (*astroCollection)[i];
00103 m_runAction->SumDepthDoseSD(hit->GetSlice(),
00104 hit->GetEnergy(),
00105 hit->GetNbProton(),
00106 hit->GetProtonTotalEkin());
00107 }
00108 }
00109
00110
00111
00112
00113
00114
00115 G4int floorEdepCollectionID = SDmanager->GetCollectionID("floorScorer/edepFloor");
00116
00117 G4THitsMap<G4double>* eventHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(floorEdepCollectionID));
00118 std::map<G4int,G4double*>::iterator itr = eventHitMap->GetMap()->begin();
00119 G4cout << "Number of edep hits in floor : " << eventHitMap->entries() << G4endl;
00120 for(; itr != eventHitMap->GetMap()->end(); itr++)
00121 {
00122 G4int key = (itr->first);
00123 G4double val = *(itr->second);
00124 G4cout << " key = " << key << " val (MeV) = " << val/MeV << G4endl;
00125 }
00126
00127
00128
00129
00130 G4int floorTrackCounterCollectionID = SDmanager->GetCollectionID("floorScorer/trackCounterFloor");
00131
00132 eventHitMap = (G4THitsMap<G4double>*)(event->GetHCofThisEvent()->GetHC(floorTrackCounterCollectionID));
00133 itr = eventHitMap->GetMap()->begin();
00134 G4cout << "Number of track hits in floor : " << eventHitMap->entries() << G4endl;
00135 for(; itr != eventHitMap->GetMap()->end(); itr++)
00136 {
00137 G4int key = (itr->first);
00138 G4double val = *(itr->second);
00139 G4cout << " key = " << key << " , # tracks = " << val << G4endl;
00140 }
00141
00142
00143 }
00144
00145
00146
00147