#include <EventAction.hh>
Public Member Functions | |
EventAction (RunAction *) | |
~EventAction () | |
void | BeginOfEventAction (const G4Event *) |
void | EndOfEventAction (const G4Event *) |
void | AddEdep (G4double edep) |
Private Attributes | |
RunAction * | m_runAction |
G4double | m_edepPerEvent |
G4int | m_printModulo |
Definition at line 16 of file EventAction.hh.
EventAction::EventAction | ( | RunAction * | run | ) |
EventAction::~EventAction | ( | ) |
void EventAction::BeginOfEventAction | ( | const G4Event * | evt | ) |
Definition at line 33 of file EventAction.cc.
00034 { 00035 G4int evtNb = evt->GetEventID(); 00036 00037 //printing survey 00038 if (evtNb%m_printModulo == 0) 00039 G4cout << "\n---> Begin of Event: " << evtNb << G4endl; 00040 00041 //energy deposited per event 00042 m_edepPerEvent = 0.; 00043 }
void EventAction::EndOfEventAction | ( | const G4Event * | event | ) |
Definition at line 47 of file EventAction.cc.
00048 { 00049 //energy deposited per event 00050 // 00051 if (m_edepPerEvent > 0.) { 00052 m_runAction->SumEvents(m_edepPerEvent); 00053 } 00054 00055 // -- jour4b2: 00056 // ------------------------------- 00057 // -- Get back collection pointer: 00058 // ------------------------------- 00059 // -- find back collection, this is made by getting the collection ID: 00060 G4SDManager* SDmanager = G4SDManager::GetSDMpointer(); 00061 G4int astronautCollectionID = SDmanager->GetCollectionID("AstronautCollection"); 00062 AstroHitCollection* astroCollection(0); 00063 // -- Collection ID is correct, we get the pointer of the collection: 00064 if (astronautCollectionID>=0) astroCollection = (AstroHitCollection*)(event->GetHCofThisEvent()->GetHC(astronautCollectionID)); 00065 else G4cout << "Collection `AstronautCollection' not found !!!!" << G4endl; 00066 00067 // -- Question : why do we need to cast (AstroHitCollection*) two lines above ? 00068 00069 // -------------------------------------------- 00070 // -- print hits found for the 5 first events: 00071 // -------------------------------------------- 00072 if (event->GetEventID() < 5) 00073 { 00074 G4cout << "Event::EndOfEventAction(...) for event # " << event->GetEventID() << " : " << G4endl; 00075 // -- get back detector pointer to get astronaut mass: 00076 DetectorConstruction* detector = (DetectorConstruction*)(G4RunManager::GetRunManager()->GetUserDetectorConstruction()); 00077 G4double mass = detector->GetAstronaut()->GetLogicalVolume()->GetMass(); 00078 if (astroCollection) 00079 { 00080 // -- Now print: 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 // -- fill the RunAction table for SD vector: 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 // -- scorer 00113 // ---------------------------------------------- 00114 // -- read back edep "collection" from scorer: 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 // -- read back track counter "collection" from scorer: 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 }
void EventAction::AddEdep | ( | G4double | edep | ) | [inline] |
Definition at line 26 of file EventAction.hh.
Referenced by SteppingAction::UserSteppingAction().
00026 {m_edepPerEvent += edep;};
RunAction* EventAction::m_runAction [private] |
G4double EventAction::m_edepPerEvent [private] |
Definition at line 30 of file EventAction.hh.
Referenced by BeginOfEventAction(), and EndOfEventAction().
G4int EventAction::m_printModulo [private] |