Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #include <cuda_runtime.h>
0002 
0003 #include <sstream>
0004 
0005 #include "qrng.h"
0006 
0007 #include "scuda.h"
0008 #include "squad.h"
0009 #include "sscint.h"
0010 #include "scerenkov.h"
0011 #include "ssys.h"
0012 
0013 #include "QBnd.hh"
0014 #include "qbnd.h"
0015 
0016 #include "QDebug.hh"
0017 #include "QState.hh"
0018 #include "qdebug.h"
0019 #include "QU.hh"
0020 #include "SLOG.hh"
0021 
0022 const plog::Severity QDebug::LEVEL = SLOG::EnvLevel("QDebug", "DEBUG") ; 
0023 const QDebug* QDebug::INSTANCE = nullptr ; 
0024 const QDebug* QDebug::Get(){ return INSTANCE ; }
0025 
0026 /**
0027 QDebug::MakeInstance
0028 ------------------------
0029 
0030 qdebug.h contains miscellaneous used by fill_state testing 
0031 
0032 **/
0033 
0034 qdebug* QDebug::MakeInstance()   // static
0035 {
0036     qdebug* dbg = new qdebug ; 
0037 
0038     float cosTheta = 0.5f ; 
0039     dbg->wavelength = 500.f ; 
0040     dbg->cosTheta = cosTheta ; 
0041     qvals( dbg->normal , "DBG_NRM", "0,0,1" ); 
0042     qvals( dbg->direction , "DBG_DIR", "0,0,-1" ); 
0043     dbg->orient = 1.f ;  // orient -1.f flips the normal direction 
0044     dbg->value = ssys::getenvfloat("DBG_VALUE", 0.2f)  ;  // eg sigma_alpha or polish 
0045 
0046     // qstate: mocking result of fill_state 
0047     dbg->s = QState::Make(); 
0048 
0049     // quad2: mocking prd per-ray-data result of optix trace calls 
0050     dbg->prd = quad2::make_eprd() ;  // see qudarap/tests/eprd.sh 
0051     
0052     dbg->p.ephoton() ;   // sphoton::ephoton 
0053  
0054     sscint& scint_gs = dbg->scint_gs ; 
0055     bool dump = false ; 
0056     sscint::FillGenstep( scint_gs, 0, 100, dump ); 
0057 
0058     scerenkov& cerenkov_gs = dbg->cerenkov_gs ; 
0059 
0060     const QBnd* qb = QBnd::Get() ; 
0061 
0062     unsigned cerenkov_matline = qb ? qb->qb->boundary_tex_MaterialLine_LS : 0 ;   
0063 
0064     LOG_IF(error, qb == nullptr) 
0065          << "AS NO QBnd at QDebug::MakeInstance the qdebug cerenkov genstep is using default matline of zero " << std::endl 
0066          << "THIS MEANS qdebug CERENKOV GENERATION WILL LIKELY INFINITE LOOP AND TIMEOUT " << std::endl 
0067          << " cerenkov_matline " << cerenkov_matline  << std::endl
0068          << " TO FIX THIS YOU PROBABLY NEED TO RERUN THE GEOMETRY CONVERSION TO UPDATE THE PERSISTED SSim IN CSGFoundry/SSim "
0069          ;
0070 
0071     scerenkov::FillGenstep( cerenkov_gs, cerenkov_matline, 100, dump ); 
0072 
0073     return dbg ; 
0074 }
0075 
0076 QDebug::QDebug()
0077     :
0078     dbg(MakeInstance()),
0079     d_dbg(QU::UploadArray<qdebug>(dbg, 1, "QDebug::QDebug/d_dbg" ))
0080 {
0081     INSTANCE = this ; 
0082     LOG(LEVEL) << desc() ; 
0083 }
0084 
0085 qdebug* QDebug::getDevicePtr() const
0086 {
0087     return d_dbg ; 
0088 }
0089  
0090 std::string QDebug::desc() const
0091 {
0092     std::stringstream ss ; 
0093     ss << "QDebug::desc " 
0094        << " dbg " << dbg 
0095        << " d_dbg " << d_dbg 
0096        << std::endl 
0097        << " QState::Desc " << QState::Desc(dbg->s)  
0098        << std::endl 
0099        << " dbg.p.desc " << dbg->p.desc() 
0100        ;
0101     std::string s = ss.str(); 
0102     return s ; 
0103 }
0104 
0105