Back to home page

EIC code displayed by LXR

 
 

    


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

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