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
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
TOUZE Francois
PSPA
Commits
c170d2ba
Commit
c170d2ba
authored
Nov 29, 2019
by
TOUZE Francois
Browse files
rework the reading of a BETA file
parent
27ba7232
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
29 deletions
+88
-29
backend/pspa/v0/src/Core/BETAParser.cc
backend/pspa/v0/src/Core/BETAParser.cc
+88
-29
No files found.
backend/pspa/v0/src/Core/BETAParser.cc
View file @
c170d2ba
...
...
@@ -29,9 +29,21 @@ UAPNode* BETAParser::FileToAMLRep (const string& fileName)
getline
(
ifs
,
buf
);
}
while
(
buf
.
find
(
"* TITRE"
)
==
string
::
npos
&&
!
ifs
.
eof
()
);
string
nameOfMachine
;
if
(
buf
.
find
(
"* TITRE"
)
==
string
::
npos
)
{
// set position of stream to the beginning
ifs
.
clear
();
ifs
.
seekg
(
0
,
ios
::
beg
);
nameOfMachine
=
"NOTITLE"
;
}
else
{
getline
(
ifs
,
buf
);
cout
<<
"found TITRE => "
<<
buf
<<
endl
;
string
nameOfMachine
=
buf
;
nameOfMachine
=
buf
;
}
// find the ELEMENTS
do
{
...
...
@@ -39,6 +51,14 @@ UAPNode* BETAParser::FileToAMLRep (const string& fileName)
getline
(
ifs
,
buf
);
}
while
(
buf
.
find
(
"* LIST OF ELEMENTS"
)
==
string
::
npos
&&
!
ifs
.
eof
()
);
if
(
buf
.
find
(
"* LIST OF ELEMENTS"
)
==
string
::
npos
)
{
cout
<<
"BETAParser::FileToAMLRep:: LIST OF ELEMENTS is mandatory
\n
"
;
return
NULL
;
}
ListOfElements
(
ifs
);
// find the STRUCTURE
...
...
@@ -47,6 +67,14 @@ UAPNode* BETAParser::FileToAMLRep (const string& fileName)
getline
(
ifs
,
buf
);
}
while
(
buf
.
find
(
"* STRUCTURE"
)
==
string
::
npos
&&
!
ifs
.
eof
()
);
if
(
buf
.
find
(
"* STRUCTURE"
)
==
string
::
npos
)
{
cout
<<
"BETAParser::FileToAMLRep:: STRUCTURE is mandatory
\n
"
;
return
NULL
;
}
getline
(
ifs
,
buf
);
int
num
=
BasicUtilities
::
string_to_int
(
buf
);
...
...
@@ -76,6 +104,15 @@ UAPNode* BETAParser::FileToAMLRep (const string& fileName)
getline
(
ifs
,
buf
);
}
while
(
buf
.
find
(
"* PARTICLE"
)
==
string
::
npos
&&
!
ifs
.
eof
()
);
if
(
buf
.
find
(
"* PARTICLE"
)
==
string
::
npos
)
{
ifs
.
clear
();
ifs
.
seekg
(
0
,
ios
::
beg
);
n5
->
addChild
(
"particle"
)
->
addAttribute
(
"type"
,
"ELECTRON"
);
}
else
{
getline
(
ifs
,
buf
);
string
ptype
;
if
(
buf
.
find
(
"E"
)
!=
string
::
npos
)
{
...
...
@@ -91,6 +128,7 @@ UAPNode* BETAParser::FileToAMLRep (const string& fileName)
ptype
=
"OTHER"
;
}
n5
->
addChild
(
"particle"
)
->
addAttribute
(
"type"
,
ptype
);
}
// find ENERGIE CINETIQUE (MeV)
do
{
...
...
@@ -98,10 +136,19 @@ UAPNode* BETAParser::FileToAMLRep (const string& fileName)
getline
(
ifs
,
buf
);
}
while
(
buf
.
find
(
"* ENERGIE"
)
==
string
::
npos
&&
!
ifs
.
eof
()
);
if
(
buf
.
find
(
"* ENERGIE"
)
==
string
::
npos
)
{
ifs
.
clear
();
ifs
.
seekg
(
0
,
ios
::
beg
);
}
else
{
ifs
>>
buf
;
n5
->
addChild
(
"total_energy"
)
->
addAttribute
(
"design"
,
buf
);
ifs
>>
buf
;
n5
->
addChild
(
"mass"
)
->
addAttribute
(
"design"
,
buf
);
}
// find EMITTANCE
do
{
...
...
@@ -109,6 +156,14 @@ UAPNode* BETAParser::FileToAMLRep (const string& fileName)
getline
(
ifs
,
buf
);
}
while
(
buf
.
find
(
"* EMITTANCE"
)
==
string
::
npos
&&
!
ifs
.
eof
()
);
if
(
buf
.
find
(
"* EMITTANCE"
)
==
string
::
npos
)
{
ifs
.
clear
();
ifs
.
seekg
(
0
,
ios
::
beg
);
}
else
{
ifs
>>
buf
;
n5
->
addChild
(
"emittance_a"
)
->
addAttribute
(
"design"
,
buf
);
ifs
>>
buf
;
...
...
@@ -116,6 +171,10 @@ UAPNode* BETAParser::FileToAMLRep (const string& fileName)
ifs
>>
buf
;
n5
->
addChild
(
"emittance_z"
)
->
addAttribute
(
"design"
,
buf
);
}
ifs
.
close
();
// Creates a UAPNode named "machine"
UAPNode
*
nde
=
NULL
;
nde
=
new
UAPNode
(
"laboratory"
);
...
...
@@ -132,7 +191,7 @@ UAPNode* BETAParser::FileToAMLRep (const string& fileName)
nde
->
addChild
(
n3
);
nde
->
addChild
(
n4
);
cout
<<
"BETAPARSER:: "
<<
nde
->
toStringTree
()
<<
endl
;
//
cout << "BETAPARSER:: " << nde->toStringTree() << endl;
return
nde
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment