BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes
BDSBunchPtc Class Reference

A bunch distribution that reads a PTC inrays file. More...

#include <BDSBunchPtc.hh>

Inheritance diagram for BDSBunchPtc:
Inheritance graph
Collaboration diagram for BDSBunchPtc:
Collaboration graph

Public Member Functions

virtual void SetOptions (const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0)
 Pull out the relevant options and then pass through to BDSBunch::SetOptions().
 
virtual void Initialise ()
 Any initialisation - to be used after SetOptions, then CheckParameters.
 
virtual BDSParticleCoordsFull GetNextParticleLocal ()
 
virtual void RecreateAdvanceToEvent (G4int eventOffset)
 
- Public Member Functions inherited from BDSBunchFileBased
 BDSBunchFileBased (const G4String &distributionName)
 
virtual void BeginOfRunAction (G4int numberOfEvents, G4bool batchMode)
 
void SetNEventsInFile (unsigned long long int nEventsInFileIn)
 
void SetNOriginalEvents (unsigned long long int nOriginalEventsIn)
 
void IncrementNEventsInFileSkipped ()
 
void IncrementNEventsInFileSkipped (unsigned long long int plus)
 
virtual void SetOptions (const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0)
 Pull out the relevant options and then pass through to BDSBunch::SetOptions().
 
BDSBunchFileBasedoperator= (const BDSBunchFileBased &)=delete
 Assignment and copy constructor not implemented nor used.
 
 BDSBunchFileBased (BDSBunchFileBased &)=delete
 Assignment and copy constructor not implemented nor used.
 
unsigned long long int NOriginalEvents () const
 Accessor.
 
unsigned long long int NEventsInFile () const
 Accessor.
 
unsigned long long int NEventsInFileSkipped () const
 Accessor.
 
G4int DistrFileLoopNTimes () const
 Accessor.
 
- Public Member Functions inherited from BDSBunch
 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.
 
BDSParticleCoordsFullGlobal GetNextParticle ()
 
virtual G4bool ExpectChangingParticleType () const
 A hint of whether we expect to require and extended particle set (ie pions, kaons, muons).
 
virtual BDSParticleCoordsFullGlobal GetNextParticleValid (G4int maxTries=100)
 
virtual void BeginOfRunAction (G4int numberOfEvents, G4bool batchMode)
 
virtual const BDSParticleDefinitionParticleDefinition () const
 Access the beam particle definition.
 
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.
 
virtual void RecreateAdvanceToEvent (G4int eventOffset)
 
G4bool BeamParticleIsAnIon () const
 Access whether the beam particle is an ion or not.
 
virtual void UpdateIonDefinition ()
 
G4bool ParticleDefinitionHasBeenUpdated () const
 
G4String Name () const
 Distribution name.
 
G4int CurrentBunchIndex () const
 Get the current bunch index for writing to output.
 
void CalculateBunchIndex (G4int eventIndex)
 Calculate which bunch index we should be at given an event index.
 

Private Member Functions

void LoadPtcFile ()
 Load the PTC file into memory.
 

Private Attributes

G4bool matchDistrFileLength
 Whether to only run the number of particles in the file.
 
G4int nRays
 Number of rays in file (1 counting).
 
G4String fileName
 File name.
 
G4int iRay
 Iterator counter for current ray.
 
std::vector< std::array< double, 6 > > ptcData
 Data.
 
G4double beta
 Velocity w.r.t. speed of light. Needed to convert mom. to energy.
 
G4int nlinesSkip
 
G4int lineCounter
 

Additional Inherited Members

- Static Public Member Functions inherited from BDSBunch
static G4double CalculateZp (G4double xp, G4double yp, G4double Zp0)
 Calculate zp safely based on other components.
 
static void SetEmittances (const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, G4double &emittGeometricX, G4double &emittGeometricY, G4double &emittNormalisedX, G4double &emittNormalisedY)
 
- Protected Member Functions inherited from BDSBunch
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.
 
void ApplyBunchTiming (BDSParticleCoordsFullGlobal &localIn) const
 Add on the offset in T for the current bunch number (i*bunchPeriod).
 
BDSParticleCoordsFullGlobal ApplyCurvilinearTransform (const BDSParticleCoordsFull &localIn) const
 Calculate the global coordinates from curvilinear coordinates of a beam line.
 
- Protected Attributes inherited from BDSBunchFileBased
unsigned long long int nOriginalEvents
 nOriginalEvents from upstream file if skimmed - need to pass through.
 
unsigned long long int nEventsInFile
 The number of entries in the file loaded.
 
unsigned long long int nEventsInFileSkipped
 Number that are skipped as we go through the file due to filters.
 
G4bool distrFileLoop
 
G4int distrFileLoopNTimes
 
- Protected Attributes inherited from BDSBunch
G4String name
 Name of distribution.
 
G4bool useCurvilinear
 Whether to ignore z and use s and transform for curvilinear coordinates.
 
BDSParticleDefinitionparticleDefinition
 Particle definition for bunch - this class owns it.
 
G4bool particleDefinitionHasBeenUpdated
 
G4bool finiteTilt
 
G4bool generatePrimariesOnly
 
G4double X0
 Centre of distributions.
 
G4double Y0
 Centre of distributions.
 
G4double Z0
 Centre of distributions.
 
G4double S0
 Centre of distributions.
 
G4double T0
 Centre of distributions.
 
G4double Xp0
 Centre of distributions.
 
G4double Yp0
 Centre of distributions.
 
