Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD4hep
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
externals
mirroring
DD4hep
Commits
8f65e8fa
Commit
8f65e8fa
authored
10 years ago
by
Markus Frank
Browse files
Options
Downloads
Patches
Plain Diff
Fix material problem if Z=0, A<1 or density below standard floating point precision
parent
22f9f089
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
DDCore/src/XML/XMLElements.cpp
+2
-2
2 additions, 2 deletions
DDCore/src/XML/XMLElements.cpp
DDCore/src/plugins/LCDDConverter.cpp
+8
-7
8 additions, 7 deletions
DDCore/src/plugins/LCDDConverter.cpp
with
10 additions
and
9 deletions
DDCore/src/XML/XMLElements.cpp
+
2
−
2
View file @
8f65e8fa
...
...
@@ -784,14 +784,14 @@ Attribute Handle_t::setAttr(const XmlChar* name, bool val) const {
/// Generic attribute setter with floating point value
Attribute
Handle_t
::
setAttr
(
const
XmlChar
*
name
,
float
val
)
const
{
char
txt
[
32
];
::
snprintf
(
txt
,
sizeof
(
txt
),
"%
f
"
,
val
);
::
snprintf
(
txt
,
sizeof
(
txt
),
"%
.8e
"
,
val
);
return
setAttr
(
name
,
Strng_t
(
txt
));
}
/// Generic attribute setter with double precision floating point value
Attribute
Handle_t
::
setAttr
(
const
XmlChar
*
name
,
double
val
)
const
{
char
txt
[
32
];
::
snprintf
(
txt
,
sizeof
(
txt
),
"%
f
"
,
val
);
::
snprintf
(
txt
,
sizeof
(
txt
),
"%
.8e
"
,
val
);
return
setAttr
(
name
,
Strng_t
(
txt
));
}
...
...
This diff is collapsed.
Click to expand it.
DDCore/src/plugins/LCDDConverter.cpp
+
8
−
7
View file @
8f65e8fa
...
...
@@ -119,15 +119,19 @@ xml_h LCDDConverter::handleElement(const string& /* name */, Atom element) const
GeometryInfo
&
geo
=
data
();
xml_h
e
=
geo
.
xmlElements
[
element
];
if
(
!
e
)
{
int
Z
=
element
->
Z
();
double
A
=
element
->
A
();
xml_elt_t
atom
(
geo
.
doc
,
_U
(
atom
));
// If we got an unphysical material (Z<1 or A<1)
// We pretend it is hydrogen and force Z=1 or A=1.00794 g/mole
geo
.
doc_materials
.
append
(
e
=
xml_elt_t
(
geo
.
doc
,
_U
(
element
)));
e
.
append
(
atom
);
e
.
setAttr
(
_U
(
name
),
element
->
GetName
());
e
.
setAttr
(
_U
(
formula
),
element
->
GetName
());
e
.
setAttr
(
_U
(
Z
),
element
->
Z
()
);
e
.
setAttr
(
_U
(
Z
),
Z
>
0
?
Z
:
1
);
atom
.
setAttr
(
_U
(
type
),
"A"
);
atom
.
setAttr
(
_U
(
unit
),
"g/mol"
);
atom
.
setAttr
(
_U
(
value
),
element
->
A
()
/* *(g/mole) */
);
atom
.
setAttr
(
_U
(
value
),
A
>
0.99
?
A
:
1.00794
/* *(g/mole) */
);
geo
.
xmlElements
[
element
]
=
e
;
}
return
e
;
...
...
@@ -141,8 +145,7 @@ xml_h LCDDConverter::handleMaterial(const string& name, Material medium) const {
xml_h
obj
;
TGeoMaterial
*
m
=
medium
->
GetMaterial
();
double
d
=
m
->
GetDensity
();
//*(gram/cm3);
if
(
d
<
1e-25
)
d
=
1e-25
;
if
(
d
<
1e-10
)
d
=
1e-10
;
mat
=
xml_elt_t
(
geo
.
doc
,
_U
(
material
));
mat
.
setAttr
(
_U
(
name
),
medium
->
GetName
());
mat
.
append
(
obj
=
xml_elt_t
(
geo
.
doc
,
_U
(
D
)));
...
...
@@ -151,9 +154,7 @@ xml_h LCDDConverter::handleMaterial(const string& name, Material medium) const {
obj
.
setAttr
(
_U
(
type
),
"density"
);
geo
.
checkMaterial
(
name
,
medium
);
if
(
name
==
"B"
)
{
cout
<<
"Converting material:"
<<
name
<<
endl
;
}
if
(
m
->
IsMixture
())
{
TGeoMixture
*
mix
=
(
TGeoMixture
*
)
m
;
const
double
*
wmix
=
mix
->
GetWmixt
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment