20#include "BDSBunchSixTrackLink.hh"
22#include "BDSEventInfo.hh"
23#include "BDSException.hh"
24#include "BDSExtent.hh"
25#include "BDSIonDefinition.hh"
26#include "BDSLinkDetectorConstruction.hh"
27#include "BDSLinkEventInfo.hh"
28#include "BDSLinkPrimaryGeneratorAction.hh"
29#include "BDSLinkRegistry.hh"
30#include "BDSPrimaryVertexInformation.hh"
31#include "BDSRandom.hh"
34#include "G4IonTable.hh"
35#include "G4ParticleGun.hh"
39 int* currentElementIndexIn,
43 currentElementIndex(currentElementIndexIn),
44 construction(constructionIn),
50 particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
55BDSLinkPrimaryGeneratorAction::~BDSLinkPrimaryGeneratorAction()
64 anEvent->SetUserInformation(eventInfo);
74 eventInfo->externalParticleIDofPrimary = bunchSTL->CurrentExternalParticleID();
75 eventInfo->externalParentIDofPrimary = bunchSTL->CurrentExternalParentID();
81 anEvent->SetEventAborted();
82 G4cout << exception.
what() << G4endl;
83 G4cout <<
"Aborting this event (#" << anEvent->GetEventID() <<
")" << G4endl;
94 G4cout <<
"PGA: Coords before " << coords;
95 G4cout <<
"Offset " << tr.getTranslation() << G4endl;
100 {G4cout <<
"Coords after " << cg.global;}
117 G4cout << __METHOD_NAME__ <<
"Event #" << anEvent->GetEventID()
118 <<
" - Particle kinetic energy smaller than 0! "
119 <<
"This will not be tracked." << G4endl;
120 anEvent->SetEventAborted();
127 G4cerr << __METHOD_NAME__ <<
"point: " << cg.global
128 <<
"mm lies outside the world volume with extent ("
129 <<
worldExtent <<
" - event aborted!" << G4endl << G4endl;
130 anEvent->SetEventAborted();
134 G4cout << __METHOD_NAME__ << coords << G4endl;
137 G4ThreeVector PartMomDir(cg.global.xp,cg.global.yp,cg.global.zp);
138 G4ThreeVector PartPosition(cg.global.x,cg.global.y,cg.global.z);
142 particleGun->SetParticleMomentumDirection(PartMomDir);
148 auto vertex = anEvent->GetPrimaryVertex();
149 vertex->SetWeight(cg.local.weight);
A bunch distribution that holds a bunch from Sixtrack Link.
The base class for bunch distribution generators.
virtual const BDSParticleDefinition * ParticleDefinition() const
Access the beam particle definition.
virtual BDSParticleCoordsFull GetNextParticleLocal()
void SetSeedStateAtStart(const G4String &seedStateAtStartIn)
Setters.
General exception with possible name of object and message.
const char * what() const noexcept override
Override message in std::exception.
G4bool Encompasses(const G4ThreeVector &point) const
Return whether the extent encompasses the point. True if point lies inside the extent.
Construction of the geometry in the case of a link model.
BDSLinkRegistry * LinkRegistry() const
Accessor.
Simple extension to cache extra variables through an event.
BDSBunch * bunch
BDSIM particle generator.
virtual void GeneratePrimaries(G4Event *)
Main interface for Geant4. Prepare primary(ies) for the event.
int * currentElementIndex
External integer for which element to track in.
G4ParticleGun * particleGun
Geant4 particle gun that creates single particles.
BDSExtent worldExtent
World extent that particle coordinates are checked against to ensure they're inside it.
BDSLinkPrimaryGeneratorAction(BDSBunch *bunchIn, int *currentElementIndexIn, BDSLinkDetectorConstruction *constructionIn, G4bool debugIn=false)
Bunch must have a valid particle definition (ie not nullptr).
BDSLinkDetectorConstruction * construction
Cache of detector construction for link registry of transforms.
A set of particle coordinates in both local and global.
A set of particle coordinates including energy and weight.
A set of particle coordinates.
BDSParticleCoords ApplyTransform(const G4Transform3D &transform) const
Apply a transform to the coordinates and return a copy of them transformed.
BDSParticleCoords ApplyOffset(const G4ThreeVector &offset) const
Apply an offset to the spatial coordinates only and return a copy.
G4double Mass() const
Accessor.
G4double Charge() const
Accessor.
G4ParticleDefinition * ParticleDefinition() const
Accessor.