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
9397c1a9
Commit
9397c1a9
authored
4 years ago
by
Maximilian Sackel
Committed by
Ralf Ulrich
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add proposal sec to corsika stack
parent
5ec6a045
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
Processes/Proposal/Interaction.cc
+16
-33
16 additions, 33 deletions
Processes/Proposal/Interaction.cc
Processes/Proposal/Interaction.h
+20
-24
20 additions, 24 deletions
Processes/Proposal/Interaction.h
with
36 additions
and
57 deletions
Processes/Proposal/Interaction.cc
+
16
−
33
View file @
9397c1a9
...
@@ -19,13 +19,11 @@ namespace corsika::process::proposal {
...
@@ -19,13 +19,11 @@ namespace corsika::process::proposal {
using
namespace
corsika
::
setup
;
using
namespace
corsika
::
setup
;
using
namespace
corsika
::
environment
;
using
namespace
corsika
::
environment
;
using
namespace
corsika
::
units
::
si
;
using
namespace
corsika
::
units
::
si
;
using
namespace
corsika
;
using
SetupParticle
=
corsika
::
setup
::
Stack
::
StackIterator
;
using
SetupParticle
=
corsika
::
setup
::
Stack
::
StackIterator
;
template
<
>
template
<
>
std
::
unordered_map
<
particles
::
Code
,
PROPOSAL
::
ParticleDef
>
std
::
unordered_map
<
particles
::
Code
,
PROPOSAL
::
ParticleDef
>
Interaction
<
SetupEnvironment
>::
particle
_map
{
Interaction
<
SetupEnvironment
>::
particle
s
{
{
particles
::
Code
::
Gamma
,
PROPOSAL
::
GammaDef
()},
{
particles
::
Code
::
Gamma
,
PROPOSAL
::
GammaDef
()},
{
particles
::
Code
::
Electron
,
PROPOSAL
::
EMinusDef
()},
{
particles
::
Code
::
Electron
,
PROPOSAL
::
EMinusDef
()},
{
particles
::
Code
::
Positron
,
PROPOSAL
::
EPlusDef
()},
{
particles
::
Code
::
Positron
,
PROPOSAL
::
EPlusDef
()},
...
@@ -40,8 +38,10 @@ namespace corsika::process::proposal {
...
@@ -40,8 +38,10 @@ namespace corsika::process::proposal {
CORSIKA_ParticleCut
const
&
e_cut
)
CORSIKA_ParticleCut
const
&
e_cut
)
:
fEnvironment
(
env
)
:
fEnvironment
(
env
)
,
cut
(
make_shared
<
const
PROPOSAL
::
EnergyCutSettings
>
(
e_cut
.
GetCutEnergy
()
/
1
_GeV
,
,
cut
(
make_shared
<
const
PROPOSAL
::
EnergyCutSettings
>
(
e_cut
.
GetCutEnergy
()
/
1
_GeV
,
0
,
false
))
{
1
,
false
))
{
}
template
<
>
void
Interaction
<
SetupEnvironment
>::
Init
()
{
auto
all_compositions
=
std
::
vector
<
NuclearComposition
>
();
auto
all_compositions
=
std
::
vector
<
NuclearComposition
>
();
fEnvironment
.
GetUniverse
()
->
walk
([
&
](
auto
&
vtn
)
{
fEnvironment
.
GetUniverse
()
->
walk
([
&
](
auto
&
vtn
)
{
if
(
vtn
.
HasModelProperties
())
if
(
vtn
.
HasModelProperties
())
...
@@ -55,44 +55,24 @@ namespace corsika::process::proposal {
...
@@ -55,44 +55,24 @@ namespace corsika::process::proposal {
*
frac_iter
);
*
frac_iter
);
++
frac_iter
;
++
frac_iter
;
}
}
medi
um_map
[
&
ncarg
]
=
PROPOSAL
::
Medium
(
medi
a
[
&
ncarg
]
=
PROPOSAL
::
Medium
(
"Modified Air"
,
1.
,
PROPOSAL
::
Air
().
GetI
(),
PROPOSAL
::
Air
().
GetC
(),
"Modified Air"
,
1.
,
PROPOSAL
::
Air
().
GetI
(),
PROPOSAL
::
Air
().
GetC
(),
PROPOSAL
::
Air
().
GetA
(),
PROPOSAL
::
Air
().
GetM
(),
PROPOSAL
::
Air
().
GetX0
(),
PROPOSAL
::
Air
().
GetA
(),
PROPOSAL
::
Air
().
GetM
(),
PROPOSAL
::
Air
().
GetX0
(),
PROPOSAL
::
Air
().
GetX1
(),
PROPOSAL
::
Air
().
GetD0
(),
1.0
,
comp_vec
);
PROPOSAL
::
Air
().
GetX1
(),
PROPOSAL
::
Air
().
GetD0
(),
1.0
,
comp_vec
);
}
}
std
::
cout
<<
"PROPOSAL done."
<<
std
::
endl
;
}
template
<
>
template
<
>
auto
Interaction
<
SetupEnvironment
>::
GetCalculator
(
SetupParticle
const
&
vP
)
{
auto
&
mediumComposition
=
vP
.
GetNode
()
->
GetModelProperties
().
GetNuclearComposition
();
auto
calc_it
=
calculators
.
find
(
&
mediumComposition
);
if
(
calc_it
!=
calculators
.
end
())
return
calc_it
;
auto
const
&
p_def
=
particle_map
[
vP
.
GetPID
()];
auto
&
medium
=
medium_map
[
&
mediumComposition
];
auto
cross
=
PROPOSAL
::
GetStdCrossSections
(
p_def
,
medium
,
cut
,
true
);
auto
inter_types
=
PROPOSAL
::
CrossSectionVector
::
GetInteractionTypes
(
cross
);
auto
[
insert_it
,
success
]
=
calculators
.
insert
(
{
&
mediumComposition
,
make_tuple
(
PROPOSAL
::
SecondariesCalculator
(
inter_types
,
p_def
,
medium
),
PROPOSAL
::
make_interaction
(
cross
,
true
),
PROPOSAL
::
make_displacement
(
cross
,
true
))});
if
(
success
)
return
insert_it
;
throw
std
::
logic_error
(
"insert failed."
);
}
}
template
<
>
template
<
>
template
<
>
template
<
>
corsika
::
process
::
EProcessReturn
Interaction
<
SetupEnvironment
>::
DoInteraction
(
corsika
::
process
::
EProcessReturn
Interaction
<
SetupEnvironment
>::
DoInteraction
(
SetupParticle
const
&
vP
)
{
SetupParticle
&
vP
)
{
auto
calc
=
GetCalculator
(
vP
);
// [CrossSections]
auto
calc
=
GetCalculator
(
vP
);
// [CrossSections]
std
::
uniform_real_distribution
<
double
>
distr
(
0.
,
1.
);
std
::
uniform_real_distribution
<
double
>
distr
(
0.
,
1.
);
auto
[
type
,
comp_ptr
,
v
]
=
std
::
get
<
INTERACTION
>
(
calc
->
second
)
auto
[
type
,
comp_ptr
,
v
]
=
std
::
get
<
INTERACTION
>
(
calc
->
second
)
->
TypeInteraction
(
vP
.
GetEnergy
()
/
1
_GeV
,
distr
(
fRNG
));
->
TypeInteraction
(
vP
.
GetEnergy
()
/
1
_GeV
,
distr
(
fRNG
));
auto
rnd
=
std
::
vector
<
double
>
();
auto
rnd
=
std
::
vector
<
double
>
();
for
(
auto
i
=
0
;
i
<
std
::
get
<
SECONDARIES
>
(
calc
->
second
).
RequiredRandomNumbers
(
type
);
for
(
size_t
i
=
0
;
++
i
)
i
<
std
::
get
<
SECONDARIES
>
(
calc
->
second
).
RequiredRandomNumbers
(
type
);
++
i
)
rnd
.
push_back
(
distr
(
fRNG
));
rnd
.
push_back
(
distr
(
fRNG
));
double
primary_energy
=
vP
.
GetEnergy
()
/
1
_GeV
;
double
primary_energy
=
vP
.
GetEnergy
()
/
1
_GeV
;
auto
point
=
auto
point
=
...
@@ -114,11 +94,14 @@ namespace corsika::process::proposal {
...
@@ -114,11 +94,14 @@ namespace corsika::process::proposal {
corsika
::
geometry
::
RootCoordinateSystem
::
GetInstance
()
corsika
::
geometry
::
RootCoordinateSystem
::
GetInstance
()
.
GetRootCoordinateSystem
(),
.
GetRootCoordinateSystem
(),
vec
);
vec
);
// particles::Code, units::si::HEPEnergyType, stack::MomentumVector,
particles
::
Code
sec_code
=
corsika
::
particles
::
ConvertFromPDG
(
// geometry::Point, units::si::TimeType
static_cast
<
particles
::
PDGCode
>
(
get
<
PROPOSAL
::
Loss
::
TYPE
>
(
s
)));
auto
sec
=
make_tuple
(
get
<
PROPOSAL
::
Loss
::
TYPE
>
(
s
),
energy
,
momentum
,
corsika
::
units
::
si
::
HEPEnergyType
sec_energy
=
energy
;
vP
.
GetPosition
(),
vP
.
GetTime
());
stack
::
MomentumVector
sec_momentum
=
momentum
;
vP
.
AddSecondary
(
sec
);
geometry
::
Point
sec_position
=
vP
.
GetPosition
();
corsika
::
units
::
si
::
TimeType
sec_time
=
vP
.
GetTime
();
vP
.
AddSecondary
(
make_tuple
(
sec_code
,
sec_energy
,
sec_momentum
,
sec_position
,
sec_time
));
}
}
return
process
::
EProcessReturn
::
eOk
;
return
process
::
EProcessReturn
::
eOk
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Processes/Proposal/Interaction.h
+
20
−
24
View file @
9397c1a9
...
@@ -27,16 +27,6 @@ using CORSIKA_ParticleCut = corsika::process::particle_cut::ParticleCut;
...
@@ -27,16 +27,6 @@ using CORSIKA_ParticleCut = corsika::process::particle_cut::ParticleCut;
namespace
corsika
::
process
::
proposal
{
namespace
corsika
::
process
::
proposal
{
/* static std::unordered_map<particles::Code, PROPOSAL::ParticleDef> particle_map{ */
/* {particles::Code::Gamma, PROPOSAL::GammaDef()}, */
/* {particles::Code::Electron, PROPOSAL::EMinusDef()}, */
/* {particles::Code::Positron, PROPOSAL::EPlusDef()}, */
/* {particles::Code::MuMinus, PROPOSAL::MuMinusDef()}, */
/* {particles::Code::MuPlus, PROPOSAL::MuPlusDef()}, */
/* {particles::Code::TauPlus, PROPOSAL::TauPlusDef()}, */
/* {particles::Code::TauMinus, PROPOSAL::TauMinusDef()}, */
/* }; */
template
<
class
TEnvironment
>
template
<
class
TEnvironment
>
class
Interaction
class
Interaction
:
public
corsika
::
process
::
InteractionProcess
<
Interaction
<
TEnvironment
>>
{
:
public
corsika
::
process
::
InteractionProcess
<
Interaction
<
TEnvironment
>>
{
...
@@ -45,26 +35,17 @@ namespace corsika::process::proposal {
...
@@ -45,26 +35,17 @@ namespace corsika::process::proposal {
TEnvironment
const
&
fEnvironment
;
TEnvironment
const
&
fEnvironment
;
shared_ptr
<
const
PROPOSAL
::
EnergyCutSettings
>
cut
;
shared_ptr
<
const
PROPOSAL
::
EnergyCutSettings
>
cut
;
static
std
::
unordered_map
<
particles
::
Code
,
PROPOSAL
::
ParticleDef
>
particle
_map
;
static
std
::
unordered_map
<
particles
::
Code
,
PROPOSAL
::
ParticleDef
>
particle
s
;
std
::
unordered_map
<
const
NuclearComposition
*
,
PROPOSAL
::
Medium
>
medi
um_map
;
std
::
unordered_map
<
const
NuclearComposition
*
,
PROPOSAL
::
Medium
>
medi
a
;
enum
{
SECONDARIES
,
INTERACTION
,
DISPLACEMENT
};
enum
{
SECONDARIES
,
INTERACTION
,
DISPLACEMENT
};
/* std::uniform_real_distribution<> rnd_uniform(0., 1.); */
/* std::map<particles::Code, std::unique_ptr<PROPOSAL::UtilityInterpolantInteraction>>
* corsika_particle_to_utility_map; */
/* std::map<particles::Code,
* std::unique_ptr<PROPOSAL::UtilityInterpolantDisplacement>>
* corsika_particle_to_displacement_map; */
corsika
::
random
::
RNG
&
fRNG
=
corsika
::
random
::
RNG
&
fRNG
=
corsika
::
random
::
RNGManager
::
GetInstance
().
GetRandomStream
(
"s_rndm"
);
corsika
::
random
::
RNGManager
::
GetInstance
().
GetRandomStream
(
"s_rndm"
);
// fTrackedParticles[proposal_particle.GetName()] return particle::Code
auto
IsTracked
(
particles
::
Code
pcode
)
const
noexcept
{
auto
IsTracked
(
particles
::
Code
pcode
)
const
noexcept
{
auto
search
=
particle
_map
.
find
(
pcode
);
auto
search
=
particle
s
.
find
(
pcode
);
if
(
search
!=
particle
_map
.
end
())
return
true
;
if
(
search
!=
particle
s
.
end
())
return
true
;
return
false
;
return
false
;
};
};
...
@@ -74,11 +55,26 @@ namespace corsika::process::proposal {
...
@@ -74,11 +55,26 @@ namespace corsika::process::proposal {
std
::
unordered_map
<
const
NuclearComposition
*
,
calculator_t
>
calculators
;
std
::
unordered_map
<
const
NuclearComposition
*
,
calculator_t
>
calculators
;
template
<
typename
Particle
>
template
<
typename
Particle
>
auto
GetCalculator
(
Particle
&
);
auto
GetCalculator
(
Particle
&
vP
)
{
auto
&
comp
=
vP
.
GetNode
()
->
GetModelProperties
().
GetNuclearComposition
();
auto
calc_it
=
calculators
.
find
(
&
comp
);
if
(
calc_it
!=
calculators
.
end
())
return
calc_it
;
auto
cross
=
PROPOSAL
::
GetStdCrossSections
(
particles
[
vP
.
GetPID
()],
media
[
&
comp
],
cut
,
true
);
auto
inter_types
=
PROPOSAL
::
CrossSectionVector
::
GetInteractionTypes
(
cross
);
auto
[
insert_it
,
success
]
=
calculators
.
insert
(
{
&
comp
,
make_tuple
(
PROPOSAL
::
SecondariesCalculator
(
inter_types
,
particles
[
vP
.
GetPID
()],
media
[
&
comp
]),
PROPOSAL
::
make_interaction
(
cross
,
true
),
PROPOSAL
::
make_displacement
(
cross
,
true
))});
return
insert_it
;
}
public
:
public
:
Interaction
(
TEnvironment
const
&
env
,
CORSIKA_ParticleCut
const
&
cut
);
Interaction
(
TEnvironment
const
&
env
,
CORSIKA_ParticleCut
const
&
cut
);
void
Init
();
template
<
typename
Particle
>
template
<
typename
Particle
>
corsika
::
process
::
EProcessReturn
DoInteraction
(
Particle
&
);
corsika
::
process
::
EProcessReturn
DoInteraction
(
Particle
&
);
...
...
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