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
Snippets
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
Antonio Augusto Alves Junior
corsika
Commits
4c838dec
Commit
4c838dec
authored
5 years ago
by
Maximilian Reininghaus
Browse files
Options
Downloads
Patches
Plain Diff
use WeightedSum in GetInteractionLength
parent
8a1c6daa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Environment/NuclearComposition.h
+3
-3
3 additions, 3 deletions
Environment/NuclearComposition.h
Processes/Pythia/Interaction.cc
+6
-20
6 additions, 20 deletions
Processes/Pythia/Interaction.cc
with
9 additions
and
23 deletions
Environment/NuclearComposition.h
+
3
−
3
View file @
4c838dec
...
...
@@ -16,6 +16,7 @@
#include
<corsika/units/PhysicalUnits.h>
#include
<cassert>
#include
<functional>
#include
<numeric>
#include
<random>
#include
<stdexcept>
...
...
@@ -82,7 +83,6 @@ namespace corsika::environment {
auto
WeightedSum
(
TFunction
func
)
const
{
using
ResultQuantity
=
decltype
(
func
(
*
fComponents
.
cbegin
()));
auto
const
sum
=
[](
auto
x
,
auto
y
)
{
return
x
+
y
;
};
auto
const
prod
=
[
&
](
auto
const
compID
,
auto
const
fraction
)
{
return
func
(
compID
)
*
fraction
;
};
...
...
@@ -91,12 +91,12 @@ namespace corsika::environment {
return
std
::
inner_product
(
fComponents
.
cbegin
(),
fComponents
.
cend
(),
fNumberFractions
.
cbegin
(),
ResultQuantity
::
zero
(),
// .zero() is defined for quantity types only
s
um
,
prod
);
s
td
::
plus
<
ResultQuantity
>
()
,
prod
);
}
else
{
return
std
::
inner_product
(
fComponents
.
cbegin
(),
fComponents
.
cend
(),
fNumberFractions
.
cbegin
(),
ResultQuantity
(
0
),
// in other cases we have to use a bare 0
s
um
,
prod
);
s
td
::
plus
<
ResultQuantity
>
()
,
prod
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Processes/Pythia/Interaction.cc
+
6
−
20
View file @
4c838dec
...
...
@@ -215,26 +215,12 @@ namespace corsika::process::pythia {
const
auto
mediumComposition
=
currentNode
->
GetModelProperties
().
GetNuclearComposition
();
// determine average interaction length
// weighted sum
int
i
=
-
1
;
si
::
CrossSectionType
weightedProdCrossSection
=
0
_mb
;
// get weights of components from environment/medium
const
auto
&
w
=
mediumComposition
.
GetFractions
();
// loop over components in medium
for
(
auto
const
targetId
:
mediumComposition
.
GetComponents
())
{
i
++
;
cout
<<
"Interaction: get interaction length for target: "
<<
targetId
<<
endl
;
auto
const
[
productionCrossSection
,
elaCrossSection
]
=
GetCrossSection
(
corsikaBeamId
,
targetId
,
ECoM
);
[[
maybe_unused
]]
const
auto
&
dummy_elaCrossSection
=
elaCrossSection
;
cout
<<
"Interaction: IntLength: pythia return (mb): "
<<
productionCrossSection
/
1
_mb
<<
endl
<<
"Interaction: IntLength: weight : "
<<
w
[
i
]
<<
endl
;
weightedProdCrossSection
+=
w
[
i
]
*
productionCrossSection
;
}
auto
const
weightedProdCrossSection
=
mediumComposition
.
WeightedSum
([
=
](
auto
vTargetID
)
{
return
std
::
get
<
0
>
(
this
->
GetCrossSection
(
corsikaBeamId
,
vTargetID
,
ECoM
));
});
cout
<<
"Interaction: IntLength: weighted CrossSection (mb): "
<<
weightedProdCrossSection
/
1
_mb
<<
endl
<<
"Interaction: IntLength: average mass number: "
...
...
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