LDMX Software
TrackProcessFilter.cxx
1#include "Biasing/Utility/TrackProcessFilter.h"
2
3/*~~~~~~~~~~~~*/
4/* Geant4 */
5/*~~~~~~~~~~~~*/
6#include "G4Track.hh"
7#include "G4VProcess.hh"
8
9/*~~~~~~~~~~~~~*/
10/* SimCore */
11/*~~~~~~~~~~~~~*/
12#include "SimCore/UserTrackInformation.h"
13
14namespace biasing {
15namespace utility {
16
18 const std::string& name, framework::config::Parameters& parameters)
19 : simcore::UserAction(name, parameters) {
20 process_ = parameters.getParameter<std::string>("process");
21}
22
24
26 if (const G4VProcess * process{track->GetCreatorProcess()}; process) {
27 auto name{process->GetProcessName()};
28 auto trackInfo{simcore::UserTrackInformation::get(track)};
29 if (name.contains(process_)) trackInfo->setSaveFlag(true);
30 } // does this track have a creator process
31}
32
33} // namespace utility
34} // namespace biasing
35
36DECLARE_ACTION(biasing::utility, TrackProcessFilter)
void PostUserTrackingAction(const G4Track *track) override
Method called when a track is done being processed.
TrackProcessFilter(const std::string &name, framework::config::Parameters &parameters)
Constructor.
std::string process_
The process to filter on.
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
static UserTrackInformation * get(const G4Track *track)
get
void setSaveFlag(bool saveFlag)
Set the save flag so the associated track will be persisted as a Trajectory.