Skip to content

Commit 7515a2a

Browse files
committed
using new DRAGON2 models as default
1 parent b7cc605 commit 7515a2a

File tree

2 files changed

+20
-35
lines changed

2 files changed

+20
-35
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ endif(APPLE)
5858
# ----------------------------------------------------------------------------
5959
OPTION(DOWNLOAD_DATA "Download HERMES data files" ON)
6060
if(DOWNLOAD_DATA)
61-
message("-- Downloading data file from heat.gssi.it ~ 200 MB")
61+
message("-- Downloading data file from zenodo.org ~ 300 MB")
6262
file(DOWNLOAD
63-
https://zenodo.org/record/7603203/files/hermes-data.tar.gz-CHECKSUM
63+
https://zenodo.org/record/15525185/files/hermes-data.tar.gz-CHECKSUM
6464
${CMAKE_BINARY_DIR}/hermes-data.tar.gz-CHECKSUM)
6565
file(STRINGS ${CMAKE_BINARY_DIR}/hermes-data.tar.gz-CHECKSUM DATA_CHECKSUM LIMIT_COUNT 1 LENGTH_MINIMUM 32 LENGTH_MAXIMUM 32)
6666
file(DOWNLOAD
67-
https://zenodo.org/record/7603203/files/hermes-data.tar.gz
67+
https://zenodo.org/record/15525185/files/hermes-data.tar.gz
6868
${CMAKE_BINARY_DIR}/hermes-data.tar.gz
6969
EXPECTED_MD5 "${DATA_CHECKSUM}")
7070
message("-- Extracting data file")

src/cosmicrays/Dragon2D.cpp

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,17 @@
1212

1313
#include "hermes/Common.h"
1414

15-
#define DEFAULT_CR_FILE \
16-
"CosmicRays/Fornieri20/run2d_gamma_D03,7_delta0,45_vA13.fits.gz"
15+
#define DEFAULT_CR_FILE "CosmicRays/DRAGON2/d2_base_max.fits.gz"
1716

