- Timestamp:
- Feb 14, 2007, 9:01:08 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
snovis/trunk/applications/snovis_session.cc
r204 r208 3 3 */ 4 4 5 // snova : 5 6 #include <snova/snova_mgr.h> 6 7 7 #include <SNvertex/base_VG_factory.h> 8 8 #include <SNvertex/CALO_basic_VG.h> 9 9 #include <SNvertex/source_simple_VG.h> 10 10 11 // Geant4 : 11 12 #include <G4RunManager.hh> 12 13 #include <G4UImanager.hh> … … 15 16 #include <G4Lab/UIOnX.h> //UIOnX 16 17 17 #include "Environment.h" 18 // Lib : 18 19 #include <Lib/Out.h> 19 20 #include <Lib/sout.h> … … 22 23 #include <Lib/smanip.h> 23 24 24 using namespace snova; 25 #include "Environment.h" 26 27 //using namespace snova; 25 28 26 29 namespace snovis { … … 54 57 int main( int argc , char** argv ) 55 58 { 56 if(argc<=0) return 1;57 if(!check_envs(argv[0])) return 1;59 if(argc<=0) return EXIT_FAILURE; 60 if(!check_envs(argv[0])) return EXIT_FAILURE; 58 61 59 62 Lib::Printer printer; … … 65 68 << " Environment variable SNOVISROOT not defined." 66 69 << Lib::endl; 67 return 1;70 return EXIT_FAILURE; 68 71 } 69 72 73 std::string params; 74 75 // We cd to $HOME/snovis/session : 70 76 if(!Lib::dirmanip::goHome()) { 71 77 out << "snovis_session : can't go home." << Lib::endl; 72 return 1; 73 } else if(!Lib::dirmanip::mkcd("OpenScientist")) { 74 out << "snovis_session : can't mkcd OpenScientist." << Lib::endl; 75 return 1; 78 return EXIT_FAILURE; 76 79 } else if(!Lib::dirmanip::mkcd("snovis")) { 77 80 out << "snovis_session : can't mkcd snovis." << Lib::endl; 78 return 1;81 return EXIT_FAILURE; 79 82 } else if(!Lib::dirmanip::mkcd("session")) { 80 83 out << "snovis_session : can't mkcd session." << Lib::endl; 81 return 1;84 return EXIT_FAILURE; 82 85 } else { 83 std::string fs = Lib::System::fileSeparator(); 84 std::string from = SNOVISROOT+fs+"scripts"+fs+"snova"; 85 if(!Lib::fmanip::copy(from+fs+"snova.par",".")) { 86 out << "snovis_session : can't copy snova.par." << Lib::endl; 87 return 1; 88 } else if(!Lib::fmanip::copy(from+fs+"snemo.geom",".")) { 89 out << "snovis_session : can't copy snemo.geom." << Lib::endl; 90 return 1; 91 } else if(!Lib::fmanip::copy(from+fs+"example_Mo100.txt",".")) { 92 out << "snovis_session : can't copy example_Mo100.txt." << Lib::endl; 93 return 1; 86 // If there is a snova.par file found under 87 // $HOME/snovis/session : 88 // we take it, else we start with $SNOVISROOT/scripts/snova/snova.par 89 if(Lib::fmanip::exists("snova.par")) { 90 params = "snova.par"; 94 91 } else { 95 //std::string pwd; 96 //Lib::dirmanip::directory(pwd); 97 //out << pwd << Lib::endl; 92 params = "$SNOVISROOT/scripts/snova/snova.par"; 98 93 } 99 94 } … … 103 98 int error_code=EXIT_SUCCESS; 104 99 try { 105 106 std::c out << "Hello, this is a sample program for class 'snova_mgr'!" << std::endl;100 //std::cerr << "snovis_session : startup" << std::endl; 101 std::cerr << "snovis_session : startup : 000" << std::endl; 107 102 108 bool debug = false;109 std::string params_filename = snova::constants::DEF_PARAMS_FILENAME;110 //std::string params_filename = SNOVISROOT+"/scripts/snova.par";111 //G4String geom_filename = SNOVISROOT+"/scripts/snemo.geom";112 std::string G4_macro = "";113 bool visual_mode = false;114 115 103 // A snova manager: 116 104 snovis::mgr my_snova_mgr; 117 105 118 106 // Configure some properties of the snova manager: 119 my_snova_mgr.set_debug( debug); // debug verbosity120 my_snova_mgr.set_params_filename(params _filename); // the main simulation configuration file121 my_snova_mgr.set_G4_macro(G4_macro); // run G4 macro107 my_snova_mgr.set_debug(false); 108 my_snova_mgr.set_params_filename(params); 109 //my_snova_mgr.set_G4_macro(G4_macro); 122 110 123 111 // Use a dedicated vertex generator factory: 124 112 snemo::base_VG_factory my_VG_factory; 125 my_VG_factory.add("CALO_basic", snemo::CALO_basic_VG::new_CALO_basic_VG ); 126 my_VG_factory.add("source_simple", snemo::source_simple_VG::new_source_simple_VG ); 113 my_VG_factory.add("CALO_basic", 114 snemo::CALO_basic_VG::new_CALO_basic_VG ); 115 my_VG_factory.add("source_simple", 116 snemo::source_simple_VG::new_source_simple_VG); 127 117 // <here you may add more functors in the factory internal map... > 128 //my_VG_factory.add("TC_nblocks", snemo::TC_nblocks_VG::new_TC_nblocks_VG ); // NOT AVAILABLE YET! 118 // NOT AVAILABLE YET! 119 //my_VG_factory.add("TC_nblocks", 120 // snemo::TC_nblocks_VG::new_TC_nblocks_VG ); 129 121 130 122 my_VG_factory.init(); 131 if( debug ) my_VG_factory.dump(std::cerr);123 //if( debug ) my_VG_factory.dump(std::cerr); 132 124 my_snova_mgr.set_VG_factory(my_VG_factory); 133 125 134 126 // Build the guts of the simulation process within the snova manager: 135 std::cerr << "prog_snova2: debug:"136 << "Build the guts" << std::endl;137 my_snova_mgr.init(); // from this point 'set_XXXX' methods failed (manager is locked!)127 //std::cerr << "snovis_session :" 128 // << " mgr.init..." << std::endl; 129 my_snova_mgr.init(); 138 130 139 131 // Run the simulation: 140 std::cerr << "prog_snova2: debug: "141 << "Run the simulation" << std::endl;142 132 my_snova_mgr.run_sim(argc,argv,is_Mac_app?"Qt":""); 143 133 144 // Clean the snova manager 145 std::cerr << "prog_snova2: debug: " 146 << "Clean the snova manager" << std::endl; 134 //std::cerr << "snovis_session :" 135 // << " mgr.reset..." << std::endl; 147 136 my_snova_mgr.reset(); // not mandatory for we do it in the d-tor. 148 137 149 std::cerr << "prog_snova2: debug:"150 << "Done" << std::endl;138 //std::cerr << "snovis_session :" 139 // << " end." << std::endl; 151 140 } 152 141 catch(std::exception & x){ 153 std::cerr << " prog_snova2: error: " << x.what() << std::endl;142 std::cerr << "snovis_session : error : " << x.what() << std::endl; 154 143 error_code=EXIT_FAILURE; 155 144 } 156 145 catch(...){ 157 std::cerr << " prog_snova2: error: " << "unexpected error!" << std::endl;146 std::cerr << "snovis_session : error : unexpected error!" << std::endl; 158 147 error_code=EXIT_FAILURE; 159 148 }
Note: See TracChangeset
for help on using the changeset viewer.