Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
TOUZE Francois
PSPA
Commits
b6ae3e24
Commit
b6ae3e24
authored
Sep 24, 2020
by
TOUZE Francois
Browse files
focus in the beam element
parent
cd72e5b1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
195 additions
and
156 deletions
+195
-156
backend/pspa/v0/src/Core/particleBeam.cc
backend/pspa/v0/src/Core/particleBeam.cc
+3
-3
backend/pspa/v0/src/Core/softwareBeta.cc
backend/pspa/v0/src/Core/softwareBeta.cc
+13
-19
backend/pspa/v0/src/Core/softwareElegant.cc
backend/pspa/v0/src/Core/softwareElegant.cc
+29
-21
backend/pspa/v0/src/Core/softwareMadx.cc
backend/pspa/v0/src/Core/softwareMadx.cc
+13
-8
backend/pspa/v0/src/KindOfElements/elementBeam.cc
backend/pspa/v0/src/KindOfElements/elementBeam.cc
+88
-76
frontend/src/utils/models/beam.js
frontend/src/utils/models/beam.js
+49
-29
No files found.
backend/pspa/v0/src/Core/particleBeam.cc
View file @
b6ae3e24
...
...
@@ -331,12 +331,12 @@ void particleBeam::buildMomentRepresentation()
double
gREF
=
referenceParticle_
.
getGamma
()
-
1.0
;
double
PREFMeV_sur_c
=
gREF
*
(
gREF
+
2
);
if
(
PREFMeV_sur_c
>
0.0
)
PREFMeV_sur_c
=
sqrt
(
PREFMeV_sur_c
);
PREFMeV_sur_c
=
sqrt
(
PREFMeV_sur_c
);
// = βγ
else
PREFMeV_sur_c
=
0.0
;
if
(
debug
>
0
)
cout
<<
"P_MeV_sur_c= "
<<
EREST_MeV
*
PREFMeV_sur_c
<<
" MeV
\n
"
;
if
(
debug
>
0
)
// E0*βγ en MeV/c
cout
<<
"P_MeV_sur_c= "
<<
EREST_MeV
*
PREFMeV_sur_c
<<
"
??
MeV
\n
"
;
double
sx
[
5
]
=
{
0.0
};
double
sy
[
5
]
=
{
0.0
};
...
...
backend/pspa/v0/src/Core/softwareBeta.cc
View file @
b6ae3e24
...
...
@@ -151,20 +151,15 @@ void softwareBeta::fromParameters(const vector<psvs>& v)
{
if
(
debug
>
0
)
cout
<<
"softwareBeta::fromParameters()
\n
"
;
string
WEN
=
"1000"
;
// 1GeV
bunch_
[
"energy"
]
=
"1
.0
000
000E+03
"
;
// 1GeV
string
key
=
v
.
at
(
1
).
second
.
at
(
1
);
if
(
key
.
find
(
"none"
)
==
std
::
string
::
npos
)
{
WEN
=
key
;
// MeV
bunch_
[
"energy"
]
=
WEN
;
bunch_
[
"energy"
]
=
key
;
}
else
{
bunch_
[
"energy"
]
=
"0.0000000E+00"
;
}
key
=
v
.
at
(
1
).
second
.
at
(
2
);
if
(
key
.
find
(
"none"
)
==
std
::
string
::
npos
)
{
bunch_
[
"p_central"
]
=
key
;
// MeV
}
else
{
bunch_
[
"p_central"
]
=
WEN
;
string
key2
=
v
.
at
(
1
).
second
.
at
(
2
);
// E0*βγ en MeV/c
if
(
key2
.
find
(
"none"
)
==
std
::
string
::
npos
)
{
bunch_
[
"energy"
]
=
key2
;
// MeV/c
}
}
bunch_
[
"emit_x"
]
=
"0.0000000E+00"
;
// default
...
...
@@ -209,8 +204,9 @@ void softwareBeta::fromDistribution(const vector<psvs>& v)
{
if
(
debug
>
0
)
cout
<<
"softwareBeta::fromDistribution()
\n
"
;
bunch_
[
"energy"
]
=
"0.0000000E+00"
;
bunch_
[
"p_central"
]
=
v
.
at
(
1
).
second
.
at
(
1
);
// MeV
double
p0
=
atof
(
v
.
at
(
1
).
second
.
at
(
1
).
c_str
());
// in MeV/c
p0
/=
EREST_MeV
;
// in MeV
bunch_
[
"energy"
]
=
mixedTools
::
doubleToString
(
p0
);
// MeV
bunch_
[
"emit_x"
]
=
v
.
at
(
1
).
second
.
at
(
2
);
// m.rad
bunch_
[
"emit_y"
]
=
v
.
at
(
1
).
second
.
at
(
3
);
// m.rad
bunch_
[
"emit_z"
]
=
"0.0000000E+00"
;
...
...
@@ -228,12 +224,10 @@ void softwareBeta::beamData(particleBeam *beam)
{
if
(
debug
>
0
)
cout
<<
"softwareBeta::beamData( 2 )
\n
"
;
bunch_
[
"energy"
]
=
"none"
;
// P0Transport(GeV/c) = EREST_GeV * p_central(GeV)
double
pc
=
beam
->
getP0Transport
()
/
EREST_GeV
;
// en GeV
pc
*=
1000.
;
// en MeV
bunch_
[
"p_central"
]
=
mixedTools
::
doubleToString
(
pc
);
bunch_
[
"energy"
]
=
mixedTools
::
doubleToString
(
pc
);
bunch_
[
"emit_z"
]
=
"0.0000000E+00"
;
bunch_
[
"sig_s"
]
=
"0.0000000E+00"
;
bunch_
[
"sig_e"
]
=
"0.0000000E+00"
;
...
...
@@ -541,7 +535,7 @@ string softwareBeta::executeCommand()
// particle kinetic energy and mass in MeV
os
.
put
(
'\
u0020
'
)
<<
"*** ENERGIE CINETIQUE (MeV) ***
\n
"
;
key
=
bunch_
.
find
(
"
p_central
"
)
->
second
;
key
=
bunch_
.
find
(
"
energy
"
)
->
second
;
os
.
put
(
'\
u0020
'
)
<<
scientific
<<
atof
(
key
.
c_str
()
)
<<
endl
;
os
.
put
(
'\
u0020
'
)
<<
scientific
<<
0.511003435
<<
endl
;
...
...
@@ -752,7 +746,7 @@ string softwareBeta::batchCommands()
os
<<
0.10000E+01
<<
" "
<<
0.10000E+01
<<
'\n'
;
os
<<
"#Label :Kinetic energy (MeV)
\n
"
;
key
=
bunch_
.
find
(
"
p_central
"
)
->
second
;
key
=
bunch_
.
find
(
"
energy
"
)
->
second
;
os
<<
atof
(
key
.
c_str
()
)
<<
'\n'
;
os
<<
"#Tabset :BEAM
\n
"
;
...
...
@@ -991,7 +985,7 @@ void softwareBeta::diagnostics(ifstream& ifs)
double
xemit
=
atof
(
bunch_
.
find
(
"emit_x"
)
->
second
.
c_str
()
);
double
yemit
=
atof
(
bunch_
.
find
(
"emit_y"
)
->
second
.
c_str
()
);
double
pCentral0
=
atof
(
bunch_
.
find
(
"
p_central
"
)
->
second
.
c_str
()
);
double
pCentral0
=
atof
(
bunch_
.
find
(
"
energy
"
)
->
second
.
c_str
()
);
json
::
iterator
kt
=
jtwiss
.
find
(
"s"
);
// int n1= getComputingBlock()->getNumberOfElements();
...
...
backend/pspa/v0/src/Core/softwareElegant.cc
View file @
b6ae3e24
...
...
@@ -168,22 +168,18 @@ void softwareElegant::fromParameters(const vector<psvs>& v)
{
if
(
debug
>
0
)
cout
<<
"softwareElegant::fromParameters()
\n
"
;
string
key
=
v
.
at
(
1
).
second
.
at
(
1
);
string
WEN
=
"1000"
;
string
key
=
v
.
at
(
1
).
second
.
at
(
1
);
// MeV
if
(
key
.
find
(
"none"
)
==
std
::
string
::
npos
)
{
double
EMev
=
atof
(
key
.
c_str
());
// MeV
WEN
=
mixedTools
::
doubleToString
(
EMev
);
bunch_
[
"energy"
].
push_back
(
WEN
);
bunch_
[
"energy"
].
push_back
(
key
);
}
else
{
bunch_
[
"energy"
].
push_back
(
"0.0"
);
// default run_setup
}
key
=
v
.
at
(
1
).
second
.
at
(
2
);
if
(
key
.
find
(
"none"
)
==
std
::
string
::
npos
)
{
double
pc
=
atof
(
key
.
c_str
()
);
// MeV
bunch_
[
"p_central"
].
push_back
(
mixedTools
::
doubleToString
(
pc
)
);
}
else
{
bunch_
[
"p_central"
].
push_back
(
WEN
);
// default 1GeV
bunch_
[
"energy"
].
push_back
(
"none"
);
// default run_setup
string
key2
=
v
.
at
(
1
).
second
.
at
(
2
);
// MeV/c
if
(
key2
.
find
(
"none"
)
==
std
::
string
::
npos
)
{
double
pc
=
atof
(
key
.
c_str
()
);
// MeV/c
bunch_
[
"p_central_mev"
].
push_back
(
key2
);
}
else
{
bunch_
[
"p_central_mev"
].
push_back
(
"none"
);
}
}
key
=
v
.
at
(
1
).
second
.
at
(
3
);
...
...
@@ -231,8 +227,8 @@ void softwareElegant::fromDistribution(const vector<psvs>& v)
{
if
(
debug
>
0
)
cout
<<
"softwareElegant::fromDistribution()
\n
"
;
bunch_
[
"energy"
].
push_back
(
"
0.0
"
);
bunch_
[
"p_central"
].
push_back
(
v
.
at
(
1
).
second
.
at
(
1
)
);
// MeV
bunch_
[
"energy"
].
push_back
(
"
none
"
);
bunch_
[
"p_central
_mev
"
].
push_back
(
v
.
at
(
1
).
second
.
at
(
1
)
);
// MeV
/c
bunch_
[
"emit_x"
].
push_back
(
v
.
at
(
1
).
second
.
at
(
2
)
);
// m.rad
bunch_
[
"emit_y"
].
push_back
(
v
.
at
(
1
).
second
.
at
(
3
)
);
// m.rad
bunch_
[
"emit_z"
].
push_back
(
"0.0"
);
...
...
@@ -248,11 +244,12 @@ void softwareElegant::beamData(particleBeam *beam)
{
if
(
debug
>
0
)
cout
<<
"softwareElegant::beamData( 2 )
\n
"
;
bunch_
[
"energy"
].
push_back
(
"0.0"
);
// P0Transport(GeV/c)= EREST_GeV * p_central(GeV)
double
pc
=
beam
->
getP0Transport
()
/
EREST_GeV
;
// en GeV
pc
*=
1000
;
// en MeV
bunch_
[
"p_central"
].
push_back
(
mixedTools
::
doubleToString
(
pc
)
);
double
pc
=
beam
->
getP0Transport
();
// en GeV/c
pc
*=
1000
;
// en MeV/c
bunch_
[
"p_central_mev"
].
push_back
(
mixedTools
::
doubleToString
(
pc
)
);
pc
/=
EREST_MeV
;
// en MeV
bunch_
[
"energy"
].
push_back
(
mixedTools
::
doubleToString
(
pc
)
);
double
epsx
=
beam
->
emit_x
();
bunch_
[
"emit_x"
].
push_back
(
mixedTools
::
doubleToString
(
epsx
)
);
...
...
@@ -289,7 +286,18 @@ string softwareElegant::run_setup(string sLattice)
os
<<
" lattice = "
<<
sLattice
<<
endl
;
// default order of transfer matrices used for elements having matrices
os
<<
" default_order = 2"
<<
endl
;
os
<<
" p_central= "
<<
bunch_
.
find
(
"p_central"
)
->
second
.
at
(
0
)
<<
endl
;
string
key
=
bunch_
.
find
(
"energy"
)
->
second
.
at
(
0
);
if
(
key
.
find
(
"none"
)
==
std
::
string
::
npos
)
{
os
<<
" p_central= "
<<
key
<<
endl
;
}
else
{
string
key2
=
bunch_
.
find
(
"p_central_mev"
)
->
second
.
at
(
0
);
if
(
key2
.
find
(
"none"
)
==
std
::
string
::
npos
)
{
os
<<
" p_central_mev= "
<<
key2
<<
endl
;
}
else
{
cout
<<
"softwareElegant::run_setup: energy of the beamline is missing
\n
"
;
}
}
os
<<
"&end
\n
"
<<
endl
;
//os << " parameters = run_setup.parameters.sdds" << endl;
...
...
backend/pspa/v0/src/Core/softwareMadx.cc
View file @
b6ae3e24
...
...
@@ -625,14 +625,18 @@ string softwareMadx::fromParameters(const vector<psvs>& v)
}
else
{
str
=
v
.
at
(
1
).
second
.
at
(
2
);
str
=
v
.
at
(
1
).
second
.
at
(
2
);
// E0*βγ en MeV/c
if
(
str
.
find
(
"none"
)
==
std
::
string
::
npos
)
{
double
EGev
=
atof
(
str
.
c_str
())
*
1.e-03
;
// GeV
double
EGev
=
atof
(
str
.
c_str
())
*
1.e-03
/
EREST_MeV
;
// GeV
str
=
mixedTools
::
doubleToString
(
EGev
);
os
<<
", pc= "
<<
str
;
//os << ", pc= " << str;
os
<<
", energy= "
<<
str
;
Energy_
=
str
;
}
else
{
Energy_
=
"1."
;
// 1GeV
}
}
str
=
v
.
at
(
1
).
second
.
at
(
3
);
...
...
@@ -655,10 +659,11 @@ string softwareMadx::fromDistribution(const vector<psvs>& v)
ostringstream
os
;
double
p0
=
atof
(
v
.
at
(
1
).
second
.
at
(
1
).
c_str
());
// MeV
p0
*=
1.e-03
;
// GeV
double
p0
=
atof
(
v
.
at
(
1
).
second
.
at
(
1
).
c_str
());
// in MeV/c
p0
/=
EREST_MeV
;
// in MeV
p0
*=
1.e-03
;
// in GeV
string
str
=
mixedTools
::
doubleToString
(
p0
);
os
<<
",
pc
= "
<<
str
;
os
<<
",
energy
= "
<<
str
;
os
<<
", ex= "
<<
v
.
at
(
1
).
second
.
at
(
2
);
// m.rad
os
<<
", ey= "
<<
v
.
at
(
1
).
second
.
at
(
3
);
// m.rad
Energy_
=
str
;
...
...
@@ -965,10 +970,10 @@ void softwareMadx::diagnostics(ifstream& ifs)
{
string
buf
;
// search the keyword @ PC
// search the keyword @ PC
(@ ENERGY)
while
(
getline
(
ifs
,
buf
)
)
{
if
(
buf
.
find
(
"@
PC
"
)
!=
string
::
npos
)
break
;
if
(
buf
.
find
(
"@
ENERGY
"
)
!=
string
::
npos
)
break
;
}
stringstream
iss
;
iss
<<
buf
;
...
...
backend/pspa/v0/src/KindOfElements/elementBeam.cc
View file @
b6ae3e24
...
...
@@ -53,7 +53,7 @@ void elementBeam::setElement()
vtr_
.
push_back
(
"0.0"
);
// emit_t
vtr_
.
push_back
(
"none"
);
// sig_t
vtr_
.
push_back
(
"none"
);
// sig_e
vtr_
.
push_back
(
"none"
);
// particle distribution
vtr_
.
push_back
(
"none"
);
// particle distribution
file
}
string
*
elementBeam
::
getParametersString
()
const
...
...
@@ -173,10 +173,10 @@ void elementBeam::fromDistribution(string fname,psvs& pstr) const
for
(
int
k
=
0
;
k
<
5
;
k
++
)
s
[
k
]
/=
np
;
for
(
int
k
=
0
;
k
<
5
;
k
++
)
u
[
k
]
/=
np
;
double
p
0
=
bgREF
*
EREST_MeV
;
pstr
.
second
.
push_back
(
mixedTools
::
doubleToString
(
p
0
)
);
if
(
debug
>
0
)
cout
<<
"
pRef sur c= "
<<
p0
<<
" en MeV
\n
"
;
double
p
_central
=
bgREF
*
EREST_MeV
;
// E0*βγ en MeV/c
pstr
.
second
.
push_back
(
mixedTools
::
doubleToString
(
p
_central
));
if
(
debug
>
0
)
cout
<<
"
E0*βγ = "
<<
p_central
<<
"
\n
"
;
double
xx
=
s
[
2
]
-
s
[
0
]
*
s
[
0
];
// m
double
xpxp
=
s
[
3
]
-
s
[
1
]
*
s
[
1
];
// rad
double
xxp
=
s
[
4
]
-
s
[
0
]
*
s
[
1
];
...
...
@@ -233,9 +233,9 @@ void elementBeam::InputRep(UAPNode *root)
}
else
{
if
(
vtr_
[
1
].
find
(
"none"
)
==
std
::
string
::
npos
)
nde
->
addChild
(
"
total_
energy"
)
->
addAttribute
(
"design"
,
vtr_
[
1
]);
nde
->
addChild
(
"energy"
)
->
addAttribute
(
"design"
,
vtr_
[
1
]);
if
(
vtr_
[
2
].
find
(
"none"
)
==
std
::
string
::
npos
)
nde
->
addChild
(
"p
c
"
)
->
addAttribute
(
"design"
,
vtr_
[
2
]);
nde
->
addChild
(
"p
_central
"
)
->
addAttribute
(
"design"
,
vtr_
[
2
]);
if
(
vtr_
[
3
].
find
(
"none"
)
==
std
::
string
::
npos
)
nde
->
addChild
(
"emittance_a"
)
->
addAttribute
(
"design"
,
vtr_
[
3
]);
if
(
vtr_
[
4
].
find
(
"none"
)
==
std
::
string
::
npos
)
...
...
@@ -313,8 +313,8 @@ void elementBeam::getChildNodes(UAPNode* nde)
NodeVec
lst
=
up
->
getChildrenByName
(
"constant"
);
string
str
;
vtr_
.
push_back
(
getKeyValue
(
nde
,
lst
,
"
total_
energy"
)
);
vtr_
.
push_back
(
getKeyValue
(
nde
,
lst
,
"p
c
"
)
);
vtr_
.
push_back
(
getKeyValue
(
nde
,
lst
,
"energy"
)
);
vtr_
.
push_back
(
getKeyValue
(
nde
,
lst
,
"p
_central
"
)
);
vtr_
.
push_back
(
getKeyValue
(
nde
,
lst
,
"emittance_a"
)
);
vtr_
.
push_back
(
getKeyValue
(
nde
,
lst
,
"emittance_b"
)
);
vtr_
.
push_back
(
getKeyValue
(
nde
,
lst
,
"emittance_z"
)
);
...
...
@@ -347,6 +347,7 @@ string elementBeam::print()
void
elementBeam
::
toJSON
(
json
&
j
)
{
if
(
debug
>
0
)
cout
<<
"elementBeam::toJSON()
\n
"
;
cout
<<
"elementBeam::toJSON()
\n
"
;
idElement_
=
"beam-"
+
mixedTools
::
alea
();
j
[
"id"
]
=
idElement_
;
...
...
@@ -356,136 +357,147 @@ void elementBeam::toJSON(json& j)
j
[
"category"
]
=
"element"
;
j
[
"color"
]
=
"#E17055"
;
j
[
"parameters"
][
"particle"
][
"displayName"
]
=
"Particle"
;
j
[
"parameters"
][
"particle"
][
"value"
]
=
vtr_
[
0
];
j
[
"parameters"
][
"particle"
][
"type"
]
=
"string"
;
j
[
"parameters"
][
"
A%
particle"
][
"displayName"
]
=
"Particle"
;
j
[
"parameters"
][
"
A%
particle"
][
"value"
]
=
vtr_
[
0
];
j
[
"parameters"
][
"
A%
particle"
][
"type"
]
=
"string"
;
if
(
vtr_
[
8
].
find
(
"none"
)
==
std
::
string
::
npos
)
{
j
[
"parameters"
][
"distribution"
][
"displayName"
]
=
"FileName"
;
j
[
"parameters"
][
"distribution"
][
"value"
]
=
vtr_
[
8
];
j
[
"parameters"
][
"distribution"
][
"type"
]
=
"string"
;
j
[
"parameters"
][
"
B%
distribution"
][
"displayName"
]
=
"FileName"
;
j
[
"parameters"
][
"
B%
distribution"
][
"value"
]
=
vtr_
[
8
];
j
[
"parameters"
][
"
B%
distribution"
][
"type"
]
=
"string"
;
}
else
{
j
[
"parameters"
][
"energy"
][
"displayName"
]
=
"Energy [MeV]"
;
j
[
"parameters"
][
"
B%
energy"
][
"displayName"
]
=
"Energy [MeV]"
;
if
(
vtr_
[
1
].
find
(
"none"
)
==
std
::
string
::
npos
)
{
j
[
"parameters"
][
"energy"
][
"value"
]
=
atof
(
vtr_
[
1
].
c_str
());
j
[
"parameters"
][
"
B%
energy"
][
"value"
]
=
atof
(
vtr_
[
1
].
c_str
());
}
else
{
j
[
"parameters"
][
"energy"
][
"value"
]
=
nullptr
;
j
[
"parameters"
][
"
B%
energy"
][
"value"
]
=
nullptr
;
}
j
[
"parameters"
][
"energy"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"
B%
energy"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"pc"
][
"displayName"
]
=
"central momentum [MeV]"
;
j
[
"parameters"
][
"
C%
pc"
][
"displayName"
]
=
"central momentum [MeV
/c
]"
;
if
(
vtr_
[
2
].
find
(
"none"
)
==
std
::
string
::
npos
)
{
j
[
"parameters"
][
"pc"
][
"value"
]
=
atof
(
vtr_
[
2
].
c_str
());
j
[
"parameters"
][
"
C%
pc"
][
"value"
]
=
atof
(
vtr_
[
2
].
c_str
());
}
else
{
j
[
"parameters"
][
"pc"
][
"value"
]
=
nullptr
;
j
[
"parameters"
][
"
C%
pc"
][
"value"
]
=
nullptr
;
}
j
[
"parameters"
][
"pc"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"
C%
pc"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"emitx"
][
"displayName"
]
=
"Emit_x [m.rad]"
;
j
[
"parameters"
][
"
D%
emitx"
][
"displayName"
]
=
"Emit_x [m.rad]"
;
if
(
vtr_
[
3
].
find
(
"none"
)
==
std
::
string
::
npos
)
{
j
[
"parameters"
][
"emitx"
][
"value"
]
=
atof
(
vtr_
[
3
].
c_str
());
j
[
"parameters"
][
"
D%
emitx"
][
"value"
]
=
atof
(
vtr_
[
3
].
c_str
());
}
else
{
j
[
"parameters"
][
"emitx"
][
"value"
]
=
0.0
;
//nullptr;
j
[
"parameters"
][
"
D%
emitx"
][
"value"
]
=
0.0
;
//nullptr;
}
j
[
"parameters"
][
"emitx"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"
D%
emitx"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"emity"
][
"displayName"
]
=
"Emit_y [m.rad]"
;
j
[
"parameters"
][
"
E%
emity"
][
"displayName"
]
=
"Emit_y [m.rad]"
;
if
(
vtr_
[
4
].
find
(
"none"
)
==
std
::
string
::
npos
)
{
j
[
"parameters"
][
"emity"
][
"value"
]
=
atof
(
vtr_
[
4
].
c_str
());
j
[
"parameters"
][
"
E%
emity"
][
"value"
]
=
atof
(
vtr_
[
4
].
c_str
());
}
else
{
j
[
"parameters"
][
"emity"
][
"value"
]
=
0.0
;
//nullptr;
j
[
"parameters"
][
"
E%
emity"
][
"value"
]
=
0.0
;
//nullptr;
}
j
[
"parameters"
][
"emity"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"
E%
emity"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"emitt"
][
"displayName"
]
=
"Emit_t [GeV.s]"
;
j
[
"parameters"
][
"
F%
emitt"
][
"displayName"
]
=
"Emit_t [GeV.s]"
;
if
(
vtr_
[
5
].
find
(
"none"
)
==
std
::
string
::
npos
)
{
j
[
"parameters"
][
"emitt"
][
"value"
]
=
atof
(
vtr_
[
5
].
c_str
());
j
[
"parameters"
][
"
F%
emitt"
][
"value"
]
=
atof
(
vtr_
[
5
].
c_str
());
}
else
{
j
[
"parameters"
][
"emitt"
][
"value"
]
=
0.0
;
//nullptr;
j
[
"parameters"
][
"
F%
emitt"
][
"value"
]
=
0.0
;
//nullptr;
}
j
[
"parameters"
][
"emitt"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"
F%
emitt"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"sigt"
][
"displayName"
]
=
"Sig_T [m]"
;
j
[
"parameters"
][
"
G%
sigt"
][
"displayName"
]
=
"Sig_T [m]"
;
if
(
vtr_
[
6
].
find
(
"none"
)
==
std
::
string
::
npos
)
{
j
[
"parameters"
][
"sigt"
][
"value"
]
=
atof
(
vtr_
[
6
].
c_str
());
j
[
"parameters"
][
"
G%
sigt"
][
"value"
]
=
atof
(
vtr_
[
6
].
c_str
());
}
else
{
j
[
"parameters"
][
"sigt"
][
"value"
]
=
nullptr
;
j
[
"parameters"
][
"
G%
sigt"
][
"value"
]
=
nullptr
;
}
j
[
"parameters"
][
"sigt"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"
G%
sigt"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"sige"
][
"displayName"
]
=
"Sig_E []"
;
j
[
"parameters"
][
"
H%
sige"
][
"displayName"
]
=
"Sig_E []"
;
if
(
vtr_
[
7
].
find
(
"none"
)
==
std
::
string
::
npos
)
{
j
[
"parameters"
][
"sige"
][
"value"
]
=
atof
(
vtr_
[
7
].
c_str
());
j
[
"parameters"
][
"
H%
sige"
][
"value"
]
=
atof
(
vtr_
[
7
].
c_str
());
}
else
{
j
[
"parameters"
][
"sige"
][
"value"
]
=
nullptr
;
j
[
"parameters"
][
"
H%
sige"
][
"value"
]
=
nullptr
;
}
j
[
"parameters"
][
"sige"
][
"type"
]
=
"number"
;
j
[
"parameters"
][
"
H%
sige"
][
"type"
]
=
"number"
;
}
}
void
elementBeam
::
fromJSON
(
json
j
)
{
if
(
debug
>
0
)
cout
<<
"elementBeam::fromJSON()
\n
"
;
cout
<<
"elementBeam::fromJSON()
\n
"
;
string
type
=
j
.
find
(
"type"
).
value
();
if
(
type
!=
genericName_
)
return
;
if
(
type
!=
genericName_
)
return
;
string
key
=
j
.
find
(
"displayName"
).
value
();
splitFullName
(
key
);
string
id
=
j
.
find
(
"id"
).
value
();
idElement_
=
id
;
vector
<
string
>
v
(
9
,
"none"
);
// <- default ?
auto
z
=
j
.
find
(
"parameters"
);
json
::
iterator
kt
;
auto
z0
=
z
->
find
(
"particle"
);
if
(
z0
!=
z
->
end
())
{
auto
zz
=
z0
->
find
(
"value"
);
if
(
zz
->
is_string
()
)
{
kt
=
z
->
find
(
"
A%
particle"
);
if
(
kt
!=
z
->
end
())
{
auto
zz
=
kt
->
find
(
"value"
);
if
(
zz
->
is_string
())
{
string
s
=
*
zz
;
v
.
at
(
0
)
=
s
;
}
}
auto
z1
=
z
->
find
(
"energy"
);
if
(
z1
!=
z
->
end
())
{
auto
zz
=
z1
->
find
(
"value"
);
if
(
zz
->
is_number
()
)
v
.
at
(
1
)
=
mixedTools
::
doubleToString
(
*
zz
);
kt
=
z
->
find
(
"B%energy"
);
if
(
kt
!=
z
->
end
())
{
auto
zz
=
kt
->
find
(
"value"
);
if
(
zz
->
is_number
())
v
.
at
(
1
)
=
mixedTools
::
doubleToString
(
*
zz
);
}
auto
z2
=
z
->
find
(
"pc"
);
if
(
z2
!=
z
->
end
())
{
auto
zz
=
z2
->
find
(
"value"
);
if
(
zz
->
is_number
()
)
v
.
at
(
2
)
=
mixedTools
::
doubleToString
(
*
zz
);
kt
=
z
->
find
(
"C%pc"
);
if
(
kt
!=
z
->
end
())
{
auto
zz
=
kt
->
find
(
"value"
);
if
(
zz
->
is_number
())
v
.
at
(
2
)
=
mixedTools
::
doubleToString
(
*
zz
);
}
auto
z3
=
z
->
find
(
"emitx"
);
if
(
z3
!=
z
->
end
())
{
auto
zz
=
z3
->
find
(
"value"
);
if
(
zz
->
is_number
()
)
v
.
at
(
3
)
=
mixedTools
::
doubleToString
(
*
zz
);
kt
=
z
->
find
(
"D%emitx"
);
if
(
kt
!=
z
->
end
())
{
auto
zz
=
kt
->
find
(
"value"
);
if
(
zz
->
is_number
())
v
.
at
(
3
)
=
mixedTools
::
doubleToString
(
*
zz
);
}
auto
z4
=
z
->
find
(
"emity"
);
if
(
z4
!=
z
->
end
())
{
auto
zz
=
z4
->
find
(
"value"
);
kt
=
z
->
find
(
"E%emity"
);
if
(
kt
!=
z
->
end
())
{
auto
zz
=
kt
->
find
(
"value"
);
if
(
zz
->
is_number
())
v
.
at
(
4
)
=
mixedTools
::
doubleToString
(
*
zz
);
}
auto
z5
=
z
->
find
(
"emitt"
);
if
(
z5
!=
z
->
end
())
{
auto
zz
=
z5
->
find
(
"value"
);
kt
=
z
->
find
(
"F%emitt"
);
if
(
kt
!=
z
->
end
())
{
auto
zz
=
kt
->
find
(
"value"
);
if
(
zz
->
is_number
())
v
.
at
(
5
)
=
mixedTools
::
doubleToString
(
*
zz
);
}
auto
z6
=
z
->
find
(
"sigt"
);
if
(
z6
!=
z
->
end
())
{
auto
zz
=
z6
->
find
(
"value"
);
kt
=
z
->
find
(
"G%sigt"
);
if
(
kt
!=
z
->
end
())
{
auto
zz
=
kt
->
find
(
"value"
);
if
(
zz
->
is_number
())
v
.
at
(
6
)
=
mixedTools
::
doubleToString
(
*
zz
);
}
auto
z7
=
z
->
find
(
"sige"
);
if
(
z7
!=
z
->
end
())
{
auto
zz
=
z7
->
find
(
"value"
);
kt
=
z
->
find
(
"H%sige"
);
if
(
kt
!=
z
->
end
())
{
auto
zz
=
kt
->
find
(
"value"
);
if
(
zz
->
is_number
())
v
.
at
(
7
)
=
mixedTools
::
doubleToString
(
*
zz
);
}
auto
z8
=
z
->
find
(
"distribution"
);
if
(
z8
!=
z
->
end
())
{
auto
zz
=
z8
->
find
(
"value"
);
if
(
zz
->
is_string
()
)
{
kt
=
z
->
find
(
"B%distribution"
);
if
(
kt
!=
z
->
end
())
{
auto
zz
=
kt
->
find
(
"value"
);
if
(
zz
->
is_string
())
{
string
s
=
*
zz
;
v
.
at
(
8
)
=
s
;
}
...
...
frontend/src/utils/models/beam.js
View file @
b6ae3e24
export
class
BeamParameters
{
particle
;
energy
;
emitx
;
emitt
;
sige
;
pc
;
emity
;
sigt
;
particle
;
distribution
;
energy
;
pc
;
emitx
;
emity
;
emitt
;
sigt
;
sige
;
constructor
()
{
constructor
()
{
this
.
particle
=
{
displayName
:
'
Particule
'
,
displayName
:
'
Species
'
,
value
:
'
electrons
'
,
type
:
'
string
'
};
this
.
distribution
=
{
displayName
:
'
Particle distribution file
'
,
value
:
null
,
type
:
'
string
'
};
this
.
energy
=
{
displayName
:
'
Energy [
G
eV]
'
,
displayName
:
'
Energy [
M
eV]
'
,
value
:
null
,
type
:
'
number
'
};
this
.
emitx
=
{
displayName
:
'
Emit_x [m.rad]
'
,
this
.
pc
=
{
displayName
:
'
Central momentum [MeV/c]
'
,
value
:
null
,
type
:
'
number
'
};
this
.
emitt
=
{
displayName
:
'
Emit_t [GeV.s]
'
,
};
this
.
emitx
=
{
displayName
:
'
Emit_x [m.rad]
'
,
value
:
null
,
type
:
'
number
'
};
this
.
sige
=
{
displayName
:
'
Sig_e
'
,
};
this
.
emity
=
{
displayName
:
'
Emit_y [m.rad]
'
,
value
:
null
,
type
:
'
number
'
};
this
.
pc
=
{
displayName
:
'
Pc [GeV]
'
,
};
this
.
emitt
=
{
displayName
:
'
Emit_t [GeV.s]
'
,
value
:
null
,
type
:
'
number
'
};
this
.
emity
=
{
displayName
:
'
Emit_y [m.rad]
'
,
};