BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
Common functionality for a 6D Gaussian distribution. More...
#include <BDSBunchGaussian.hh>
Public Member Functions | |
BDSBunchGaussian (const G4String &nameIn) | |
virtual void | SetOptions (const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0) |
virtual void | BeginOfRunAction (G4int numberOfEvents) |
virtual BDSParticleCoordsFull | GetNextParticleLocal () |
![]() | |
BDSBunch (const G4String &nameIn) | |
virtual void | SetOptions (const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0) |
virtual void | CheckParameters () |
virtual void | Initialise () |
Any initialisation - to be used after SetOptions, then CheckParameters. More... | |
BDSParticleCoordsFullGlobal | GetNextParticle () |
virtual G4bool | ExpectChangingParticleType () const |
A hint of whether we expect to require and extended particle set (ie pions, kaons, muons). More... | |
virtual BDSParticleCoordsFullGlobal | GetNextParticleValid (G4int maxTries=100) |
virtual void | BeginOfRunAction (G4int numberOfEvents) |
virtual const BDSParticleDefinition * | ParticleDefinition () const |
Access the beam particle definition. More... | |
virtual void | SetGeneratePrimariesOnly (G4bool generatePrimariesOnlyIn) |
virtual BDSParticleCoordsFull | GetNextParticleLocal () |
G4bool | UseCurvilinearTransform () const |
Access whether there's a finite S offset and therefore we're using a CL transform. More... | |
virtual void | RecreateAdvanceToEvent (G4int) |
G4bool | BeamParticleIsAnIon () const |
Access whether the beam particle is an ion or not. More... | |
virtual void | UpdateIonDefinition () |
G4bool | ParticleDefinitionHasBeenUpdated () const |
G4String | Name () const |
Protected Member Functions | |
CLHEP::RandMultiGauss * | CreateMultiGauss (CLHEP::HepRandomEngine &anEngine, const CLHEP::HepVector &mu, CLHEP::HepSymMatrix &sigma) |
void | PreGenerateEvents (G4int nGenerate) |
Pre-generate all the particle coordinates and subtract the sample mean. More... | |
virtual BDSParticleCoordsFull | GetNextParticleLocalCoords () |
Fire random number generator and get coordinates. Can be overloaded if required. More... | |
![]() | |
BDSParticleCoordsFullGlobal | ApplyTransform (const BDSParticleCoordsFull &localIn) const |
void | ApplyTilt (BDSParticleCoordsFull &localIn) const |
Apply a rotation about unitZ for the local coordinates according to member variable tilt. More... | |
BDSParticleCoordsFullGlobal | ApplyCurvilinearTransform (const BDSParticleCoordsFull &localIn) const |
Calculate the global coordinates from curvilinear coordinates of a beam line. More... | |
Protected Attributes | |
CLHEP::HepVector | meansGM |
CLHEP::HepSymMatrix | sigmaGM |
CLHEP::RandMultiGauss * | gaussMultiGen |
Randon number generator with sigma matrix and mean. More... | |
G4bool | offsetSampleMean |
Whether to offset the sample mean. More... | |
G4int | iPartIteration |
Iterator for reading out pre-calculate coordinates. More... | |
std::vector< std::vector< G4double > * > | coordinates |
Convenience vector of vectors for clearing up. More... | |
std::vector< G4double > | x0_v |
Holder for pre-calculated coordinates. More... | |
std::vector< G4double > | xp_v |
Holder for pre-calculated coordinates. More... | |
std::vector< G4double > | y0_v |
Holder for pre-calculated coordinates. More... | |
std::vector< G4double > | yp_v |
Holder for pre-calculated coordinates. More... | |
std::vector< G4double > | z0_v |
Holder for pre-calculated coordinates. More... | |
std::vector< G4double > | zp_v |
Holder for pre-calculated coordinates. More... | |
std::vector< G4double > | E_v |
Holder for pre-calculated coordinates. More... | |
std::vector< G4double > | t_v |
Holder for pre-calculated coordinates. More... | |
std::vector< G4double > | weight_v |
Holder for pre-calculated coordinates. More... | |
![]() | |
G4String | name |
Name of distribution. More... | |
G4bool | useCurvilinear |
Whether to ignore z and use s and transform for curvilinear coordinates. More... | |
BDSParticleDefinition * | particleDefinition |
Particle definition for bunch - this class owns it. More... | |
G4bool | particleDefinitionHasBeenUpdated |
G4bool | finiteTilt |
G4bool | generatePrimariesOnly |
G4double | X0 |
Centre of distributions. More... | |
G4double | Y0 |
Centre of distributions. More... | |
G4double | Z0 |
Centre of distributions. More... | |
G4double | S0 |
Centre of distributions. More... | |
G4double | T0 |
Centre of distributions. More... | |
G4double | Xp0 |
Centre of distributions. More... | |
G4double | Yp0 |
Centre of distributions. More... | |
G4double | Zp0 |
Centre of distributions. More... | |
G4double | E0 |
Centre of distributions. More... | |
G4double | P0 |
central momentum More... | |
G4double | tilt |
Centre of distributions. More... | |
G4double | sigmaT |
Centre of distributions. More... | |
G4double | sigmaP |
Centre of distributions. More... | |
G4double | sigmaE |
Centre of distributions. More... | |
G4double | sigmaEk |
Centre of distributions. More... | |
G4bool | finiteSigmaE |
Flags to ignore random number generator in case of no finite E or T. More... | |
G4bool | finiteSigmaT |
Flags to ignore random number generator in case of no finite E or T. More... | |
Additional Inherited Members | |
![]() | |
static G4double | CalculateZp (G4double xp, G4double yp, G4double Zp0) |
Calculate zp safely based on other components. More... | |
static void | SetEmittances (const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, G4double &emittGeometricX, G4double &emittGeometricY, G4double &emittNormalisedX, G4double &emittNormalisedY) |
Common functionality for a 6D Gaussian distribution.
Definition at line 49 of file BDSBunchGaussian.hh.
|
explicit |
Definition at line 54 of file BDSBunchGaussian.cc.
|
virtual |
Definition at line 65 of file BDSBunchGaussian.cc.
|
virtual |
Called at the beginning of a run. Override here to call PreGenerateEvents that will generate all coordinates and subtract the sample mean.
clear previous means
Reimplemented from BDSBunch.
Definition at line 98 of file BDSBunchGaussian.cc.
References coordinates, iPartIteration, offsetSampleMean, and PreGenerateEvents().
|
protected |
Create multidimensional Gaussian random number generator for Twiss and Gauss. Can change sigma matrix to make non-definite.
check if sigma matrix is positive definite if not add small offset and cout warning
Definition at line 110 of file BDSBunchGaussian.cc.
Referenced by BDSBunchSigmaMatrix::SetOptions(), and BDSBunchTwiss::SetOptions().
|
virtual |
Either draw from the vector of already created points or fire fresh from the matrix.
Reimplemented from BDSBunch.
Definition at line 228 of file BDSBunchGaussian.cc.
References E_v, GetNextParticleLocalCoords(), iPartIteration, offsetSampleMean, BDSBunch::S0, t_v, weight_v, x0_v, xp_v, y0_v, yp_v, z0_v, and zp_v.
|
protectedvirtual |
Fire random number generator and get coordinates. Can be overloaded if required.
Definition at line 252 of file BDSBunchGaussian.cc.
References BDSBunch::CalculateZp(), BDSBunch::E0, BDSBunch::finiteSigmaE, BDSBunch::finiteSigmaT, gaussMultiGen, BDSBunch::S0, BDSBunch::T0, BDSBunch::Z0, and BDSBunch::Zp0.
Referenced by GetNextParticleLocal(), and PreGenerateEvents().
|
protected |
Pre-generate all the particle coordinates and subtract the sample mean.
Definition at line 163 of file BDSBunchGaussian.cc.
References BDSBunch::E0, E_v, GetNextParticleLocalCoords(), BDSBunch::T0, t_v, weight_v, BDSBunch::X0, x0_v, BDSBunch::Xp0, xp_v, BDSBunch::Y0, y0_v, BDSBunch::Yp0, yp_v, BDSBunch::Z0, z0_v, BDSBunch::Zp0, and zp_v.
Referenced by BeginOfRunAction().
|
virtual |
Extract and set the relevant options from the beam definition. The distribution type is explicitly required as this function may be used inside a nested bunch distribution. This argument is for the most part ignored, but there's no way to have a default for it. Also, some classes can cover multiple input distributions so need to know which one they're meant to be.
Reimplemented from BDSBunch.
Reimplemented in BDSBunchSigmaMatrix, and BDSBunchTwiss.
Definition at line 70 of file BDSBunchGaussian.cc.
References BDSBunch::finiteSigmaE, BDSBunch::finiteSigmaT, iPartIteration, offsetSampleMean, BDSBunch::SetOptions(), BDSBunch::sigmaE, BDSBunch::sigmaT, BDSBunch::T0, BDSBunch::X0, BDSBunch::Xp0, BDSBunch::Y0, and BDSBunch::Yp0.
Referenced by BDSBunchSigmaMatrix::SetOptions(), and BDSBunchTwiss::SetOptions().
|
protected |
Convenience vector of vectors for clearing up.
Definition at line 97 of file BDSBunchGaussian.hh.
Referenced by BeginOfRunAction().
|
protected |
Holder for pre-calculated coordinates.
Definition at line 92 of file BDSBunchGaussian.hh.
Referenced by GetNextParticleLocal(), and PreGenerateEvents().
|
protected |
Randon number generator with sigma matrix and mean.
Definition at line 87 of file BDSBunchGaussian.hh.
Referenced by GetNextParticleLocalCoords(), BDSBunchSigmaMatrix::SetOptions(), and BDSBunchTwiss::SetOptions().
|
protected |
Iterator for reading out pre-calculate coordinates.
Definition at line 94 of file BDSBunchGaussian.hh.
Referenced by BeginOfRunAction(), GetNextParticleLocal(), and SetOptions().
|
protected |
Definition at line 83 of file BDSBunchGaussian.hh.
|
protected |
Whether to offset the sample mean.
Definition at line 89 of file BDSBunchGaussian.hh.
Referenced by BeginOfRunAction(), GetNextParticleLocal(), and SetOptions().
|
protected |
Definition at line 84 of file BDSBunchGaussian.hh.
|
protected |
Holder for pre-calculated coordinates.
Definition at line 92 of file BDSBunchGaussian.hh.
Referenced by GetNextParticleLocal(), and PreGenerateEvents().
|
protected |
Holder for pre-calculated coordinates.
Definition at line 92 of file BDSBunchGaussian.hh.
Referenced by GetNextParticleLocal(), and PreGenerateEvents().
|
protected |
Holder for pre-calculated coordinates.
Definition at line 92 of file BDSBunchGaussian.hh.
Referenced by GetNextParticleLocal(), and PreGenerateEvents().
|
protected |
Holder for pre-calculated coordinates.
Definition at line 92 of file BDSBunchGaussian.hh.
Referenced by GetNextParticleLocal(), and PreGenerateEvents().
|
protected |
Holder for pre-calculated coordinates.
Definition at line 92 of file BDSBunchGaussian.hh.
Referenced by GetNextParticleLocal(), and PreGenerateEvents().
|
protected |
Holder for pre-calculated coordinates.
Definition at line 92 of file BDSBunchGaussian.hh.
Referenced by GetNextParticleLocal(), and PreGenerateEvents().
|
protected |
Holder for pre-calculated coordinates.
Definition at line 92 of file BDSBunchGaussian.hh.
Referenced by GetNextParticleLocal(), and PreGenerateEvents().
|
protected |
Holder for pre-calculated coordinates.
Definition at line 92 of file BDSBunchGaussian.hh.
Referenced by GetNextParticleLocal(), and PreGenerateEvents().