Skip to content

Commit

Permalink
address error
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Oct 3, 2024
1 parent aa10e1b commit c5acba6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/TRestGeant4Metadata.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -983,18 +983,19 @@ Double_t TRestGeant4Metadata::GetCosmicIntensityInCountsPerSecond() const {

Double_t TRestGeant4Metadata::GetEquivalentSimulatedTime() const {
const auto type = ToLower(fGeant4PrimaryGeneratorInfo.GetSpatialGeneratorType());
const auto shape = ToLower(fGeant4PrimaryGeneratorInfo.GetSpatialGeneratorShape());

double scalingFactor = 1.0;
if (type == "cosmic") {
// get the cosmic generator
auto cosmicSource = dynamic_cast<TRestGeant4ParticleSourceCosmics*>(GetParticleSource());
if (cosmicSource == nullptr) {
throw std::runtime_error("Cosmic source not found");
if (cosmicSource != nullptr) {
scalingFactor =
cosmicSource
->GetEnergyRangeScalingFactor(); // number less than 1, to account for energy range
if (scalingFactor < 0 || scalingFactor > 1) {
throw std::runtime_error("Energy range scaling factor must be between 0 and 1");
}
}
scalingFactor =
cosmicSource->GetEnergyRangeScalingFactor(); // number less than 1, to account for energy range
// vs full range of the hist (is 1 if full range)
}

// counts per seconds should be reduced proportionally to the range we are sampling
Expand Down

0 comments on commit c5acba6

Please sign in to comment.