ATLAS Offline Software
TestActionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Main header include
6 #include "TestActionTool.h"
7 
8 // Geant4 includes
9 #include "G4ios.hh"
10 
11 namespace G4UA
12 {
13 
14  //---------------------------------------------------------------------------
15  // TestAction constructor
16  //---------------------------------------------------------------------------
18  {}
19 
20  //---------------------------------------------------------------------------
21  // Begin of G4 run method
22  //---------------------------------------------------------------------------
23  void TestAction::BeginOfRunAction(const G4Run*)
24  {
25  G4cout << "TestAction::BeginOfRunAction" << G4endl;
26  }
27 
28  //---------------------------------------------------------------------------
29  // End of G4 run method
30  //---------------------------------------------------------------------------
31  void TestAction::EndOfRunAction(const G4Run*)
32  {
33  G4cout << "TestAction::EndOfRunAction - "
34  << m_report.numEvent << " events processed, "
35  << m_report.numStep << " steps processed"
36  << G4endl;
37  }
38 
39  //---------------------------------------------------------------------------
40  // Begin of G4 event method
41  //---------------------------------------------------------------------------
42  void TestAction::BeginOfEventAction(const G4Event*)
43  {
44  G4cout << "TestAction::BeginOfEventAction" << G4endl;
46  }
47 
48  //---------------------------------------------------------------------------
49  // End of G4 event method
50  //---------------------------------------------------------------------------
51  void TestAction::EndOfEventAction(const G4Event*)
52  {
53  G4cout << "TestAction::EndOfEventAction" << G4endl;
54  }
55 
56  //---------------------------------------------------------------------------
57  // G4 stepping method
58  //---------------------------------------------------------------------------
59  void TestAction::UserSteppingAction(const G4Step*)
60  {
61  m_report.numStep++;
62  }
63 
64  //---------------------------------------------------------------------------
65  // Constructor
66  //---------------------------------------------------------------------------
68  const std::string& name,
69  const IInterface* parent)
71  {
72  }
73 
74  //---------------------------------------------------------------------------
75  // Initialize the tool
76  //---------------------------------------------------------------------------
78  {
79  ATH_MSG_INFO( "Initializing " << name() );
80  return StatusCode::SUCCESS;
81  }
82 
83  //---------------------------------------------------------------------------
84  // Finalize the tool
85  //---------------------------------------------------------------------------
87  {
88  ATH_MSG_INFO( "Finalizing " << name() );
89 
90  // Accumulate results across threads
94  ATH_MSG_INFO("Final accumulated results: " <<
95  results.numEvent << " events processed, " <<
96  results.numStep << " steps processed");
97 
98  return StatusCode::SUCCESS;
99  }
100 
101  //---------------------------------------------------------------------------
102  // Construct and fill the user action
103  //---------------------------------------------------------------------------
104  std::unique_ptr<TestAction>
106  {
107  ATH_MSG_INFO("Constructing and filling a TestAction");
108 
109  auto action = std::make_unique<TestAction>();
110  actions.runActions.push_back( action.get() );
111  actions.eventActions.push_back( action.get() );
112  actions.steppingActions.push_back( action.get() );
113  return action;
114  }
115 
116 } // namespace G4UA
G4UA::TestAction::BeginOfRunAction
virtual void BeginOfRunAction(const G4Run *) override final
Executes before the run.
Definition: TestActionTool.cxx:23
G4UA::G4AtlasUserActions
Struct for passing around user actions.
Definition: IUserActionTool.h:32
G4UA::TestAction::TestAction
TestAction()
Constructor.
Definition: TestActionTool.cxx:17
verify_menu_config.results
results
Definition: verify_menu_config.py:67
G4UA::TestAction::getReport
const Report & getReport() const
Get the results report.
Definition: TestActionTool.h:64
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
G4UA::TestAction::UserSteppingAction
virtual void UserSteppingAction(const G4Step *step) override final
Stepping action method.
Definition: TestActionTool.cxx:59
G4UA
for nSW
Definition: CalibrationDefaultProcessing.h:19
G4UA::TestAction::m_report
Report m_report
Results report.
Definition: TestActionTool.h:70
G4UA::ThreadSpecificUserAction::accumulate
void accumulate(ResultType &result, Mapper mapOp, Reducer reduceOp)
Accumulate results across user actions with specified operations.
Definition: ThreadSpecificUserAction.h:88
G4UA::TestActionTool::TestActionTool
TestActionTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: TestActionTool.cxx:67
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
G4UA::UserActionToolBase< TestAction >::m_actions
ThreadSpecificUserAction< TestAction > m_actions
Thread-specific storage of the user action.
Definition: UserActionToolBase.h:63
G4UA::TestAction::Report::numEvent
int numEvent
Definition: TestActionTool.h:37
test_pyathena.parent
parent
Definition: test_pyathena.py:15
G4UA::TestAction::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override final
Executes at end of G4 event.
Definition: TestActionTool.cxx:51
G4UA::TestActionTool::initialize
virtual StatusCode initialize() override final
Initialize the tool.
Definition: TestActionTool.cxx:77
G4UA::TestAction::Report::numStep
int numStep
Definition: TestActionTool.h:38
TestActionTool.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
G4UA::G4AtlasUserActions::runActions
std::vector< G4UserRunAction * > runActions
Definition: IUserActionTool.h:33
G4UA::UserActionToolBase
abstract template utility base-class for G4 user-action tools.
Definition: UserActionToolBase.h:33
G4UA::TestAction::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *) override final
Executes at beginning of G4 event.
Definition: TestActionTool.cxx:42
G4UA::TestAction
Definition: TestActionTool.h:30
python.CaloScaleNoiseConfig.action
action
Definition: CaloScaleNoiseConfig.py:77
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
G4UA::TestAction::Report
Results to be accumulated across threads at end of job.
Definition: TestActionTool.h:36
G4UA::G4AtlasUserActions::eventActions
std::vector< G4UserEventAction * > eventActions
Definition: IUserActionTool.h:34
G4UA::TestActionTool::makeAndFillAction
virtual std::unique_ptr< TestAction > makeAndFillAction(G4AtlasUserActions &actions) override final
Fill user action.
Definition: TestActionTool.cxx:105
G4UA::G4AtlasUserActions::steppingActions
std::vector< G4UserSteppingAction * > steppingActions
Definition: IUserActionTool.h:36
G4UA::TestActionTool::finalize
virtual StatusCode finalize() override final
Finalize the tool.
Definition: TestActionTool.cxx:86
G4UA::TestAction::EndOfRunAction
virtual void EndOfRunAction(const G4Run *) override final
Exeuctes after the run.
Definition: TestActionTool.cxx:31
G4UA::TestAction::Report::merge
void merge(const Report &other)
Definition: TestActionTool.h:39