Skip to content

Commit

Permalink
Potentially fix reading DRF from DB.
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohns committed Oct 12, 2023
1 parent c6bfb8c commit 3604f0a
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions InterSpec/DetectorPeakResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ class DetectorPeakResponse
//const uint64_t fixed_geom_bit = 0x80000000;
const uint64_t fixed_geom_bits = 0xF80000000;

int64_t hash, parentHash, flags;
int64_t hash = 0, parentHash = 0, flags = 0;
if( a.getsValue() )
{
hash = reinterpret_cast<int64_t&>(m_hash);
Expand Down Expand Up @@ -974,25 +974,41 @@ class DetectorPeakResponse

//m_fixedGeometry = (m_flags & fixed_geom_bit);
//m_flags &= ~fixed_geom_bit; //clear fixed

const uint64_t geom_flags = ((reinterpret_cast<uint64_t&>(flags) & fixed_geom_bits) >> 31);
const EffGeometryType geom_type = static_cast<EffGeometryType>( geom_flags );
m_flags &= ~fixed_geom_bits; //clear fixed

assert( (geom_type == EffGeometryType::FarField)
|| (geom_type == EffGeometryType::FixedGeomTotalAct)
|| (geom_type == EffGeometryType::FixedGeomActPerCm2)
|| (geom_type == EffGeometryType::FixedGeomActPerM2)
|| (geom_type == EffGeometryType::FixedGeomActPerGram) );
if( !a.isSchema() )
{
assert( (geom_type == EffGeometryType::FarField)
|| (geom_type == EffGeometryType::FixedGeomTotalAct)
|| (geom_type == EffGeometryType::FixedGeomActPerCm2)
|| (geom_type == EffGeometryType::FixedGeomActPerM2)
|| (geom_type == EffGeometryType::FixedGeomActPerGram) );

if( (geom_type != EffGeometryType::FarField)
&& (geom_type != EffGeometryType::FixedGeomTotalAct)
&& (geom_type != EffGeometryType::FixedGeomActPerCm2)
&& (geom_type != EffGeometryType::FixedGeomActPerM2)
&& (geom_type != EffGeometryType::FixedGeomActPerGram) )
{
throw std::runtime_error( "Invalid geometry flags read in DetectorPeakResponse::persist ("
+ std::to_string(static_cast<uint64_t>(geom_type)) + ")" );
}
}//if( !a.isSchema() )

if( (geom_type != EffGeometryType::FarField)
&& (geom_type != EffGeometryType::FixedGeomTotalAct)
&& (geom_type != EffGeometryType::FixedGeomActPerCm2)
&& (geom_type != EffGeometryType::FixedGeomActPerM2)
&& (geom_type != EffGeometryType::FixedGeomActPerGram) )
switch( geom_type )
{
throw std::runtime_error( "Invalid geometry flags read in DetectorPeakResponse::persist" );
}
case EffGeometryType::FarField:
case EffGeometryType::FixedGeomTotalAct:
case EffGeometryType::FixedGeomActPerCm2:
case EffGeometryType::FixedGeomActPerM2:
case EffGeometryType::FixedGeomActPerGram:
m_geomType = geom_type;
break;
}//switch( geom_type )

m_geomType = geom_type;
}//if( a.setsValue() || a.isSchema() )

if( a.getsValue() )
Expand Down

0 comments on commit 3604f0a

Please sign in to comment.