G4-DESCSS/src/EventAction.cpp

22 lines
726 B
C++

#include "EventAction.h"
#include "G4HumanPhantomHit.h"
#include "RunAction.h"
#include "G4Event.hh"
#include "G4VHitsCollection.hh"
EventAction::EventAction(RunAction* runAction) : fRunAction(runAction) {}
EventAction::~EventAction() {}
void EventAction::BeginOfEventAction(const G4Event*) { fEdep.clear(); }
void EventAction::EndOfEventAction(const G4Event* event) {
G4HumanPhantomHitsCollection* hc = (G4HumanPhantomHitsCollection*)event->GetHCofThisEvent()->GetHC(0);
int numHits = hc->entries();
for (int i = 0; i < numHits; i++) {
G4String name = (*hc)[0]->GetBodyPartID();
fEdep[name] += (*hc)[i]->GetEdep();
}
if (numHits > 0) fRunAction->AddEdep(fEdep);
}