LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
artg4tk::ActionHolderService Class Reference

#include "ActionHolder_service.hh"

Public Member Functions

 ActionHolderService (fhicl::ParameterSet const &)
 
void registerAction (RunActionBase *const action)
 
void registerAction (EventActionBase *const action)
 
void registerAction (TrackingActionBase *const action)
 
void registerAction (SteppingActionBase *const action)
 
void registerAction (StackingActionBase *const action)
 
void registerAction (PrimaryGeneratorActionBase *const action)
 
void initialize ()
 
void callArtProduces (art::ProducesCollector &prod)
 
void setCurrArtEvent (art::Event &e)
 
art::EventgetCurrArtEvent ()
 
void setCurrArtRun (art::Run &r)
 
art::RungetCurrArtRun ()
 
void beginOfEventAction (const G4Event *)
 
void endOfEventAction (const G4Event *)
 
void preUserTrackingAction (const G4Track *)
 
void postUserTrackingAction (const G4Track *)
 
void userSteppingAction (const G4Step *)
 
bool killNewTrack (const G4Track *)
 
void generatePrimaries (G4Event *)
 

Private Member Functions

template<typename A >
void doRegisterAction (A *const action, std::map< std::string, A * > &actionMap)
 

Private Attributes

std::map< std::string, RunActionBase * > runActionsMap_ {}
 
std::map< std::string, EventActionBase * > eventActionsMap_ {}
 
std::map< std::string, TrackingActionBase * > trackingActionsMap_ {}
 
std::map< std::string, SteppingActionBase * > steppingActionsMap_ {}
 
std::map< std::string, StackingActionBase * > stackingActionsMap_ {}
 
std::map< std::string, PrimaryGeneratorActionBase * > primaryGeneratorActionsMap_ {}
 
art::EventcurrentArtEvent_ {nullptr}
 
art::RuncurrentArtRun_ {nullptr}
 
std::map< std::string, ActionBase * > allActionsMap_ {}
 

Detailed Description

Definition at line 46 of file ActionHolder_service.hh.

Constructor & Destructor Documentation

artg4tk::ActionHolderService::ActionHolderService ( fhicl::ParameterSet const &  )
explicit

Definition at line 31 of file ActionHolder.cc.

31 {}

Member Function Documentation

void artg4tk::ActionHolderService::beginOfEventAction ( const G4Event *  theEvent)

Definition at line 122 of file ActionHolder.cc.

References eventActionsMap_, and util::values().

Referenced by artg4tk::ArtG4EventAction::BeginOfEventAction().

123 {
124  for (auto action : eventActionsMap_ | values) {
125  action->beginOfEventAction(theEvent);
126  }
127 }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
std::map< std::string, EventActionBase * > eventActionsMap_
void artg4tk::ActionHolderService::callArtProduces ( art::ProducesCollector prod)

Definition at line 103 of file ActionHolder.cc.

References eventActionsMap_, and util::values().

104 {
105  for (auto action : eventActionsMap_ | values) {
106  action->callArtProduces(collector);
107  }
108 }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
std::map< std::string, EventActionBase * > eventActionsMap_
template<typename A >
void artg4tk::ActionHolderService::doRegisterAction ( A *const  action,
std::map< std::string, A * > &  actionMap 
)
private

Definition at line 36 of file ActionHolder.cc.

References allActionsMap_, and msgctg.

Referenced by registerAction().

38 {
39  mf::LogDebug(msgctg) << "Registering action " << action->myName();
40 
41  // Check if the name exists in the specific action map
42  if (0 == actionMap.count(action->myName())) {
43  // Add the action!
44  actionMap.try_emplace(action->myName(), action);
45 
46  // Now, check whether the name exists in the overall map of all the actions
47  // If so, move on (don't throw an exception, since a single action may need
48  // to register in multiple maps). Otherwise, add it.
49  allActionsMap_.try_emplace(action->myName(), action);
50  }
51 
52  else {
53  // We already have this action in the specific action map - this is bad!
54  throw cet::exception("ActionHolderService")
55  << "Duplicate action named " << action->myName() << ".\n";
56  }
57 }
static std::string const msgctg
Definition: ActionHolder.cc:27
std::map< std::string, ActionBase * > allActionsMap_
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void artg4tk::ActionHolderService::endOfEventAction ( const G4Event *  theEvent)

