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

#include "PrimaryEventAction_service.hh"

Inheritance diagram for artg4tk::PrimaryEventActionService:
artg4tk::PrimaryGeneratorActionBase artg4tk::ActionBase

Public Member Functions

 PrimaryEventActionService (fhicl::ParameterSet const &)
 
std::string const & myName () const
 
virtual void initialize ()
 

Private Member Functions

void addG4Particle (G4Event *event, int pdgId, const G4ThreeVector &pos, double time, double energy, const G4ThreeVector &mom)
 
void generatePrimaries (G4Event *anEvent) override
 

Detailed Description

Definition at line 39 of file PrimaryEventAction_service.hh.

Constructor & Destructor Documentation

artg4tk::PrimaryEventActionService::PrimaryEventActionService ( fhicl::ParameterSet const &  p)

Definition at line 17 of file PrimaryEventAction.cc.

18  : PrimaryGeneratorActionBase(p.get<std::string>("name", "PrimaryEventActionService"))
19 {}

Member Function Documentation

void artg4tk::PrimaryEventActionService::addG4Particle ( G4Event *  event,
int  pdgId,
const G4ThreeVector &  pos,
double  time,
double  energy,
const G4ThreeVector &  mom 
)
private

Definition at line 47 of file PrimaryEventAction.cc.

Referenced by generatePrimaries().

53 {
54  auto vertex = new G4PrimaryVertex{pos, time};
55  vertex->SetPrimary(new G4PrimaryParticle{pdgId, mom.x(), mom.y(), mom.z(), energy});
56  event->AddPrimaryVertex(vertex);
57 }
double energy
Definition: plottest35.C:25
vertex reconstruction
void artg4tk::PrimaryEventActionService::generatePrimaries ( G4Event *  anEvent)
overrideprivatevirtual

Reimplemented from artg4tk::PrimaryGeneratorActionBase.

Definition at line 24 of file PrimaryEventAction.cc.

References addG4Particle(), e, and art::ProductRetriever::getMany().

25 {
27  auto const allGens = e.getMany<GenParticleCollection>();
28  std::cout << "Primary:: GenParticles*******************Size: " << allGens.size() << '\n';
29  for (auto const& h : allGens) {
30  GenParticleCollection const& gens = *h;
31  std::cout << "Primary:: GenParticlesCollection*******************Size: " << gens.size() << '\n';
32  for (GenParticle const& genpart : gens) {
33  std::cout << " genpart.pdgId(): " << genpart.pdgId()
34  << "\n position: " << genpart.position() << "\nmomentum: " << genpart.momentum()
35  << "\nenergy: " << genpart.momentum().e() << '\n';
36  addG4Particle(anEvent,
37  genpart.pdgId(),
38  genpart.position(),
39  0.0,
40  genpart.momentum().e(),
41  genpart.momentum());
42  }
43  }
44 }
std::vector< GenParticle > GenParticleCollection
Float_t e
Definition: plot.C:35
void addG4Particle(G4Event *event, int pdgId, const G4ThreeVector &pos, double time, double energy, const G4ThreeVector &mom)
std::vector< Handle< PROD > > getMany(SelectorBase const &selector=MatchAllSelector{}) const
virtual void artg4tk::ActionBase::initialize ( )
inlinevirtualinherited

Reimplemented in artg4tk::myParticleGunActionService, and artg4tk::HepevtInputActionService.

Definition at line 36 of file ActionBase.hh.

37  {}
std::string const& artg4tk::ActionBase::myName ( ) const
inlineinherited

Definition at line 25 of file ActionBase.hh.

References artg4tk::ActionBase::myName_.

26  {
27  return myName_;
28  }
std::string myName_
Definition: ActionBase.hh:41

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