IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Pranav Sampathkumar
corsika
Commits
83bf21d6
Commit
83bf21d6
authored
4 years ago
by
Maximilian Reininghaus
Committed by
ralfulrich
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
adapted testHistoryView to new semantics
parent
8fce9f64
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
Framework/Cascade/History.h
+0
-70
0 additions, 70 deletions
Framework/Cascade/History.h
Stack/History/testHistoryView.cc
+22
-49
22 additions, 49 deletions
Stack/History/testHistoryView.cc
with
22 additions
and
119 deletions
Framework/Cascade/History.h
deleted
100644 → 0
+
0
−
70
View file @
8fce9f64
/*
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#include
<memory>
#include
<utility>
#include
<variant>
using
ParticleCode
=
std
::
variant
<
corsika
::
particles
::
ParticleCode
,
std
::
pair
<
int
,
int
>>
;
class
SecondaryParticle
{
corsika
::
units
::
si
::
HEPEnergyType
const
energy_
;
corsika
::
geometry
::
Vector
<
corsika
::
units
::
si
::
hepmomentum_d
>
const
momentum_
;
ParticleCode
const
pid_
;
// what else...?
// - polarization
public:
SecondaryParticle
(
energy
,
momentum
,
pid
)
:
energy_
{
energy
}
,
momentum_
{
momentum
}
,
pid_
{
pid
}
{}
};
class
Event
;
// forward declaration
using
EventPtr
=
std
::
shared_ptr
<
Event
>
;
struct
ProjectileParticle
{
std
::
pair
<
EventPtr
,
size_t
>
origin
;
corsika
::
geometry
::
Point
position
;
coriska
::
units
::
si
::
TimeType
time
;
corsika
::
geometry
::
Vector
<
corsika
::
units
::
si
::
hepmomentum_d
>
momentum
;
corsika
::
units
::
si
::
HEPEnergyType
energy
;
// weight
};
struct
Event
{
corsika
::
particles
::
ParticleCode
targetCode
;
// cannot be const...
ProjectileParticle
projectile
;
std
::
vector
<
SecondaryParticle
>
secondaries
;
};
template
<
typename
TStackView
>
class
EventBuilder
{
TStackView
&
stackView_
;
EventPtr
event_
;
public:
EventBuilder
(
TStackView
&
view
)
:
stackView_
{
stackView
}
,
event_
{
std
::
make_shared
<
Event
>
()}
{}
template
<
typename
...
Args
>
void
AddSecondary
(
Args
&&
...
args
)
{
auto
const
s
=
stackView
.
AddSecondary
(
std
::
forward
<
Args
>
(
args
),
event
);
event
->
secondaries
.
emplace_back
(
s
.
GetEnergy
(),
s
.
GetMomentum
(),
s
.
GetParticleID
());
}
void
SetProjectile
()
{}
void
SetTarget
(
corsika
::
particles
::
ParticleCode
targetCode
)
{
event_
->
targetCode
=
targetCode
;
}
};
This diff is collapsed.
Click to expand it.
Stack/History/testHistoryView.cc
+
22
−
49
View file @
83bf21d6
...
...
@@ -19,7 +19,6 @@
#include
<iostream>
using
namespace
corsika
;
using
namespace
corsika
::
stack
;
using
namespace
corsika
::
geometry
;
using
namespace
corsika
::
units
::
si
;
...
...
@@ -31,8 +30,8 @@ using namespace corsika::units::si;
// combine dummy stack with geometry information for tracking
template
<
typename
TStackIter
>
using
StackWithHistoryInterface
=
corsika
::
stack
::
CombinedParticleInterface
<
stack
::
nuclear_extension
::
ParticleDataStack
::
PIType
,
history
::
HistoryEventDataInterface
,
TStackIter
>
;
stack
::
nuclear_extension
::
ParticleDataStack
::
PIType
,
history
::
HistoryEventDataInterface
,
TStackIter
>
;
using
TestStack
=
corsika
::
stack
::
CombinedStack
<
typename
stack
::
nuclear_extension
::
ParticleDataStack
::
StackImpl
,
...
...
@@ -62,25 +61,25 @@ TEST_CASE("HistoryStackExtension", "[stack]") {
geometry
::
RootCoordinateSystem
::
GetInstance
().
GetRootCoordinateSystem
();
// in this test we only use one singel stack !
TestStack
s
;
TestStack
s
tack
;
// add primary particle
auto
p0
=
s
.
AddParticle
(
auto
p0
=
s
tack
.
AddParticle
(
std
::
tuple
<
particles
::
Code
,
units
::
si
::
HEPEnergyType
,
corsika
::
stack
::
MomentumVector
,
geometry
::
Point
,
units
::
si
::
TimeType
>
{
particles
::
Code
::
Electron
,
1.5
_GeV
,
corsika
::
stack
::
MomentumVector
(
dummyCS
,
{
1
_GeV
,
1
_GeV
,
1
_GeV
}),
Point
(
dummyCS
,
{
1
*
meter
,
1
*
meter
,
1
*
meter
}),
100
_s
});
CHECK
(
s
.
getEntries
()
==
1
);
corsika
::
history
::
EvtPtr
evt
=
p0
.
GetEvent
();
CHECK
(
s
tack
.
getEntries
()
==
1
);
corsika
::
history
::
Ev
en
tPtr
evt
=
p0
.
GetEvent
();
CHECK
(
evt
==
nullptr
);
// add secondaries, 1st generation
history
::
HistorySecondaryView
<
TestStackView
>
hview0
(
p0
);
auto
ev0
=
p0
.
GetEvent
();
CHECK
(
ev0
!
=
nullptr
);
auto
const
ev0
=
p0
.
GetEvent
();
CHECK
(
ev0
=
=
nullptr
);
// CHECK(ev0->projectile(s.begin()) == p0);
// add 5 secondaries
...
...
@@ -92,16 +91,17 @@ TEST_CASE("HistoryStackExtension", "[stack]") {
corsika
::
stack
::
MomentumVector
(
dummyCS
,
{
1
_GeV
,
1
_GeV
,
1
_GeV
}),
Point
(
dummyCS
,
{
1
*
meter
,
1
*
meter
,
1
*
meter
}),
100
_s
});
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
==
ev0
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
->
parentEvent
()
==
nullptr
);
CHECK
(
sec
.
GetParentEventIndex
()
==
i
);
CHECK
(
sec
.
GetEvent
()
!=
nullptr
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
==
nullptr
);
}
// read 1st genertion particle particle
auto
p1
=
s
.
GetNextParticle
();
auto
p1
=
s
tack
.
GetNextParticle
();
history
::
HistorySecondaryView
<
TestStackView
>
hview1
(
p1
);
auto
ev1
=
p1
.
GetEvent
();
auto
const
ev1
=
p1
.
GetEvent
();
// add second generation of secondaries
// add 10 secondaries
...
...
@@ -113,17 +113,20 @@ TEST_CASE("HistoryStackExtension", "[stack]") {
corsika
::
stack
::
MomentumVector
(
dummyCS
,
{
1
_GeV
,
1
_GeV
,
1
_GeV
}),
Point
(
dummyCS
,
{
1
*
meter
,
1
*
meter
,
1
*
meter
}),
100
_s
});
CHECK
(
sec
.
GetParentEventIndex
()
==
i
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
==
ev1
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
->
parentEvent
()
==
ev0
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
->
parentEvent
()
->
parentEvent
()
==
nullptr
);
CHECK
((
stack
.
begin
()
+
sec
.
GetEvent
()
->
projectileIndex
()).
GetEvent
()
==
sec
.
GetEvent
()
->
parentEvent
());
}
// read 2nd genertion particle particle
auto
p2
=
s
.
GetNextParticle
();
auto
p2
=
s
tack
.
GetNextParticle
();
history
::
HistorySecondaryView
<
TestStackView
>
hview2
(
p2
);
auto
ev2
=
p2
.
GetEvent
();
auto
const
ev2
=
p2
.
GetEvent
();
// add third generation of secondaries
// add 15 secondaries
...
...
@@ -135,41 +138,10 @@ TEST_CASE("HistoryStackExtension", "[stack]") {
corsika
::
stack
::
MomentumVector
(
dummyCS
,
{
1
_GeV
,
1
_GeV
,
1
_GeV
}),
Point
(
dummyCS
,
{
1
*
meter
,
1
*
meter
,
1
*
meter
}),
100
_s
});
CHECK
(
sec
.
GetParentEventIndex
()
==
i
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
==
ev2
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
->
parentEvent
()
==
ev1
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
->
parentEvent
()
->
parentEvent
()
==
ev0
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
->
parentEvent
()
->
parentEvent
()
->
parentEvent
()
==
nullptr
);
}
// read 3rd genertion particle particle
auto
p3
=
s
.
GetNextParticle
();
history
::
HistorySecondaryView
<
TestStackView
>
hview3
(
p3
);
auto
ev3
=
p3
.
GetEvent
();
// add fourth generation of secondaries
// add 20 secondaries
for
(
int
i
=
0
;
i
<
20
;
++
i
)
{
auto
sec
=
hview3
.
AddSecondary
(
std
::
tuple
<
particles
::
Code
,
units
::
si
::
HEPEnergyType
,
corsika
::
stack
::
MomentumVector
,
geometry
::
Point
,
units
::
si
::
TimeType
>
{
particles
::
Code
::
Electron
,
1.5
_GeV
,
corsika
::
stack
::
MomentumVector
(
dummyCS
,
{
1
_GeV
,
1
_GeV
,
1
_GeV
}),
Point
(
dummyCS
,
{
1
*
meter
,
1
*
meter
,
1
*
meter
}),
100
_s
});
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
==
ev3
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
->
parentEvent
()
==
ev2
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
->
parentEvent
()
->
parentEvent
()
==
ev1
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
->
parentEvent
()
->
parentEvent
()
->
parentEvent
()
==
ev0
);
CHECK
(
sec
.
GetEvent
()
->
parentEvent
()
->
parentEvent
()
->
parentEvent
()
->
parentEvent
()
->
parentEvent
()
==
nullptr
);
}
/*
...
...
@@ -179,7 +151,7 @@ TEST_CASE("HistoryStackExtension", "[stack]") {
secondaries), with another projectil (with 10 secondaries), with
antother projectil (5 secondaries), with NO parent
**/
{
auto test_ev3 = p3.GetEvent();
auto test_sec3 = test_ev3->secondaries();
...
...
@@ -203,4 +175,5 @@ TEST_CASE("HistoryStackExtension", "[stack]") {
CHECK(test_proj1.GetEvent()->parentEvent() == ev0);
CHECK(test_proj1.GetEvent()->parentEvent()->parentEvent() == nullptr);
}
*/
}
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