UserAction.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file UserAction.h
3 /// \brief see below
4 ///
5 /// \version $Id: UserAction.h,v 1.4 2012-09-20 21:47:05 greenc Exp $
6 /// \author seligman@nevis.columbia.edu, brebel@fnal.gov, rhatcher@fnal.gov
7 ////////////////////////////////////////////////////////////////////////
8 /// G4Base::UserAction.h
9 /// 1-Sep-1999 Bill Seligman
10 ///
11 /// 27-Jan-2009 <seligman@nevis.columbia.edu> Revised for LArSoft.
12 ///
13 /// 2012-08-17 <rhatcher@fnal.gov> Add G4UserStackingAction-like interfaces
14 ///
15 /// This is an abstract base class to be used with Geant 4.0.1 (and
16 /// possibly higher, if the User classes don't change).
17 ///
18 /// Why is this interface useful? Answer: Geant4 provides several
19 /// classes that are meant to be "user hooks" in G4 processing. A
20 /// couple of examples are G4UserRunAction and G4EventAction. The user
21 /// is meant to publically inherit from these classes in order to
22 /// perform tasks at the beginning and ending of run or event
23 /// processing.
24 ///
25 /// However, typical tasks that physicists perform generally involve
26 /// more than one user-hook class. For example, to make histograms, a
27 /// physicist might define the histograms at the beginning of a run,
28 /// fill the histograms after each event, and write the histograms at
29 /// the end of a run.
30 ///
31 /// It's handy to have all the code for such tasks (making histograms,
32 /// studying G4 tracking, event persistency) all in one class, rather
33 /// than split between two or three different classes. That's where
34 /// UserAction comes in. It gathers all the G4 user-hook or
35 /// user-action classes into one place.
36 
37 #ifndef G4BASE_UserAction_H
38 #define G4BASE_UserAction_H
39 
40 // The following objects are the arguments to the methods
41 // invoked in the user action classes. In other words, they
42 // contain the variables that we are normally able to record
43 // in Geant.
44 
45 class G4Run;
46 class G4Event;
47 class G4Track;
48 class G4Step;
49 #include "Geant4/G4ClassificationOfNewTrack.hh"
50 
51 #include <string>
52 #include "fhiclcpp/ParameterSet.h"
53 
54 namespace g4b {
55 
56  class UserAction {
57 
58  public:
59 
60  UserAction() {};
61  UserAction(fhicl::ParameterSet const& pset) { Config(pset); }
62  virtual ~UserAction() {};
63 
64  /// Override Config() to extract any necessary parameters
65  virtual void Config(fhicl::ParameterSet const& /* pset */ ) {};
66 
67  /// Override PrintConfig() to print out current configuration
68  virtual void PrintConfig(std::string const& /* opt */ ) {};
69 
70  /// The following a list of methods that correspond to the available
71  /// user action classes in Geant 4.0.1 and higher.
72 
73  /// G4UserRunAction interfaces
74  virtual void BeginOfRunAction (const G4Run* ) {};
75  virtual void EndOfRunAction (const G4Run* ) {};
76 
77  /// G4UserEventAction interfaces
78  virtual void BeginOfEventAction(const G4Event*) {};
79  virtual void EndOfEventAction (const G4Event*) {};
80 
81  /// G4UserTrackingAction interfaces
82  virtual void PreTrackingAction (const G4Track*) {};
83  virtual void PostTrackingAction(const G4Track*) {};
84 
85  /// G4UserSteppingAction interface
86  virtual void SteppingAction (const G4Step* ) {};
87 
88  /// Does this UserAction do stacking?
89  /// Override to return "true" if the following interfaces are implemented
90  virtual bool ProvidesStacking() { return false; }
91  /// G4UserStackingAction interfaces
92  virtual G4ClassificationOfNewTrack
93  StackClassifyNewTrack(const G4Track*) { return fUrgent; }
94  virtual void StackNewStage() {};
95  virtual void StackPrepareNewEvent() {};
96 
97  // allow self-identification
98  std::string const & GetName() const { return myName; }
99  void SetName(std::string const& name) { myName = name; }
100  private:
101  std::string myName; ///< self-knowledge
102  };
103 
104 } // namespace g4b
105 
106 #endif // G4BASE_UserAction_H
static QCString name
Definition: declinfo.cpp:673
virtual void StackPrepareNewEvent()
Definition: UserAction.h:95
UserAction(fhicl::ParameterSet const &pset)
Definition: UserAction.h:61
virtual void PreTrackingAction(const G4Track *)
G4UserTrackingAction interfaces.
Definition: UserAction.h:82
std::string string
Definition: nybbler.cc:12
virtual void EndOfRunAction(const G4Run *)
Definition: UserAction.h:75
virtual void BeginOfEventAction(const G4Event *)
G4UserEventAction interfaces.
Definition: UserAction.h:78
std::string myName
self-knowledge
Definition: UserAction.h:101
virtual void BeginOfRunAction(const G4Run *)
G4UserRunAction interfaces.
Definition: UserAction.h:74
virtual bool ProvidesStacking()
Definition: UserAction.h:90
virtual ~UserAction()
Definition: UserAction.h:62
virtual void StackNewStage()
Definition: UserAction.h:94
virtual G4ClassificationOfNewTrack StackClassifyNewTrack(const G4Track *)
G4UserStackingAction interfaces.
Definition: UserAction.h:93
void SetName(std::string const &name)
Definition: UserAction.h:99
std::string const & GetName() const
Definition: UserAction.h:98
basic interface to Geant4 for ART-based software
virtual void Config(fhicl::ParameterSet const &)
Override Config() to extract any necessary parameters.
Definition: UserAction.h:65
virtual void SteppingAction(const G4Step *)
G4UserSteppingAction interface.
Definition: UserAction.h:86
virtual void PostTrackingAction(const G4Track *)
Definition: UserAction.h:83
virtual void EndOfEventAction(const G4Event *)
Definition: UserAction.h:79
virtual void PrintConfig(std::string const &)
Override PrintConfig() to print out current configuration.
Definition: UserAction.h:68