fixed errors

This commit is contained in:
AndreaRigoni
2026-03-25 20:30:46 +00:00
parent 6a65fe94c8
commit e4a8499104
17 changed files with 344 additions and 269 deletions

View File

@@ -17,6 +17,14 @@ DetectorActionInitialization::DetectorActionInitialization(EmitterPrimary *emitt
{}
DetectorActionInitialization::~DetectorActionInitialization() {}
class DetectorSteppingActionWrapper : public G4UserSteppingAction {
public:
DetectorSteppingActionWrapper(DetectorSteppingAction *real) : m_Real(real) {}
virtual void UserSteppingAction(const G4Step* step) override { m_Real->UserSteppingAction(step); }
private:
DetectorSteppingAction *m_Real;
};
void DetectorActionInitialization::BuildForMaster() const {}
@@ -34,8 +42,10 @@ void DetectorActionInitialization::Build() const {
if (m_Output) {
DetectorSteppingAction *sa = new DetectorSteppingAction(m_Output, m_Planes);
sa->SetVerbosity(m_Verbosity);
SetUserAction(static_cast<G4UserSteppingAction*>(sa));
// EventManager will delete sa via the Event slot
SetUserAction(static_cast<G4UserEventAction*>(sa));
// EventManager will delete the wrapper, leaving sa alive for the other deletion.
SetUserAction(new DetectorSteppingActionWrapper(sa));
}
}