19#include "BDSSurvey.hh"
21#include "BDSAcceleratorComponent.hh"
22#include "BDSBeamline.hh"
23#include "BDSBeamlineElement.hh"
24#include "BDSBeamPipeInfo.hh"
26#include "BDSMagnet.hh"
27#include "BDSMagnetStrength.hh"
36BDSSurvey::BDSSurvey(G4String filename):
40 magnetKeys = nullStrength->AllKeys();
42 G4cout << __METHOD_NAME__ <<
"Generating Survey: " << filename <<
" ..." << G4endl;
43 survey.open(filename);
47BDSSurvey::~BDSSurvey()
58 std::string timestring = asctime(localtime(¤ttime));
59 timestring = timestring.substr(0,timestring.size()-1);
61 survey <<
"### BDSIM output - created "<< timestring << G4endl;
63 << setw(15) <<
"Type " <<
" "
64 << setw(40) <<
"Name " <<
" "
65 << setw(
gp) <<
"SStart[m] " <<
" "
66 << setw(
gp) <<
"SMid[m] " <<
" "
67 << setw(
gp) <<
"SEnd[m] " <<
" "
68 << setw(
gp) <<
"ChordLength[m]" <<
" "
69 << setw(
gp) <<
"ArcLength[m] " <<
" "
70 << setw(
gp) <<
"X[m] " <<
" "
71 << setw(
gp) <<
"Y[m] " <<
" "
72 << setw(
gp) <<
"Z[m] " <<
" "
73 << setw(
gp) <<
"Phi[rad] " <<
" "
74 << setw(
gp) <<
"Theta[rad] " <<
" "
75 << setw(
gp) <<
"Psi[rad] " <<
" "
76 << setw(
gp) <<
"Aper1[m] " <<
" "
77 << setw(
gp) <<
"Aper2[m] " <<
" "
78 << setw(
gp) <<
"Aper3[m] " <<
" "
79 << setw(
gp) <<
"Aper4[m] " <<
" "
80 << setw(15) <<
"Aper_Type " <<
" "
81 << setw(
gp) <<
"Angle[rad] ";
87 {
survey <<
" " << setw(18) << key +
"[" + unit +
"]";}
89 {
survey <<
" " << setw(18) << key;}
93 survey.setf(std::ios::fixed, std::ios::floatfield);
94 survey.setf(std::ios::showpoint);
101 for (
auto element : *beamline)
114 G4double phi = rm->getPhi();
115 G4double theta = rm->getTheta();
116 G4double psi = rm->getPsi();
125 survey << std::left << std::setprecision(6) << std::fixed
126 << setw(15) << acceleratorComponent->
GetType() <<
" "
127 << setw(40) << acceleratorComponent->
GetName() <<
" "
128 << setw(
gp) << sStart <<
" "
129 << setw(
gp) << sMiddle <<
" "
130 << setw(
gp) << sEnd <<
" "
132 << setw(
gp) << acceleratorComponent->
GetArcLength()/CLHEP::m <<
" "
133 << setw(
gp) << pos.x()/CLHEP::m <<
" "
134 << setw(
gp) << pos.y()/CLHEP::m <<
" "
135 << setw(
gp) << pos.z()/CLHEP::m <<
" "
136 << setw(
gp) << phi/CLHEP::radian <<
" "
137 << setw(
gp) << theta/CLHEP::radian <<
" "
138 << setw(
gp) << psi/CLHEP::radian <<
" "
139 << setw(
gp) << (beamPipeInfo ? beamPipeInfo->
aper1/CLHEP::m : 0) <<
" "
140 << setw(
gp) << (beamPipeInfo ? beamPipeInfo->
aper2/CLHEP::m : 0) <<
" "
141 << setw(
gp) << (beamPipeInfo ? beamPipeInfo->
aper3/CLHEP::m : 0) <<
" "
142 << setw(
gp) << (beamPipeInfo ? beamPipeInfo->
aper4/CLHEP::m : 0) <<
" "
143 << setw(15) << (beamPipeInfo ? beamPipeInfo->
beamPipeType : 0) <<
" "
144 << setw(
gp) << acceleratorComponent->
GetAngle();
149 st = magCast->MagnetStrength();
Abstract class that represents a component of an accelerator.
G4double GetAngle() const
virtual G4String GetName() const
The name of the component without modification.
virtual G4double GetChordLength() const
virtual G4double GetArcLength() const
BDSBeamPipeInfo * GetBeamPipeInfo() const
G4String GetType() const
Get a string describing the type of the component.
Holder class for all information required to describe a beam pipe model.
G4double aper3
Public member for direct access.
G4double aper1
Public member for direct access.
G4double aper4
Public member for direct access.
G4double aper2
Public member for direct access.
BDSBeamPipeType beamPipeType
Public member for direct access.
A class that holds a fully constructed BDSAcceleratorComponent as well as any information relevant to...
G4ThreeVector GetPositionMiddle() const
Accessor.
G4double GetSPositionEnd() const
Accessor.
BDSAcceleratorComponent * GetAcceleratorComponent() const
Accessor.
G4double GetSPositionMiddle() const
Accessor.
G4RotationMatrix * GetRotationMiddle() const
Accessor.
G4double GetSPositionStart() const
Accessor.
A vector of BDSBeamlineElement instances - a beamline.
G4double GetTotalChordLength() const
Get the total length of the beamline - the sum of the chord length of each element.
G4double GetTotalArcLength() const
Get the total ARC length for the beamline - ie the maximum s position.
Efficient storage of magnet strengths.
std::ostream & WriteValuesInSIUnitsForSuvey(std::ostream &out, const G4int precision=14) const
static G4String UnitName(const G4String &key)
Access a unit name for a given key.
Abstract base class that implements features common to all magnets.
const int gp
General precision - number of characters / item.
BDSMagnetStrength const * nullStrength
std::ofstream survey
Output file stream.
std::vector< G4String > magnetKeys
Cache of all the possible magnet strength parameters.
void WriteHeader()
Write header.
void Write(BDSBeamlineElement *beamlineElement)
write line