Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
athena_MET
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Plebani
athena_MET
Commits
2d038ceb
Commit
2d038ceb
authored
3 years ago
by
Christos Anastopoulos
Browse files
Options
Downloads
Patches
Plain Diff
BFieldMesh: add static assert on the types , try to vecotrize the int to double conversions
parent
c1cae291
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
MagneticField/MagFieldElements/MagFieldElements/BFieldMesh.h
+7
-2
7 additions, 2 deletions
MagneticField/MagFieldElements/MagFieldElements/BFieldMesh.h
MagneticField/MagFieldElements/MagFieldElements/BFieldMesh.icc
+83
-44
83 additions, 44 deletions
...ticField/MagFieldElements/MagFieldElements/BFieldMesh.icc
with
90 additions
and
46 deletions
MagneticField/MagFieldElements/MagFieldElements/BFieldMesh.h
+
7
−
2
View file @
2d038ceb
/*
Copyright (C) 2002-202
1
CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-202
2
CERN for the benefit of the ATLAS collaboration
*/
/**
...
...
@@ -15,7 +15,9 @@
* Then we have
* numz X numr X numphi field values at these corners
*
* The field type is templated - it is short for both solenoid and toroid
* The field type is templated simalar to BFieldVector
*
* It is short for both solenoid and toroid
* for the nominal case.
* There is a special case for BFieldSolenoid (not used in the nominal case)
* which allows a tilt between the nominal and 'tilted' solenoid fields
...
...
@@ -40,6 +42,9 @@ template<class T>
class
BFieldMesh
{
public:
static_assert
((
std
::
is_same
<
T
,
short
>::
value
||
std
::
is_same
<
T
,
double
>::
value
),
"Type for the BField Mesh must be one of short or double"
);
BFieldMesh
()
=
default
;
BFieldMesh
(
const
BFieldMesh
&
)
=
default
;
BFieldMesh
(
BFieldMesh
&&
)
=
default
;
...
...
This diff is collapsed.
Click to expand it.
MagneticField/MagFieldElements/MagFieldElements/BFieldMesh.icc
+
83
−
44
View file @
2d038ceb
/*
Copyright (C) 2002-202
0
CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-202
2
CERN for the benefit of the ATLAS collaboration
*/
#include
"CxxUtils/vec.h"
...
...
@@ -167,21 +167,21 @@ BFieldMesh<T>::getCache(double z,
// find the mesh, and relative location in the mesh
// z
const
std
::
vector
<
double
>&
mz
(
m_mesh
[
0
]);
int
iz
=
int
((
z
-
zmin
())
*
m_invUnit
[
0
]);
// index to LUT
iz
=
m_LUT
[
0
][
iz
];
// tentative mesh index from LUT
int
iz
=
static_cast
<
int
>
((
z
-
zmin
())
*
m_invUnit
[
0
]);
// index to LUT
iz
=
m_LUT
[
0
][
iz
];
// tentative mesh index from LUT
if
(
z
>
mz
[
iz
+
1
])
{
++
iz
;
}
// r
const
std
::
vector
<
double
>&
mr
(
m_mesh
[
1
]);
int
ir
=
int
((
r
-
rmin
())
*
m_invUnit
[
1
]);
// index to LUT
ir
=
m_LUT
[
1
][
ir
];
// tentative mesh index from LUT
int
ir
=
static_cast
<
int
>
((
r
-
rmin
())
*
m_invUnit
[
1
]);
// index to LUT
ir
=
m_LUT
[
1
][
ir
];
// tentative mesh index from LUT
if
(
r
>
mr
[
ir
+
1
])
{
++
ir
;
}
// phi
const
std
::
vector
<
double
>&
mphi
(
m_mesh
[
2
]);
int
iphi
=
int
((
phi
-
phimin
())
*
m_invUnit
[
2
]);
// index to LUT
int
iphi
=
static_cast
<
int
>
((
phi
-
phimin
())
*
m_invUnit
[
2
]);
// index to LUT
iphi
=
m_LUT
[
2
][
iphi
];
// tentative mesh index from LUT
if
(
phi
>
mphi
[
iphi
+
1
])
{
++
iphi
;
...
...
@@ -189,48 +189,87 @@ BFieldMesh<T>::getCache(double z,
// store the bin edges
cache
.
setRange
(
mz
[
iz
],
mz
[
iz
+
1
],
mr
[
ir
],
mr
[
ir
+
1
],
mphi
[
iphi
],
mphi
[
iphi
+
1
]);
// store the B field at the 8 corners
in
cache
// store the B field at the 8 corners
of the bin in the
cache
const
int
im0
=
iz
*
m_zoff
+
ir
*
m_roff
+
iphi
;
// index of the first corner
const
double
sf
=
scaleFactor
;
/*
* The typical case is that we convert from short to double
* (explicitly or implicitly) in order to multiply with the double sf
*/
CxxUtils
::
vec
<
double
,
8
>
field1
=
{
static_cast
<
double
>
(
m_field
[
im0
][
0
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_roff
][
0
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
][
0
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
+
m_roff
][
0
]),
static_cast
<
double
>
(
m_field
[
im0
+
1
][
0
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_roff
+
1
][
0
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
+
1
][
0
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
+
m_roff
+
1
][
0
])
};
CxxUtils
::
vec
<
double
,
8
>
field2
=
{
static_cast
<
double
>
(
m_field
[
im0
][
1
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_roff
][
1
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
][
1
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
+
m_roff
][
1
]),
static_cast
<
double
>
(
m_field
[
im0
+
1
][
1
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_roff
+
1
][
1
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
+
1
][
1
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
+
m_roff
+
1
][
1
])
};
CxxUtils
::
vec
<
double
,
8
>
field3
=
{
static_cast
<
double
>
(
m_field
[
im0
][
2
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_roff
][
2
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
][
2
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
+
m_roff
][
2
]),
static_cast
<
double
>
(
m_field
[
im0
+
1
][
2
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_roff
+
1
][
2
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
+
1
][
2
]),
static_cast
<
double
>
(
m_field
[
im0
+
m_zoff
+
m_roff
+
1
][
2
])
};
cache
.
setField
(
sf
*
field1
,
sf
*
field2
,
sf
*
field3
);
// store the B scale
cache
.
setBscale
(
m_scale
);
// In the usual case the m_field is of type short int
// else (special case) can be double
if
constexpr
(
std
::
is_same
<
T
,
short
>::
value
)
{
CxxUtils
::
vec
<
int
,
8
>
field1I
=
{
(
m_field
[
im0
][
0
]),
(
m_field
[
im0
+
m_roff
][
0
]),
(
m_field
[
im0
+
m_zoff
][
0
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
][
0
]),
(
m_field
[
im0
+
1
][
0
]),
(
m_field
[
im0
+
m_roff
+
1
][
0
]),
(
m_field
[
im0
+
m_zoff
+
1
][
0
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
+
1
][
0
])
};
CxxUtils
::
vec
<
double
,
8
>
field1
;
CxxUtils
::
vconvert
(
field1
,
field1I
);
CxxUtils
::
vec
<
int
,
8
>
field2I
=
{
(
m_field
[
im0
][
1
]),
(
m_field
[
im0
+
m_roff
][
1
]),
(
m_field
[
im0
+
m_zoff
][
1
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
][
1
]),
(
m_field
[
im0
+
1
][
1
]),
(
m_field
[
im0
+
m_roff
+
1
][
1
]),
(
m_field
[
im0
+
m_zoff
+
1
][
1
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
+
1
][
1
])
};
CxxUtils
::
vec
<
double
,
8
>
field2
;
CxxUtils
::
vconvert
(
field2
,
field2I
);
CxxUtils
::
vec
<
int
,
8
>
field3I
=
{
(
m_field
[
im0
][
2
]),
(
m_field
[
im0
+
m_roff
][
2
]),
(
m_field
[
im0
+
m_zoff
][
2
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
][
2
]),
(
m_field
[
im0
+
1
][
2
]),
(
m_field
[
im0
+
m_roff
+
1
][
2
]),
(
m_field
[
im0
+
m_zoff
+
1
][
2
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
+
1
][
2
])
};
CxxUtils
::
vec
<
double
,
8
>
field3
;
CxxUtils
::
vconvert
(
field3
,
field3I
);
cache
.
setField
(
sf
*
field1
,
sf
*
field2
,
sf
*
field3
);
}
else
{
CxxUtils
::
vec
<
double
,
8
>
field1
=
{
(
m_field
[
im0
][
0
]),
(
m_field
[
im0
+
m_roff
][
0
]),
(
m_field
[
im0
+
m_zoff
][
0
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
][
0
]),
(
m_field
[
im0
+
1
][
0
]),
(
m_field
[
im0
+
m_roff
+
1
][
0
]),
(
m_field
[
im0
+
m_zoff
+
1
][
0
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
+
1
][
0
])
};
CxxUtils
::
vec
<
double
,
8
>
field2
=
{
(
m_field
[
im0
][
1
]),
(
m_field
[
im0
+
m_roff
][
1
]),
(
m_field
[
im0
+
m_zoff
][
1
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
][
1
]),
(
m_field
[
im0
+
1
][
1
]),
(
m_field
[
im0
+
m_roff
+
1
][
1
]),
(
m_field
[
im0
+
m_zoff
+
1
][
1
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
+
1
][
1
])
};
CxxUtils
::
vec
<
double
,
8
>
field3
=
{
(
m_field
[
im0
][
2
]),
(
m_field
[
im0
+
m_roff
][
2
]),
(
m_field
[
im0
+
m_zoff
][
2
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
][
2
]),
(
m_field
[
im0
+
1
][
2
]),
(
m_field
[
im0
+
m_roff
+
1
][
2
]),
(
m_field
[
im0
+
m_zoff
+
1
][
2
]),
(
m_field
[
im0
+
m_zoff
+
m_roff
+
1
][
2
])
};
cache
.
setField
(
sf
*
field1
,
sf
*
field2
,
sf
*
field3
);
}
}
//
...
...
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