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

#include "myParticleGunAction_service.hh"

Inheritance diagram for artg4tk::myParticleGunActionService:
artg4tk::PrimaryGeneratorActionBase artg4tk::ActionBase

Public Member Functions

 myParticleGunActionService (fhicl::ParameterSet const &)
 
void initialize () override
 
void generatePrimaries (G4Event *anEvent) override
 
G4ParticleGun const * GetGun () const
 
std::string const & myName () const
 

Private Attributes

std::unique_ptr< G4ParticleGun > particleGun_ {nullptr}
 
G4int nparticle_
 
std::string particleName_
 
std::vector< double > momentumDirection_
 
double energy_
 
std::vector< double > position_
 

Detailed Description

Definition at line 51 of file myParticleGunAction_service.hh.

Constructor & Destructor Documentation

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

Definition at line 43 of file myParticleGunAction.cc.

44  : PrimaryGeneratorActionBase(p.get<std::string>("name", "myParticleGunAction"))
45  , nparticle_(p.get<G4int>("NParticle"))
46  , particleName_(p.get<std::string>("Name"))
47  , momentumDirection_(p.get<std::vector<double>>("Direction"))
48  , energy_(p.get<double>("Energy"))
49  , position_(p.get<std::vector<double>>("Position"))
50 {}

Member Function Documentation

void artg4tk::myParticleGunActionService::generatePrimaries ( G4Event *  anEvent)
overridevirtual

Reimplemented from artg4tk::PrimaryGeneratorActionBase.

Definition at line 71 of file myParticleGunAction.cc.

References particleGun_.

72 {
73  particleGun_->GeneratePrimaryVertex(anEvent);
74 }
std::unique_ptr< G4ParticleGun > particleGun_
G4ParticleGun const* artg4tk::myParticleGunActionService::GetGun ( ) const
inline

Definition at line 62 of file myParticleGunAction_service.hh.

References particleGun_.

63  {
64  return particleGun_.get();
65  };
std::unique_ptr< G4ParticleGun > particleGun_
void artg4tk::myParticleGunActionService::initialize ( )
overridevirtual

Reimplemented from artg4tk::ActionBase.

Definition at line 53 of file myParticleGunAction.cc.

References energy_, momentumDirection_, nparticle_, particleGun_, particleName_, and position_.

54 {
55  mf::LogInfo("myParticleGunAction") << "Initializing particle gun.";
56  auto particleGun = std::make_unique<G4ParticleGun>(nparticle_);
57  particleGun->SetParticleDefinition(
58  G4ParticleTable::GetParticleTable()->FindParticle(particleName_));
59  particleGun->SetParticleMomentumDirection(
60  G4ThreeVector(momentumDirection_[0], momentumDirection_[1], momentumDirection_[2]));
61  particleGun->SetParticleEnergy(energy_ * CLHEP::GeV);
62  particleGun->SetParticlePosition(
63  G4ThreeVector(position_[0] * CLHEP::cm, position_[1] * CLHEP::cm, position_[2] * CLHEP::cm));
64  particleGun_ = move(particleGun);
65 }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::unique_ptr< G4ParticleGun > particleGun_
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

Member Data Documentation

double artg4tk::myParticleGunActionService::energy_
private

Definition at line 72 of file myParticleGunAction_service.hh.

Referenced by initialize().

std::vector<double> artg4tk::myParticleGunActionService::momentumDirection_
private

Definition at line 71 of file myParticleGunAction_service.hh.

Referenced by initialize().

G4int artg4tk::myParticleGunActionService::nparticle_
private

Definition at line 69 of file myParticleGunAction_service.hh.

Referenced by initialize().

std::unique_ptr<G4ParticleGun> artg4tk::myParticleGunActionService::particleGun_ {nullptr}
private

Definition at line 68 of file myParticleGunAction_service.hh.

Referenced by generatePrimaries(), GetGun(), and initialize().

std::string artg4tk::myParticleGunActionService::particleName_
private

Definition at line 70 of file myParticleGunAction_service.hh.

Referenced by initialize().

std::vector<double> artg4tk::myParticleGunActionService::position_
private

Definition at line 73 of file myParticleGunAction_service.hh.

Referenced by initialize().


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