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
9492117a
Commit
9492117a
authored
7 years ago
by
Frank Gaede
Committed by
Frank Gaede
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add utility dumpBfield.cpp
parent
3615c713
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
UtilityApps/CMakeLists.txt
+2
-0
2 additions, 0 deletions
UtilityApps/CMakeLists.txt
UtilityApps/src/dumpBfield.cpp
+98
-0
98 additions, 0 deletions
UtilityApps/src/dumpBfield.cpp
with
100 additions
and
0 deletions
UtilityApps/CMakeLists.txt
+
2
−
0
View file @
9492117a
...
...
@@ -19,6 +19,8 @@ dd4hep_add_executable( geoConverter src/converter.cpp )
#-----------------------------------------------------------------------------------
dd4hep_add_executable
(
geoPluginRun src/plugin_runner.cpp
)
#-----------------------------------------------------------------------------------
dd4hep_add_executable
(
dumpBfield src/dumpBfield.cpp
)
#-----------------------------------------------------------------------------------
dd4hep_add_executable
(
print_materials src/print_materials.cpp USES DDRec
)
#-----------------------------------------------------------------------------------
dd4hep_add_executable
(
materialScan src/materialScan.cpp USES DDRec
)
...
...
This diff is collapsed.
Click to expand it.
UtilityApps/src/dumpBfield.cpp
0 → 100644
+
98
−
0
View file @
9492117a
//==========================================================================
// AIDA Detector description implementation for LCD
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
//==========================================================================
//
// Simple program to dump the B-field of the world volume in a cartesian grid
//
// Author : F.Gaede, DESY
// Date : 29 Mar 2017
//==========================================================================
// Framework include files
#include
"DD4hep/LCDD.h"
#include
"DD4hep/DD4hepUnits.h"
using
namespace
std
;
using
namespace
DD4hep
;
using
namespace
DD4hep
::
Geometry
;
//=============================================================================
static
int
invoke_dump_B_field
(
int
argc
,
char
**
argv
){
if
(
argc
!=
8
)
{
std
::
cout
<<
" usage: dumpBfield compact.xml x y z dx dy dz [in cm]"
<<
" will dump the B-field in volume [-x:x,-y:y,-z,z] with steps [dx,dy,dz] "
<<
std
::
endl
;
exit
(
1
)
;
}
std
::
string
inFile
=
argv
[
1
]
;
std
::
stringstream
sstr
;
sstr
<<
argv
[
2
]
<<
" "
<<
argv
[
3
]
<<
" "
<<
argv
[
4
]
<<
" "
<<
argv
[
5
]
<<
" "
<<
argv
[
6
]
<<
" "
<<
argv
[
7
]
;
float
xRange
,
yRange
,
zRange
,
dx
,
dy
,
dz
;
sstr
>>
xRange
;
sstr
>>
yRange
;
sstr
>>
zRange
;
sstr
>>
dx
;
sstr
>>
dy
;
sstr
>>
dz
;
LCDD
&
lcdd
=
LCDD
::
getInstance
();
lcdd
.
fromCompact
(
inFile
);
DetElement
world
=
lcdd
.
world
()
;
std
::
cout
<<
"#######################################################################################################"
<<
std
::
endl
;
std
::
cout
<<
" x[cm] y[cm] z[cm] Bx[Tesla] By[cm] Bz[cm] "
<<
std
::
endl
;
for
(
float
x
=
-
xRange
;
x
<=
xRange
;
x
+=
dx
){
for
(
float
y
=
-
yRange
;
y
<=
yRange
;
y
+=
dy
){
for
(
float
z
=
-
zRange
;
z
<=
zRange
;
z
+=
dz
){
double
posV
[
3
]
=
{
x
,
y
,
z
}
;
double
bfieldV
[
3
]
;
lcdd
.
field
().
magneticField
(
{
0.
,
0.
,
0.
}
,
bfieldV
)
;
printf
(
" %+15.8e %+15.8e %+15.8e %+15.8e %+15.8e %+15.8e
\n
"
,
posV
[
0
],
posV
[
1
],
posV
[
2
],
bfieldV
[
0
]
/
dd4hep
::
tesla
,
bfieldV
[
1
]
/
dd4hep
::
tesla
,
bfieldV
[
2
]
/
dd4hep
::
tesla
)
;
}
}
}
std
::
cout
<<
"#######################################################################################################"
<<
std
::
endl
;
return
0
;
}
int
main
(
int
argc
,
char
**
argv
){
try
{
return
invoke_dump_B_field
(
argc
,
argv
);
}
catch
(
const
std
::
exception
&
e
)
{
std
::
cout
<<
"Got uncaught exception: "
<<
e
.
what
()
<<
std
::
endl
;
}
catch
(...)
{
std
::
cout
<<
"Got UNKNOWN uncaught exception."
<<
std
::
endl
;
}
return
EINVAL
;
}
//=============================================================================
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