Creating your own actions in ArtG4¶
Geant actions are code with hooks to run a certain times in the Geant event creation process. In general, to make your own action, you have to create an Art
service that inherits from one or more base classes.
You can use multiple inheritance it you want an more than one action to share information between themselves.
See https://cdcvs.fnal.gov/codeDocify/codedocify/rmineRepository.html?proj=artg4&rev=develop&path=actionBase and look at each base class for what you need to override.
Your service's constructor must register with the
ActionHolder. For example, if you inherit from only one action base class, you can do,
art::ServiceHandle<ActionHolderService> actionHolder; actionHolder -> registerAction(this);
If you inherit from multiple action base classes, you must register for each base classs,
TrackingActionBase * trackingPtr = dynamic_cast<TrackingActionBase*>(this); RunActionBase * runPtr = dynamic_cast<RunActionBase*>(this); SteppingActionBase * steppingPtr = dynamic_cast<SteppingActionBase*>(this); // We need to register ourselves as each base class... actionHolder -> registerAction(trackingPtr); actionHolder -> registerAction(runPtr); actionHolder -> registerAction(steppingPtr);
If your action creates data to go into the event, you must override these two member functions,
void callArtProduces(art::EDProducer * producer) fillEventWithArtStuff(art::Event & e)