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
d82b8ca0
Commit
d82b8ca0
authored
4 years ago
by
Maximilian Reininghaus
Committed by
Maximilian Reininghaus
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
updated to latest coding style
parent
59d25dd5
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/UrQMD/UrQMD.cc
+48
-49
48 additions, 49 deletions
Processes/UrQMD/UrQMD.cc
Processes/UrQMD/UrQMD.h
+8
-8
8 additions, 8 deletions
Processes/UrQMD/UrQMD.h
with
56 additions
and
57 deletions
Processes/UrQMD/UrQMD.cc
+
48
−
49
View file @
d82b8ca0
...
...
@@ -36,18 +36,18 @@ UrQMD::UrQMD(std::string const& xs_file) {
iniurqmd_
();
}
CrossSectionType
UrQMD
::
GetTabulatedCrossSection
(
particles
::
Code
vP
rojectileCode
,
corsika
::
particles
::
Code
vT
argetCode
,
HEPEnergyType
vL
abEnergy
)
const
{
CrossSectionType
UrQMD
::
GetTabulatedCrossSection
(
particles
::
Code
p
rojectileCode
,
corsika
::
particles
::
Code
t
argetCode
,
HEPEnergyType
l
abEnergy
)
const
{
// translated to C++ from CORSIKA 7 subroutine cxtot_u
auto
const
kinEnergy
=
vL
abEnergy
-
particles
::
GetMass
(
vP
rojectileCode
);
auto
const
kinEnergy
=
l
abEnergy
-
particles
::
GetMass
(
p
rojectileCode
);
assert
(
kinEnergy
>=
HEPEnergyType
::
zero
());
double
const
logKinEnergy
=
std
::
log10
(
kinEnergy
*
(
1
/
1
_GeV
));
double
const
ye
=
std
::
max
(
10
*
logKinEnergy
+
10.5
,
1.
);
int
const
je
=
std
::
min
(
int
(
ye
),
int
(
xs_interp_support_table
.
shape
()[
2
]
-
2
));
int
const
je
=
std
::
min
(
int
(
ye
),
int
(
xs_interp_support_table
_
.
shape
()[
2
]
-
2
));
std
::
array
<
double
,
3
>
w
;
w
[
2
-
1
]
=
ye
-
je
;
w
[
3
-
1
]
=
w
[
2
-
1
]
*
(
w
[
2
-
1
]
-
1.
)
*
.5
;
...
...
@@ -55,7 +55,7 @@ CrossSectionType UrQMD::GetTabulatedCrossSection(particles::Code vProjectileCode
w
[
2
-
1
]
=
w
[
2
-
1
]
-
2
*
w
[
3
-
1
];
int
projectileIndex
;
switch
(
vP
rojectileCode
)
{
switch
(
p
rojectileCode
)
{
case
particles
::
Code
::
Proton
:
projectileIndex
=
0
;
break
;
...
...
@@ -89,13 +89,13 @@ CrossSectionType UrQMD::GetTabulatedCrossSection(particles::Code vProjectileCode
projectileIndex
=
8
;
break
;
default:
std
::
cout
<<
"WARNING: UrQMD cross-section not tabulated for "
<<
vP
rojectileCode
std
::
cout
<<
"WARNING: UrQMD cross-section not tabulated for "
<<
p
rojectileCode
<<
std
::
endl
;
return
CrossSectionType
::
zero
();
}
int
targetIndex
;
switch
(
vT
argetCode
)
{
switch
(
t
argetCode
)
{
case
particles
::
Code
::
Nitrogen
:
targetIndex
=
0
;
break
;
...
...
@@ -107,38 +107,37 @@ CrossSectionType UrQMD::GetTabulatedCrossSection(particles::Code vProjectileCode
break
;
default:
std
::
stringstream
ss
;
ss
<<
"UrQMD cross-section not tabluated for target "
<<
vT
argetCode
;
ss
<<
"UrQMD cross-section not tabluated for target "
<<
t
argetCode
;
throw
std
::
runtime_error
(
ss
.
str
().
data
());
}
auto
result
=
CrossSectionType
::
zero
();
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
result
+=
xs_interp_support_table
[
projectileIndex
][
targetIndex
][
je
+
i
-
1
-
1
]
*
w
[
i
];
xs_interp_support_table
_
[
projectileIndex
][
targetIndex
][
je
+
i
-
1
-
1
]
*
w
[
i
];
}
return
result
;
}
CrossSectionType
UrQMD
::
GetCrossSection
(
particles
::
Code
vProjectileCode
,
corsika
::
particles
::
Code
vTargetCode
,
HEPEnergyType
vLabEnergy
,
int
vAProjectile
)
const
{
CrossSectionType
UrQMD
::
GetCrossSection
(
particles
::
Code
projectileCode
,
corsika
::
particles
::
Code
targetCode
,
HEPEnergyType
labEnergy
,
int
projectileA
)
const
{
// the following is a (incomplete!) translation of ptsigtot() into C++
if
(
vP
rojectileCode
!=
particles
::
Code
::
Nucleus
&&
!
IsNucleus
(
vT
argetCode
))
{
// both particles are "special"
auto
const
mProj
=
particles
::
GetMass
(
vP
rojectileCode
);
auto
const
mTar
=
particles
::
GetMass
(
vT
argetCode
);
if
(
p
rojectileCode
!=
particles
::
Code
::
Nucleus
&&
!
IsNucleus
(
t
argetCode
))
{
// both particles are "special"
auto
const
mProj
=
particles
::
GetMass
(
p
rojectileCode
);
auto
const
mTar
=
particles
::
GetMass
(
t
argetCode
);
double
sqrtS
=
sqrt
(
units
::
si
::
detail
::
static_pow
<
2
>
(
mProj
)
+
units
::
si
::
detail
::
static_pow
<
2
>
(
mTar
)
+
2
*
vL
abEnergy
*
mTar
)
*
units
::
si
::
detail
::
static_pow
<
2
>
(
mTar
)
+
2
*
l
abEnergy
*
mTar
)
*
(
1
/
1
_GeV
);
// we must set some UrQMD globals first...
auto
const
[
ityp
,
iso3
]
=
ConvertToUrQMD
(
vP
rojectileCode
);
auto
const
[
ityp
,
iso3
]
=
ConvertToUrQMD
(
p
rojectileCode
);
inputs_
.
spityp
[
0
]
=
ityp
;
inputs_
.
spiso3
[
0
]
=
iso3
;
auto
const
[
itypTar
,
iso3Tar
]
=
ConvertToUrQMD
(
vT
argetCode
);
auto
const
[
itypTar
,
iso3Tar
]
=
ConvertToUrQMD
(
t
argetCode
);
inputs_
.
spityp
[
1
]
=
itypTar
;
inputs_
.
spiso3
[
1
]
=
iso3Tar
;
...
...
@@ -178,8 +177,8 @@ CrossSectionType UrQMD::GetCrossSection(particles::Code vProjectileCode,
return
sigEl
*
0
_mb
;
}
}
else
{
int
const
Ap
=
vAP
rojectile
;
int
const
At
=
IsNucleus
(
vT
argetCode
)
?
particles
::
GetNucleusA
(
vT
argetCode
)
:
1
;
int
const
Ap
=
p
rojectile
A
;
int
const
At
=
IsNucleus
(
t
argetCode
)
?
particles
::
GetNucleusA
(
t
argetCode
)
:
1
;
double
const
maxImpact
=
nucrad_
(
Ap
)
+
nucrad_
(
At
)
+
2
*
options_
.
CTParam
[
30
-
1
];
return
10
_mb
*
M_PI
*
units
::
si
::
detail
::
static_pow
<
2
>
(
maxImpact
);
...
...
@@ -206,7 +205,7 @@ CrossSectionType UrQMD::GetCrossSection(TParticle const& projectile,
return
GetTabulatedCrossSection
(
projectileCode
,
targetCode
,
projectileEnergyLab
);
}
bool
UrQMD
::
CanInteract
(
particles
::
Code
vC
ode
)
const
{
bool
UrQMD
::
CanInteract
(
particles
::
Code
c
ode
)
const
{
// According to the manual, UrQMD can use all mesons, baryons and nucleons
// which are modeled also as input particles. I think it is safer to accept
// only the usual long-lived species as input.
...
...
@@ -222,52 +221,52 @@ bool UrQMD::CanInteract(particles::Code vCode) const {
particles
::
Code
::
K0Long
};
return
std
::
find
(
std
::
cbegin
(
validProjectileCodes
),
std
::
cend
(
validProjectileCodes
),
vC
ode
)
!=
std
::
cend
(
validProjectileCodes
);
c
ode
)
!=
std
::
cend
(
validProjectileCodes
);
}
GrammageType
UrQMD
::
GetInteractionLength
(
SetupParticle
const
&
vP
article
)
const
{
if
(
!
CanInteract
(
vP
article
.
GetPID
()))
{
GrammageType
UrQMD
::
GetInteractionLength
(
SetupParticle
const
&
p
article
)
const
{
if
(
!
CanInteract
(
p
article
.
GetPID
()))
{
// we could do the canInteract check in GetCrossSection, too but if
// we do it here we have the advantage of avoiding the loop
return
std
::
numeric_limits
<
double
>::
infinity
()
*
1
_g
/
(
1
_cm
*
1
_cm
);
}
auto
const
&
mediumComposition
=
vP
article
.
GetNode
()
->
GetModelProperties
().
GetNuclearComposition
();
p
article
.
GetNode
()
->
GetModelProperties
().
GetNuclearComposition
();
using
namespace
std
::
placeholders
;
CrossSectionType
const
weightedProdCrossSection
=
mediumComposition
.
WeightedSum
(
std
::
bind
(
&
UrQMD
::
GetCrossSection
<
decltype
(
vP
article
)
>
,
this
,
vP
article
,
_1
));
std
::
bind
(
&
UrQMD
::
GetCrossSection
<
decltype
(
p
article
)
>
,
this
,
p
article
,
_1
));
return
mediumComposition
.
GetAverageMassNumber
()
*
units
::
constants
::
u
/
weightedProdCrossSection
;
}
corsika
::
process
::
EProcessReturn
UrQMD
::
DoInteraction
(
SetupProjectile
&
vP
rojectile
)
{
corsika
::
process
::
EProcessReturn
UrQMD
::
DoInteraction
(
SetupProjectile
&
p
rojectile
)
{
using
namespace
units
::
si
;
auto
projectileCode
=
vP
rojectile
.
GetPID
();
auto
const
projectileEnergyLab
=
vP
rojectile
.
GetEnergy
();
auto
const
&
projectileMomentumLab
=
vP
rojectile
.
GetMomentum
();
auto
const
&
projectilePosition
=
vP
rojectile
.
GetPosition
();
auto
const
projectileTime
=
vP
rojectile
.
GetTime
();
auto
projectileCode
=
p
rojectile
.
GetPID
();
auto
const
projectileEnergyLab
=
p
rojectile
.
GetEnergy
();
auto
const
&
projectileMomentumLab
=
p
rojectile
.
GetMomentum
();
auto
const
&
projectilePosition
=
p
rojectile
.
GetPosition
();
auto
const
projectileTime
=
p
rojectile
.
GetTime
();
// sample target particle
auto
const
&
mediumComposition
=
vP
rojectile
.
GetNode
()
->
GetModelProperties
().
GetNuclearComposition
();
p
rojectile
.
GetNode
()
->
GetModelProperties
().
GetNuclearComposition
();
auto
const
componentCrossSections
=
std
::
invoke
([
&
]()
{
auto
const
&
components
=
mediumComposition
.
GetComponents
();
std
::
vector
<
CrossSectionType
>
crossSections
;
crossSections
.
reserve
(
components
.
size
());
for
(
auto
const
c
:
components
)
{
crossSections
.
push_back
(
GetCrossSection
(
vP
rojectile
,
c
));
crossSections
.
push_back
(
GetCrossSection
(
p
rojectile
,
c
));
}
return
crossSections
;
});
auto
const
targetCode
=
mediumComposition
.
SampleTarget
(
componentCrossSections
,
fRNG
);
auto
const
targetCode
=
mediumComposition
.
SampleTarget
(
componentCrossSections
,
rng_
);
auto
const
targetA
=
particles
::
GetNucleusA
(
targetCode
);
auto
const
targetZ
=
particles
::
GetNucleusZ
(
targetCode
);
...
...
@@ -281,10 +280,10 @@ corsika::process::EProcessReturn UrQMD::DoInteraction(SetupProjectile& vProjecti
// is this everything?
inputs_
.
prspflg
=
0
;
sys_
.
Ap
=
vP
rojectile
.
GetNuclearA
();
sys_
.
Zp
=
vP
rojectile
.
GetNuclearZ
();
rsys_
.
ebeam
=
(
projectileEnergyLab
-
vP
rojectile
.
GetMass
())
*
(
1
/
1
_GeV
)
/
vP
rojectile
.
GetNuclearA
();
sys_
.
Ap
=
p
rojectile
.
GetNuclearA
();
sys_
.
Zp
=
p
rojectile
.
GetNuclearZ
();
rsys_
.
ebeam
=
(
projectileEnergyLab
-
p
rojectile
.
GetMass
())
*
(
1
/
1
_GeV
)
/
p
rojectile
.
GetNuclearA
();
rsys_
.
bdist
=
nucrad_
(
targetA
)
+
nucrad_
(
sys_
.
Ap
)
+
2
*
options_
.
CTParam
[
30
-
1
];
...
...
@@ -294,11 +293,11 @@ corsika::process::EProcessReturn UrQMD::DoInteraction(SetupProjectile& vProjecti
inputs_
.
prspflg
=
1
;
sys_
.
Ap
=
1
;
// even for non-baryons this has to be set, see vanilla UrQMD.f
rsys_
.
bdist
=
nucrad_
(
targetA
)
+
nucrad_
(
1
)
+
2
*
options_
.
CTParam
[
30
-
1
];
rsys_
.
ebeam
=
(
projectileEnergyLab
-
vP
rojectile
.
GetMass
())
*
(
1
/
1
_GeV
);
rsys_
.
ebeam
=
(
projectileEnergyLab
-
p
rojectile
.
GetMass
())
*
(
1
/
1
_GeV
);
if
(
projectileCode
==
particles
::
Code
::
K0Long
||
projectileCode
==
particles
::
Code
::
K0Short
)
{
projectileCode
=
fB
ooleanDist
(
fRNG
)
?
particles
::
Code
::
K0
:
particles
::
Code
::
K0Bar
;
projectileCode
=
b
ooleanDist
_
(
rng_
)
?
particles
::
Code
::
K0
:
particles
::
Code
::
K0Bar
;
}
auto
const
[
ityp
,
iso3
]
=
ConvertToUrQMD
(
projectileCode
);
...
...
@@ -332,7 +331,7 @@ corsika::process::EProcessReturn UrQMD::DoInteraction(SetupProjectile& vProjecti
for
(
int
i
=
0
;
i
<
sys_
.
npart
;
++
i
)
{
auto
code
=
ConvertFromUrQMD
(
isys_
.
ityp
[
i
],
isys_
.
iso3
[
i
]);
if
(
code
==
particles
::
Code
::
K0
||
code
==
particles
::
Code
::
K0Bar
)
{
code
=
fB
ooleanDist
(
fRNG
)
?
particles
::
Code
::
K0Short
:
particles
::
Code
::
K0Long
;
code
=
b
ooleanDist
_
(
rng_
)
?
particles
::
Code
::
K0Short
:
particles
::
Code
::
K0Long
;
}
// "coor_.p0[i] * 1_GeV" is likely off-shell as UrQMD doesn't preserve masses well
...
...
@@ -346,7 +345,7 @@ corsika::process::EProcessReturn UrQMD::DoInteraction(SetupProjectile& vProjecti
momentum
.
rebase
(
originalCS
);
// transform back into standard lab frame
std
::
cout
<<
i
<<
" "
<<
code
<<
" "
<<
momentum
.
GetComponents
()
<<
std
::
endl
;
vP
rojectile
.
AddSecondary
(
p
rojectile
.
AddSecondary
(
std
::
tuple
<
particles
::
Code
,
HEPEnergyType
,
stack
::
MomentumVector
,
geometry
::
Point
,
TimeType
>
{
code
,
energy
,
momentum
,
projectilePosition
,
projectileTime
});
}
...
...
@@ -452,8 +451,8 @@ void UrQMD::readXSFile(std::string const& filename) {
int
nTargets
,
nProjectiles
,
nSupports
;
ss
>>
dummy
>>
nTargets
>>
nProjectiles
>>
nSupports
;
decltype
(
xs_interp_support_table
)
::
extent_gen
extents
;
xs_interp_support_table
.
resize
(
extents
[
nProjectiles
][
nTargets
][
nSupports
]);
decltype
(
xs_interp_support_table
_
)
::
extent_gen
extents
;
xs_interp_support_table
_
.
resize
(
extents
[
nProjectiles
][
nTargets
][
nSupports
]);
for
(
int
i
=
0
;
i
<
nTargets
;
++
i
)
{
for
(
int
j
=
0
;
j
<
nProjectiles
;
++
j
)
{
...
...
@@ -462,7 +461,7 @@ void UrQMD::readXSFile(std::string const& filename) {
std
::
stringstream
s
(
line
);
double
energy
,
sigma
;
s
>>
energy
>>
sigma
;
xs_interp_support_table
[
j
][
i
][
k
]
=
sigma
*
1
_mb
;
xs_interp_support_table
_
[
j
][
i
][
k
]
=
sigma
*
1
_mb
;
}
std
::
getline
(
file
,
line
);
...
...
This diff is collapsed.
Click to expand it.
Processes/UrQMD/UrQMD.h
+
8
−
8
View file @
d82b8ca0
...
...
@@ -52,14 +52,14 @@ namespace corsika::process::UrQMD {
private
:
void
readXSFile
(
std
::
string
const
&
);
corsika
::
random
::
RNG
&
fRNG
=
corsika
::
random
::
RNG
&
rng_
=
corsika
::
random
::
RNGManager
::
GetInstance
().
GetRandomStream
(
"UrQMD"
);
std
::
uniform_int_distribution
<
int
>
fB
ooleanDist
{
0
,
1
};
boost
::
multi_array
<
corsika
::
units
::
si
::
CrossSectionType
,
3
>
xs_interp_support_table
;
std
::
uniform_int_distribution
<
int
>
b
ooleanDist
_
{
0
,
1
};
boost
::
multi_array
<
corsika
::
units
::
si
::
CrossSectionType
,
3
>
xs_interp_support_table
_
;
};
namespace
constants
{
namespace
details
::
constants
{
// from coms.f
int
constexpr
nmax
=
500
;
...
...
@@ -70,10 +70,10 @@ namespace corsika::process::UrQMD {
// from inputs.f
int
constexpr
aamax
=
300
;
}
// namespace constants
}
// namespace
details::
constants
template
<
typename
T
>
using
nmaxArray
=
std
::
array
<
T
,
constants
::
nmax
>
;
using
nmaxArray
=
std
::
array
<
T
,
details
::
constants
::
nmax
>
;
using
nmaxIntArray
=
nmaxArray
<
int
>
;
using
nmaxDoubleArray
=
nmaxArray
<
double
>
;
...
...
@@ -134,8 +134,8 @@ namespace corsika::process::UrQMD {
// defined in options.f
extern
struct
{
std
::
array
<
double
,
constants
::
numcto
>
CTOption
;
std
::
array
<
double
,
constants
::
numctp
>
CTParam
;
std
::
array
<
double
,
details
::
constants
::
numcto
>
CTOption
;
std
::
array
<
double
,
details
::
constants
::
numctp
>
CTParam
;
}
options_
;
extern
struct
{
...
...
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