22 std::shared_ptr<std::ifstream> twissFile =
TwissFile(cData,
side);
24 std::ifstream&
pfile = *twissFile;
28 std::cout <<
"beamEnergy[GeV] = " <<
beamEnergy << std::endl;
30 while (
pfile.peek() ==
'@' ||
pfile.peek() ==
'*' ||
pfile.peek() ==
'$')
pfile.ignore(1000,
'\n');
32 std::ios::fmtflags cout_flags = std::cout.flags();
34 std::cout << std::left
35 << std::setw(15) <<
"magName"
36 << std::setw(15) <<
"magSort"
38 << std::setw(10) <<
"magType"
39 << std::setw(15) <<
"magEndPos"
40 << std::setw(15) <<
"magLength"
41 << std::setw(15) <<
"magStrength"
42 << std::setw(15) <<
"magAperType"
43 << std::setw(10) <<
"magAper1"
44 << std::setw(10) <<
"magAper2"
45 << std::setw(10) <<
"magAper3"
46 << std::setw(10) <<
"magAper4"
51 std::string magName, magSort, magBasic;
52 double magEndPos, magLength;
54 double K0L, K1L, K2L, K3L;
55 double X, PX, BETX, ALFX, MUX, DX, DPX;
56 double Y, PY, BETY, ALFY, MUY, DY, DPY;
57 std::string magAperType;
58 double magAper1, magAper2, magAper3, magAper4;
60 pfile >> magName >> magSort >> magBasic >> magEndPos >> magLength
62 >> K0L >> K1L >> K2L >> K3L
64 >> BETX >> BETY >> ALFX >> ALFY >> MUX >> MUY
65 >> DX >> DY >> DPX >> DPY
67 >> magAper1 >> magAper2 >> magAper3 >> magAper4;
69 if (magEndPos < 0)
throw std::runtime_error(
"Magnet End Position cannot be negative.");
70 else if (magEndPos > cData.
endMarker)
break;
73 double magStrength = 0;
82 std::cout.precision(6);
83 if (magName.find(
"DRIFT") != 1)
84 std::cout << std::fixed
86 << std::setw(15) << magName
87 << std::setw(15) << magSort
89 << std::setw(10) << magType
90 << std::setw(15) << magEndPos
91 << std::setw(15) << magLength
92 << std::setw(15) << magStrength
93 << std::setw(15) << magAperType
94 << std::setw(10) << magAper1
95 << std::setw(10) << magAper2
96 << std::setw(10) << magAper3
97 << std::setw(10) << magAper4
100 if (magLength < 0)
throw std::runtime_error(
"magLength must be positive.");
101 else if (magLength == 0) {
102 if (magType ==
Magnet::hfQuadrupole)
throw std::runtime_error(
"magLength cannot be zero for hfQuadrupole.");
103 if (magType ==
Magnet::vfQuadrupole)
throw std::runtime_error(
"magLength cannot be zero for vfQuadrupole.");
122 magnets.push_back(mptr);
125 std::sort(magnets.begin(), magnets.end(), absZGreater<Magnet::ConstPtr_t>);
127 std::cout.flags(cout_flags);