Definition at line 130 of file ActionHolder.cc.

References eventActionsMap_, and util::values().

Referenced by artg4tk::ArtG4EventAction::EndOfEventAction().

131 {
132  for (auto action : eventActionsMap_ | values) {
133  action->endOfEventAction(theEvent);
134  }
135 }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
std::map< std::string, EventActionBase * > eventActionsMap_
void artg4tk::ActionHolderService::generatePrimaries ( G4Event *  theEvent)

Definition at line 177 of file ActionHolder.cc.

References primaryGeneratorActionsMap_, and util::values().

Referenced by artg4tk::ArtG4PrimaryGeneratorAction::GeneratePrimaries().

178 {
179  for (auto action : primaryGeneratorActionsMap_ | values) {
180  action->generatePrimaries(theEvent);
181  }
182 }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
std::map< std::string, PrimaryGeneratorActionBase * > primaryGeneratorActionsMap_
art::Event& artg4tk::ActionHolderService::getCurrArtEvent ( )
inline

Definition at line 73 of file ActionHolder_service.hh.

74  {
75  return (*currentArtEvent_);
76  }
art::Run& artg4tk::ActionHolderService::getCurrArtRun ( )
inline

Definition at line 85 of file ActionHolder_service.hh.

86  {
87  return (*currentArtRun_);
88  }
void artg4tk::ActionHolderService::initialize ( )

Definition at line 111 of file ActionHolder.cc.

References allActionsMap_, and util::values().

112 {
113  for (auto action : allActionsMap_ | values) {
114  action->initialize();
115  }
116 }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
std::map< std::string, ActionBase * > allActionsMap_
bool artg4tk::ActionHolderService::killNewTrack ( const G4Track *  newTrack)

Definition at line 165 of file ActionHolder.cc.

References stackingActionsMap_, and util::values().

Referenced by artg4tk::ArtG4StackingAction::ClassifyNewTrack().

166 {
167  for (auto action : stackingActionsMap_ | values) {
168  if (action->killNewTrack(newTrack)) {
169  return true;
170  }
171  }
172  return false;
173 }
std::map< std::string, StackingActionBase * > stackingActionsMap_
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
void artg4tk::ActionHolderService::postUserTrackingAction ( const G4Track *  theTrack)

Definition at line 147 of file ActionHolder.cc.

References trackingActionsMap_, and util::values().

Referenced by artg4tk::ArtG4TrackingAction::PostUserTrackingAction().

148 {
149  for (auto action : trackingActionsMap_ | values) {
150  action->postUserTrackingAction(theTrack);
151  }
152 }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
std::map< std::string, TrackingActionBase * > trackingActionsMap_
void artg4tk::ActionHolderService::preUserTrackingAction ( const G4Track *  theTrack)

Definition at line 139 of file ActionHolder.cc.

References trackingActionsMap_, and util::values().

Referenced by artg4tk::ArtG4TrackingAction::PreUserTrackingAction().

140 {
141  for (auto action : trackingActionsMap_ | values) {
142  action->preUserTrackingAction(theTrack);
143  }
144 }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
std::map< std::string, TrackingActionBase * > trackingActionsMap_
void artg4tk::ActionHolderService::registerAction ( RunActionBase *const  action)

Definition at line 60 of file ActionHolder.cc.

References doRegisterAction(), and runActionsMap_.

Referenced by artg4tk::RunActionBase::RunActionBase().

61 {
62  std::cerr << "registering to runActionsMap_\n";
64 }
void doRegisterAction(A *const action, std::map< std::string, A * > &actionMap)
Definition: ActionHolder.cc:36
std::map< std::string, RunActionBase * > runActionsMap_
void artg4tk::ActionHolderService::registerAction ( EventActionBase *const  action)

Definition at line 67 of file ActionHolder.cc.

References doRegisterAction(), and eventActionsMap_.

68 {
69  std::cerr << "registering to eventActionsMap_\n";
71 }
void doRegisterAction(A *const action, std::map< std::string, A * > &actionMap)
Definition: ActionHolder.cc:36
std::map< std::string, EventActionBase * > eventActionsMap_
void artg4tk::ActionHolderService::registerAction ( TrackingActionBase *const  action)

Definition at line 74 of file ActionHolder.cc.

References doRegisterAction(), and trackingActionsMap_.

