Changeset 208 for snovis


Ignore:
Timestamp:
Feb 14, 2007, 9:01:08 AM (15 years ago)
Author:
barrand
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • snovis/trunk/applications/snovis_session.cc

    r204 r208  
    33 */
    44
     5// snova :
    56#include <snova/snova_mgr.h>
    6 
    77#include <SNvertex/base_VG_factory.h>
    88#include <SNvertex/CALO_basic_VG.h>
    99#include <SNvertex/source_simple_VG.h>
    1010
     11// Geant4 :
    1112#include <G4RunManager.hh>
    1213#include <G4UImanager.hh>
     
    1516#include <G4Lab/UIOnX.h> //UIOnX
    1617
    17 #include "Environment.h"
     18// Lib :
    1819#include <Lib/Out.h>
    1920#include <Lib/sout.h>
     
    2223#include <Lib/smanip.h>
    2324
    24 using namespace snova;
     25#include "Environment.h"
     26
     27//using namespace snova;
    2528
    2629namespace snovis {
     
    5457int main( int argc , char** argv )
    5558{
    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;
    5861
    5962  Lib::Printer printer;
     
    6568        << " Environment variable SNOVISROOT not defined."
    6669        << Lib::endl;
    67     return 1;
     70    return EXIT_FAILURE;
    6871  }
    6972
     73  std::string params;
     74
     75  // We cd to $HOME/snovis/session :
    7076  if(!Lib::dirmanip::goHome()) {
    7177    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;
    7679  } else if(!Lib::dirmanip::mkcd("snovis")) {
    7780    out << "snovis_session : can't mkcd snovis." << Lib::endl;
    78     return 1;
     81    return EXIT_FAILURE;
    7982  } else if(!Lib::dirmanip::mkcd("session")) {
    8083    out << "snovis_session : can't mkcd session." << Lib::endl;
    81     return 1;
     84    return EXIT_FAILURE;
    8285  } 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";
    9491    } else {
    95       //std::string pwd;
    96       //Lib::dirmanip::directory(pwd);
    97       //out << pwd << Lib::endl;
     92      params = "$SNOVISROOT/scripts/snova/snova.par";
    9893    }
    9994  }
     
    10398  int error_code=EXIT_SUCCESS;
    10499  try {
    105 
    106     std::cout << "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;
    107102 
    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    
    115103    // A snova manager:
    116104    snovis::mgr my_snova_mgr;
    117105
    118106    // Configure some properties of the snova manager:
    119     my_snova_mgr.set_debug(debug);                     // debug verbosity
    120     my_snova_mgr.set_params_filename(params_filename); // the main simulation configuration file
    121     my_snova_mgr.set_G4_macro(G4_macro);               // run G4 macro
     107    my_snova_mgr.set_debug(false);
     108    my_snova_mgr.set_params_filename(params);
     109    //my_snova_mgr.set_G4_macro(G4_macro);
    122110
    123111    // Use a dedicated vertex generator factory:
    124112    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);
    127117    // <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 );
    129121
    130122    my_VG_factory.init();
    131     if( debug ) my_VG_factory.dump(std::cerr);
     123    //if( debug ) my_VG_factory.dump(std::cerr);
    132124    my_snova_mgr.set_VG_factory(my_VG_factory);
    133125
    134126    // 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();
    138130
    139131    // Run the simulation:
    140     std::cerr << "prog_snova2: debug: "
    141               << "Run the simulation" << std::endl;
    142132    my_snova_mgr.run_sim(argc,argv,is_Mac_app?"Qt":"");
    143133
    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;
    147136    my_snova_mgr.reset(); // not mandatory for we do it in the d-tor.
    148137
    149     std::cerr << "prog_snova2: debug: "
    150               << "Done" << std::endl;
     138    //std::cerr << "snovis_session :"
     139    //          << " end." << std::endl;
    151140  }
    152141  catch(std::exception & x){
    153     std::cerr << "prog_snova2: error: " << x.what() << std::endl;
     142    std::cerr << "snovis_session : error : " << x.what() << std::endl;
    154143    error_code=EXIT_FAILURE;
    155144  }
    156145  catch(...){
    157     std::cerr << "prog_snova2: error: " << "unexpected error!" << std::endl;
     146    std::cerr << "snovis_session : error : unexpected error!" << std::endl;
    158147    error_code=EXIT_FAILURE;
    159148  }
Note: See TracChangeset for help on using the changeset viewer.