Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:14

0001 // ~/opticks/sysrap/tests/OpticksPhotonSTANDALONETest.sh
0002 
0003 #include <iostream>
0004 #include <iomanip>
0005 
0006 #include "OpticksPhoton.h"
0007 #include "OpticksPhoton.hh"
0008 
0009 #include "spath.h"
0010 #include "NP.hh"
0011 
0012 void test_list()
0013 {
0014     for(unsigned i=0 ; i < 16 ; i++) 
0015     {
0016         unsigned flag = 0x1 << i ; 
0017         std::cout 
0018             << " i " << std::setw(3) << i 
0019             << " flag " << std::setw(10) << flag 
0020             << " OpticksPhoton::Flag " << std::setw(20)  << OpticksPhoton::Flag(flag) 
0021             << " OpticksPhoton::Abbrev " << std::setw(4) << OpticksPhoton::Abbrev(flag) 
0022             << std::endl 
0023             ;
0024     }
0025 }
0026 
0027 
0028 
0029 void test_load_seq()
0030 {
0031     const char* _path = "$TMP/GEOM/$GEOM/G4CXTest/ALL0/p001/seq.npy" ; 
0032     const char* path = spath::Resolve(_path) ; 
0033     NP* a = NP::Load(path); 
0034     std::cout 
0035         << "OpticksPhotonTest:test_load_seq" 
0036         << std::endl
0037         << " _path " << _path 
0038         << std::endl
0039         << " path  " << path 
0040         << std::endl
0041         << " a " << ( a ? a->sstr() : "-" ) 
0042         << std::endl
0043          ; 
0044     if(a == nullptr) return ; 
0045 
0046     const uint64_t* aa = a->cvalues<uint64_t>(); 
0047     int num = a->shape[0] ;  
0048     int edge = 10 ; 
0049 
0050     for(int i=0 ; i < num ; i++)
0051     {
0052         if( i < edge || i > (num - edge) ) 
0053             std::cout << OpticksPhoton::FlagSequence_( aa + 4*i, 2 ) << std::endl ;  
0054         else if( i == edge ) 
0055             std::cout << "..." << std::endl ;
0056     }
0057 }
0058 
0059 /**
0060 test_unique_count_comparison
0061 -------------------------------
0062 
0063 Currently doing this in python starting from::
0064 
0065    np.unique(a, return_index=True, return_counts=True ) 
0066 
0067 but its rather slow with 1M photons::
0068 
0069    notes/issues/sevt_SAB_slow_with_1M_and_order_2000_histories.rst
0070 
0071 Look into alternatives::
0072 
0073    sysrap/tests/unique_count_comparison/
0074    thrustrap/TSparse_.cu
0075 
0076 HMM a CPU version of TSparse_.cu would be interesting to see speedup::
0077 
0078    NP* uic = NP::UniqueIndexCount(a) ; 
0079 
0080 **/
0081 
0082 void test_unique()
0083 {
0084     const char* _path = "$TMP/GEOM/$GEOM/G4CXTest/ALL0/p001/seq.npy" ; 
0085     const char* path = spath::Resolve(_path) ; 
0086     NP* a = NP::Load(path); 
0087     if(a == nullptr) return ; 
0088     std::cout << " a " << ( a ? a->sstr() : "-" ) << std::endl ; 
0089 }
0090 
0091 
0092 
0093 int main(int argc, char** argv)
0094 {
0095     test_load_seq(); 
0096     return 0 ; 
0097 }