#include "event.hh" #include "run.hh" #include "G4Event.hh" #include "G4EventManager.hh" #include "CLHEP/Units/SystemOfUnits.h" #include "G4AnalysisManager.hh" #include "G4SDManager.hh" #include "G4HCofThisEvent.hh" #include "G4ThreeVector.hh" #include "TFile.h" #include "TNtuple.h" #include "G4SDManager.hh" #include "G4ThreeVector.hh" #include "G4PrimaryVertex.hh" #include "G4PrimaryParticle.hh" #include "G4Track.hh" #include "G4RunManager.hh" #include "G4Track.hh" #include "G4Step.hh" #include "G4SystemOfUnits.hh" #include "G4VProcess.hh" #include "G4VTrajectoryPoint.hh" /* * MyEventAction::MyEventAction(MyRunAction* runAction) : G4UserEventAction(), fRunAction(runAction), fEdep(0.) { //fEdep = 0.; } */ MyEventAction::MyEventAction() {} MyEventAction::~MyEventAction() {} void MyEventAction::BeginOfEventAction(const G4Event*) { // fEdep = 0.; //G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); //analysisManager->OpenFile("output.root"); } void MyEventAction::EndOfEventAction(const G4Event* event) { // Retrieve the proton trajectory data G4TrajectoryContainer* trajectoryContainer = event->GetTrajectoryContainer(); if (!trajectoryContainer) return; G4int n_trajectories = trajectoryContainer->entries(); if (n_trajectories == 0) return; G4VTrajectory* trajectory = (*trajectoryContainer)[n_trajectories - 1]; G4int n_points = trajectory->GetPointEntries(); if (n_points == 0) return; G4ThreeVector position = trajectory->GetPoint(n_points - 1)->GetPosition(); //fRunAction->AddEventInfo(eventID, fEdep, position); TFile* rootFile = TFile::Open("output.root", "UPDATE"); TNtuple* ntuple = (TNtuple*)rootFile->Get("trajectory"); ntuple->Fill(position.x(), position.y(), position.z()); rootFile->Write(); rootFile->Close(); } /* * * void MyEventAction::AddEdep(G4double edep) { fEdep += edep; } */