nulook_wrapper Class Reference

#include <neugen3_dummy.h>

List of all members.

Public Member Functions

 nulook_wrapper ()
 ~nulook_wrapper ()
void configure (const neugen_config *conf)
xsec_vs_energyrun (const neugen_inputs *inputs)

Protected Member Functions

void create_neugen_config_card (void) const
void create_neugen_inputs_card (void) const
void run_nulook (void) const
void merge_nulook_output (void) const
const char * path (const char *env_var) const
const char * full_path_to_file (const char *env_var, const char *filename) const
bool file_exists (const char *env_var, const char *filename) const
bool cards_were_created (void) const

Protected Attributes

const neugen_config_current_config
const neugen_inputs_current_inputs

Detailed Description

____________________________________________________________________________

Definition at line 37 of file neugen3_dummy.h.


Constructor & Destructor Documentation

nulook_wrapper::nulook_wrapper (  ) 

Definition at line 27 of file nulook_wrapper.cxx.

00028 {
00029 
00030 }

nulook_wrapper::~nulook_wrapper (  ) 

Definition at line 32 of file nulook_wrapper.cxx.

00033 {
00034 
00035 }


Member Function Documentation

bool nulook_wrapper::cards_were_created ( void   )  const [protected]

Definition at line 146 of file nulook_wrapper.cxx.

References file_exists().

Referenced by run().

00147 {
00148   return file_exists("NEUGEN3PATH","inputs.txt");
00149 }

void nulook_wrapper::configure ( const neugen_config conf  ) 

Definition at line 37 of file nulook_wrapper.cxx.

References _current_config.

00038 {
00039   _current_config = conf;
00040 
00041   cout << "Configuring NuGEN: " << endl;
00042   cout << _current_config << endl;
00043 }

void nulook_wrapper::create_neugen_config_card ( void   )  const [protected]

Definition at line 89 of file nulook_wrapper.cxx.

Referenced by run().

00090 {
00091 // not yet in NeuGEN
00092 }

void nulook_wrapper::create_neugen_inputs_card ( void   )  const [protected]

Definition at line 94 of file nulook_wrapper.cxx.

References _current_inputs, file_exists(), full_path_to_file(), gSystem(), and neugen_inputs::write_neugen_input_card().

Referenced by run().

00095 {
00096   //-- backup the previous card (if one exists)
00097 
00098   if ( file_exists("NEUGEN3PATH","inputs.txt") )
00099             gSystem->Rename( full_path_to_file("NEUGEN3PATH","inputs.txt"),
00100                              full_path_to_file("NEUGEN3PATH","inputs.txt.bak") );
00101 
00102   //-- and create the new one
00103 
00104   _current_inputs->write_neugen_input_card(
00105                               full_path_to_file("NEUGEN3PATH", "inputs.txt"));
00106 }

bool nulook_wrapper::file_exists ( const char *  env_var,
const char *  filename 
) const [protected]

Definition at line 138 of file nulook_wrapper.cxx.

References full_path_to_file(), and gSystem().

Referenced by cards_were_created(), and create_neugen_inputs_card().

00140 {
00141   //-- invert the strange/default definition of TSystem::AccessPathName return
00142 
00143   return !(gSystem->AccessPathName(full_path_to_file(env_var,filename) ));
00144 }

const char * nulook_wrapper::full_path_to_file ( const char *  env_var,
const char *  filename 
) const [protected]

Definition at line 128 of file nulook_wrapper.cxx.

References path().

Referenced by create_neugen_inputs_card(), file_exists(), and run().

00130 {
00131   ostringstream full_path;
00132 
00133   full_path << path(env_var) << "/" << filename;
00134 
00135   return full_path.str().c_str();
00136 }

void nulook_wrapper::merge_nulook_output ( void   )  const [protected]

Definition at line 114 of file nulook_wrapper.cxx.

References gSystem(), and path().

Referenced by run().

00115 {
00116   ostringstream command;
00117 
00118   command << path("VALIDATOR") << "/src/scripts/merge_nulook";
00119 
00120   gSystem->Exec( command.str().c_str() );
00121 }

const char * nulook_wrapper::path ( const char *  env_var  )  const [protected]

Definition at line 123 of file nulook_wrapper.cxx.

References gSystem().

Referenced by full_path_to_file(), merge_nulook_output(), and run_nulook().

00124 {
00125   return gSystem->Getenv(env_var);
00126 }

xsec_vs_energy * nulook_wrapper::run ( const neugen_inputs inputs  ) 

Definition at line 45 of file nulook_wrapper.cxx.

References _current_inputs, cards_were_created(), create_neugen_config_card(), create_neugen_inputs_card(), full_path_to_file(), gSystem(), k_timeout, xsec_vs_energy::load_from_file(), merge_nulook_output(), and run_nulook().

00046 {
00047   _current_inputs = inputs;
00048 
00049   xsec_vs_energy * xsec_e = new xsec_vs_energy();
00050 
00051   //-- create NeuGEN cards
00052   create_neugen_config_card();
00053   create_neugen_inputs_card();
00054 
00055   //-- create a TStopwatch and use it to check whether card creation time
00056   //   exceeds an acceptable time limit...
00057 
00058   TStopwatch timeout_guard;
00059   timeout_guard.Start();
00060 
00061   //-- now wait for cards to be created, but do not lock me in this state -
00062   //   if it does not happen in t < k_timeout, tide up your mess & exit
00063   //   returning a null pointer
00064 
00065   while( ! cards_were_created() ) {
00066 
00067       gSystem->Sleep(100); // wait a little bit
00068 
00069       timeout_guard.Stop();
00070       if( timeout_guard.CpuTime() > k_timeout) {
00071           delete xsec_e;
00072           return 0;
00073        }
00074       timeout_guard.Start(kFALSE); // do not reset the timer
00075   }
00076 
00077   //-- run nulook
00078   run_nulook();
00079 
00080   //-- merge nulook output files
00081   merge_nulook_output();
00082 
00083   //-- load xsec_vs_energy object
00084   xsec_e->load_from_file( full_path_to_file("NEUGEN3PATH", "fort.16_17") );
00085 
00086   return xsec_e;
00087 }

void nulook_wrapper::run_nulook ( void   )  const [protected]

Definition at line 108 of file nulook_wrapper.cxx.

References cd(), gSystem(), and path().

Referenced by run().

00109 {
00110   gSystem -> cd   ( path("NEUGEN3PATH") );
00111   gSystem -> Exec ( "./nulook"          );
00112 }


Member Data Documentation

Definition at line 48 of file nulook_wrapper.h.

Referenced by configure().

Definition at line 49 of file nulook_wrapper.h.

Referenced by create_neugen_inputs_card(), and run().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1