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
d1537e72
Commit
d1537e72
authored
10 years ago
by
Markus Frank
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug in DetElement transformations - test example with boxes
parent
3d02f90a
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
examples/ClientTests/compact/BoxTrafos.xml
+50
-0
50 additions, 0 deletions
examples/ClientTests/compact/BoxTrafos.xml
examples/ClientTests/scripts/BoxTrafos.C
+118
-0
118 additions, 0 deletions
examples/ClientTests/scripts/BoxTrafos.C
with
168 additions
and
0 deletions
examples/ClientTests/compact/BoxTrafos.xml
0 → 100644
+
50
−
0
View file @
d1537e72
<lccdd
xmlns:compact=
"http://www.lcsim.org/schemas/compact/1.0"
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
xs:noNamespaceSchemaLocation=
"http://www.lcsim.org/schemas/compact/1.0/compact.xsd"
>
<info
name=
"alignment_boxes"
title=
"Alignment test with 2 simple boxes"
author=
"Markus Frank"
url=
"http://www.cern.ch/lhcb"
status=
"development"
version=
"$Id: compact.xml 513 2013-04-05 14:31:53Z gaede $"
>
<comment>
Alignment test with 2 simple boxes
</comment>
</info>
<includes>
<gdmlFile
ref=
"elements.xml"
/>
<gdmlFile
ref=
"materials.xml"
/>
</includes>
<define>
<constant
name=
"world_side"
value=
"30000"
/>
<constant
name=
"world_x"
value=
"world_side"
/>
<constant
name=
"world_y"
value=
"world_side"
/>
<constant
name=
"world_z"
value=
"world_side"
/>
</define>
<display>
<vis
name=
"InvisibleNoDaughters"
showDaughters=
"false"
visible=
"false"
/>
<vis
name=
"InvisibleWithDaughters"
showDaughters=
"true"
visible=
"false"
/>
<vis
name=
"B1_vis"
alpha=
"1.0"
r=
"1"
g=
"0"
b=
"0"
showDaughters=
"true"
visible=
"true"
/>
<vis
name=
"B2_vis"
alpha=
"1.0"
r=
"0"
g=
"1"
b=
"0"
showDaughters=
"true"
visible=
"true"
/>
</display>
<detectors>
<comment>
Boxes
</comment>
<detector
id=
"3"
name=
"B3"
type=
"BoxSegment"
vis=
"B2_vis"
>
<comment>
Vertical box
</comment>
<material
name=
"Steel235"
/>
<box
x=
"10"
y=
"20"
z=
"30"
/>
<position
x=
"-10"
y=
"30"
z=
"10"
/>
<rotation
x=
"0"
y=
"0"
z=
"0"
/>
</detector>
<detector
id=
"3"
name=
"B4"
type=
"BoxSegment"
vis=
"B1_vis"
>
<comment>
Vertical box
</comment>
<material
name=
"Steel235"
/>
<box
x=
"10"
y=
"20"
z=
"30"
/>
<position
x=
"0"
y=
"0"
z=
"0"
/>
<rotation
x=
"0"
y=
"0"
z=
"0"
/>
</detector>
</detectors>
</lccdd>
This diff is collapsed.
Click to expand it.
examples/ClientTests/scripts/BoxTrafos.C
0 → 100644
+
118
−
0
View file @
d1537e72
namespace
{
struct
Loader
{
Loader
()
{
gSystem
->
Load
(
"libDD4hepCore"
);
}
}
_load
;
}
using
namespace
DD4hep
::
Geometry
;
void
printPos
(
const
char
*
com
,
const
Position
&
p
)
{
printf
(
"%-24s: %7.3f %7.3f %7.3f
\n
"
,
com
,
p
.
x
(),
p
.
y
(),
p
.
z
());
}
void
printCoord
(
const
Position
&
global
,
const
Position
&
local
)
{
printPos
(
"Global"
,
global
);
printPos
(
"Local"
,
local
);
}
void
local_to_world
(
const
char
*
com
,
const
DetElement
de
,
const
Position
&
pos
,
const
Position
&
loc
)
{
Position
glob
;
printf
(
"Local to World: Transformation '%s'(%7.3f, %7.3f, %7.3f)->world (Should be: (%7.3f, %7.3f, %7.3f) :
\n
"
,
com
,
loc
.
x
(),
loc
.
y
(),
loc
.
z
(),
loc
.
x
()
+
pos
.
x
(),
loc
.
y
()
+
pos
.
y
(),
loc
.
z
()
+
pos
.
z
()
);
de
.
localToWorld
(
loc
,
glob
);
printCoord
(
glob
,
loc
);
}
void
world_to_local
(
const
char
*
com
,
const
DetElement
de
,
const
Position
&
pos
,
const
Position
&
glob
)
{
Position
loc
;
printf
(
"World to Local: Transformation '%s'(%7.3f, %7.3f, %7.3f)->world (Should be: (%7.3f, %7.3f, %7.3f) :
\n
"
,
com
,
glob
.
x
(),
glob
.
y
(),
glob
.
z
(),
glob
.
x
()
-
pos
.
x
(),
glob
.
y
()
-
pos
.
y
(),
glob
.
z
()
-
pos
.
z
()
);
de
.
worldToLocal
(
glob
,
loc
);
printCoord
(
glob
,
loc
);
}
int
BoxTrafos
()
{
string
xml
=
"file:"
;
xml
+=
gSystem
->
Getenv
(
"DD4hepINSTALL"
);
xml
+=
"/examples/ClientTests/compact/BoxTrafos.xml"
;
const
char
*
argv
[]
=
{
xml
.
c_str
(),
"BUILD_DEFAULT"
,
0
};
gSystem
->
Load
(
"libDD4hepCore"
);
LCDD
&
lcdd
=
LCDD
::
getInstance
();
lcdd
.
apply
(
"DD4hepCompactLoader"
,
2
,(
char
**
)
argv
);
lcdd
.
apply
(
"DD4hepGeometryDisplay"
,
0
,
0
);
DetElement
de
=
lcdd
.
detector
(
"B3"
);
PlacedVolume
pv
=
de
.
placement
();
Volume
vol
=
pv
.
volume
();
Solid
solid
=
vol
.
solid
();
TGeoBBox
*
box
=
(
TGeoBBox
*
)(
solid
.
ptr
());
Position
glob
,
loc
,
pos
(
-
10
,
30
,
10
);
printf
(
"
\n
++++ local->world:
\n\n
"
);
loc
=
Position
(
-
pos
.
x
(),
-
pos
.
y
(),
-
pos
.
z
());
local_to_world
(
"origine"
,
de
,
pos
,
loc
);
loc
=
Position
();
local_to_world
(
"center"
,
de
,
pos
,
loc
);
loc
=
Position
(
box
->
GetDX
(),
box
->
GetDY
(),
box
->
GetDZ
());
local_to_world
(
"top edge"
,
de
,
pos
,
loc
);
loc
=
Position
(
box
->
GetDX
(),
box
->
GetDY
(),
-
box
->
GetDZ
());
local_to_world
(
"top edge"
,
de
,
pos
,
loc
);
loc
=
Position
(
-
box
->
GetDX
(),
box
->
GetDY
(),
box
->
GetDZ
());
local_to_world
(
"top edge"
,
de
,
pos
,
loc
);
loc
=
Position
(
-
box
->
GetDX
(),
box
->
GetDY
(),
-
box
->
GetDZ
());
local_to_world
(
"top edge"
,
de
,
pos
,
loc
);
loc
=
Position
(
box
->
GetDX
(),
-
box
->
GetDY
(),
box
->
GetDZ
());
local_to_world
(
"bottom edge"
,
de
,
pos
,
loc
);
loc
=
Position
(
box
->
GetDX
(),
-
box
->
GetDY
(),
-
box
->
GetDZ
());
local_to_world
(
"bottom edge"
,
de
,
pos
,
loc
);
loc
=
Position
(
-
box
->
GetDX
(),
-
box
->
GetDY
(),
box
->
GetDZ
());
local_to_world
(
"bottom edge"
,
de
,
pos
,
loc
);
loc
=
Position
(
-
box
->
GetDX
(),
-
box
->
GetDY
(),
-
box
->
GetDZ
());
local_to_world
(
"bottom edge"
,
de
,
pos
,
loc
);
printf
(
"
\n
++++ world->local:
\n\n
"
);
glob
=
Position
(
0
,
0
,
0
);
world_to_local
(
"world center"
,
de
,
pos
,
glob
);
glob
=
Position
(
pos
.
x
(),
pos
.
y
(),
pos
.
z
());
world_to_local
(
"position"
,
de
,
pos
,
glob
);
glob
=
Position
(
box
->
GetDX
()
+
pos
.
x
(),
box
->
GetDY
()
+
pos
.
y
(),
box
->
GetDZ
()
+
pos
.
z
());
world_to_local
(
"top edge"
,
de
,
pos
,
glob
);
glob
=
Position
(
box
->
GetDX
()
+
pos
.
x
(),
box
->
GetDY
()
+
pos
.
y
(),
-
box
->
GetDZ
()
+
pos
.
z
());
world_to_local
(
"top edge"
,
de
,
pos
,
glob
);
glob
=
Position
(
-
box
->
GetDX
()
+
pos
.
x
(),
box
->
GetDY
()
+
pos
.
y
(),
box
->
GetDZ
()
+
pos
.
z
());
world_to_local
(
"top edge"
,
de
,
pos
,
glob
);
glob
=
Position
(
-
box
->
GetDX
()
+
pos
.
x
(),
box
->
GetDY
()
+
pos
.
y
(),
-
box
->
GetDZ
()
+
pos
.
z
());
world_to_local
(
"top edge"
,
de
,
pos
,
glob
);
glob
=
Position
(
box
->
GetDX
()
+
pos
.
x
(),
-
box
->
GetDY
()
+
pos
.
y
(),
box
->
GetDZ
()
+
pos
.
z
());
world_to_local
(
"bottom edge"
,
de
,
pos
,
glob
);
glob
=
Position
(
box
->
GetDX
()
+
pos
.
x
(),
-
box
->
GetDY
()
+
pos
.
y
(),
-
box
->
GetDZ
()
+
pos
.
z
());
world_to_local
(
"bottom edge"
,
de
,
pos
,
glob
);
glob
=
Position
(
-
box
->
GetDX
()
+
pos
.
x
(),
-
box
->
GetDY
()
+
pos
.
y
(),
box
->
GetDZ
()
+
pos
.
z
());
world_to_local
(
"bottom edge"
,
de
,
pos
,
glob
);
glob
=
Position
(
-
box
->
GetDX
()
+
pos
.
x
(),
-
box
->
GetDY
()
+
pos
.
y
(),
-
box
->
GetDZ
()
+
pos
.
z
());
world_to_local
(
"bottom edge"
,
de
,
pos
,
glob
);
return
1
;
}
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