Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /**
0002 scerenkov_test.cc : CPU tests of scerenkov.h CUDA code using mocking 
0003 ========================================================================
0004 
0005 Standalone compile and run with::
0006 
0007     ~/o/sysrap/tests/scerenkov_test.sh 
0008 
0009 TODO: instead of this use actual qcerenkov.h together with srngcpu.h ?
0010 
0011 
0012 
0013 **/
0014 #include <numeric>
0015 #include <vector>
0016 
0017 #include "srngcpu.h"
0018 using RNG = srngcpu ; 
0019 
0020 #include "scuda.h"
0021 #include "squad.h"
0022 #include "sphoton.h"
0023 #include "scerenkov.h"
0024 
0025 #include "SEvent.hh"
0026 
0027 #include "NP.hh"
0028 
0029 NP* make_cerenkov_photon( const NP* gs, const NP* se )
0030 {
0031     const quad6* gg = (quad6*)gs->bytes() ;  
0032     const int*   seed = (int*)se->bytes() ;  
0033 
0034     RNG rng ; 
0035   
0036     int tot_photon = se->shape[0] ; 
0037     NP* ph = NP::Make<float>( tot_photon, 4, 4); 
0038     sphoton* pp = (sphoton*)ph->bytes() ; 
0039 
0040     for(int i=0 ; i < tot_photon ; i++ )
0041     {
0042         unsigned photon_id = i ; 
0043         unsigned genstep_id = seed[photon_id] ; 
0044 
0045         sphoton& p = pp[photon_id] ; 
0046         const quad6& g = gg[genstep_id] ;  
0047         
0048         // scerenkov::generate(p, rng, g, photon_id, genstep_id ); 
0049         // HUH : there isnt one 
0050 
0051         std::cout << p.desc() << std::endl;  
0052     }
0053     return ph ; 
0054 }
0055 
0056 void test_generate()
0057 {
0058     NP* gs = SEvent::MakeCerenkovGenstep(); 
0059     NP* se = SEvent::MakeSeed(gs) ; 
0060     NP* ph = make_cerenkov_photon(gs, se); 
0061 
0062     gs->save("$FOLD/gs.npy"); 
0063     se->save("$FOLD/se.npy"); 
0064     ph->save("$FOLD/ph.npy"); 
0065 }
0066 
0067 int main(int argc, char** argv)
0068 {
0069     test_generate(); 
0070     return 0 ; 
0071 }
0072