From 2d1b56805da7e365de0fd5ccb36cd566fde6e0ef Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 13 Jul 2026 21:06:37 +0000 Subject: [PATCH 1/8] refactor(sysrap): remove obsolete SDigestNP Remove the duplicate NP item-digest wrapper and its standalone test.\n\nUse the existing sdigest::Item implementation as the sole item-digest path and clean up stale build entries and references. --- sysrap/CMakeLists.txt | 2 -- sysrap/SBnd.h | 5 ++--- sysrap/SDigestNP.cc | 14 ------------ sysrap/SDigestNP.hh | 21 ------------------ sysrap/SSim.cc | 1 - sysrap/tests/CMakeLists.txt | 1 - sysrap/tests/SDigestNPTest.cc | 41 ----------------------------------- 7 files changed, 2 insertions(+), 83 deletions(-) delete mode 100644 sysrap/SDigestNP.cc delete mode 100644 sysrap/SDigestNP.hh delete mode 100644 sysrap/tests/SDigestNPTest.cc diff --git a/sysrap/CMakeLists.txt b/sysrap/CMakeLists.txt index 5c019c2db2..68be274aef 100644 --- a/sysrap/CMakeLists.txt +++ b/sysrap/CMakeLists.txt @@ -30,7 +30,6 @@ set(SOURCES SMap.cc SCount.cc SDigest.cc - SDigestNP.cc SDirect.cc SArrayDigest.cc @@ -196,7 +195,6 @@ set(HEADERS - SDigestNP.hh SDirect.hh sdirect.h SArrayDigest.hh diff --git a/sysrap/SBnd.h b/sysrap/SBnd.h index c4dbb4e56e..6d42b0d424 100644 --- a/sysrap/SBnd.h +++ b/sysrap/SBnd.h @@ -123,7 +123,7 @@ inline SBnd::SBnd(const NP* bnd_) inline std::string SBnd::getItemDigest( int i, int j, int w ) const { - return sdigest::Item(bnd, i, j, w ); // formerly SSim::GetItemDigest + return sdigest::Item(bnd, i, j, w ); } inline std::string SBnd::descBoundary() const { @@ -354,7 +354,7 @@ inline std::string SBnd::DescDigest(const NP* bnd, int w ) // static ss << std::setw(3) << i << " " ; for(int j=0 ; j < nj ; j++) { - std::string dig = sdigest::Item(bnd, i, j ) ; // formerly SDigestNP::Item + std::string dig = sdigest::Item(bnd, i, j ); std::string sdig = dig.substr(0, w); ss << std::setw(w) << sdig << " " ; } @@ -732,4 +732,3 @@ inline NP* SBnd::reconstruct_sur() const { return nullptr ; } - diff --git a/sysrap/SDigestNP.cc b/sysrap/SDigestNP.cc deleted file mode 100644 index 1cfc8e90c2..0000000000 --- a/sysrap/SDigestNP.cc +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include "NP.hh" -#include "SDigest.hh" -#include "SDigestNP.hh" - -std::string SDigestNP::Item( const NP* a, int i, int j, int k, int l, int m, int o ) // static -{ - const char* start = nullptr ; - NP::INT num_bytes = 0 ; - a->itembytes_(&start, num_bytes, i, j, k, l, m, o ); - assert( start && num_bytes > 0 ); - return SDigest::Buffer( start, num_bytes ); -} - diff --git a/sysrap/SDigestNP.hh b/sysrap/SDigestNP.hh deleted file mode 100644 index f7ec92a291..0000000000 --- a/sysrap/SDigestNP.hh +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -/** -SDigestNP.hh -============== - -TODO: explore relocating this and SDigest functionality into NP.hh - -**/ - -struct NP ; - -#include -#include "SYSRAP_API_EXPORT.hh" - -struct SYSRAP_API SDigestNP -{ - static std::string Item( const NP* a, int i=-1, int j=-1, int k=-1, int l=-1, int m=-1, int o=-1 ); -}; - - - diff --git a/sysrap/SSim.cc b/sysrap/SSim.cc index 9ae5599a15..e45d697b02 100644 --- a/sysrap/SSim.cc +++ b/sysrap/SSim.cc @@ -1026,7 +1026,6 @@ std::string SSim::DescOptical(const NP* optical, const NP* bnd ) std::string SSim::GetItemDigest( const NP* bnd, int i, int j, int w ) { - //std::string dig = SDigestNP::Item(bnd, i, j ) ; std::string dig = sdigest::Item(bnd, i, j ) ; std::string sdig = dig.substr(0, w); return sdig ; diff --git a/sysrap/tests/CMakeLists.txt b/sysrap/tests/CMakeLists.txt index 6c4ae88c50..1a20ae66f5 100644 --- a/sysrap/tests/CMakeLists.txt +++ b/sysrap/tests/CMakeLists.txt @@ -23,7 +23,6 @@ set(TEST_SOURCES SSortKVTest.cc SPairVecTest.cc SDigestTest.cc - SDigestNPTest.cc SCFTest.cc diff --git a/sysrap/tests/SDigestNPTest.cc b/sysrap/tests/SDigestNPTest.cc deleted file mode 100644 index b798d6e84a..0000000000 --- a/sysrap/tests/SDigestNPTest.cc +++ /dev/null @@ -1,41 +0,0 @@ -#include "OPTICKS_LOG.hh" -#include "NP.hh" -#include "SDigest.hh" -#include "SDigestNP.hh" - -int main(int argc, char** argv) -{ - OPTICKS_LOG(argc, argv); - - const char* h = "hello" ; - std::string xdig = SDigest::Buffer( h, 5 ); - - std::cout - << " i " << std::setw(4) << -1 - << " xdig " << xdig - << std::endl - ; - - - NP* a = NP::Make(3,5) ; - char* aa = a->values(); - memcpy( aa+0 , h, 5 ); - memcpy( aa+5 , h, 5 ); - memcpy( aa+10 , h, 5 ); - - for(int i=0 ; i < a->shape[0] ; i++) - { - std::string dig = SDigestNP::Item( a, i ); - std::cout - << " i " << std::setw(4) << i - << " dig " << dig - << std::endl - ; - - assert( strcmp( dig.c_str(), xdig.c_str() ) == 0 ); - } - - return 0 ; -} - - From 07b411e167d14f598fcddf08e19fedb85f11702e Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 13 Jul 2026 21:07:33 +0000 Subject: [PATCH 2/8] refactor(sysrap): remove obsolete SProfile Remove the unused template profiling helper and its unregistered example test.\n\nSProf remains the supported profiling implementation. --- sysrap/CMakeLists.txt | 1 - sysrap/SProfile.h | 79 ----------------------------------- sysrap/tests/SProfile_test.cc | 47 --------------------- sysrap/tests/SProfile_test.h | 11 ----- 4 files changed, 138 deletions(-) delete mode 100644 sysrap/SProfile.h delete mode 100644 sysrap/tests/SProfile_test.cc delete mode 100644 sysrap/tests/SProfile_test.h diff --git a/sysrap/CMakeLists.txt b/sysrap/CMakeLists.txt index 68be274aef..bbbbfc8a18 100644 --- a/sysrap/CMakeLists.txt +++ b/sysrap/CMakeLists.txt @@ -119,7 +119,6 @@ set(HEADERS SBacktrace.h SStackFrame.h - SProfile.h ssys.h SSys.hh diff --git a/sysrap/SProfile.h b/sysrap/SProfile.h deleted file mode 100644 index 1ef8ea4ec0..0000000000 --- a/sysrap/SProfile.h +++ /dev/null @@ -1,79 +0,0 @@ -#pragma once -/** -SProfile.h -=========== - -NOW RECOMMEND TO USE THE MORE GENERAL SProf.hh SProf.cc APPROACH RATHER THAN THIS - -For example used to collect timestamps from junoSD_PMT_v2::ProcessHits -for persisting into .npy files for analysis, using NPX.h functionality - - -The static fixing of template parameter N is inconvenient when -needing to change the N. But trying to do that dynamically for example -with placement new would get complicated and would need in anycase -an oversized buffer. Hence, just be pragmatic and fix N larger -than typically needed (eg 16) so will then not have to change it very often. - -See tests/SProfile_test.cc for example of use. -In summary:: - - // in header, forward decl - template struct SProfile ; - - // member - SProfile<16>* m_profile ; - - - - // in impl - #include "SProfile.h" - template<> - std::vector> SProfile<16>::RECORD = {} ; - - // instanciate m_profile in ctor - m_profile(new SProfile<16>), - - // at appropriate juncture - - m_profile->zero(); - - m_profile->stamp(0); - m_profile->stamp(1); - m_profile->stamp(2); - .. - - m_profile->add(); - - - -**/ - -#include -#include -#include -#include "NPX.h" - -template -struct SProfile -{ - uint64_t idx ; - uint64_t t[N] ; - - static std::vector> RECORD ; - void add(){ RECORD.push_back(*this) ; } - - static uint64_t Now() - { - std::chrono::time_point t0 = std::chrono::system_clock::now(); - return std::chrono::duration_cast(t0.time_since_epoch()).count() ; - } - void zero(){ idx = 0 ; for(int i=0 ; i < N ; i++) t[i] = 0 ; } - void stamp(int i){ t[i] = Now(); } - - static constexpr const char* NAME = "SProfile.npy" ; - static NP* Array(){ return NPX::ArrayFromVec>(RECORD,1+N); } - static void Save(const char* dir, const char* reldir=nullptr){ NP* a = Array(); a->save(dir, reldir, NAME) ; } - static void Clear(){ RECORD.clear() ; } -}; - diff --git a/sysrap/tests/SProfile_test.cc b/sysrap/tests/SProfile_test.cc deleted file mode 100644 index a2d7825e6b..0000000000 --- a/sysrap/tests/SProfile_test.cc +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include - -#include "SProfile_test.h" -#include "SProfile.h" - -template<> -std::vector> SProfile<4>::RECORD = {} ; - - -SProfile_test::SProfile_test() - : - d(std::atoi(getenv("DELAY"))), - prof(new SProfile<4>) -{ - std::chrono::microseconds delay(d); - - for(int i=0 ; i < 10 ; i++) // eg over events - { - for(int j=0 ; j < 100 ; j++) //eg over photons on the event - { - *prof = {} ; - prof->idx = i*100+j ; - - for(int k=0 ; k < 4 ; k++) //eg over a few code sites to monitor - { - prof->stamp(k) ; - std::this_thread::sleep_for(delay); - } - prof->add(); - } - std::string reldir = std::to_string(i) ; - SProfile<4>::Save("$FOLD", reldir.c_str() ); - SProfile<4>::Clear(); - } - -} - - - -int main() -{ - SProfile_test spt ; - return 0 ; -} - - diff --git a/sysrap/tests/SProfile_test.h b/sysrap/tests/SProfile_test.h deleted file mode 100644 index 30a0b7b48f..0000000000 --- a/sysrap/tests/SProfile_test.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -template struct SProfile ; - -struct SProfile_test -{ - int d ; - SProfile<4>* prof ; - - SProfile_test(); -}; From 99c72a9163f810e1747dab02537b4c0c38f3ab12 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 13 Jul 2026 21:11:06 +0000 Subject: [PATCH 3/8] refactor(sysrap): remove obsolete SLabelCache Remove the unused pointer-to-label cache, its explicit instantiation, and its standalone test.\n\nNo production callers remain. --- sysrap/CMakeLists.txt | 4 -- sysrap/SLabelCache.cc | 4 -- sysrap/SLabelCache.hh | 56 --------------------------- sysrap/tests/CMakeLists.txt | 2 - sysrap/tests/SLabelCacheTest.cc | 68 --------------------------------- 5 files changed, 134 deletions(-) delete mode 100644 sysrap/SLabelCache.cc delete mode 100644 sysrap/SLabelCache.hh delete mode 100644 sysrap/tests/SLabelCacheTest.cc diff --git a/sysrap/CMakeLists.txt b/sysrap/CMakeLists.txt index bbbbfc8a18..b657dc741d 100644 --- a/sysrap/CMakeLists.txt +++ b/sysrap/CMakeLists.txt @@ -56,8 +56,6 @@ set(SOURCES CheckGeo.cc - SLabelCache.cc - SMath.cc snd.cc @@ -235,8 +233,6 @@ set(HEADERS SRand.hh CheckGeo.hh - SLabelCache.hh - SRng.hh SName.h diff --git a/sysrap/SLabelCache.cc b/sysrap/SLabelCache.cc deleted file mode 100644 index 5291a47b45..0000000000 --- a/sysrap/SLabelCache.cc +++ /dev/null @@ -1,4 +0,0 @@ -#include "SLabelCache.hh" - -template struct SLabelCache ; - diff --git a/sysrap/SLabelCache.hh b/sysrap/SLabelCache.hh deleted file mode 100644 index f6d8a97530..0000000000 --- a/sysrap/SLabelCache.hh +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -/** -SLabelCache.hh -=============== - -Used from X4::MakeSurfaceIndexCache to -create cache of surface void* pointers and -an integer index. - -**/ - -#include "SYSRAP_API_EXPORT.hh" -#include - -template -struct SYSRAP_API SLabelCache -{ - typedef std::unordered_map MVT ; - - T missing ; - MVT cache ; - - SLabelCache( T missing ); - - void add(const void* obj, T label); - T find(const void* obj) ; -}; - - -template -SLabelCache::SLabelCache(T missing_) : missing(missing_) {} - -template -inline void SLabelCache::add(const void* obj, T label) -{ - cache[obj] = label ; -} - -/** -SLabelCache::find -------------------- - -Returns the label associated with the obj by SLabelCache::add - -**/ - -template -inline T SLabelCache::find(const void* obj) -{ - typename MVT::const_iterator en = cache.end(); - typename MVT::const_iterator it = cache.find( obj ); - return it == en ? missing : it->second ; -} - - diff --git a/sysrap/tests/CMakeLists.txt b/sysrap/tests/CMakeLists.txt index 1a20ae66f5..e0e3e9af13 100644 --- a/sysrap/tests/CMakeLists.txt +++ b/sysrap/tests/CMakeLists.txt @@ -69,8 +69,6 @@ set(TEST_SOURCES SGLMTest.cc SConstantTest.cc - SLabelCacheTest.cc - CastTest.cc SRngTest.cc diff --git a/sysrap/tests/SLabelCacheTest.cc b/sysrap/tests/SLabelCacheTest.cc deleted file mode 100644 index 4aea309f05..0000000000 --- a/sysrap/tests/SLabelCacheTest.cc +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include "OPTICKS_LOG.hh" -#include "SLabelCache.hh" - -struct Surf -{ - const char* name ; - int index ; - Surf(const char* name_, int index_) : name(strdup(name_)), index(index_) {} -}; - -struct Turf -{ - const char* name ; - int index ; - Turf(const char* name_, int index_) : name(strdup(name_)), index(index_) {} -}; - - -inline std::ostream& operator<<(std::ostream& os, const Surf& s){ os << "Surf " << s.index << " " << s.name ; return os; } -inline std::ostream& operator<<(std::ostream& os, const Turf& s){ os << "Turf " << s.index << " " << s.name ; return os; } - - -int main(int argc, char** argv) -{ - OPTICKS_LOG(argc, argv); - LOG(info) ; - - - Surf* r = new Surf("red", 100); - Surf* g = new Surf("green", 200); - Surf* b = new Surf("blue", 300); - - Turf* c = new Turf("cyan", 1000); - Turf* m = new Turf("magenta", 2000); - Turf* y = new Turf("yellow", 3000); - Turf* k = new Turf("black", 4000); - - std::vector oo = {r,g,b,c,m,y,k} ; - - // hmm after mixing up the types need to have external info on which is which - for(unsigned i=0 ; i < 3 ; i++) std::cout << *(Surf*)oo[i] << std::endl ; - for(unsigned i=3 ; i < oo.size() ; i++) std::cout << *(Turf*)oo[i] << std::endl ; - - - SLabelCache cache(-1); - - for(unsigned i=0 ; i < oo.size() ; i++) - { - const void* o = oo[i] ; - cache.add(o, int(i)); - int idx = cache.find(o); - bool idx_expect = idx == int(i) ; - assert( idx_expect ); - if(!idx_expect) std::raise(SIGINT); - } - - const void* anon = (const void*)m ; - int idx_m = cache.find(anon) ; - bool idx_m_expect = idx_m == 4 ; - assert( idx_m_expect ); - if(!idx_m_expect) std::raise(SIGINT); - - return 0 ; -} - - From 588d90b37ffca703cb3a0cf52508daec6284bef4 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 13 Jul 2026 21:12:57 +0000 Subject: [PATCH 4/8] refactor(sysrap): remove obsolete SPack Remove the unused byte-packing utility and its standalone test.\n\nNo production callers remain. --- sysrap/CMakeLists.txt | 2 - sysrap/SPack.cc | 303 ------------------------ sysrap/SPack.hh | 80 ------- sysrap/tests/CMakeLists.txt | 1 - sysrap/tests/SPackTest.cc | 449 ------------------------------------ 5 files changed, 835 deletions(-) delete mode 100644 sysrap/SPack.cc delete mode 100644 sysrap/SPack.hh delete mode 100644 sysrap/tests/SPackTest.cc diff --git a/sysrap/CMakeLists.txt b/sysrap/CMakeLists.txt index b657dc741d..b6878787a2 100644 --- a/sysrap/CMakeLists.txt +++ b/sysrap/CMakeLists.txt @@ -49,7 +49,6 @@ set(SOURCES SGDML.cc S_get_option.cc STime.cc - SPack.cc SBit.cc SEnabled.cc SRand.cc @@ -226,7 +225,6 @@ set(HEADERS SColor.hh SId.hh SGDML.hh - SPack.hh SBit.hh SBitSet.h SEnabled.hh diff --git a/sysrap/SPack.cc b/sysrap/SPack.cc deleted file mode 100644 index 0b404363fa..0000000000 --- a/sysrap/SPack.cc +++ /dev/null @@ -1,303 +0,0 @@ -#include -#include "SPack.hh" - -struct C4 -{ - unsigned char x, y, z, w ; -}; - -struct u2 -{ - unsigned x, y ; -}; - -union ucccc_t -{ - unsigned int u ; - C4 c4 ; -}; - -bool SPack::IsLittleEndian() -{ - int n = 1; - return (*(char *)&n == 1) ; -} - - -unsigned SPack::Encode(unsigned x, unsigned y, unsigned z, unsigned w) // static -{ - assert( x <= 0xff ); - assert( y <= 0xff ); - assert( z <= 0xff ); - assert( w <= 0xff ); - - unsigned char xc = x ; - unsigned char yc = y ; - unsigned char zc = z ; - unsigned char wc = w ; - - return SPack::Encode(xc, yc, zc, wc); -} - - -unsigned SPack::Encode(unsigned char x, unsigned char y, unsigned char z, unsigned char w) // static -{ - assert( sizeof(unsigned char) == 1); - assert( sizeof(unsigned int) == 4); - - ucccc_t uc ; - uc.c4.x = x ; - uc.c4.y = y ; - uc.c4.z = z ; - uc.c4.w = w ; - - unsigned int value = uc.u ; - return value ; -} -unsigned SPack::Encode(const unsigned char* ptr, const unsigned num) // static -{ - assert( num == 4 ); - unsigned char x = *(ptr+0) ; - unsigned char y = *(ptr+1) ; - unsigned char z = *(ptr+2) ; - unsigned char w = *(ptr+3) ; - return SPack::Encode( x, y, z, w ); -} - - -unsigned SPack::Encode13(unsigned char c, unsigned int ccc) // static -{ - assert( (ccc & (0xff << 24)) == 0 ); - unsigned int value = ccc | ( c << 24 ) ; - return value ; -} - -void SPack::Decode13( const unsigned int value, unsigned char& c, unsigned int& ccc ) // static -{ - c = ( value >> 24 ) & 0xff ; - ccc = value & 0xffffff ; -} - - - - - - - - -unsigned SPack::Encode22(unsigned a, unsigned b) // static -{ - assert( sizeof(unsigned) == 4 ); - assert( (a & 0xffff0000) == 0 ); - assert( (b & 0xffff0000) == 0 ); - unsigned packed = ( a << 16 ) | ( b << 0 ) ; - return packed ; -} -void SPack::Decode22( const unsigned packed, unsigned& hi, unsigned& lo ) // static -{ - assert( sizeof(unsigned) == 4 ); - hi = ( packed & 0xffff0000 ) >> 16 ; - lo = ( packed & 0x0000ffff ) >> 0 ; -} - -unsigned SPack::Decode22a( const unsigned packed ) // static -{ - return ( packed & 0xffff0000 ) >> 16 ; -} -unsigned SPack::Decode22b( const unsigned packed ) // static -{ - return ( packed & 0x0000ffff ) >> 0 ; -} - -/** -SPack::Decode22hilo SPack::Decode22hi SPack::Decode22lo ------------------------------------------------------------ - -Signed variants of SPack::Decode22 SPack::Decode22a and SPack::Decode22b - -**/ - -unsigned SPack::Encode22hilo( int a, int b ) -{ - assert( a >= -0x8000 && a <= 0x7fff ); // 16 bit signed range 0x8000 - 0x10000 = -0x8000 - assert( b >= -0x8000 && b <= 0x7fff ); - unsigned packed = (( a & 0x0000ffff ) << 16 ) | (( b & 0x0000ffff ) << 0 ) ; - return packed ; -} - -void SPack::Decode22hilo( const unsigned packed, int& a, int& b ) // static -{ - unsigned hi = ( packed & 0xffff0000 ) >> 16 ; - unsigned lo = ( packed & 0x0000ffff ) >> 0 ; - - a = hi <= 0x7fff ? hi : hi - 0x10000 ; // 16-bit twos complement - b = lo <= 0x7fff ? lo : lo - 0x10000 ; -} - -int SPack::Decode22hi( const unsigned packed ) // static -{ - unsigned hi = ( packed & 0xffff0000 ) >> 16 ; - return hi <= 0x7fff ? hi : hi - 0x10000 ; // 16-bit twos complement -} -int SPack::Decode22lo( const unsigned packed ) // static -{ - unsigned lo = ( packed & 0x0000ffff ) >> 0 ; - return lo <= 0x7fff ? lo : lo - 0x10000 ; // 16-bit twos complement -} - - - - -void SPack::Decode( const unsigned int value, unsigned& x, unsigned& y, unsigned& z, unsigned& w ) // static -{ - unsigned char ucx ; - unsigned char ucy ; - unsigned char ucz ; - unsigned char ucw ; - - Decode(value, ucx, ucy, ucz, ucw ); - - x = ucx ; - y = ucy ; - z = ucz ; - w = ucw ; -} - - -void SPack::Decode( const unsigned int value, unsigned char& x, unsigned char& y, unsigned char& z, unsigned char& w ) // static -{ - assert( sizeof(unsigned char) == 1); - assert( sizeof(unsigned int) == 4); - - ucccc_t uc ; - uc.u = value ; - x = uc.c4.x ; - y = uc.c4.y ; - z = uc.c4.z ; - w = uc.c4.w ; -} - -void SPack::Decode( const unsigned int value, unsigned char* ptr, const unsigned num ) // static -{ - assert( num == 4); - assert( sizeof(unsigned char) == 1); - assert( sizeof(unsigned int) == 4); - - ucccc_t uc ; - uc.u = value ; - - *(ptr + 0) = uc.c4.x ; - *(ptr + 1) = uc.c4.y ; - *(ptr + 2) = uc.c4.z ; - *(ptr + 3) = uc.c4.w ; -} - - - -float SPack::int_as_float(const int i) -{ - uif_t uif ; - uif.i = i ; - return uif.f ; -} -int SPack::int_from_float(const float f) -{ - uif_t uif ; - uif.f = f ; - return uif.i ; -} -float SPack::uint_as_float(const unsigned i) -{ - uif_t uif ; - uif.i = i ; - return uif.f ; -} -unsigned SPack::uint_from_float(const float f) -{ - uif_t uif ; - uif.f = f ; - return uif.u ; -} - - -float SPack::unsigned_as_float( const unsigned u ) -{ - union { unsigned u; int i; float f; } uif ; - uif.u = u ; - return uif.f ; -} - -double SPack::unsigned_as_double( const unsigned x, const unsigned y ) -{ - union { u2 uu ; double d ; } uud ; - uud.uu.x = x ; - uud.uu.y = y ; - return uud.d ; -} - -void SPack::double_as_unsigned(unsigned& x, unsigned& y, const double d ) -{ - union { u2 uu ; double d ; } uud ; - uud.d = d ; - x = uud.uu.x ; - y = uud.uu.y ; -} - - - - -unsigned SPack::float_as_unsigned( const float f ) -{ - union { unsigned u; int i; float f; } uif ; - uif.f = f ; - return uif.u ; -} - - - - - - -/** -SPack::unsigned_as_int ------------------------ - -The bits of unsigned integers can hold the bits of a signed int without problem -(within the signed range), thus can reinterpret those bits as a signed integer -using twos-complement. Notice how the number of bits is relevant to the bit field -representation of negative integers in a way that is not the case for positive ones. - -**/ - -template -int SPack::unsigned_as_int(unsigned value) // static -{ - unsigned twos_complement_sum = 0x1 << NUM_BITS ; - unsigned signed_max = (0x1 << (NUM_BITS-1)) - 1 ; - int ivalue = value <= signed_max ? value : value - twos_complement_sum ; - return ivalue ; -} - - - -template int SPack::unsigned_as_int<8>(unsigned value) ; -template int SPack::unsigned_as_int<16>(unsigned value) ; - - -int SPack::unsigned_as_int_32(unsigned value) -{ - uif_t uif ; - uif.u = value ; - return uif.i ; -} -int SPack::unsigned_as_int_16(unsigned value) -{ - ui16_t ui ; - ui.u = value ; - return ui.i ; -} - - - - - diff --git a/sysrap/SPack.hh b/sysrap/SPack.hh deleted file mode 100644 index 50bc0d0e2e..0000000000 --- a/sysrap/SPack.hh +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once - -/** -SPack -====== - -Static packing/unpacking utilities. - - -**/ - - -#include -#include - -#include "SYSRAP_API_EXPORT.hh" - -class SYSRAP_API SPack { - public: - union uif_t { - unsigned u ; - int i ; - float f ; - }; - - union ui16_t { - uint16_t u ; - int16_t i ; - }; - - - public: - static bool IsLittleEndian(); - static unsigned Encode(unsigned x, unsigned y, unsigned z, unsigned w); // values must fit into unsigned char, ie up to 0xff - static void Decode( const unsigned int value, unsigned& x, unsigned& y, unsigned& z, unsigned& w ); - - static unsigned Encode(unsigned char x, unsigned char y, unsigned char z, unsigned char w); - static unsigned Encode(const unsigned char* ptr, const unsigned num); - - static void Decode( const unsigned value, unsigned char& x, unsigned char& y, unsigned char& z, unsigned char& w ); - static void Decode( const unsigned value, unsigned char* ptr, const unsigned num); - - public: - static unsigned Encode13(unsigned char c, unsigned int ccc); - static void Decode13( const unsigned int value, unsigned char& c, unsigned int& ccc ); - - public: - static unsigned Encode22(unsigned a, unsigned b); - static void Decode22( const unsigned value, unsigned& a, unsigned& b); - static unsigned Decode22a( const unsigned value ); - static unsigned Decode22b( const unsigned value ); - public: - static unsigned Encode22hilo( int a, int b ); - static void Decode22hilo( const unsigned packed, int& a, int& b ); - static int Decode22hi( const unsigned packed ); - static int Decode22lo( const unsigned packed ); - public: - static float int_as_float( const int i ); - static int int_from_float( const float f ); - static float uint_as_float( const unsigned f ); - static unsigned uint_from_float( const float f ); - - static float unsigned_as_float( const unsigned u ) ; - static unsigned float_as_unsigned( const float f ) ; - - - template - static int unsigned_as_int(unsigned value); - - static int unsigned_as_int_32(unsigned value); - static int unsigned_as_int_16(unsigned value); - - static double unsigned_as_double( const unsigned x, const unsigned y ) ; - static void double_as_unsigned(unsigned& x, unsigned& y, const double d ) ; - - - -}; - - diff --git a/sysrap/tests/CMakeLists.txt b/sysrap/tests/CMakeLists.txt index e0e3e9af13..190b220b08 100644 --- a/sysrap/tests/CMakeLists.txt +++ b/sysrap/tests/CMakeLists.txt @@ -58,7 +58,6 @@ set(TEST_SOURCES SSetTest.cc STimeTest.cc SColorTest.cc - SPackTest.cc SBitTest.cc SBitSetTest.cc SEnabledTest.cc diff --git a/sysrap/tests/SPackTest.cc b/sysrap/tests/SPackTest.cc deleted file mode 100644 index ceb5a0c36b..0000000000 --- a/sysrap/tests/SPackTest.cc +++ /dev/null @@ -1,449 +0,0 @@ -// om-;TEST=SPackTest om-t - -#include -#include -#include -#include -#include "SPack.hh" -#include "OPTICKS_LOG.hh" - -void test_Encode_Decode_unsigned() -{ - unsigned x = 0x00 ; - unsigned y = 0xaa ; - unsigned z = 0xbb ; - unsigned w = 0xff ; - - unsigned value_expect = 0xffbbaa00 ; - unsigned value = SPack::Encode(x,y,z,w); - - LOG(info) - << " value " << std::hex << value - << " value_expect " << std::hex << value_expect - ; - - assert( value == value_expect ); - - unsigned x_ ; - unsigned y_ ; - unsigned z_ ; - unsigned w_ ; - - SPack::Decode( value, x_, y_, z_, w_ ); - - assert( x == x_ ); - assert( y == y_ ); - assert( z == z_ ); - assert( w == w_ ); -} - - -void test_Encode() -{ - unsigned char nu = 10 ; - unsigned char nv = 10 ; - unsigned char nw = 4 ; - - unsigned char u = nu - 1 ; - unsigned char v = nv - 1 ; - unsigned char w = nw - 1 ; - - unsigned int packed = SPack::Encode(u,v,w,0); - LOG(info) - << " u " << u - << " v " << v - << " w " << w - << " packed " << packed - ; - -} - - -void test_Encode_Decode() -{ - unsigned char x = 1 ; - unsigned char y = 128 ; - unsigned char z = 255 ; - unsigned char w = 128 ; - - unsigned int value = SPack::Encode(x,y,z,w); - LOG(info) << " value " << value ; - - unsigned char x2, y2, z2, w2 ; - SPack::Decode( value, x2, y2, z2, w2 ); - - assert( x == x2 ); - assert( y == y2 ); - assert( z == z2 ); - assert( w == w2 ); -} - - -void test_Encode_Decode_ptr() -{ - unsigned char a[4] ; - a[0] = 1 ; - a[1] = 128 ; - a[2] = 255 ; - a[3] = 128 ; - - unsigned int value = SPack::Encode(a, 4); - LOG(info) << " value " << value ; - - unsigned char b[4] ; - SPack::Decode( value, b, 4 ); - - assert( a[0] == b[0] ); - assert( a[1] == b[1] ); - assert( a[2] == b[2] ); - assert( a[3] == b[3] ); -} - - -void test_Encode13_Decode13() -{ - LOG(info); - - unsigned char c = 0xff ; - unsigned int ccc = 0xffffff ; - unsigned expect = 0xffffffff ; - - unsigned value = SPack::Encode13( c, ccc ); - bool value_expect = value == expect ; - assert( value_expect ); - if(!value_expect) std::raise(SIGINT); - - unsigned char c2 ; - unsigned int ccc2 ; - SPack::Decode13( value, c2, ccc2 ); - assert( c == c2 ); - assert( ccc == ccc2 ); -} - - -void test_Encode22_Decode22() -{ - LOG(info); - - unsigned a0 = 0xdead ; - unsigned b0 = 0xbeef ; - unsigned expect = 0xdeadbeef ; - - unsigned value = SPack::Encode22( a0, b0 ); - bool value_expect = value == expect ; - assert( value_expect ); - if(!value_expect) std::raise(SIGINT); - - - unsigned a1 ; - unsigned b1 ; - SPack::Decode22( value, a1, b1 ); - - bool decode22_expect = a0 == a1 && b0 == b1 ; - assert( decode22_expect ); - if(!decode22_expect) std::raise(SIGINT); - - unsigned a2 = SPack::Decode22a( value ); - unsigned b2 = SPack::Decode22b( value ); - - bool decode22a_expect = a0 == a2 && b0 == b2 ; - assert( decode22a_expect ); - if(!decode22a_expect) std::raise(SIGINT); - - - -} - - -void test_Encode22hilo_Decode22hilo(int a0, int b0, bool dump) -{ - unsigned packed = SPack::Encode22hilo( a0, b0 ); - - int a1 ; - int b1 ; - SPack::Decode22hilo(packed, a1, b1 ); - - int a2 = SPack::Decode22hi(packed); - int b2 = SPack::Decode22lo(packed); - - if(dump) - { - std::cout - << std::hex - << " pk " << std::setw(8) << packed - << " " - << " a0 " << std::setw(8) << a0 - << " a1 " << std::setw(8) << a1 - << " a2 " << std::setw(8) << a2 - << " " - << " b0 " << std::setw(8) << b0 - << " b1 " << std::setw(8) << b1 - << " b2 " << std::setw(8) << b2 - << std::endl - ; - } - - assert( a0 == a1 ); - assert( b0 == b1 ); - assert( a0 == a2 ); - assert( b0 == b2 ); -} - -void test_Encode22hilo_Decode22hilo() -{ - LOG(info); - int i0 = -0x8000 ; - int i1 = 0x7fff ; - int s = 10 ; - bool dump = false ; - - for(int i=i0 ; i <= i1 ; i+=s ) for(int j=i0 ; j <= i1 ; j+=s ) test_Encode22hilo_Decode22hilo(i,j,dump); - - typedef std::vector> VII ; - VII hilo = { - { 0x0000, -0x0000}, - { 0x0001, -0x0001}, - { 0x0002, -0x0002}, - { 0x0003, -0x0003}, - { 0x0004, -0x0004}, - { 0x0005, -0x0005}, - { 0x0006, -0x0006}, - { 0x0007, -0x0007}, - { 0x0008, -0x0008}, - }; - - for(VII::const_iterator it=hilo.begin() ; it != hilo.end() ; it++) - test_Encode22hilo_Decode22hilo( it->first, it->second, true); - - for(VII::const_iterator it=hilo.begin() ; it != hilo.end() ; it++) - test_Encode22hilo_Decode22hilo( -it->first, -it->second, true); - -} - - - -void test_int_as_float() -{ - int i0 = -420042 ; - float f0 = SPack::int_as_float( i0 ); - int i1 = SPack::int_from_float( f0 ); - assert( i0 == i1 ); - LOG(info) << " i0 " << i0 << " f0 " << f0 << " i1 " << i1 << " (NaN is expected) " ; -} - -void test_uint_as_float() -{ - unsigned u0 = 420042 ; - float f0 = SPack::uint_as_float( u0 ); - unsigned u1 = SPack::uint_from_float( f0 ); - assert( u0 == u1 ); - LOG(info) << " u0 " << u0 << " f0 " << f0 << " u1 " << u1 ; -} - - -void test_IsLittleEndian() -{ - const char* LE = "LITTLE_ENDIAN : least significant byte at smaller memory address " ; - const char* BE = "BIG_ENDIAN : most significant byte at smaller memory address " ; - LOG(info) << ( SPack::IsLittleEndian() ? LE : BE ) ; -} - - -void test_unsigned_as_int(int boundary, unsigned sensorIndex, bool dump) -{ - // LOG(info) << " boundary " << boundary ; - - //unsigned packed = ( boundary << 16 | sensorIndex << 0 ); - // simple packing like this doesnt work with signed ints, - // must control the masking first otherwise the bits from eg -1:0xffffffff leak - - unsigned packed = ((boundary & 0xffff) << 16 ) | ((sensorIndex & 0xffff) << 0 ) ; - unsigned hi = ( packed & 0xffff0000 ) >> 16 ; - unsigned lo = ( packed & 0x0000ffff ) >> 0 ; - - // int hi_s = hi <= 0x7fff ? hi : hi - 0x10000 ; // twos complement - int hi_s = SPack::unsigned_as_int<16>(hi); - - bool expect = hi_s == boundary && lo == sensorIndex ; - - if(!expect || dump) - std::cout - << " boundary " << std::setw(10) << std::dec << boundary - << " sensorIndex(hex) " << std::hex << sensorIndex - << " packed(hex) " << std::hex << packed - << " hi(hex) " << std::hex << hi - << " lo(hex) " << std::hex << lo - << " hi_s " << std::dec << hi_s - << std::endl - ; - - assert(expect) ; -} - -void test_unsigned_as_int() -{ - //int boundary = -1 ; // 0xffff ; // signed int that can easily fit into 16 bits - unsigned sensorIndex = 0xbeef ; // unsigned int that can easily fit into 16 bits - unsigned signed_max_16 = (0x1 << (16 - 1)) - 1 ; // 0x7fff - - test_unsigned_as_int( -1 , sensorIndex, true ); - test_unsigned_as_int( -(signed_max_16+1) , sensorIndex, true ); - test_unsigned_as_int( signed_max_16 , sensorIndex, true ); - - int boundary0 = -(signed_max_16+1) ; - int boundary1 = signed_max_16 ; - - LOG(info) - << " boundary0 " << boundary0 - << " boundary1 " << boundary1 - ; - - for(int boundary=boundary0 ; boundary <= boundary1 ; boundary++) - test_unsigned_as_int(boundary, sensorIndex, false); - - //test_unsigned_as_int( -(signed_max_16+2), sensorIndex, false ); - //test_unsigned_as_int( (signed_max_16+1), sensorIndex, false ); - -} - - -/** -test_unsigned_as_int_16 ------------------------- - -This demonstrates that the union trick and twos-complement -reinterpretation give the same result : although note that -must use a union with elements of the appropriate number of bits. - -**/ - -void test_unsigned_as_int_16(unsigned value) -{ - int v16_0 = SPack::unsigned_as_int<16>(value); - int v16_1 = SPack::unsigned_as_int_16( value ); - - bool expect = v16_0 == v16_1 ; - bool dump = false ; - - if(!expect || dump) - { - std::cout - << " v16_0 " << v16_0 - << " v16_1 " << v16_1 - << ( expect ? " " : " NOT-EXPECT " ) - << std::endl - ; - } - assert( expect ); -} - -void test_unsigned_as_int_16() -{ - unsigned value0 = 0 ; - unsigned value1 = ( 0x1 << 16 ) - 1 ; // 0xffff - for(unsigned value=value0 ; value <= value1 ; value++) test_unsigned_as_int_16(value); -} - -/** - -OptiX_700/SDK/optixWhitted/helpers.h - -138 #define float3_as_args(u) \ -139 reinterpret_cast((u).x), \ -140 reinterpret_cast((u).y), \ -141 reinterpret_cast((u).z) - -**/ - - -union uif_t { - unsigned u ; - int i ; - float f ; -}; - - -void dummy_optixTrace(unsigned& p0 ) -{ - p0 += 100u ; -} - - - -#ifdef DEREFERENCING_TYPE_PUNNED_POINTER -void test_reinterpret_cast() -{ - unsigned u = 42 ; - uif_t uif ; - uif.u = u ; - - //unsigned u2 = reinterpret_cast(uif.f) ; - unsigned u2 = reinterpret_cast(uif.f) ; - LOG(info) << " uif.f " << uif.f << " u2 " << u2 ; - - bool u_expect = u2 == u ; - assert( u_expect ); - if(!u_expect) std::raise(SIGINT) ; -} - -void test_reinterpret_cast_arg() -{ - uif_t uif ; - uif.u = 42u ; - LOG(info) << " uif.f " << uif.f << " uif.u " << uif.u ; - dummy_optixTrace( reinterpret_cast(uif.f) ) ; - LOG(info) << " uif.f " << uif.f << " uif.u " << uif.u ; - assert( uif.u == 142u ); -} -#endif - -void test_unsigned_as_double() -{ - unsigned x = 42u ; - unsigned y = 420u ; - - double d = SPack::unsigned_as_double(x, y ); - - unsigned x2, y2 ; - SPack::double_as_unsigned(x2, y2, d ); - assert( x2 == x ); - assert( y2 == y ); - - LOG(info) << " d " << d << " x2 " << x2 << " y2 " << y2 ; -} - - - - -int main(int argc , char** argv ) -{ - OPTICKS_LOG(argc, argv); - - //test_Encode(); - - //test_Encode_Decode(); - //test_Encode_Decode_ptr(); - //test_Encode13_Decode13(); - //test_Encode22_Decode22(); - - //test_int_as_float(); - //test_uint_as_float(); - - //test_Encode_Decode_unsigned(); - //test_IsLittleEndian(); - - //test_unsigned_as_int(); - //test_unsigned_as_int_16(); - - //test_Encode22hilo_Decode22hilo(); - - //test_reinterpret_cast(); - //test_reinterpret_cast_arg(); - - test_unsigned_as_double(); - - return 0 ; -} - -// om-;TEST=SPackTest om-t - From 85b95fe3bcd1a537068eacaf8eae209db403c85d Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 13 Jul 2026 21:22:44 +0000 Subject: [PATCH 5/8] refactor(u4): remove unused random tools header Remove the orphaned U4RandomTools header, which has no remaining callers or build references. --- u4/U4RandomTools.hh | 54 --------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 u4/U4RandomTools.hh diff --git a/u4/U4RandomTools.hh b/u4/U4RandomTools.hh deleted file mode 100644 index e88b19f4d6..0000000000 --- a/u4/U4RandomTools.hh +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once - -#include - -#include "globals.hh" -#include "Randomize.hh" -#include "G4TwoVector.hh" -#include "G4ThreeVector.hh" -#include "U4RandomDirection.hh" - -#ifdef DEBUG_TAG -#include "U4Stack.h" -#include "SEvt.hh" -#endif - - - -// --------------------------------------------------------------------------- -// Returns a random lambertian unit vector (rejection sampling) -// -inline G4ThreeVector U4LambertianRand(const G4ThreeVector& normal) -{ - G4ThreeVector vect; - G4double ndotv; - G4int count=0; - const G4int max_trials = 1024; - - G4double u_exitloop ; - - do - { - ++count; - vect = U4RandomDirection(); - ndotv = normal * vect; - - if (ndotv < 0.0) - { - vect = -vect; - ndotv = -ndotv; - } - - u_exitloop = G4UniformRand() ; -#ifndef PRODUCTION -#ifdef DEBUG_TAG - SEvt::AddTag(1, U4Stack_LambertianRand, u_exitloop ); -#endif -#endif - - } while (!(u_exitloop < ndotv) && (count < max_trials)); - - return vect; -} - - From 1f6402ea72e5ec30ecb91dbf009da3ed87bdd082 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 13 Jul 2026 22:37:11 +0000 Subject: [PATCH 6/8] refactor: remove unused utility headers --- qudarap/qutil.h | 93 ------------------------------ sysrap/squad_double.h | 78 ------------------------- sysrap/tests/SComponent_OLDTest.cc | 28 --------- u4/U4RandomDirection.hh | 43 -------------- 4 files changed, 242 deletions(-) delete mode 100644 qudarap/qutil.h delete mode 100644 sysrap/squad_double.h delete mode 100644 sysrap/tests/SComponent_OLDTest.cc delete mode 100644 u4/U4RandomDirection.hh diff --git a/qudarap/qutil.h b/qudarap/qutil.h deleted file mode 100644 index 268969fd49..0000000000 --- a/qudarap/qutil.h +++ /dev/null @@ -1,93 +0,0 @@ -#pragma once - - -#if defined(__CUDACC__) || defined(__CUDABE__) - #define QUTIL_METHOD __device__ -#else - #define QUTIL_METHOD -#endif - - -struct qutil -{ - QUTIL_METHOD static void rotateUz(float3& d, const float3& u ); -}; - - -/** -qutil::rotateUz ------------------ - -This rotates the reference frame of a vector such that the original Z-axis will lie in the -direction of *u*. Many rotations would accomplish this; the one selected -uses *u* as its third column and is given by the below matrix. - -The below CUDA implementation follows the CLHEP implementation used by Geant4:: - - // geant4.10.00.p01/source/externals/clhep/src/ThreeVector.cc - 72 Hep3Vector & Hep3Vector::rotateUz(const Hep3Vector& NewUzVector) { - 73 // NewUzVector must be normalized ! - 74 - 75 double u1 = NewUzVector.x(); - 76 double u2 = NewUzVector.y(); - 77 double u3 = NewUzVector.z(); - 78 double up = u1*u1 + u2*u2; - 79 - 80 if (up>0) { - 81 up = std::sqrt(up); - 82 double px = dx, py = dy, pz = dz; - 83 dx = (u1*u3*px - u2*py)/up + u1*pz; - 84 dy = (u2*u3*px + u1*py)/up + u2*pz; - 85 dz = -up*px + u3*pz; - 86 } - 87 else if (u3 < 0.) { dx = -dx; dz = -dz; } // phi=0 teta=pi - 88 else {}; - 89 return *this; - 90 } - -This implements rotation of (px,py,pz) vector into (dx,dy,dz) -using the below rotation matrix, the columns of which must be -orthogonal unit vectors.:: - - | u.x * u.z / up -u.y / up u.x | - d = | u.y * u.z / up +u.x / up u.y | p - | -up 0. u.z | - -Taking dot products between and within columns shows that to be the case for -normalized u. - -Special cases: - -u = [0,0,1] (up=0.) - does nothing, effectively identity matrix - -u = [0,0,-1] (up=0., u.z<0. ) - flip x, and z which is a rotation of pi/2 about y - - | -1 0 0 | - d = | 0 1 0 | p - | 0 0 -1 | - -**/ - -inline QUTIL_METHOD void qutil::rotateUz(float3& d, const float3& u ) -{ - float up = u.x*u.x + u.y*u.y ; - if (up>0.f) - { - up = sqrt(up); - float px = d.x ; - float py = d.y ; - float pz = d.z ; - d.x = (u.x*u.z*px - u.y*py)/up + u.x*pz; - d.y = (u.y*u.z*px + u.x*py)/up + u.y*pz; - d.z = -up*px + u.z*pz; - } - else if (u.z < 0.f ) - { - d.x = -d.x; - d.z = -d.z; - } -} - - diff --git a/sysrap/squad_double.h b/sysrap/squad_double.h deleted file mode 100644 index e09cc7e879..0000000000 --- a/sysrap/squad_double.h +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once - -#if defined(__CUDACC__) || defined(__CUDABE__) -# define SQUAD_METHOD __host__ __device__ __forceinline__ -#else -# define SQUAD_METHOD inline -#endif - - -union dquad -{ - double4 f ; - longlong4 i ; - ulonglong4 u ; -}; - - - -struct dquad4 -{ - dquad q0 ; - dquad q1 ; - dquad q2 ; - dquad q3 ; - - SQUAD_METHOD void zero(); - SQUAD_METHOD double* data() ; - SQUAD_METHOD const double* cdata() const ; -}; - -SQUAD_METHOD void dquad4::zero() -{ - q0.u.x = 0 ; q0.u.y = 0 ; q0.u.z = 0 ; q0.u.w = 0 ; - q1.u.x = 0 ; q1.u.y = 0 ; q1.u.z = 0 ; q1.u.w = 0 ; - q2.u.x = 0 ; q2.u.y = 0 ; q2.u.z = 0 ; q2.u.w = 0 ; - q3.u.x = 0 ; q3.u.y = 0 ; q3.u.z = 0 ; q3.u.w = 0 ; -} - -SQUAD_METHOD double* dquad4::data() { return &q0.f.x ; } -SQUAD_METHOD const double* dquad4::cdata() const { return &q0.f.x ; } - - - -#if defined(__CUDACC__) || defined(__CUDABE__) -#else - - -inline std::ostream& operator<<(std::ostream& os, const dquad& q) -{ - os - << "f " << q.f - // << "i " << q.i - // << "u " << q.u - ; - return os; -} - - -inline std::ostream& operator<<(std::ostream& os, const dquad4& v) -{ - os - << std::endl - << v.q0.f - << std::endl - << v.q1.f - << std::endl - << v.q2.f - << std::endl - << v.q3.f - << std::endl - ; - return os; -} - -#endif - - - diff --git a/sysrap/tests/SComponent_OLDTest.cc b/sysrap/tests/SComponent_OLDTest.cc deleted file mode 100644 index 9afb9cc535..0000000000 --- a/sysrap/tests/SComponent_OLDTest.cc +++ /dev/null @@ -1,28 +0,0 @@ -// name=SComponent_OLDTest ; gcc $name.cc -g -std=c++11 -lstdc++ -I.. -o /tmp/$name && gdb__ /tmp/$name - -#include -#include -#include -#include "OpticksGenstep.h" - -#include "SComponent_OLD.hh" - -int main(int argc, char** argv) -{ - std::vector names = {"photon.npy", "genstep.npy", "hit.npy" } ; - - for(unsigned i=0 ; i < 20 + names.size() ; i++) - { - const char* name = i < 20 ? SComponent_OLD::Name(i) : names[i-20] ; - unsigned comp = SComponent_OLD::Component(name); - const char* compname = SComponent_OLD::Name(comp); - std::cout - << " i " << std::setw(3) << i - << " name " << std::setw(20) << ( name ? name : "-" ) - << " comp " << std::setw(3) << comp - << " compname " << std::setw(20) << ( compname ? compname : "-" ) - << std::endl - ; - } - return 0 ; -} diff --git a/u4/U4RandomDirection.hh b/u4/U4RandomDirection.hh deleted file mode 100644 index c264bd8504..0000000000 --- a/u4/U4RandomDirection.hh +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once - -#include - -#include "globals.hh" -#include "Randomize.hh" -#include "G4ThreeVector.hh" - -#ifdef DEBUG_TAG -#include "SEvt.hh" -#include "U4Stack.h" -#endif - - -// G.Marsaglia (1972) method -inline G4ThreeVector U4RandomDirection() -{ - G4double u0, u1 ; - - G4double u, v, b; - do { - - u0 = G4UniformRand() ; -#ifndef PRODUCTION -#ifdef DEBUG_TAG - SEvt::AddTag(1, U4Stack_RandomDirection, u0 ); -#endif -#endif - u1 = G4UniformRand() ; -#ifndef PRODUCTION -#ifdef DEBUG_TAG - SEvt::AddTag(1, U4Stack_RandomDirection, u1 ); -#endif -#endif - u = 2.*u0 - 1.; - v = 2.*u1 - 1.; - b = u*u + v*v; - } while (b > 1.); - G4double a = 2.*std::sqrt(1. - b); - return G4ThreeVector(a*u, a*v, 2.*b - 1.); -} - - From 1211942bd4e5a9c43e57e0738d83a2b820370762 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 13 Jul 2026 23:02:02 +0000 Subject: [PATCH 7/8] refactor(sysrap): remove legacy path and options APIs --- sysrap/SBnd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysrap/SBnd.h b/sysrap/SBnd.h index 6d42b0d424..6ebe3041e1 100644 --- a/sysrap/SBnd.h +++ b/sysrap/SBnd.h @@ -123,7 +123,7 @@ inline SBnd::SBnd(const NP* bnd_) inline std::string SBnd::getItemDigest( int i, int j, int w ) const { - return sdigest::Item(bnd, i, j, w ); + return sdigest::Item(bnd, i, j, w); } inline std::string SBnd::descBoundary() const { @@ -354,7 +354,7 @@ inline std::string SBnd::DescDigest(const NP* bnd, int w ) // static ss << std::setw(3) << i << " " ; for(int j=0 ; j < nj ; j++) { - std::string dig = sdigest::Item(bnd, i, j ); + std::string dig = sdigest::Item(bnd, i, j); std::string sdig = dig.substr(0, w); ss << std::setw(w) << sdig << " " ; } From a68e84adad722d803c291ae53fd354ac25ccf060 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Jul 2026 18:10:39 +0000 Subject: [PATCH 8/8] fix(sysrap): truncate boundary item digest correctly --- sysrap/SBnd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysrap/SBnd.h b/sysrap/SBnd.h index 6ebe3041e1..48d7638bd6 100644 --- a/sysrap/SBnd.h +++ b/sysrap/SBnd.h @@ -123,7 +123,7 @@ inline SBnd::SBnd(const NP* bnd_) inline std::string SBnd::getItemDigest( int i, int j, int w ) const { - return sdigest::Item(bnd, i, j, w); + return sdigest::Item(bnd, i, j).substr(0, w); } inline std::string SBnd::descBoundary() const {