Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /**
0002 u4/tests/U4AppTest.cc (formerly names U4RecorderTest ? Geant4 simulation with Opticks SEvt instrumentation)
0003 =============================================================================================================
0004 
0005 See g4cx/test/G4CXTest.cc for further development that started
0006 from this and added opticks simulate.
0007 
0008 **/
0009 
0010 #include "U4App.h"
0011 
0012 int main(int argc, char** argv)
0013 {
0014     OPTICKS_LOG(argc, argv);
0015 
0016     //U4Material::LoadOri();  // currently needs  "source ./IDPath_override.sh" to find _ori materials
0017     //U4Material::LoadBnd();   // "back" creation of G4 material properties from the Opticks bnd.npy obtained from SSim::Load
0018     //U4Material::LoadBnd("$A_CFBASE/CSGFoundry/SSim");
0019 
0020     // NB: dependency on $A_CFBASE/CSGFoundry/SSim means that when changing GEOM is is necessary
0021     // to run the A-side first before this B-side in order to write the $A_CFBASE/CSGFoundry/SSim
0022 
0023     U4Random* rnd = U4Random::Create() ;             // load precooked randoms for aligned running
0024     LOG(info) << rnd->desc() ;
0025 
0026     std::string desc = U4App::Desc();
0027     LOG(info) << " desc " << desc ;
0028     SEventConfig::SetEventReldir(desc.c_str() );
0029 
0030     SEventConfig::SetDebugLite();
0031     SEvt* evt = SEvt::Create(SEvt::EGPU) ;  // ECPU would be more appropriate
0032      // SEvt must be instanciated before QEvt
0033     const char* outdir = evt->getDir();
0034     LOG(info) << "outdir [" << outdir << "]" ;
0035     LOG(info) << " desc [" << desc << "]" ;
0036 
0037     evt->random = rnd  ;  // so can use getFlatPrior within SEvt::addTag
0038 
0039 #ifdef WITH_OLD_FRAME
0040     sframe fr = sframe::Load_("$A_FOLD/sframe.npy");
0041     evt->setFrame(fr);   // setFrame tees up Gensteps
0042 #else
0043     sfr fr = sfr::Load_("$A_FOLD/sfr.npy");
0044     evt->setFr(fr);
0045 #endif
0046 
0047 
0048     // NB: dependency on A_FOLD means that when changing GEOM is is necessary
0049     // to run the A-side first before this B-side in order to write the $A_FOLD/sframe.npy
0050     // The frame is needed for transforming input photons when using OPTICKS_INPUT_PHOTON_FRAME.
0051 
0052     if(U4App::PrimaryMode() == 'T') SEvt::AddTorchGenstep();
0053 
0054     if(ssys::getenvbool("DRYRUN"))
0055     {
0056         LOG(fatal) << " DRYRUN early exit " ;
0057         return 0 ;
0058     }
0059 
0060     G4RunManager* runMgr = new G4RunManager ;
0061     runMgr->SetUserInitialization((G4VUserPhysicsList*)new U4Physics);
0062     U4App t(runMgr) ;
0063     runMgr->BeamOn(1);
0064 
0065 
0066     rnd->saveProblemIdx(outdir);
0067 
0068     evt->save();
0069     LOG(info) << "outdir [" << outdir << "]" ;
0070     LOG(info) << " desc [" << desc << "]" ;
0071 
0072     return 0 ;
0073 }