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
00d47c87
Commit
00d47c87
authored
4 years ago
by
Maximilian Reininghaus
Browse files
Options
Downloads
Patches
Plain Diff
style, explanations
parent
b3df43bd
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
Environment/ShowerAxis.cc
+11
-6
11 additions, 6 deletions
Environment/ShowerAxis.cc
Environment/ShowerAxis.h
+13
-12
13 additions, 12 deletions
Environment/ShowerAxis.h
with
24 additions
and
18 deletions
Environment/ShowerAxis.cc
+
11
−
6
View file @
00d47c87
/*
* (c) Copyright 20
18
CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 20
20
CORSIKA Project, corsika-project@lists.kit.edu
*
* See file AUTHORS for a list of contributors.
*
...
...
@@ -9,6 +9,7 @@
*/
#include
<corsika/environment/ShowerAxis.h>
#include
<sstream>
using
namespace
corsika
::
environment
;
using
namespace
corsika
::
units
::
si
;
...
...
@@ -19,21 +20,25 @@ GrammageType ShowerAxis::X(LengthType l) const {
auto
const
lambda
=
fractionalBin
-
lower
;
int
const
upper
=
lower
+
1
;
if
(
upper
>=
steps
)
{
throw
std
::
runtime_error
(
"shower axis too short, cannot extrapolate"
);
if
(
upper
>=
X_
.
size
())
{
std
::
stringstream
errormsg
;
errormsg
<<
"shower axis too short, cannot extrapolate (l / max_length_ = "
<<
l
/
max_length_
<<
")"
;
throw
std
::
runtime_error
(
errormsg
.
str
().
c_str
());
}
else
if
(
lower
<
0
)
{
throw
std
::
runtime_error
(
"cannot extrapolate to points behind point of injection"
);
}
assert
(
0
<=
lambda
&&
lambda
<=
1.
);
return
(
*
X_
)[
lower
]
*
lambda
+
(
*
X_
)[
upper
]
*
(
1
-
lambda
);
// linear interpolation between X[lower] and X[upper]
return
X_
[
lower
]
*
lambda
+
X_
[
upper
]
*
(
1
-
lambda
);
}
LengthType
ShowerAxis
::
steplength
()
const
{
return
steplength_
;
}
GrammageType
ShowerAxis
::
maximumX
()
const
{
return
*
(
X_
->
rbegin
()
)
;
}
GrammageType
ShowerAxis
::
maximumX
()
const
{
return
*
X_
.
rbegin
();
}
GrammageType
ShowerAxis
::
minimumX
()
const
{
return
*
(
X_
->
cbegin
()
)
;
}
GrammageType
ShowerAxis
::
minimumX
()
const
{
return
*
X_
.
cbegin
();
}
GrammageType
ShowerAxis
::
projectedX
(
geometry
::
Point
const
&
p
)
const
{
auto
const
projectedLength
=
(
p
-
pointStart_
).
dot
(
axis_normalized_
);
...
...
This diff is collapsed.
Click to expand it.
Environment/ShowerAxis.h
+
13
−
12
View file @
00d47c87
...
...
@@ -31,12 +31,13 @@ namespace corsika::environment {
template
<
typename
TEnvModel
>
ShowerAxis
(
geometry
::
Point
const
&
pStart
,
geometry
::
Vector
<
units
::
si
::
length_d
>
length
,
environment
::
Environment
<
TEnvModel
>
const
&
env
)
environment
::
Environment
<
TEnvModel
>
const
&
env
,
int
steps
=
10'000
)
:
pointStart_
(
pStart
)
,
length_
(
length
)
,
max_length_
(
length_
.
norm
())
,
steplength_
(
max_length_
/
steps
)
,
axis_normalized_
(
length
/
max_length_
)
{
,
axis_normalized_
(
length
/
max_length_
)
,
X_
(
steps
)
{
auto
const
*
const
universe
=
env
.
GetUniverse
().
get
();
auto
rho
=
[
pStart
,
length
,
universe
](
double
x
)
{
...
...
@@ -56,15 +57,15 @@ namespace corsika::environment {
auto
const
result
=
units
::
si
::
MassDensityType
(
phys
::
units
::
detail
::
magnitude_tag
,
r
)
*
max_length_
;
auto
const
resultTotal
=
result
+
(
*
X_
)
[
i
-
1
];
(
*
X_
)
[
i
]
=
resultTotal
;
auto
const
resultTotal
=
result
+
X_
[
i
-
1
];
X_
[
i
]
=
resultTotal
;
for
(;
resultTotal
>
k
*
X_binning_
;
++
k
)
{
d_
.
emplace_back
(
d_prev
+
k
*
X_binning_
*
steplength_
/
result
);
}
}
assert
(
std
::
is_sorted
(
X_
->
cbegin
(),
X_
->
cend
()));
assert
(
std
::
is_sorted
(
X_
.
cbegin
(),
X_
.
cend
()));
assert
(
std
::
is_sorted
(
d_
.
cbegin
(),
d_
.
cend
()));
}
...
...
@@ -79,17 +80,17 @@ namespace corsika::environment {
units
::
si
::
GrammageType
X
(
units
::
si
::
LengthType
)
const
;
private
:
static
constexpr
int
steps
=
10'000
;
units
::
si
::
GrammageType
const
X_binning_
=
std
::
invoke
([]()
{
using
namespace
units
::
si
;
return
1
_g
/
1
_cm
/
1
_cm
;
});
std
::
unique_ptr
<
std
::
array
<
units
::
si
::
GrammageType
,
steps
>>
const
X_
{
new
std
::
array
<
units
::
si
::
GrammageType
,
steps
>
};
geometry
::
Point
const
pointStart_
;
geometry
::
Vector
<
units
::
si
::
length_d
>
const
length_
;
units
::
si
::
LengthType
const
max_length_
,
steplength_
;
geometry
::
Vector
<
units
::
si
::
dimensionless_d
>
const
axis_normalized_
;
std
::
vector
<
units
::
si
::
GrammageType
>
X_
;
// for storing the lengths corresponding to equidistant X values
units
::
si
::
GrammageType
const
X_binning_
=
std
::
invoke
([]()
{
using
namespace
units
::
si
;
return
1
_g
/
1
_cm
/
1
_cm
;
});
std
::
vector
<
units
::
si
::
LengthType
>
d_
;
};
}
// namespace corsika::environment
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