G4double Zp0
 Centre of distributions.
 
G4double E0
 Centre of distributions.
 
G4double P0
 central momentum
 
G4double tilt
 Centre of distributions.
 
G4double sigmaT
 Centre of distributions.
 
G4double sigmaP
 Centre of distributions.
 
G4double sigmaE
 Centre of distributions.
 
G4double sigmaEk
 Centre of distributions.
 
bool useBunchTiming
 Bunch offset in time parameters.
 
G4int currentBunchIndex
 Bunch offset in time parameters.
 
G4int eventsPerBunch
 Bunch offset in time parameters.
 
G4double bunchPeriod
 Bunch offset in time parameters.
 
G4bool finiteSigmaE
 Flags to ignore random number generator in case of no finite E or T.
 
G4bool finiteSigmaT
 Flags to ignore random number generator in case of no finite E or T.
 

Detailed Description

A bunch distribution that reads a PTC inrays file.

Author
Stewart Boogert

Definition at line 36 of file BDSBunchPtc.hh.

Constructor & Destructor Documentation

◆ BDSBunchPtc()

BDSBunchPtc::BDSBunchPtc ( )

Definition at line 41 of file BDSBunchPtc.cc.

◆ ~BDSBunchPtc()

BDSBunchPtc::~BDSBunchPtc ( )
virtual

Definition at line 51 of file BDSBunchPtc.cc.

Member Function Documentation

◆ GetNextParticleLocal()

BDSParticleCoordsFull BDSBunchPtc::GetNextParticleLocal ( )
virtual

Each derived class can override this default method of reference position. If S0 > 0 or derived class changes member bool 'curvilinear' z0 will be treated as S and the global z0 be calculated.

Reimplemented from BDSBunch.

Definition at line 221 of file BDSBunchPtc.cc.

References beta, BDSBunch::CalculateZp(), BDSBunch::E0, iRay, nRays, ptcData, BDSBunch::S0, BDSBunch::T0, BDSBunch::X0, BDSBunch::Xp0, BDSBunch::Y0, BDSBunch::Yp0, BDSBunch::Z0, and BDSBunch::Zp0.

Here is the call graph for this function:

◆ Initialise()

void BDSBunchPtc::Initialise ( )
virtual

Any initialisation - to be used after SetOptions, then CheckParameters.

Reimplemented from BDSBunch.

Definition at line 156 of file BDSBunchPtc.cc.

References BDSGlobalConstants::Instance(), LoadPtcFile(), matchDistrFileLength, BDSBunchFileBased::nEventsInFile, and nRays.

Here is the call graph for this function:

◆ LoadPtcFile()

void BDSBunchPtc::LoadPtcFile ( )
private

Load the PTC file into memory.

Definition at line 56 of file BDSBunchPtc.cc.

References fileName, nRays, and ptcData.

Referenced by Initialise().

Here is the caller graph for this function:

◆ RecreateAdvanceToEvent()

void BDSBunchPtc::RecreateAdvanceToEvent ( G4int  eventOffset)
virtual

When recreating events, it's possible that setting the seed state may not be sufficient for the bunch to get the right distribution. This is true when the bunch coordinates are based on an external source of data i.e. user bunch file. This default method allows such a distribution to advance to the correct event number. Updates the bunch index by default.

Reimplemented from BDSBunch.

Definition at line 253 of file BDSBunchPtc.cc.

References BDSGlobalConstants::Instance(), iRay, and nRays.

Here is the call graph for this function:

◆ SetOptions()

void BDSBunchPtc::SetOptions ( const BDSParticleDefinition beamParticle,
const GMAD::Beam beam,
const BDSBunchType distrType,
G4Transform3D  beamlineTransformIn = G4Transform3D::Identity,
const G4double  beamlineS = 0 
)
virtual

Field Documentation

◆ beta

G4double BDSBunchPtc::beta
private

Velocity w.r.t. speed of light. Needed to convert mom. to energy.

Definition at line 62 of file BDSBunchPtc.hh.

Referenced by GetNextParticleLocal(), and SetOptions().

◆ fileName

G4String BDSBunchPtc::fileName
private

File name.

Definition at line 59 of file BDSBunchPtc.hh.

Referenced by LoadPtcFile(), and SetOptions().

◆ iRay

G4int BDSBunchPtc::iRay
private

Iterator counter for current ray.

Definition at line 60 of file BDSBunchPtc.hh.

Referenced by GetNextParticleLocal(), and RecreateAdvanceToEvent().

◆ lineCounter

G4int BDSBunchPtc::lineCounter
private

Definition at line 64 of file BDSBunchPtc.hh.

◆ matchDistrFileLength

G4bool BDSBunchPtc::matchDistrFileLength
private

Whether to only run the number of particles in the file.

Definition at line 57 of file BDSBunchPtc.hh.

Referenced by Initialise(), and SetOptions().

◆ nlinesSkip

G4int BDSBunchPtc::nlinesSkip
private

Definition at line 63 of file BDSBunchPtc.hh.

◆ nRays

G4int BDSBunchPtc::nRays
private

Number of rays in file (1 counting).

Definition at line 58 of file BDSBunchPtc.hh.

Referenced by GetNextParticleLocal(), Initialise(), LoadPtcFile(), and RecreateAdvanceToEvent().

◆ ptcData

std::vector<std::array<double, 6> > BDSBunchPtc::ptcData
private

Data.

Definition at line 61 of file BDSBunchPtc.hh.

Referenced by GetNextParticleLocal(), and LoadPtcFile().


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