Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: embed SEvt into G4App #37

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
ignore: |
include/argparse
thread-comments: true
format-review: true
tidy-checks: '-*'

- name: Fail fast?!
Expand Down
29 changes: 22 additions & 7 deletions src/simg4ox.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <filesystem>

Check notice on line 1 in src/simg4ox.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

Run clang-format on src/simg4ox.cpp

File src/simg4ox.cpp does not conform to Microsoft style guidelines. (lines 45, 75, 117, 152, 208, 284, 286, 287)
#include <iostream>
#include <string>

Expand Down Expand Up @@ -44,7 +44,6 @@

using namespace std;

SEvt *sev = nullptr;

plexoos marked this conversation as resolved.
Show resolved Hide resolved
plexoos marked this conversation as resolved.
Show resolved Hide resolved
struct DetectorConstruction : G4VUserDetectorConstruction
{
Expand All @@ -71,6 +70,9 @@

struct PrimaryGenerator : G4VUserPrimaryGeneratorAction
{
SEvt *sev;

PrimaryGenerator(SEvt *sev) : sev(sev) {}
plexoos marked this conversation as resolved.
Show resolved Hide resolved

void GeneratePrimaries(G4Event *event) override
{
Expand Down Expand Up @@ -110,6 +112,9 @@

struct EventAction : G4UserEventAction
{
SEvt *sev;

EventAction(SEvt *sev) : sev(sev) {}
plexoos marked this conversation as resolved.
Show resolved Hide resolved

void BeginOfEventAction(const G4Event *event) override
{
Expand Down Expand Up @@ -142,6 +147,9 @@

struct SteppingAction : G4UserSteppingAction
{
SEvt *sev;

SteppingAction(SEvt *sev) : sev(sev) {}
plexoos marked this conversation as resolved.
Show resolved Hide resolved

void UserSteppingAction(const G4Step *step)
{
Expand Down Expand Up @@ -195,6 +203,9 @@
struct TrackingAction : G4UserTrackingAction
{
const G4Track *transient_fSuspend_track = nullptr;
SEvt *sev;

TrackingAction(SEvt *sev) : sev(sev) {}
plexoos marked this conversation as resolved.
Show resolved Hide resolved

void PreUserTrackingAction_Optical_FabricateLabel(const G4Track *track)
{
Expand Down Expand Up @@ -270,16 +281,23 @@
struct G4App
{
G4App(filesystem::path gdml_file)
: det_cons_(new DetectorConstruction(gdml_file)), prim_gen_(new PrimaryGenerator),
stepping_(new SteppingAction), tracking_(new TrackingAction), event_act_(new EventAction)
: sev(SEvt::HighLevelCreate(SEvt::ECPU)),
det_cons_(new DetectorConstruction(gdml_file)),
prim_gen_(new PrimaryGenerator(sev)),
event_act_(new EventAction(sev)),
stepping_(new SteppingAction(sev)),
plexoos marked this conversation as resolved.
Show resolved Hide resolved
tracking_(new TrackingAction(sev))
{
}

// Create "global" event
SEvt *sev;

G4VUserDetectorConstruction *det_cons_;
G4VUserPrimaryGeneratorAction *prim_gen_;
EventAction *event_act_;
SteppingAction *stepping_;
TrackingAction *tracking_;
EventAction *event_act_;
};

int main(int argc, char **argv)
Expand Down Expand Up @@ -317,9 +335,6 @@
exit(EXIT_FAILURE);
}

// Create global event
sev = SEvt::HighLevelCreate(SEvt::ECPU);

// Configure Geant4
// The physics list must be instantiated before other user actions
G4VModularPhysicsList *physics = new FTFP_BERT;
Expand Down
Loading