1817
namespace hermes { namespace cosmicrays {
1918

20-
Dragon2D::Dragon2D(const std::string &filename_, const PID &pid_)
21-
: CosmicRayDensity(pid_), filename(filename_) {
19+
Dragon2D::Dragon2D(const std::string &filename_, const PID &pid_) : CosmicRayDensity(pid_), filename(filename_) {
2220
readFile();
2321
}
2422

25-
Dragon2D::Dragon2D(const PID &pid_)
26-
: CosmicRayDensity(pid_), filename(getDataPath(DEFAULT_CR_FILE)) {
27-
readFile();
28-
}
23+
Dragon2D::Dragon2D(const PID &pid_) : CosmicRayDensity(pid_), filename(getDataPath(DEFAULT_CR_FILE)) { readFile(); }
2924

30-
Dragon2D::Dragon2D(const std::vector<PID> &pids_)
31-
: CosmicRayDensity(pids_), filename(getDataPath(DEFAULT_CR_FILE)) {
25+
Dragon2D::Dragon2D(const std::vector<PID> &pids_) : CosmicRayDensity(pids_), filename(getDataPath(DEFAULT_CR_FILE)) {
3226
readFile();
3327
}
3428

@@ -38,6 +32,8 @@ Dragon2D::Dragon2D(const std::string &filename_, const std::vector<PID> &pids_)
3832
}
3933

4034
void Dragon2D::readFile() {
35+
std::cout << "hermes: reading DRAGON2 file " << filename << std::endl;
36+
4137
ffile = std::make_unique<FITSFile>(FITSFile(filename));
4238

4339
ffile->openFile(FITS::READ);
@@ -50,13 +46,11 @@ void Dragon2D::readFile() {
5046
readDensity2D();
5147
}
5248

53-
QPDensityPerEnergy Dragon2D::getDensityPerEnergy(
54-
const QEnergy &E_, const Vector3QLength &pos_) const {
49+
QPDensityPerEnergy Dragon2D::getDensityPerEnergy(const QEnergy &E_, const Vector3QLength &pos_) const {
5550
return getDensityPerEnergy(static_cast<int>(energyIndex.at(E_)), pos_);
5651
}
5752

58-
QPDensityPerEnergy Dragon2D::getDensityPerEnergy(
59-
int iE_, const Vector3QLength &pos_) const {
53+
QPDensityPerEnergy Dragon2D::getDensityPerEnergy(int iE_, const Vector3QLength &pos_) const {
6054
if (pos_.z < zmin || pos_.z > zmax) return QPDensityPerEnergy(0);
6155

6256
QLength rho = sqrt(pos_.x * pos_.x + pos_.y * pos_.y);
@@ -74,8 +68,7 @@ void Dragon2D::readEnergyAxis() {
7468

7569
// input files are in GeV
7670
for (int i = 0; i < dimE; ++i) {
77-
E = 1_GeV * std::exp(std::log(Ekmin) + static_cast<double>(i) *
78-
std::log(energyScaleFactor));
71+
E = 1_GeV * std::exp(std::log(Ekmin) + static_cast<double>(i) * std::log(energyScaleFactor));
7972
energyRange.push_back(E);
8073
energyIndex[E] = i;
8174
}
@@ -95,19 +88,16 @@ void Dragon2D::readSpatialGrid2D() {
9588

9689
// Vector3d origin(-1*rmax.getValue(), -1*rmax.getValue(),
9790
// zmin.getValue());
98-
Vector3d origin(-1 * static_cast<double>(rmax), static_cast<double>(zmin),
99-
0);
100-
Vector3d spacing(static_cast<double>(deltar), static_cast<double>(deltaz),
101-
0);
91+
Vector3d origin(-1 * static_cast<double>(rmax), static_cast<double>(zmin), 0);
92+
Vector3d spacing(static_cast<double>(deltar), static_cast<double>(deltaz), 0);
10293

10394
for (int i = 0; i < dimE; ++i) {
10495
grid.push_back(std::make_unique<ScalarGrid2DQPDensityPerEnergy>(
10596
ScalarGrid2DQPDensityPerEnergy(origin, dimr, dimz, spacing)));
10697
}
10798
}
10899

109-
std::size_t Dragon2D::calcArrayIndex2D(std::size_t iE, std::size_t ir,
110-
std::size_t iz) {
100+
std::size_t Dragon2D::calcArrayIndex2D(std::size_t iE, std::size_t ir, std::size_t iz) {
111101
return (iz * dimr + ir) * dimE + iE;
112102
}
113103

@@ -119,8 +109,7 @@ void Dragon2D::readDensity2D() {
119109

120110
auto vecSize = dimr * dimz;
121111
unsigned long nElements = energyRange.size() * vecSize;
122-
constexpr double fluxToDensity =
123-
static_cast<double>(4_pi / (c_light * 1_GeV));
112+
constexpr double fluxToDensity = static_cast<double>(4_pi / (c_light * 1_GeV));
124113

125114
auto hduNumber = ffile->getNumberOfHDUs();
126115
while (hduActual < hduNumber) {
@@ -138,18 +127,14 @@ void Dragon2D::readDensity2D() {
138127
int A = ffile->readKeyValueAsInt("A");
139128

140129
if (isPIDEnabled(PID(Z, A))) {
141-
std::cerr << "hermes: info: reading species with Z = " << Z
142-
<< " A = " << A << " at HDU = " << hduActual << std::endl;
130+
std::cerr << "hermes: info: reading species with Z = " << Z << " A = " << A << " at HDU = " << hduActual
131+
<< std::endl;
143132

144-
std::vector<float> rawData =
145-
ffile->readImageAsFloat(firstElement, nElements);
133+
std::vector<float> rawData = ffile->readImageAsFloat(firstElement, nElements);
146134
for (std::size_t iE = 0; iE < dimE; ++iE) {
147135
for (std::size_t ir = 0; ir < dimr; ++ir) {
148136
for (std::size_t iz = 0; iz < dimz; ++iz) {
149-
grid[iE]->addValue(
150-
ir, iz,
151-
fluxToDensity *
152-
rawData[calcArrayIndex2D(iE, ir, iz)]);
137+
grid[iE]->addValue(ir, iz, fluxToDensity * rawData[calcArrayIndex2D(iE, ir, iz)]);
153138
}
154139
}
155140
}

0 commit comments

Comments
 (0)