LDMX Software
UserAction.h
Go to the documentation of this file.
1
6#ifndef SIMCORE_USERACTION_H
7#define SIMCORE_USERACTION_H
8
9/*~~~~~~~~~~~~~~~~*/
10/* C++ StdLib */
11/*~~~~~~~~~~~~~~~~*/
12#include <iostream>
13#include <map>
14#include <string>
15#include <vector>
16
17/*~~~~~~~~~~~~*/
18/* Geant4 */
19/*~~~~~~~~~~~~*/
20#include "G4EventManager.hh"
21#include "G4UserStackingAction.hh"
22
23/*~~~~~~~~~~~~~~~*/
24/* Framework */
25/*~~~~~~~~~~~~~~~*/
26#include "Framework/Configure/Parameters.h"
27#include "Framework/Factory.h"
28#include "Framework/Logger.h"
29#include "SimCore/Event/SimParticle.h"
30#include "SimCore/G4User/UserEventInformation.h"
31
32// Forward Declarations
33class G4Event;
34class G4Run;
35class G4Step;
36class G4Track;
37
38namespace simcore {
39
41enum TYPE { RUN = 1, EVENT, TRACKING, STEPPING, STACKING, NONE };
42
48 public:
54 UserAction(const std::string& name,
56
58 DECLARE_FACTORY(UserAction, std::shared_ptr<UserAction>, const std::string&,
60
62 virtual ~UserAction() = default;
63
71 virtual void BeginOfEventAction(const G4Event*) {};
72
80 virtual void EndOfEventAction(const G4Event*) {};
81
89 virtual void BeginOfRunAction(const G4Run*) {};
90
98 virtual void EndOfRunAction(const G4Run*) {};
99
107 virtual void PreUserTrackingAction(const G4Track*) {};
108
116 virtual void PostUserTrackingAction(const G4Track*) {};
117
125 virtual void stepping(const G4Step*) {};
126
135 virtual G4ClassificationOfNewTrack ClassifyNewTrack(
136 const G4Track*, const G4ClassificationOfNewTrack& cl) {
137 return cl;
138 };
139
145 virtual void NewStage() {};
146
152 virtual void PrepareNewEvent() {};
153
159 virtual std::vector<TYPE> getTypes() = 0;
160
161 protected:
173
181 const std::map<int, ldmx::SimParticle>& getCurrentParticleMap() const;
182
183 protected:
185 std::string name_{""};
186
189
191 mutable ::framework::logging::logger the_log_;
192
193}; // UserAction
194
195} // namespace simcore
196
206#define DECLARE_ACTION(CLASS) FACTORY_REGISTRATION(simcore::UserAction, CLASS)
207
208#endif // SIMCORE_USERACTION_H
Header holding Factory class and supporting macros.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
Interface that defines a user action.
Definition UserAction.h:47
virtual void stepping(const G4Step *)
Method called after each simulation step.
Definition UserAction.h:125
virtual void PrepareNewEvent()
Method called at the beginning of a new event.
Definition UserAction.h:152
virtual void BeginOfEventAction(const G4Event *)
Method called at the beginning of every event.
Definition UserAction.h:71
mutable::framework::logging::logger the_log_
the logging channel user actions can use ldmx_log with
Definition UserAction.h:191
virtual void EndOfRunAction(const G4Run *)
Method called at the end of a run.
Definition UserAction.h:98
virtual ~UserAction()=default
Destructor.
DECLARE_FACTORY(UserAction, std::shared_ptr< UserAction >, const std::string &, framework::config::Parameters &)
factory for user actions
UserAction(const std::string &name, framework::config::Parameters &parameters)
Constructor.
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *, const G4ClassificationOfNewTrack &cl)
Method called when a track is updated.
Definition UserAction.h:135
virtual void PreUserTrackingAction(const G4Track *)
Method called before the UserTrackingAction.
Definition UserAction.h:107
virtual void BeginOfRunAction(const G4Run *)
Method called at the beginning of a run.
Definition UserAction.h:89
const std::map< int, ldmx::SimParticle > & getCurrentParticleMap() const
Get the current particle map.
virtual void EndOfEventAction(const G4Event *)
Method called at the end of every event.
Definition UserAction.h:80
virtual std::vector< TYPE > getTypes()=0
UserEventInformation * getEventInfo() const
Get a handle to the event information.
virtual void NewStage()
Method called at the beginning of a new stage.
Definition UserAction.h:145
virtual void PostUserTrackingAction(const G4Track *)
Method called after the UserTrackingAction.
Definition UserAction.h:116
std::string name_
Name of the UserAction.
Definition UserAction.h:185
framework::config::Parameters parameters_
The set of parameters used to configure this class.
Definition UserAction.h:188
Encapsulates user defined information associated with a Geant4 event.
Dynamically loadable photonuclear models either from SimCore or external libraries implementing this ...
TYPE
Enum for each of the user action types.
Definition UserAction.h:41