MCTruthEventAction_service.h
Go to the documentation of this file.
1 // MCTruthEventAction is the service that injects particles into
2 // the simulation.
3 // To use this action, all you need to do is put it in the services section
4 // of the configuration file, like this:
5 //
6 // services: {
7 // ...
8 // MCTruthEventAction: {}
9 // ...
10 // }
11 // Expected parameters:
12 // - name (string): A name describing the action service.
13 // Default is 'exampleParticleGun'
14 
15 // Include guard
16 #ifndef EXAMPLE_MCTRUTHEVENTACTION_SERVICE_HH
17 #define EXAMPLE_MCTRUTHEVENTACTION_SERVICE_HH
18 
21 #include "fhiclcpp/ParameterSet.h"
22 
23 #include "artg4tk/actionBase/PrimaryGeneratorActionBase.hh"
24 #include "nug4/G4Base/ConvertMCTruthToG4.h"
25 
26 #include "Geant4/G4Event.hh"
27 #include "Geant4/G4ParticleTable.hh"
28 #include "Geant4/G4VPrimaryGenerator.hh"
29 #include "Geant4/G4VUserPrimaryGeneratorAction.hh"
30 #include "Geant4/globals.hh"
31 
32 #include <map>
33 
34 namespace larg4 {
35 
36  class MCTruthEventActionService : public artg4tk::PrimaryGeneratorActionBase {
37  public:
40 
41  void
42  setInputCollections(std::vector<art::Handle<std::vector<simb::MCTruth>>> const& mclists)
43  {
44  fMCLists = &mclists;
45  }
46 
47  private:
48  // To generate primaries, we need to overload the GeneratePrimaries
49  // method.
50 
51  void generatePrimaries(G4Event* anEvent) override;
52 
53  static G4ParticleTable* fParticleTable; ///< Geant4's table of particle definitions.
54  std::vector<art::Handle<std::vector<simb::MCTruth>>> const*
55  fMCLists; ///< MCTruthCollection input lists
56  std::map<G4int, G4int> fUnknownPDG; ///< map of unknown PDG codes to instances
57  std::map<G4int, G4int> fNon1StatusPDG; ///< PDG codes skipped because not status 1
58  std::map<G4int, G4int> fProcessedPDG; ///< PDG codes processed
59  };
60 } //namespace larg4
61 
63 
64 #endif
static G4ParticleTable * fParticleTable
Geant4&#39;s table of particle definitions.
struct vector vector
Geant4 interface.
std::vector< art::Handle< std::vector< simb::MCTruth > > > const * fMCLists
MCTruthCollection input lists.
void setInputCollections(std::vector< art::Handle< std::vector< simb::MCTruth >>> const &mclists)
#define DECLARE_ART_SERVICE(svc, scope)
void generatePrimaries(G4Event *anEvent) override
std::map< G4int, G4int > fProcessedPDG
PDG codes processed.
std::map< G4int, G4int > fNon1StatusPDG
PDG codes skipped because not status 1.
std::map< G4int, G4int > fUnknownPDG
map of unknown PDG codes to instances
MCTruthEventActionService(fhicl::ParameterSet const &)