54 lines
1.8 KiB
C++
54 lines
1.8 KiB
C++
#include "DetectorActionInitialization.hh"
|
|
#include "EmitterPrimary.hh"
|
|
#include "DetectorSteppingAction.hh"
|
|
|
|
namespace uLib {
|
|
namespace Geant {
|
|
|
|
DetectorActionInitialization::DetectorActionInitialization(EmitterPrimary *emitter,
|
|
Vector<MuonEvent> *output,
|
|
const Vector<HLine3f> &planes,
|
|
int verbosity)
|
|
: G4VUserActionInitialization(),
|
|
m_Emitter(emitter),
|
|
m_Output(output),
|
|
m_Planes(planes),
|
|
m_Verbosity(verbosity)
|
|
{}
|
|
|
|
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 {}
|
|
|
|
void DetectorActionInitialization::Build() const {
|
|
if (m_Verbosity > 0) {
|
|
std::cout << "[Geant] Worker thread Building actions... Output ptr: " << m_Output
|
|
<< ", Planes count: " << m_Planes.size() << std::endl;
|
|
}
|
|
if (m_Emitter) {
|
|
SetUserAction(m_Emitter->Clone());
|
|
} else {
|
|
SetUserAction(new EmitterPrimary());
|
|
}
|
|
|
|
if (m_Output) {
|
|
DetectorSteppingAction *sa = new DetectorSteppingAction(m_Output, m_Planes);
|
|
sa->SetVerbosity(m_Verbosity);
|
|
// 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));
|
|
}
|
|
}
|
|
|
|
} // namespace Geant
|
|
} // namespace uLib
|