Skip to content

Commit

Permalink
event & generator actions - just run action then I can test
Browse files Browse the repository at this point in the history
  • Loading branch information
tdealtry committed Apr 26, 2024
1 parent 43edd1a commit 2ea67de
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ hk_add_tool(HKG4TrackingAction)
hk_add_tool(HKG4StackingAction)
hk_add_tool(HKG4PhysicsList)
hk_add_tool(HKG4SteppingAction)
hk_add_tool(HKG4PrimaryGeneratorAction)
hk_add_tool(HKG4EventAction)

option(WCSIM_Check_Geometry_Overlaps
"Toggle WCSim to save photon scattering and reflection history"
Expand Down
44 changes: 44 additions & 0 deletions HKG4EventAction/HKG4EventAction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "HKG4EventAction.h"

#include "WCSimEventAction.hh"
#include "WCSimPrimaryGeneratorAction.hh"
#include "WCSimDetectorConstruction.hh"
#include "WCSimRunAction.hh"

using namespace HK::Ghost::G4;

HKG4EventAction::HKG4EventAction() : Tool() {}

bool HKG4EventAction::Initialise(std::string configfile, DataModel& data) {

if(configfile != "")
m_variables.Initialise(configfile);
// m_variables.Print();

m_data = &data;
m_log = m_data->Log;

if(!m_variables.Get("verbose", m_verbose))
m_verbose = 1;

const WCSimRunAction* cp_run =
static_cast<const WCSimRunAction*>(m_data->m_p_run_manager->GetUserRunAction());
const WCSimDetectorConstruction* cp_det =
static_cast<const WCSimDetectorConstruction*>(m_data->m_p_run_manager->GetUserDetectorConstruction());
const WCSimPrimaryGeneratorAction* cp_gen =
static_cast<const WCSimPrimaryGeneratorAction*>(m_data->m_p_run_manager->GetUserPrimaryGeneratorAction());

m_data->m_p_run_manager->SetUserAction(new WCSimEventAction(cp_run, cp_det, cp_gen));

return true;
}

bool HKG4EventAction::Execute() {

return true;
}

bool HKG4EventAction::Finalise() {

return true;
}
42 changes: 42 additions & 0 deletions HKG4EventAction/HKG4EventAction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef HKG4EventAction_H
#define HKG4EventAction_H

#include <iostream>
#include <string>

#include <DataModel.h>
#include "Tool.h"

/**
* \class HKG4EventAction
*
* This is a blank template for a Tool used by the script to generate a new custom tool. Please fill out the
* description and author information.
*
* $Author: B.Richards $
* $Date: 2019/05/28 10:44:00 $
*/

namespace HK {
namespace Ghost {
namespace G4 {
class HKG4EventAction : public Tool {

public:

HKG4EventAction(); ///< Simple constructor
bool Initialise(std::string configfile,
DataModel& data); ///< Initialise Function for setting up Tool resources. @param
///< configfile The path and name of the dynamic configuration file
///< to read in. @param data A reference to the transient data
///< class used to pass information between Tools.
bool Execute(); ///< Execute function used to perform Tool purpose.
bool Finalise(); ///< Finalise funciton used to clean up resources.

private:
};
} // namespace G4
} // namespace Ghost
} // namespace HK

#endif
1 change: 1 addition & 0 deletions HKG4EventAction/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# HKG4EventAction
34 changes: 34 additions & 0 deletions HKG4PrimaryGeneratorAction/HKG4PrimaryGeneratorAction.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "HKG4PrimaryGeneratorAction.h"

#include "WCSimPrimaryGeneratorAction.hh"

using namespace HK::Ghost::G4;

HKG4PrimaryGeneratorAction::HKG4PrimaryGeneratorAction() : Tool() {}

bool HKG4PrimaryGeneratorAction::Initialise(std::string configfile, DataModel& data) {

if(configfile != "")
m_variables.Initialise(configfile);
// m_variables.Print();

m_data = &data;
m_log = m_data->Log;

if(!m_variables.Get("verbose", m_verbose))
m_verbose = 1;

m_data->m_p_run_manager->SetUserAction(new WCSimPrimaryGeneratorAction(static_cast<const WCSimDetectorConstruction*>(m_data->m_p_run_manager->GetUserDetectorConstruction())));

return true;
}

bool HKG4PrimaryGeneratorAction::Execute() {

return true;
}

bool HKG4PrimaryGeneratorAction::Finalise() {

return true;
}
42 changes: 42 additions & 0 deletions HKG4PrimaryGeneratorAction/HKG4PrimaryGeneratorAction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef HKG4PrimaryGeneratorAction_H
#define HKG4PrimaryGeneratorAction_H

#include <iostream>
#include <string>

#include <DataModel.h>
#include "Tool.h"

/**
* \class HKG4PrimaryGeneratorAction
*
* This is a blank template for a Tool used by the script to generate a new custom tool. Please fill out the
* description and author information.
*
* $Author: B.Richards $
* $Date: 2019/05/28 10:44:00 $
*/

namespace HK {
namespace Ghost {
namespace G4 {
class HKG4PrimaryGeneratorAction : public Tool {

public:

HKG4PrimaryGeneratorAction(); ///< Simple constructor
bool Initialise(std::string configfile,
DataModel& data); ///< Initialise Function for setting up Tool resources. @param
///< configfile The path and name of the dynamic configuration file
///< to read in. @param data A reference to the transient data
///< class used to pass information between Tools.
bool Execute(); ///< Execute function used to perform Tool purpose.
bool Finalise(); ///< Finalise funciton used to clean up resources.

private:
};
} // namespace G4
} // namespace Ghost
} // namespace HK

#endif
1 change: 1 addition & 0 deletions HKG4PrimaryGeneratorAction/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# HKG4PrimaryGeneratorAction
6 changes: 3 additions & 3 deletions WCSim_exe/WCSim_exe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ bool WCSim_exe::Initialise(std::string configfile, DataModel& data) {
m_data->m_p_run_manager->SetUserInitialization(WCSimdetector);

// Set user action classes
WCSimPrimaryGeneratorAction* myGeneratorAction = new WCSimPrimaryGeneratorAction(WCSimdetector);
m_data->m_p_run_manager->SetUserAction(myGeneratorAction);
//WCSimPrimaryGeneratorAction* myGeneratorAction = new WCSimPrimaryGeneratorAction(WCSimdetector);
//m_data->m_p_run_manager->SetUserAction(myGeneratorAction);

WCSimRunAction* myRunAction = new WCSimRunAction(WCSimdetector, randomparameters);

Expand All @@ -91,7 +91,7 @@ bool WCSim_exe::Initialise(std::string configfile, DataModel& data) {

m_data->m_p_run_manager->SetUserAction(myRunAction);

m_data->m_p_run_manager->SetUserAction(new WCSimEventAction(myRunAction, WCSimdetector, myGeneratorAction));
//m_data->m_p_run_manager->SetUserAction(new WCSimEventAction(myRunAction, WCSimdetector, myGeneratorAction));
//m_data->m_p_run_manager->SetUserAction(new WCSimTrackingAction);

//m_data->m_p_run_manager->SetUserAction(new WCSimStackingAction(WCSimdetector));
Expand Down

0 comments on commit 2ea67de

Please sign in to comment.