Skip to content

Commit

Permalink
Use double to store energy in hits (#193)
Browse files Browse the repository at this point in the history
* Use double to store energy in RMGGermaniumDetector, RMGScintillatorDetector, RMGOpticalDetector

* prevent this problem from happening again (add compiler warning for this)

* fix compiler warnings in RMGGeneratorCosmicMuons
  • Loading branch information
ManuelHu authored Dec 11, 2024
1 parent 03ee5cd commit 1a1d1c3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
3 changes: 3 additions & 0 deletions cmake/modules/BuildType.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ else()
message(STATUS "Setting build type to '${CMAKE_BUILD_TYPE}'")
endif()

# prevent us assuming double when we actually only have float.
add_compile_options(-Wdouble-promotion)

# build flags for special ASAN build.
set(CMAKE_C_FLAGS_ASAN
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=address,undefined -fno-omit-frame-pointer")
Expand Down
28 changes: 14 additions & 14 deletions include/RMGGeneratorCosmicMuons.hh
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ class RMGGeneratorCosmicMuons : public RMGVGenerator {
void SetSkyShape(std::string shape);

SkyShape fSkyShape = SkyShape::kSphere;
float fSkyPlaneSize = -1;
float fSkyPlaneHeight = 50;

float fSpherePositionThetaMin = 0 * u::deg;
float fSpherePositionThetaMax = 90 * u::deg;
float fSpherePositionPhiMin = 0 * u::deg;
float fSpherePositionPhiMax = 360 * u::deg;

float fMomentumMin = 0 * u::GeV;
float fMomentumMax = 1 * u::TeV;
float fThetaMin = 0 * u::deg;
float fThetaMax = 90 * u::deg;
float fPhiMin = 0 * u::deg;
float fPhiMax = 360 * u::deg;
double fSkyPlaneSize = -1;
double fSkyPlaneHeight = 50;

double fSpherePositionThetaMin = 0 * u::deg;
double fSpherePositionThetaMax = 90 * u::deg;
double fSpherePositionPhiMin = 0 * u::deg;
double fSpherePositionPhiMax = 360 * u::deg;

double fMomentumMin = 0 * u::GeV;
double fMomentumMax = 1 * u::TeV;
double fThetaMin = 0 * u::deg;
double fThetaMax = 90 * u::deg;
double fPhiMin = 0 * u::deg;
double fPhiMax = 360 * u::deg;
};

#endif
Expand Down
2 changes: 1 addition & 1 deletion include/RMGGermaniumDetector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RMGGermaniumDetectorHit : public G4VHit {

int detector_uid = -1;
int particle_type = -1;
float energy_deposition = -1;
double energy_deposition = -1;
G4ThreeVector global_position;
double global_time = -1;
};
Expand Down
2 changes: 1 addition & 1 deletion include/RMGOpticalDetector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RMGOpticalDetectorHit : public G4VHit {

G4TouchableHandle detector_touchable; // for Draw()
int detector_uid = -1;
float photon_wavelength = 0.;
double photon_wavelength = 0.;
double global_time = -1;
};

Expand Down
2 changes: 1 addition & 1 deletion include/RMGScintillatorDetector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RMGScintillatorDetectorHit : public G4VHit {

int detector_uid = -1;
int particle_type = -1;
float energy_deposition = -1;
double energy_deposition = -1;
G4ThreeVector global_position_pre;
G4ThreeVector global_position_post;
double global_time = -1;
Expand Down

0 comments on commit 1a1d1c3

Please sign in to comment.