IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
corsika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
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
Air Shower Physics
corsika
Commits
5f7e219c
Commit
5f7e219c
authored
2 years ago
by
Nikos Karastathis
Committed by
Maximilian Reininghaus
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix testProcessSequence.cpp
parent
c6eadaa0
No related branches found
No related tags found
1 merge request
!426
Resolve "Cascade: Problems with Multiple Scattering (in combination with tracking)"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
corsika/detail/framework/core/Cascade.inl
+1
-0
1 addition, 0 deletions
corsika/detail/framework/core/Cascade.inl
tests/framework/testProcessSequence.cpp
+48
-27
48 additions, 27 deletions
tests/framework/testProcessSequence.cpp
with
49 additions
and
27 deletions
corsika/detail/framework/core/Cascade.inl
+
1
−
0
View file @
5f7e219c
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
#pragma once
#pragma once
#include
<corsika/framework/core/PhysicalUnits.hpp>
#include
<corsika/framework/core/PhysicalUnits.hpp>
#include
<corsika/framework/core/Step.hpp>
#include
<corsika/framework/process/ProcessReturn.hpp>
#include
<corsika/framework/process/ProcessReturn.hpp>
#include
<corsika/framework/process/ContinuousProcessStepLength.hpp>
#include
<corsika/framework/process/ContinuousProcessStepLength.hpp>
...
...
This diff is collapsed.
Click to expand it.
tests/framework/testProcessSequence.cpp
+
48
−
27
View file @
5f7e219c
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
#include
<corsika/framework/process/ContinuousProcessStepLength.hpp>
#include
<corsika/framework/process/ContinuousProcessStepLength.hpp>
#include
<corsika/framework/core/PhysicalUnits.hpp>
#include
<corsika/framework/core/PhysicalUnits.hpp>
#include
<corsika/framework/core/Step.hpp>
#include
<corsika/framework/utility/COMBoost.hpp>
#include
<corsika/framework/utility/COMBoost.hpp>
...
@@ -60,13 +61,19 @@ struct DummyData {
...
@@ -60,13 +61,19 @@ struct DummyData {
return
MomentumVector
{
get_root_CoordinateSystem
(),
0
_eV
,
0
_eV
,
0
_eV
};
return
MomentumVector
{
get_root_CoordinateSystem
(),
0
_eV
,
0
_eV
,
0
_eV
};
}
}
HEPEnergyType
getEnergy
()
const
{
return
10
_GeV
;
}
HEPEnergyType
getEnergy
()
const
{
return
10
_GeV
;
}
Point
getPosition
()
const
{
return
Point
(
get_root_CoordinateSystem
(),
0
_m
,
0
_m
,
0
_m
);
}
DirectionVector
getDirection
()
const
{
return
DirectionVector
{
get_root_CoordinateSystem
(),
{
0
,
0
,
0
}
};
}
};
};
// The stack is non-existent for this example
// The stack is non-existent for this example
struct
DummyStack
{};
struct
DummyStack
{};
// there is no real trajectory/track
// there is no real trajectory/track
struct
DummyTrajectory
{};
struct
DummyTrajectory
{
TimeType
getDuration
(
int
u
)
const
{
return
0
_s
;
}
Point
getPosition
(
int
u
)
const
{
return
Point
(
get_root_CoordinateSystem
(),
0
_m
,
0
_m
,
0
_m
);
}
DirectionVector
getDirection
(
int
u
)
const
{
return
DirectionVector
{
get_root_CoordinateSystem
(),
{
0
,
0
,
0
}
};
}
};
// since there is no stack, there is also no view. This is a simplistic dummy object
// since there is no stack, there is also no view. This is a simplistic dummy object
// sufficient here.
// sufficient here.
...
@@ -101,12 +108,19 @@ public:
...
@@ -101,12 +108,19 @@ public:
void
setStep
(
LengthType
const
v
)
{
step_
=
v
;
}
void
setStep
(
LengthType
const
v
)
{
step_
=
v
;
}
template
<
typename
D
,
typename
T
>
template
<
typename
D
>
ProcessReturn
doContinuous
(
D
&
d
,
T
&
,
bool
flag
)
const
{
ProcessReturn
doContinuous
(
Step
<
D
>&
d
,
bool
flag
)
const
{
flag_
=
flag
;
flag_
=
flag
;
CORSIKA_LOG_TRACE
(
"ContinuousProcess1::DoContinuous"
);
CORSIKA_LOG_TRACE
(
"ContinuousProcess1::DoContinuous"
);
checkCont
|=
1
;
checkCont
|=
1
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
d
.
data_
[
i
]
+=
0.933
;
LengthVector
displacement_
{
get_root_CoordinateSystem
(),
1
_m
,
0
_m
,
0
_m
};
DirectionVector
dU_
{
get_root_CoordinateSystem
(),
{
1
,
0
,
0
}
};
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
{
d
.
add_dt
(
1
_s
);
d
.
add_displacement
(
displacement_
);
d
.
add_dU
(
dU_
);
d
.
add_dEkin
(
1
_eV
);
}
return
ProcessReturn
::
Ok
;
return
ProcessReturn
::
Ok
;
}
}
...
@@ -138,12 +152,12 @@ public:
...
@@ -138,12 +152,12 @@ public:
void
setStep
(
LengthType
const
v
)
{
step_
=
v
;
}
void
setStep
(
LengthType
const
v
)
{
step_
=
v
;
}
template
<
typename
D
,
typename
T
>
template
<
typename
D
>
ProcessReturn
doContinuous
(
D
&
d
,
T
&
,
bool
const
flag
)
const
{
ProcessReturn
doContinuous
(
Step
<
D
>&
d
,
bool
const
flag
)
const
{
flag_
=
flag
;
flag_
=
flag
;
CORSIKA_LOG_DEBUG
(
"ContinuousProcess2::DoContinuous"
);
CORSIKA_LOG_DEBUG
(
"ContinuousProcess2::DoContinuous"
);
checkCont
|=
2
;
checkCont
|=
2
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
d
.
data_
[
i
]
+=
0.111
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
d
.
add_dt
(
10
_s
)
;
return
ProcessReturn
::
Ok
;
return
ProcessReturn
::
Ok
;
}
}
...
@@ -175,12 +189,12 @@ public:
...
@@ -175,12 +189,12 @@ public:
void
setStep
(
LengthType
const
v
)
{
step_
=
v
;
}
void
setStep
(
LengthType
const
v
)
{
step_
=
v
;
}
template
<
typename
D
,
typename
T
>
template
<
typename
D
>
ProcessReturn
doContinuous
(
D
&
d
,
T
&
,
bool
const
flag
)
const
{
ProcessReturn
doContinuous
(
Step
<
D
>&
d
,
bool
const
flag
)
const
{
flag_
=
flag
;
flag_
=
flag
;
CORSIKA_LOG_DEBUG
(
"ContinuousProcess3::DoContinuous"
);
CORSIKA_LOG_DEBUG
(
"ContinuousProcess3::DoContinuous"
);
checkCont
|=
4
;
checkCont
|=
4
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
d
.
data_
[
i
]
+=
0.333
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
d
.
add_dEkin
(
1
_eV
)
;
return
ProcessReturn
::
Ok
;
return
ProcessReturn
::
Ok
;
}
}
...
@@ -295,11 +309,11 @@ public:
...
@@ -295,11 +309,11 @@ public:
globalCount
++
;
globalCount
++
;
}
}
template
<
typename
D
,
typename
T
>
template
<
typename
D
>
ProcessReturn
doContinuous
(
D
&
d
,
T
&
,
bool
const
)
const
{
ProcessReturn
doContinuous
(
Step
<
D
>&
d
,
bool
const
)
const
{
CORSIKA_LOG_DEBUG
(
"Base::doContinuous"
);
CORSIKA_LOG_DEBUG
(
"Base::doContinuous"
);
checkCont
|=
8
;
checkCont
|=
8
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
{
d
.
data_
[
i
]
/=
1.2
;
}
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
{
d
.
add_dEkin
(
1
_eV
)
;
}
return
ProcessReturn
::
Ok
;
return
ProcessReturn
::
Ok
;
}
}
template
<
typename
TView
>
template
<
typename
TView
>
...
@@ -476,7 +490,7 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") {
...
@@ -476,7 +490,7 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") {
globalCount
=
0
;
globalCount
=
0
;
}
}
SECTION
(
"ContinousProcess"
)
{
SECTION
(
"Contin
u
ousProcess"
)
{
globalCount
=
0
;
globalCount
=
0
;
ContinuousProcess1
cp1
(
0
,
1
_m
);
// += 0.933
ContinuousProcess1
cp1
(
0
,
1
_m
);
// += 0.933
ContinuousProcess2
cp2
(
1
,
1.1
_m
);
// += 0.111
ContinuousProcess2
cp2
(
1
,
1.1
_m
);
// += 0.111
...
@@ -490,13 +504,14 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") {
...
@@ -490,13 +504,14 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") {
DummyData
particle
;
DummyData
particle
;
DummyTrajectory
track
;
DummyTrajectory
track
;
Step
step
(
particle
,
track
);
cp1
.
resetFlag
();
cp1
.
resetFlag
();
cp2
.
resetFlag
();
cp2
.
resetFlag
();
ContinuousProcessStepLength
const
step1
=
sequence2
.
getMaxStepLength
(
particle
,
track
);
ContinuousProcessStepLength
const
step1
=
sequence2
.
getMaxStepLength
(
particle
,
track
);
CHECK
(
LengthType
(
step1
)
==
1
_m
);
CHECK
(
LengthType
(
step1
)
==
1
_m
);
sequence2
.
doContinuous
(
particle
,
track
,
step1
);
sequence2
.
doContinuous
(
step
,
step1
);
CHECK
(
cp1
.
getFlag
());
CHECK
(
cp1
.
getFlag
());
CHECK_FALSE
(
cp2
.
getFlag
());
CHECK_FALSE
(
cp2
.
getFlag
());
CORSIKA_LOG_INFO
(
"step1, l={}, i={}"
,
LengthType
(
step1
),
CORSIKA_LOG_INFO
(
"step1, l={}, i={}"
,
LengthType
(
step1
),
...
@@ -509,7 +524,7 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") {
...
@@ -509,7 +524,7 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") {
ContinuousProcessStepLength
const
step2
=
sequence2
.
getMaxStepLength
(
particle
,
track
);
ContinuousProcessStepLength
const
step2
=
sequence2
.
getMaxStepLength
(
particle
,
track
);
CHECK
(
LengthType
(
step2
)
==
1.1
_m
);
CHECK
(
LengthType
(
step2
)
==
1.1
_m
);
CHECK
(
ContinuousProcessIndex
(
step1
)
!=
ContinuousProcessIndex
(
step2
));
CHECK
(
ContinuousProcessIndex
(
step1
)
!=
ContinuousProcessIndex
(
step2
));
sequence2
.
doContinuous
(
particle
,
track
,
step2
);
sequence2
.
doContinuous
(
step
,
step2
);
CHECK_FALSE
(
cp1
.
getFlag
());
CHECK_FALSE
(
cp1
.
getFlag
());
CHECK
(
cp2
.
getFlag
());
CHECK
(
cp2
.
getFlag
());
CORSIKA_LOG_INFO
(
"step2, l={}, i={}"
,
LengthType
(
step2
),
CORSIKA_LOG_INFO
(
"step2, l={}, i={}"
,
LengthType
(
step2
),
...
@@ -530,12 +545,16 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") {
...
@@ -530,12 +545,16 @@ TEST_CASE("ProcessSequence General", "ProcessSequence") {
CORSIKA_LOG_DEBUG
(
"Running loop with n={}"
,
nLoop
);
CORSIKA_LOG_DEBUG
(
"Running loop with n={}"
,
nLoop
);
for
(
int
iLoop
=
0
;
iLoop
<
nLoop
;
++
iLoop
)
{
for
(
int
iLoop
=
0
;
iLoop
<
nLoop
;
++
iLoop
)
{
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
{
test_data
[
i
]
+=
0.933
+
0.111
;
}
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
{
test_data
[
i
]
+=
0.933
+
0.111
;
}
sequence2
.
doContinuous
(
particle
,
track
,
ContinuousProcessIndex
(
1
));
sequence2
.
doContinuous
(
step
,
ContinuousProcessIndex
(
1
));
}
for
(
int
i
=
0
;
i
<
nData
;
i
++
)
{
CORSIKA_LOG_DEBUG
(
"data_[{}]={}"
,
i
,
particle
.
data_
[
i
]);
CHECK
(
particle
.
data_
[
i
]
==
Approx
(
test_data
[
i
]).
margin
(
1e-9
));
}
}
CHECK
(
step
.
getDiffT
()
/
1
_s
==
Approx
(
770
));
CHECK
(
step
.
getDiffEkin
()
/
1
_eV
==
Approx
(
70
));
CHECK
(
step
.
getDisplacement
().
getX
(
get_root_CoordinateSystem
())
/
1
_m
==
Approx
(
70
));
CHECK
(
step
.
getDisplacement
().
getY
(
get_root_CoordinateSystem
())
/
1
_m
==
Approx
(
0
));
CHECK
(
step
.
getDisplacement
().
getZ
(
get_root_CoordinateSystem
())
/
1
_m
==
Approx
(
0
));
CHECK
(
step
.
getDiffDirection
().
getX
(
get_root_CoordinateSystem
())
==
Approx
(
70
));
CHECK
(
step
.
getDiffDirection
().
getY
(
get_root_CoordinateSystem
())
==
Approx
(
0
));
CHECK
(
step
.
getDiffDirection
().
getZ
(
get_root_CoordinateSystem
())
==
Approx
(
0
));
CORSIKA_LOG_DEBUG
(
"done"
);
CORSIKA_LOG_DEBUG
(
"done"
);
}
}
...
@@ -676,13 +695,14 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
...
@@ -676,13 +695,14 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
DummyData
particle
;
DummyData
particle
;
DummyTrajectory
track
;
DummyTrajectory
track
;
DummyView
view
(
particle
);
DummyView
view
(
particle
);
Step
step
(
particle
,
track
);
checkDecay
=
0
;
checkDecay
=
0
;
checkInteract
=
0
;
checkInteract
=
0
;
checkSec
=
0
;
checkSec
=
0
;
checkCont
=
0
;
checkCont
=
0
;
particle
.
data_
[
0
]
=
100
;
// data positive --> sequence1
particle
.
data_
[
0
]
=
100
;
// data positive --> sequence1
sequence3
.
doContinuous
(
particle
,
track
,
ContinuousProcessIndex
(
1
));
sequence3
.
doContinuous
(
step
,
ContinuousProcessIndex
(
1
));
CHECK
(
checkInteract
==
0
);
CHECK
(
checkInteract
==
0
);
CHECK
(
checkDecay
==
0
);
CHECK
(
checkDecay
==
0
);
CHECK
(
checkCont
==
0b011
);
CHECK
(
checkCont
==
0b011
);
...
@@ -693,7 +713,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
...
@@ -693,7 +713,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
checkSec
=
0
;
checkSec
=
0
;
checkCont
=
0
;
checkCont
=
0
;
particle
.
data_
[
0
]
=
-
100
;
// data negative --> sequence2
particle
.
data_
[
0
]
=
-
100
;
// data negative --> sequence2
sequence3
.
doContinuous
(
particle
,
track
,
ContinuousProcessIndex
(
1
));
sequence3
.
doContinuous
(
step
,
ContinuousProcessIndex
(
1
));
CHECK
(
checkInteract
==
0
);
CHECK
(
checkInteract
==
0
);
CHECK
(
checkDecay
==
0
);
CHECK
(
checkDecay
==
0
);
CHECK
(
checkCont
==
0b101
);
CHECK
(
checkCont
==
0b101
);
...
@@ -877,6 +897,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
...
@@ -877,6 +897,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
DummyData
particle
;
DummyData
particle
;
DummyTrajectory
track
;
DummyTrajectory
track
;
Step
step
(
particle
,
track
);
particle
.
data_
[
0
]
=
particle
.
data_
[
0
]
=
100
;
// data positive, selects particular branch on SwitchProcessSequence
100
;
// data positive, selects particular branch on SwitchProcessSequence
...
@@ -891,7 +912,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
...
@@ -891,7 +912,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
ContinuousProcessStepLength
const
step1
=
sequence3
.
getMaxStepLength
(
particle
,
track
);
ContinuousProcessStepLength
const
step1
=
sequence3
.
getMaxStepLength
(
particle
,
track
);
CHECK
(
LengthType
(
step1
)
==
10
_m
);
CHECK
(
LengthType
(
step1
)
==
10
_m
);
sequence3
.
doContinuous
(
particle
,
track
,
step1
);
sequence3
.
doContinuous
(
step
,
step1
);
CHECK
(
cp1
.
getFlag
());
CHECK
(
cp1
.
getFlag
());
CHECK_FALSE
(
cp2
.
getFlag
());
CHECK_FALSE
(
cp2
.
getFlag
());
CHECK_FALSE
(
cp3
.
getFlag
());
CHECK_FALSE
(
cp3
.
getFlag
());
...
@@ -911,7 +932,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
...
@@ -911,7 +932,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
ContinuousProcessStepLength
const
step2
=
sequence3
.
getMaxStepLength
(
particle
,
track
);
ContinuousProcessStepLength
const
step2
=
sequence3
.
getMaxStepLength
(
particle
,
track
);
CHECK
(
LengthType
(
step2
)
==
15
_m
);
CHECK
(
LengthType
(
step2
)
==
15
_m
);
sequence3
.
doContinuous
(
particle
,
track
,
step2
);
sequence3
.
doContinuous
(
step
,
step2
);
CHECK_FALSE
(
cp1
.
getFlag
());
CHECK_FALSE
(
cp1
.
getFlag
());
CHECK
(
cp2
.
getFlag
());
CHECK
(
cp2
.
getFlag
());
CHECK_FALSE
(
cp3
.
getFlag
());
CHECK_FALSE
(
cp3
.
getFlag
());
...
@@ -932,7 +953,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
...
@@ -932,7 +953,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
ContinuousProcessStepLength
const
step3
=
sequence3
.
getMaxStepLength
(
particle
,
track
);
ContinuousProcessStepLength
const
step3
=
sequence3
.
getMaxStepLength
(
particle
,
track
);
CHECK
(
LengthType
(
step3
)
==
11
_m
);
CHECK
(
LengthType
(
step3
)
==
11
_m
);
sequence3
.
doContinuous
(
particle
,
track
,
step3
);
sequence3
.
doContinuous
(
step
,
step3
);
CHECK
(
cp1
.
getFlag
());
CHECK
(
cp1
.
getFlag
());
CHECK_FALSE
(
cp2
.
getFlag
());
CHECK_FALSE
(
cp2
.
getFlag
());
CHECK_FALSE
(
cp3
.
getFlag
());
CHECK_FALSE
(
cp3
.
getFlag
());
...
@@ -953,7 +974,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
...
@@ -953,7 +974,7 @@ TEST_CASE("SwitchProcessSequence", "ProcessSequence") {
ContinuousProcessStepLength
const
step4
=
sequence3
.
getMaxStepLength
(
particle
,
track
);
ContinuousProcessStepLength
const
step4
=
sequence3
.
getMaxStepLength
(
particle
,
track
);
CHECK
(
LengthType
(
step4
)
==
2
_m
);
CHECK
(
LengthType
(
step4
)
==
2
_m
);
sequence3
.
doContinuous
(
particle
,
track
,
step4
);
sequence3
.
doContinuous
(
step
,
step4
);
CHECK_FALSE
(
cp1
.
getFlag
());
CHECK_FALSE
(
cp1
.
getFlag
());
CHECK_FALSE
(
cp2
.
getFlag
());
CHECK_FALSE
(
cp2
.
getFlag
());
CHECK
(
cp3
.
getFlag
());
CHECK
(
cp3
.
getFlag
());
...
...
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