Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:50:28

0001 /**
0002 U4SimtraceSimpleTest.cc
0003 ============================
0004 
0005 Split from U4SimtraceTest.cc as that has PMTSim_standalone dependency complications
0006 
0007 Usually invoked from U4SimtraceSimpleTest.sh
0008 
0009 This does simtrace scans of all unique solids in a Geant4 geometry tree and
0010 saves the placement transforms of all nodes into *base* directory with NP set_names
0011 containing the solid names of all nodes.  These folders of .npy files
0012 can be presented as 2D cross sections of the geometry using U4SimtraceSimpleTest.py
0013 as orchestrated by U4SimtraceSimpleTest.sh
0014 
0015 Although in principal this should work for any geometry it is intended to
0016 assist with debugging within small test geometries.  With large geometries it
0017 will be very slow and write huge amounts of output.
0018 
0019 HMM: Actually this is not so general, because the gensteps pick a plane
0020 in which to collect intersects : so combining those only makes sense
0021 when the transforms of the solids correspond. So it will work for the
0022 solids of a single PMT, but will not usually work across multiple PMTs.
0023 
0024 Of course CSGOptiX simtrace that does similar on GPU works fine
0025 across any geometry with solids having any relation to each other.
0026 
0027 TODO: review the GPU simtrace approach and see if something similar
0028 could be done with G4Navigator (see initial work in U4Navigator.h)
0029 
0030 **/
0031 
0032 #include "G4VSolid.hh"
0033 
0034 #include "OPTICKS_LOG.hh"
0035 #include "stree.h"
0036 #include "SEventConfig.hh"
0037 
0038 #include "U4Tree.h"
0039 #include "U4VolumeMaker.hh"
0040 
0041 struct U4SimtraceSimpleTest
0042 {
0043     stree st ;
0044     U4Tree ut ;
0045 
0046     U4SimtraceSimpleTest(const G4VPhysicalVolume* pv );
0047     void scan(const char* base );
0048 };
0049 
0050 inline U4SimtraceSimpleTest::U4SimtraceSimpleTest(const G4VPhysicalVolume* pv )
0051     :
0052     ut(&st, pv)   // instanciation of U4Tree populates the stree
0053     // NOTE : DIRECT USE OF U4Tree CTOR IS NON-STANDARD
0054     // NORMALLY SHOULD USE VIA U4Tree::Create
0055 {
0056 }
0057 
0058 inline void U4SimtraceSimpleTest::scan(const char* base)
0059 {
0060     ut.simtrace_scan(base) ;
0061 }
0062 
0063 int main(int argc, char** argv)
0064 {
0065     OPTICKS_LOG(argc, argv);
0066 
0067     SEventConfig::SetRGModeSimtrace();
0068 
0069     const G4VPhysicalVolume* pv = U4VolumeMaker::PV();  // sensitive to GEOM envvar
0070     LOG(info) << " U4VolumeMaker::Desc() " << U4VolumeMaker::Desc() ;
0071 
0072     U4SimtraceSimpleTest t(pv);
0073     t.scan("$FOLD");  
0074     // TODO: get rid of the FOLD here, as sev::save not using it only the transforms
0075     // instead arrange to save the transforms via sev machinery 
0076 
0077     return 0 ;
0078 }
0079 
0080