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
1817namespace 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
4034void 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