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
cb09a237
Commit
cb09a237
authored
8 years ago
by
Pospelov, Gennady
Browse files
Options
Downloads
Patches
Plain Diff
Unit test for SphericalDetector::createDetectorMap
parent
4cbc733c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Core/Instrument/IDetector2D.cpp
+16
-13
16 additions, 13 deletions
Core/Instrument/IDetector2D.cpp
Tests/UnitTests/Core/3/SphericalDetectorTest.h
+42
-1
42 additions, 1 deletion
Tests/UnitTests/Core/3/SphericalDetectorTest.h
with
58 additions
and
14 deletions
Core/Instrument/IDetector2D.cpp
+
16
−
13
View file @
cb09a237
...
@@ -116,21 +116,24 @@ OutputData<double>* IDetector2D::createDetectorMap(const Beam&, EAxesUnits) cons
...
@@ -116,21 +116,24 @@ OutputData<double>* IDetector2D::createDetectorMap(const Beam&, EAxesUnits) cons
//!
//!
void
IDetector2D
::
initOutputData
(
OutputData
<
double
>&
data
)
const
void
IDetector2D
::
initOutputData
(
OutputData
<
double
>
&
data
)
const
{
{
data
.
clear
();
data
.
clear
();
if
(
m_region_of_interest
)
{
std
::
unique_ptr
<
IAxis
>
axis0
(
getAxis
(
0
).
createClippedAxis
(
m_region_of_interest
->
getXlow
(),
m_region_of_interest
->
getXup
()));
std
::
unique_ptr
<
IAxis
>
axis1
(
getAxis
(
1
).
createClippedAxis
(
m_region_of_interest
->
getYlow
(),
m_region_of_interest
->
getYup
()));
data
.
addAxis
(
*
axis0
);
data
.
addAxis
(
*
axis1
);
}
else
{
if
(
m_region_of_interest
)
{
for
(
size_t
i
=
0
;
i
<
getDimension
();
++
i
)
std
::
unique_ptr
<
IAxis
>
axis0
(
getAxis
(
0
).
createClippedAxis
(
data
.
addAxis
(
getAxis
(
i
));
m_region_of_interest
->
getXlow
(),
m_region_of_interest
->
getXup
()));
}
data
.
addAxis
(
*
axis0
);
std
::
unique_ptr
<
IAxis
>
axis1
(
getAxis
(
1
).
createClippedAxis
(
m_region_of_interest
->
getYlow
(),
m_region_of_interest
->
getYup
()));
data
.
addAxis
(
*
axis1
);
}
else
{
for
(
size_t
i
=
0
;
i
<
getDimension
();
++
i
)
data
.
addAxis
(
getAxis
(
i
));
}
data
.
setAllTo
(
0.
);
data
.
setAllTo
(
0.
);
}
}
std
::
vector
<
IDetector2D
::
EAxesUnits
>
IDetector2D
::
getValidAxesUnits
()
const
std
::
vector
<
IDetector2D
::
EAxesUnits
>
IDetector2D
::
getValidAxesUnits
()
const
...
...
This diff is collapsed.
Click to expand it.
Tests/UnitTests/Core/3/SphericalDetectorTest.h
+
42
−
1
View file @
cb09a237
...
@@ -10,6 +10,8 @@
...
@@ -10,6 +10,8 @@
#include
"Polygon.h"
#include
"Polygon.h"
#include
"BornAgainNamespace.h"
#include
"BornAgainNamespace.h"
#include
"Rectangle.h"
#include
"Rectangle.h"
#include
"Units.h"
#include
"Beam.h"
#include
<memory>
#include
<memory>
class
SphericalDetectorTest
:
public
::
testing
::
Test
class
SphericalDetectorTest
:
public
::
testing
::
Test
...
@@ -109,7 +111,7 @@ TEST_F(SphericalDetectorTest, constructionWithParameters)
...
@@ -109,7 +111,7 @@ TEST_F(SphericalDetectorTest, constructionWithParameters)
EXPECT_EQ
(
BornAgain
::
ALPHA_AXIS_NAME
,
detector
.
getAxis
(
1
).
getName
());
EXPECT_EQ
(
BornAgain
::
ALPHA_AXIS_NAME
,
detector
.
getAxis
(
1
).
getName
());
}
}
//! Init external data with detector axes
//! Init external data with detector axes
.
TEST_F
(
SphericalDetectorTest
,
initOutputData
)
TEST_F
(
SphericalDetectorTest
,
initOutputData
)
{
{
...
@@ -129,6 +131,45 @@ TEST_F(SphericalDetectorTest, initOutputData)
...
@@ -129,6 +131,45 @@ TEST_F(SphericalDetectorTest, initOutputData)
EXPECT_EQ
(
BornAgain
::
ALPHA_AXIS_NAME
,
data
.
getAxis
(
1
)
->
getName
());
EXPECT_EQ
(
BornAgain
::
ALPHA_AXIS_NAME
,
data
.
getAxis
(
1
)
->
getName
());
}
}
//! Creation of the detector map with axes in given units
TEST_F
(
SphericalDetectorTest
,
createDetectorMap
)
{
SphericalDetector
detector
(
10
,
-
1.0
*
Units
::
deg
,
1.0
*
Units
::
deg
,
20
,
0.0
*
Units
::
deg
,
2.0
*
Units
::
deg
);
Beam
beam
;
beam
.
setCentralK
(
1.0
*
Units
::
angstrom
,
0.4
*
Units
::
deg
,
0.0
);
// creating map in default units, which are radians and checking axes
std
::
unique_ptr
<
OutputData
<
double
>>
data
(
detector
.
createDetectorMap
(
beam
,
IDetector2D
::
DEFAULT
));
EXPECT_EQ
(
data
->
getAxis
(
0
)
->
getSize
(),
10
);
EXPECT_EQ
(
data
->
getAxis
(
0
)
->
getMin
(),
-
1.0
*
Units
::
deg
);
EXPECT_EQ
(
data
->
getAxis
(
0
)
->
getMax
(),
1.0
*
Units
::
deg
);
EXPECT_EQ
(
data
->
getAxis
(
1
)
->
getSize
(),
20
);
EXPECT_EQ
(
data
->
getAxis
(
1
)
->
getMin
(),
0.0
*
Units
::
deg
);
EXPECT_EQ
(
data
->
getAxis
(
1
)
->
getMax
(),
2.0
*
Units
::
deg
);
// creating map in degrees and checking axes
data
.
reset
(
detector
.
createDetectorMap
(
beam
,
IDetector2D
::
DEGREES
));
EXPECT_EQ
(
data
->
getAxis
(
0
)
->
getSize
(),
10
);
EXPECT_FLOAT_EQ
(
data
->
getAxis
(
0
)
->
getMin
(),
-
1.0
);
EXPECT_FLOAT_EQ
(
data
->
getAxis
(
0
)
->
getMax
(),
1.0
);
EXPECT_EQ
(
data
->
getAxis
(
1
)
->
getSize
(),
20
);
EXPECT_FLOAT_EQ
(
data
->
getAxis
(
1
)
->
getMin
(),
0.0
);
EXPECT_FLOAT_EQ
(
data
->
getAxis
(
1
)
->
getMax
(),
2.0
);
// creating map in nbins and checking axes
data
.
reset
(
detector
.
createDetectorMap
(
beam
,
IDetector2D
::
NBINS
));
EXPECT_EQ
(
data
->
getAxis
(
0
)
->
getSize
(),
10
);
EXPECT_FLOAT_EQ
(
data
->
getAxis
(
0
)
->
getMin
(),
0.0
);
EXPECT_FLOAT_EQ
(
data
->
getAxis
(
0
)
->
getMax
(),
10.0
);
EXPECT_EQ
(
data
->
getAxis
(
1
)
->
getSize
(),
20
);
EXPECT_FLOAT_EQ
(
data
->
getAxis
(
1
)
->
getMin
(),
0.0
);
EXPECT_FLOAT_EQ
(
data
->
getAxis
(
1
)
->
getMax
(),
20.0
);
}
//! Testing region of interest.
//! Testing region of interest.
TEST_F
(
SphericalDetectorTest
,
regionOfInterest
)
TEST_F
(
SphericalDetectorTest
,
regionOfInterest
)
...
...
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