Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
6f164b32
Commit
6f164b32
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
Detector2D has equidistant nominal scales, and cached true scattering angles
parent
3549bd1d
No related branches found
No related tags found
1 merge request
!2088
Replace FlatDetector and SphericalDetector by Detector2D
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Device/Detector/Detector2D.cpp
+29
-17
29 additions, 17 deletions
Device/Detector/Detector2D.cpp
Device/Detector/Detector2D.h
+6
-0
6 additions, 0 deletions
Device/Detector/Detector2D.h
with
35 additions
and
17 deletions
Device/Detector/Detector2D.cpp
+
29
−
17
View file @
6f164b32
...
...
@@ -23,33 +23,48 @@
namespace
{
Scale
*
scatteringAngles
(
const
std
::
string
&
label
,
size_t
n
,
double
angle_min
,
double
angle_max
)
//! Returns true scattering angles for given nominal scale.
//! The nominal scale is an equidistant partition of the interval between true minimum and
//! maximum scattering angle. It is used for the graphical representation of detector pixels.
//! The true scattering angle is used for the computation of scattering towards a detector pixel.
Scale
*
scatteringAngles
(
const
Scale
&
in
)
{
const
size_t
n
=
in
.
size
();
ASSERT
(
n
>
0
);
const
double
p0
=
tan
(
angle_
min
);
const
double
dp
=
(
tan
(
angle_
max
)
-
tan
(
angle_
min
))
/
n
;
const
double
p0
=
tan
(
in
.
min
()
);
const
double
dp
=
(
tan
(
in
.
max
()
)
-
tan
(
in
.
min
()
))
/
n
;
std
::
vector
<
double
>
limits
;
limits
.
reserve
(
2
*
n
);
limits
.
push_back
(
angle_
min
);
limits
.
push_back
(
in
.
min
()
);
for
(
size_t
i
=
1
;
i
<
n
;
++
i
)
{
limits
.
push_back
(
atan
(
p0
+
i
*
dp
));
limits
.
push_back
(
atan
(
p0
+
i
*
dp
));
}
limits
.
push_back
(
angle_
max
);
return
newGenericScale
(
l
abel
,
limits
);
limits
.
push_back
(
in
.
max
()
);
return
newGenericScale
(
in
.
axisL
abel
()
,
limits
);
}
}
// namespace
Detector2D
::
Detector2D
(
Frame
*
frame
)
:
IDetector
(
frame
)
,
m_scattering_phi
(
::
scatteringAngles
(
frame
->
xAxis
()))
,
m_scattering_alpha
(
::
scatteringAngles
(
frame
->
yAxis
()))
{
}
Detector2D
::
Detector2D
(
size_t
n_phi
,
double
phi_min
,
double
phi_max
,
size_t
n_alpha
,
double
alpha_min
,
double
alpha_max
)
:
I
Detector
(
new
Frame
(
::
scatteringAngles
(
"phi_f (rad)"
,
n_phi
,
phi_min
,
phi_max
),
::
scatteringAngles
(
"alpha_f (rad)"
,
n_alpha
,
alpha_min
,
alpha_max
)))
:
Detector
2D
(
new
Frame
(
newEquiDivision
(
"phi_f (rad)"
,
n_phi
,
phi_min
,
phi_max
),
newEquiDivision
(
"alpha_f (rad)"
,
n_alpha
,
alpha_min
,
alpha_max
)))
{
}
Detector2D
::
Detector2D
(
const
Detector2D
&
other
)
=
default
;
Detector2D
::
Detector2D
(
const
Detector2D
&
other
)
:
Detector2D
(
other
.
frame
().
clone
())
{
}
Detector2D
*
Detector2D
::
clone
()
const
{
...
...
@@ -58,13 +73,11 @@ Detector2D* Detector2D::clone() const
IPixel
*
Detector2D
::
createPixel
(
size_t
index
)
const
{
const
Scale
&
phi_axis
=
axis
(
0
);
const
Scale
&
alpha_axis
=
axis
(
1
);
const
size_t
phi_index
=
axisBinIndex
(
index
,
0
);
const
size_t
alpha_index
=
axisBinIndex
(
index
,
1
);
const
Bin1D
alpha_bin
=
alpha_axis
.
bin
(
alpha_index
);
const
Bin1D
phi_bin
=
phi_axis
.
bin
(
phi_index
);
const
Bin1D
alpha_bin
=
m_scattering_alpha
->
bin
(
alpha_index
);
const
Bin1D
phi_bin
=
m_scattering_phi
->
bin
(
phi_index
);
return
new
SphericalPixel
(
alpha_bin
,
phi_bin
);
}
...
...
@@ -72,9 +85,8 @@ size_t Detector2D::indexOfSpecular(const Beam& beam) const
{
double
alpha
=
beam
.
alpha_i
();
double
phi
=
beam
.
phi_i
();
const
Scale
&
phi_axis
=
axis
(
0
);
const
Scale
&
alpha_axis
=
axis
(
1
);
if
(
phi_axis
.
rangeComprises
(
phi
)
&&
alpha_axis
.
rangeComprises
(
alpha
))
return
getGlobalIndex
(
phi_axis
.
closestIndex
(
phi
),
alpha_axis
.
closestIndex
(
alpha
));
if
(
m_scattering_phi
->
rangeComprises
(
phi
)
&&
m_scattering_alpha
->
rangeComprises
(
alpha
))
return
getGlobalIndex
(
m_scattering_phi
->
closestIndex
(
phi
),
m_scattering_alpha
->
closestIndex
(
alpha
));
return
totalSize
();
}
This diff is collapsed.
Click to expand it.
Device/Detector/Detector2D.h
+
6
−
0
View file @
6f164b32
...
...
@@ -40,6 +40,12 @@ public:
//! If no pixel contains this specular wavevector, the number of pixels is
//! returned. This corresponds to an overflow index.
size_t
indexOfSpecular
(
const
Beam
&
beam
)
const
override
;
private
:
Detector2D
(
Frame
*
frame
);
std
::
unique_ptr
<
Scale
>
m_scattering_phi
;
std
::
unique_ptr
<
Scale
>
m_scattering_alpha
;
};
#endif // BORNAGAIN_DEVICE_DETECTOR_DETECTOR2D_H
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