75 {
76  std::cerr << "registering to trackingActionsMap_\n";
78 }
void doRegisterAction(A *const action, std::map< std::string, A * > &actionMap)
Definition: ActionHolder.cc:36
std::map< std::string, TrackingActionBase * > trackingActionsMap_
void artg4tk::ActionHolderService::registerAction ( SteppingActionBase *const  action)

Definition at line 81 of file ActionHolder.cc.

References doRegisterAction(), and steppingActionsMap_.

82 {
83  std::cerr << "registering to steppingActionsMap_\n";
85 }
void doRegisterAction(A *const action, std::map< std::string, A * > &actionMap)
Definition: ActionHolder.cc:36
std::map< std::string, SteppingActionBase * > steppingActionsMap_
void artg4tk::ActionHolderService::registerAction ( StackingActionBase *const  action)

Definition at line 88 of file ActionHolder.cc.

References doRegisterAction(), and stackingActionsMap_.

89 {
90  std::cerr << "registering to stackingActionsMap_\n";
92 }
std::map< std::string, StackingActionBase * > stackingActionsMap_
void doRegisterAction(A *const action, std::map< std::string, A * > &actionMap)
Definition: ActionHolder.cc:36
void artg4tk::ActionHolderService::registerAction ( PrimaryGeneratorActionBase *const  action)

Definition at line 95 of file ActionHolder.cc.

References doRegisterAction(), and primaryGeneratorActionsMap_.

96 {
97  std::cerr << "registering to primaryGeneratorActionsMap_\n";
99 }
void doRegisterAction(A *const action, std::map< std::string, A * > &actionMap)
Definition: ActionHolder.cc:36
std::map< std::string, PrimaryGeneratorActionBase * > primaryGeneratorActionsMap_
void artg4tk::ActionHolderService::setCurrArtEvent ( art::Event e)
inline

Definition at line 68 of file ActionHolder_service.hh.

References e.

69  {
71  }
Float_t e
Definition: plot.C:35
void artg4tk::ActionHolderService::setCurrArtRun ( art::Run r)
inline

Definition at line 80 of file ActionHolder_service.hh.

References r.

81  {
82  currentArtRun_ = &r;
83  }
TRandom r
Definition: spectrum.C:23
void artg4tk::ActionHolderService::userSteppingAction ( const G4Step *  theStep)

Definition at line 156 of file ActionHolder.cc.

References steppingActionsMap_, and util::values().

Referenced by artg4tk::ArtG4SteppingAction::UserSteppingAction().

157 {
158  for (auto action : steppingActionsMap_ | values) {
159  action->userSteppingAction(theStep);
160  }
161 }
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
std::map< std::string, SteppingActionBase * > steppingActionsMap_

Member Data Documentation

std::map<std::string, ActionBase*> artg4tk::ActionHolderService::allActionsMap_ {}
private

Definition at line 125 of file ActionHolder_service.hh.

Referenced by doRegisterAction(), and initialize().

art::Event* artg4tk::ActionHolderService::currentArtEvent_ {nullptr}
private

Definition at line 119 of file ActionHolder_service.hh.

art::Run* artg4tk::ActionHolderService::currentArtRun_ {nullptr}
private

Definition at line 122 of file ActionHolder_service.hh.

std::map<std::string, EventActionBase*> artg4tk::ActionHolderService::eventActionsMap_ {}
private
std::map<std::string, PrimaryGeneratorActionBase*> artg4tk::ActionHolderService::primaryGeneratorActionsMap_ {}
private

Definition at line 116 of file ActionHolder_service.hh.

Referenced by generatePrimaries(), and registerAction().

std::map<std::string, RunActionBase*> artg4tk::ActionHolderService::runActionsMap_ {}
private

Definition at line 111 of file ActionHolder_service.hh.

Referenced by registerAction().

std::map<std::string, StackingActionBase*> artg4tk::ActionHolderService::stackingActionsMap_ {}
private

Definition at line 115 of file ActionHolder_service.hh.

Referenced by killNewTrack(), and registerAction().

std::map<std::string, SteppingActionBase*> artg4tk::ActionHolderService::steppingActionsMap_ {}
private

Definition at line 114 of file ActionHolder_service.hh.

Referenced by registerAction(), and userSteppingAction().

std::map<std::string, TrackingActionBase*> artg4tk::ActionHolderService::trackingActionsMap_ {}
private

The documentation for this class was generated from the following files: