print hits at the end of event

parent 89e565e9
......@@ -29,9 +29,16 @@
#include "B1EventAction.hh"
#include "B1RunAction.hh"
#include "B1Hits.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "G4EventManager.hh"
#include "G4HCofThisEvent.hh"
#include "G4VHitsCollection.hh"
#include "G4SDManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4ios.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
......@@ -39,7 +46,7 @@ B1EventAction::B1EventAction(B1RunAction* runAction)
: G4UserEventAction(),
fRunAction(runAction),
fEdep(0.)
{}
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
......@@ -48,17 +55,40 @@ B1EventAction::~B1EventAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1EventAction::BeginOfEventAction(const G4Event*)
{
void B1EventAction::BeginOfEventAction(const G4Event* event)
{
fEdep = 0.;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B1EventAction::EndOfEventAction(const G4Event*)
{
void B1EventAction::EndOfEventAction(const G4Event* event)
{
// accumulate statistics in run action
fRunAction->AddEdep(fEdep);
static int CHCID = -1;
if (CHCID < 0) {
CHCID = G4SDManager::GetSDMpointer()->GetCollectionID("HitCollection");//Descobrir isso
}
G4HCofThisEvent* HCE = event->GetHCofThisEvent();
B1HitsCollection* HitsCol = 0;
if(HCE) {
HitsCol = (B1HitsCollection*)(HCE->GetHC(CHCID));
}
if(HitsCol) {
int n_hit = HitsCol->entries();
G4cout << "My detector has " << n_hit << "hits" << G4endl;
for(int i1 = 0; i1 < n_hit; i1++) {
B1Hits* hit = (*HitsCol)[i1];
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment