19#ifndef BDSBUNCHUSERFILE_H
20#define BDSBUNCHUSERFILE_H
31#include "src-external/gzstream/gzstream.h"
52 G4Transform3D beamlineTransformIn = G4Transform3D::Identity,
93 void skip(std::stringstream& stream, G4int nvalues);
100 template <
typename Type>
void ReadValue(std::stringstream& stream, Type& value);
114 template <
typename U>
115 void CheckAndParseUnits(
const G4String&
name,
const G4String& rest, U unitParser);
128 G4bool matchDistrFileLength;
A bunch distribution that reads a user specified column file.
void CheckConflictingParameters(const std::set< G4String > &s) const
Check conflicting columns aren't specified in file, e.g. P and Ek. Throw exception if wrong.
virtual void RecreateAdvanceToEvent(G4int eventOffset)
G4double ffact
Cache of flip factor from global constants.
void ReadValue(std::stringstream &stream, Type &value)
void SkipLines()
Read lines according to nlinesIgnore.
G4int lineCounter
Line counter.
G4int nlinesIgnore
Number of lines that will be ignored at the start the file.
G4int CountLinesInFile()
Open the file, skip lines, then count number of lines, then close file again.
T InputBunchFile
The file handler. Templated as could be std::ifstream or igzstream for example.
G4int nlinesSkip
Number of lines that will be skipped after the nlinesIgnore.
virtual BDSParticleCoordsFullGlobal GetNextParticleValid(G4int maxTries)
G4bool changingParticleType
Whether the particle type is a column.
void skip(std::stringstream &stream, G4int nvalues)
void ParseFileFormat()
Parse the column tokens and units factors.
virtual void SetOptions(const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0)
G4String distrFilePath
Bunch file including absolute path.
G4String bunchFormat
Format of the file.
G4bool printedOutFirstTime
Whether we've printed out opening the file the first time.
G4double particleMass
Cache of nominal beam particle mass.
std::list< Doublet > fields
List of variables to parse on each line.
void CloseBunchFile()
Close the file handler.
virtual void CheckParameters()
virtual BDSParticleCoordsFull GetNextParticleLocal()
Get the next particle.
virtual void Initialise()
Open the file and skip lines.
G4String distrFile
Bunch file.
virtual G4bool ExpectChangingParticleType() const
For this class we generally can expect a few extra particle types.
void OpenBunchFile()
Open the file and check it's open.
G4bool anEnergyCoordinateInUse
Whether Et, Ek or P are in the columns.
The base class for bunch distribution generators.
G4double beamlineS
Beamline initial S position.
G4String name
Name of distribution.
A set of particle coordinates in both local and global.
A set of particle coordinates including energy and weight.
Wrapper for particle definition.
Improve type-safety of native enum data type in C++.
Return either G4Tubs or G4CutTubs depending on flat face.
G4double ParseTimeUnit(const G4String &fmt)
G4double ParseEnergyUnit(const G4String &fmt)
G4double ParseAngleUnit(const G4String &fmt)
G4double ParseLengthUnit(const G4String &fmt)
Struct for name and unit pair.
G4double unit
relative to SI units, i.e. mm=0.001 etc.