Skip to content

Commit 189921d

Browse files
committed
Improve exporting user-labeled ROIs to IAEA SPE files.
Previously only peaks that had a nuclide/xray/reaction assigned would make it into the SPE. Now user-labeled ROIs will make it in, even if they don't have a nuclide/xray/reaction.
1 parent 0f96ff3 commit 189921d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/SpecMeas.cpp

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -989,14 +989,28 @@ bool SpecMeas::write_iaea_spe( std::ostream &output,
989989

990990
if( peak.userLabel().size() || peak.gammaParticleEnergy() > 0.0f )
991991
{
992-
//channel should actually be a float (well, thats what Peak Easy uses),
993-
// but for current ease of implementation will just truncate
994-
size_t channel = 0;
992+
// The channel should be a floating point number
993+
double channel = 0.0;
994+
const shared_ptr<const SpecUtils::EnergyCalibration> energycal = summed->energy_calibration();
995995
try
996996
{
997-
channel = summed->find_gamma_channel( peak.gammaParticleEnergy() );
997+
if( energycal && (energycal->type() != SpecUtils::EnergyCalType::InvalidEquationType) )
998+
{
999+
try
1000+
{
1001+
if( peak.xrayElement() || peak.nuclearTransition() || peak.reaction() )
1002+
channel = energycal->channel_for_energy( peak.gammaParticleEnergy() );
1003+
else
1004+
channel = energycal->channel_for_energy( peak.mean() );
1005+
}catch(...)
1006+
{
1007+
channel = energycal->channel_for_energy( peak.mean() );
1008+
}
1009+
}//if( we have energy calibration info - which we should )
9981010
}catch(...)
9991011
{
1012+
// We probably shouldnt really get to here unless the peak is outside of reasonable range
1013+
// of the energy calibration
10001014
continue;
10011015
}
10021016

0 commit comments

Comments
 (0)