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
f72bd59f
Commit
f72bd59f
authored
4 years ago
by
ralfulrich
Browse files
Options
Downloads
Patches
Plain Diff
better unit tests
parent
7de91386
No related branches found
No related tags found
1 merge request
!269
Resolve "Distinguish between alternative interaction processes and competing processes"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/ProcessSequence/testProcessSequence.cc
+25
-13
25 additions, 13 deletions
Framework/ProcessSequence/testProcessSequence.cc
Framework/ProcessSequence/testSwitchProcessSequence.cc
+11
-11
11 additions, 11 deletions
Framework/ProcessSequence/testSwitchProcessSequence.cc
with
36 additions
and
24 deletions
Framework/ProcessSequence/testProcessSequence.cc
+
25
−
13
View file @
f72bd59f
...
...
@@ -65,7 +65,7 @@ public:
inline
EProcessReturn
DoContinuous
(
D
&
d
,
T
&
)
const
{
cout
<<
"ContinuousProcess2::DoContinuous"
<<
endl
;
checkCont
|=
2
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
d
.
data_
[
i
]
+=
0.
933
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
d
.
data_
[
i
]
+=
0.
111
;
return
EProcessReturn
::
eOk
;
}
};
...
...
@@ -84,7 +84,7 @@ public:
inline
EProcessReturn
DoContinuous
(
D
&
d
,
T
&
)
const
{
cout
<<
"ContinuousProcess3::DoContinuous"
<<
endl
;
checkCont
|=
4
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
d
.
data_
[
i
]
+=
0.
9
33
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
d
.
data_
[
i
]
+=
0.
3
33
;
return
EProcessReturn
::
eOk
;
}
};
...
...
@@ -124,8 +124,9 @@ public:
}
template
<
typename
TView
>
inline
EProcessReturn
DoInteraction
(
TView
&
)
const
{
inline
EProcessReturn
DoInteraction
(
TView
&
v
)
const
{
checkInteract
|=
2
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
v
.
parent
().
data_
[
i
]
/=
1.1
;
cout
<<
"Process2::DoInteraction"
<<
endl
;
return
EProcessReturn
::
eOk
;
}
...
...
@@ -147,8 +148,9 @@ public:
}
template
<
typename
TView
>
inline
EProcessReturn
DoInteraction
(
TView
&
)
const
{
inline
EProcessReturn
DoInteraction
(
TView
&
v
)
const
{
checkInteract
|=
4
;
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
v
.
parent
().
data_
[
i
]
*=
1.01
;
cout
<<
"Process3::DoInteraction"
<<
endl
;
return
EProcessReturn
::
eOk
;
}
...
...
@@ -284,6 +286,9 @@ TEST_CASE("Process Sequence", "[Process Sequence]") {
GrammageType
const
tot
=
sequence2
.
GetInteractionLength
(
particle
);
InverseGrammageType
const
tot_inv
=
sequence2
.
GetInverseInteractionLength
(
particle
);
cout
<<
"lambda_tot="
<<
tot
<<
"; lambda_tot_inv="
<<
tot_inv
<<
endl
;
CHECK
(
tot
/
1
_g
*
square
(
1
_cm
)
==
12
);
CHECK
(
tot_inv
*
1
_g
/
square
(
1
_cm
)
==
1.
/
12
);
globalCount
=
0
;
}
...
...
@@ -301,15 +306,17 @@ TEST_CASE("Process Sequence", "[Process Sequence]") {
InverseTimeType
const
tot_inv
=
sequence2
.
GetInverseLifetime
(
particle
);
cout
<<
"lambda_tot="
<<
tot
<<
"; lambda_tot_inv="
<<
tot_inv
<<
endl
;
CHECK
(
tot
/
1
_s
==
1
);
CHECK
(
tot_inv
*
1
_s
==
1.
);
globalCount
=
0
;
}
SECTION
(
"sectionTwo"
)
{
globalCount
=
0
;
ContinuousProcess1
cp1
(
0
);
ContinuousProcess2
cp2
(
1
);
Process2
m2
(
2
);
Process3
m3
(
3
);
ContinuousProcess1
cp1
(
0
);
// += 0.933
ContinuousProcess2
cp2
(
1
);
// += 0.111
Process2
m2
(
2
);
// /= 1.1
Process3
m3
(
3
);
// *= 1.01
auto
sequence2
=
sequence
(
cp1
,
m2
,
m3
,
cp2
);
...
...
@@ -320,15 +327,20 @@ TEST_CASE("Process Sequence", "[Process Sequence]") {
globalCount
=
0
;
cout
<<
"-->docont"
<<
endl
;
sequence2
.
DoContinuous
(
particle
,
track
);
cout
<<
"-->dodisc"
<<
endl
;
cout
<<
"-->done"
<<
endl
;
// validation data
double
test_data
[
nData
]
=
{
0
};
const
int
nLoop
=
5
;
cout
<<
"Running loop with n="
<<
nLoop
<<
endl
;
for
(
int
i
=
0
;
i
<
nLoop
;
++
i
)
{
sequence2
.
DoContinuous
(
particle
,
track
);
}
for
(
int
iLoop
=
0
;
iLoop
<
nLoop
;
++
iLoop
)
{
for
(
int
i
=
0
;
i
<
nData
;
++
i
)
{
test_data
[
i
]
+=
0.933
+
0.111
;
}
sequence2
.
DoContinuous
(
particle
,
track
);
}
for
(
int
i
=
0
;
i
<
nData
;
i
++
)
{
cout
<<
"data_["
<<
i
<<
"]="
<<
particle
.
data_
[
i
]
<<
endl
;
CHECK
(
particle
.
data_
[
i
]
==
Approx
(
test_data
[
i
]).
margin
(
1e-9
));
}
cout
<<
"done"
<<
endl
;
}
...
...
This diff is collapsed.
Click to expand it.
Framework/ProcessSequence/testSwitchProcessSequence.cc
+
11
−
11
View file @
f72bd59f
...
...
@@ -134,8 +134,8 @@ TEST_CASE("SwitchProcess from InteractionProcess") {
// low energy process returns 1 kg/m²
SECTION
(
"interaction length"
)
{
REQUIRE
(
switchProcess
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
1
));
REQUIRE
(
seq
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
3.
/
4
));
CHECK
(
switchProcess
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
1
));
CHECK
(
seq
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
3.
/
4
));
}
}
...
...
@@ -145,8 +145,8 @@ TEST_CASE("SwitchProcess from InteractionProcess") {
// high energy process returns 2 kg/m²
SECTION
(
"interaction length"
)
{
REQUIRE
(
switchProcess
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
2
));
REQUIRE
(
seq
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
6.
/
5
));
CHECK
(
switchProcess
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
2
));
CHECK
(
seq
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
6.
/
5
));
}
// high energy process creates 2 secondaries
...
...
@@ -159,7 +159,7 @@ TEST_CASE("SwitchProcess from InteractionProcess") {
InverseGrammageType
invLambda
=
0
/
kgMSq
;
switchProcess
.
SelectInteraction
(
p
,
projectile
,
0.01
/
kgMSq
,
invLambda
);
REQUIRE
(
view
.
getSize
()
==
2
);
CHECK
(
view
.
getSize
()
==
2
);
}
}
}
...
...
@@ -182,8 +182,8 @@ TEST_CASE("SwitchProcess from ProcessSequence") {
auto
p
=
stack
.
GetNextParticle
();
SECTION
(
"interaction length"
)
{
REQUIRE
(
switchProcess
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
2.
/
3
));
REQUIRE
(
completeSeq
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
4.
/
7
));
CHECK
(
switchProcess
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
2.
/
3
));
CHECK
(
completeSeq
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
4.
/
7
));
}
SECTION
(
"SelectInteraction"
)
{
...
...
@@ -207,7 +207,7 @@ TEST_CASE("SwitchProcess from ProcessSequence") {
auto
const
mean
=
std
::
accumulate
(
numberOfSecondaries
.
cbegin
(),
numberOfSecondaries
.
cend
(),
0.
)
/
numberOfSecondaries
.
size
();
REQUIRE
(
mean
==
Approx
(
12.
/
7.
).
margin
(
0.01
));
CHECK
(
mean
==
Approx
(
12.
/
7.
).
margin
(
0.01
));
}
}
...
...
@@ -216,8 +216,8 @@ TEST_CASE("SwitchProcess from ProcessSequence") {
auto
p
=
stack
.
GetNextParticle
();
SECTION
(
"interaction length"
)
{
REQUIRE
(
switchProcess
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
3
));
REQUIRE
(
completeSeq
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
12.
/
7.
));
CHECK
(
switchProcess
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
3
));
CHECK
(
completeSeq
.
GetInteractionLength
(
p
)
/
kgMSq
==
Approx
(
12.
/
7.
));
}
SECTION
(
"SelectInteraction"
)
{
...
...
@@ -241,7 +241,7 @@ TEST_CASE("SwitchProcess from ProcessSequence") {
auto
const
mean
=
std
::
accumulate
(
numberOfSecondaries
.
cbegin
(),
numberOfSecondaries
.
cend
(),
0.
)
/
numberOfSecondaries
.
size
();
REQUIRE
(
mean
==
Approx
(
24.
/
7.
).
margin
(
0.01
));
CHECK
(
mean
==
Approx
(
24.
/
7.
).
margin
(
0.01
));
}
}
}
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