File indexing completed on 2026-04-09 07:49:06
0001 #include "SSys.hh"
0002 #include "SPath.hh"
0003 #include "NP.hh"
0004
0005 #include "QMultiFilm.hh"
0006 #include "scuda.h"
0007 #include "squad.h"
0008 #include "OPTICKS_LOG.hh"
0009
0010
0011 void test_check(QMultiFilm& sc)
0012 {
0013 std::cout<< sc.desc()<<std::endl;
0014 sc.check();
0015 }
0016
0017 void test_mock_lookup(QMultiFilm& sc){
0018
0019
0020
0021 NP* input_arr = NP::LoadIfExists("$QMultiFilmTest_FOLD/test_texture.npy");
0022
0023 assert(input_arr->has_shape(128,256,2,4));
0024
0025 int height = input_arr->shape[0];
0026 int width = input_arr->shape[1];
0027 int num_item = height*width;
0028 int edge_item = 10;
0029 quad2* arr_v = (quad2*)input_arr->values<float>();
0030
0031 for(int i = 0 ; i < num_item; i++){
0032 if(i < edge_item || i > (num_item - edge_item)){
0033 quad2 qd2 = arr_v[i];
0034 std::cout<<" pmtcat = "<< qd2.q0.i.x
0035 <<" wv_nm = " << qd2.q0.f.y
0036 <<" aoi = " << qd2.q0.f.z
0037
0038 <<" R_s = " << qd2.q1.f.x
0039 <<" T_s = " << qd2.q1.f.y
0040 <<" R_p = " << qd2.q1.f.z
0041 <<" T_p = " << qd2.q1.f.w
0042 << std::endl;
0043 }
0044 }
0045 std::cout<<'\n';
0046
0047 NP* res = sc.mock_lookup(input_arr);
0048
0049
0050 float4* res4 = (float4*)res->values<float>();
0051 for(int i = 0 ; i<num_item ; i++){
0052 if(i < edge_item || i > (num_item - edge_item)){
0053 std::cout<<" Rs = "<< res4[i].x
0054 <<" Ts = "<< res4[i].y
0055 <<" Rp = "<< res4[i].z
0056 <<" Tp = "<< res4[i].w
0057 <<std::endl;
0058 }
0059 }
0060 int create_dirs = 2 ;
0061 const char* FOLD = SPath::Resolve("$TMP/QMultiFilmTest", create_dirs) ;
0062
0063 res->save(FOLD, "gpu_texture_interp.npy");
0064 input_arr->save(FOLD, "test_texture.npy");
0065 }
0066
0067 void test_lookup(QMultiFilm& sc)
0068 {
0069 int pmtcatDim = sc.src->shape[0];
0070 int resDim = sc.src->shape[1];
0071
0072
0073 int create_dirs = 2 ;
0074 const char* fold = SPath::Resolve("$TMP/QMultiFilmTest", create_dirs) ;
0075 LOG(info) << " save to " << fold ;
0076 for(int pmtcatIdx = 0 ; pmtcatIdx < pmtcatDim ; pmtcatIdx++){
0077 for( int resIdx = 0 ; resIdx < resDim ; resIdx++){
0078 NP* dst = sc.lookup(pmtcatIdx,resIdx );
0079 std::stringstream ss;
0080 ss<<"pmtcat_"<<pmtcatIdx
0081 <<"resolution_"<<resIdx
0082 <<".npy";
0083 dst->save(fold, ss.str().c_str());
0084 }
0085 }
0086 sc.src->save(fold, "src.npy") ;
0087 }
0088
0089 int main(int argc, char** argv)
0090 {
0091 OPTICKS_LOG(argc, argv);
0092
0093 const char* artpath = SSys::getenvvar("ARTPATH", "/data/ihep/tmp/debug_multi_film_table/multifilm.npy") ;
0094 NP* art = NP::LoadIfExists(artpath) ;
0095
0096 LOG(info)
0097 << " ARTPATH " << artpath
0098 << " art " << ( art ? art->sstr() : "-" )
0099 ;
0100
0101 LOG_IF(error, !art ) << " FAILED to load art array " ;
0102 if(!art) return 0 ;
0103
0104 QMultiFilm mf(art);
0105
0106
0107
0108 test_mock_lookup(mf);
0109 return 0 ;
0110 }
0111