/* * Version of prog_snova.cc to handle a G4Lab::UIOnX session */ // snova : #include #include #include #include // Geant4 : #include #include // G4Lab : #include //UIOnX // Lib : #include #include #include #include #include #include "Environment.h" //using namespace snova; namespace snovis { class mgr : public snova::snova_mgr { public: mgr(){} virtual ~mgr(){} public: void run_sim(int argc , char** argv,const std::string& aTk = "") { G4UImanager* UI = G4UImanager::GetUIpointer(); UI->ApplyCommand("/control/shell cp currentEvent.rndm currentRun.rndm"); UI->ApplyCommand("/random/setSavingFlag true"); UI->ApplyCommand("/random/resetEngineFrom currentRun.rndm"); UI->ApplyCommand("/tracking/storeTrajectory 1"); //UI->ApplyCommand("/tracking/verbose 1"); //G4RunManager* runManager = __runManager; G4RunManager* runManager = G4RunManager::GetRunManager(); std::string gui = "$SNOVISROOT/scripts/OnX/snovis_session.onx"; //UIOnX G4Lab::UIOnX* session = new G4Lab::UIOnX(*runManager,gui,argc,argv); //UIOnX session->createUI(aTk); session->SessionStart(); delete session; } }; } int main( int argc , char** argv ) { if(argc<=0) return EXIT_FAILURE; if(!check_envs(argv[0])) return EXIT_FAILURE; Lib::Printer printer; Lib::Out out(printer); std::string SNOVISROOT; if(!Lib::System::getenv("SNOVISROOT",SNOVISROOT)) { out << "snovis_session :" << " Environment variable SNOVISROOT not defined." << Lib::endl; return EXIT_FAILURE; } std::string params; // We cd to $HOME/snovis/session : if(!Lib::dirmanip::goHome()) { out << "snovis_session : can't go home." << Lib::endl; return EXIT_FAILURE; } else if(!Lib::dirmanip::mkcd("snovis")) { out << "snovis_session : can't mkcd snovis." << Lib::endl; return EXIT_FAILURE; } else if(!Lib::dirmanip::mkcd("session")) { out << "snovis_session : can't mkcd session." << Lib::endl; return EXIT_FAILURE; } else { // If there is a snova.par file found under // $HOME/snovis/session : // we take it, else we start with $SNOVISROOT/scripts/snova/snova.par if(Lib::fmanip::exists("snova.par")) { params = "snova.par"; } else { params = "$SNOVISROOT/scripts/snova/snova.par"; } } bool is_Mac_app = Lib::main::isMacApp(argv[0]); int error_code=EXIT_SUCCESS; try { //std::cerr << "snovis_session : startup" << std::endl; std::cerr << "snovis_session : startup : 000" << std::endl; // A snova manager: snovis::mgr my_snova_mgr; // Configure some properties of the snova manager: my_snova_mgr.set_debug(false); my_snova_mgr.set_params_filename(params); //my_snova_mgr.set_G4_macro(G4_macro); // Use a dedicated vertex generator factory: snemo::base_VG_factory my_VG_factory; my_VG_factory.add("CALO_basic", snemo::CALO_basic_VG::new_CALO_basic_VG ); my_VG_factory.add("source_simple", snemo::source_simple_VG::new_source_simple_VG); // // NOT AVAILABLE YET! //my_VG_factory.add("TC_nblocks", // snemo::TC_nblocks_VG::new_TC_nblocks_VG ); my_VG_factory.init(); //if( debug ) my_VG_factory.dump(std::cerr); my_snova_mgr.set_VG_factory(my_VG_factory); // Build the guts of the simulation process within the snova manager: //std::cerr << "snovis_session :" // << " mgr.init..." << std::endl; my_snova_mgr.init(); // Run the simulation: my_snova_mgr.run_sim(argc,argv,is_Mac_app?"Qt":""); //std::cerr << "snovis_session :" // << " mgr.reset..." << std::endl; my_snova_mgr.reset(); // not mandatory for we do it in the d-tor. //std::cerr << "snovis_session :" // << " end." << std::endl; } catch(std::exception & x){ std::cerr << "snovis_session : error : " << x.what() << std::endl; error_code=EXIT_FAILURE; } catch(...){ std::cerr << "snovis_session : error : unexpected error!" << std::endl; error_code=EXIT_FAILURE; } return error_code; }