45 #ifdef CEXMC_USE_PERSISTENCY
46 #include <boost/algorithm/string.hpp>
47 #include <boost/archive/archive_exception.hpp>
48 #ifdef CEXMC_USE_CUSTOM_FILTER
49 #include <boost/variant/get.hpp>
53 #include <G4String.hh>
81 const G4String CexmcVisManagerVerboseLevel(
"errors" );
107 #ifdef CEXMC_PROG_NAME
108 const char * progName( CEXMC_PROG_NAME );
110 const char * progName(
"cexmc" );
113 G4cout <<
"Usage: " << progName <<
" [-i] "
117 "[-p preinit_macro] [-m init_macro] "
118 #ifdef CEXMC_USE_PERSISTENCY
119 "[[-y] -w project]" <<
G4endl <<
121 #ifdef CEXMC_USE_CUSTOM_FILTER
122 "[-f filter_script] "
127 G4cout <<
"or " << progName <<
" [--help | -h]" <<
G4endl;
130 G4cout <<
" -g - start graphical interface (Qt), implies "
131 "interactive mode " <<
G4endl;
133 G4cout <<
" -p - use specified preinit macro file " <<
G4endl;
134 G4cout <<
" -m - use specified init macro file " <<
G4endl;
135 #ifdef CEXMC_USE_PERSISTENCY
136 G4cout <<
" -w - save data in specified project files" <<
G4endl;
137 G4cout <<
" -r - read data from specified project files" <<
139 #ifdef CEXMC_USE_CUSTOM_FILTER
140 G4cout <<
" -f - use specified custom filter script" <<
G4endl;
142 G4cout <<
" -o - comma-separated list of data to output, "
143 "possible values:" << G4endl <<
144 " run, geom, events" <<
G4endl;
147 G4cout <<
" --help | -h - print this message and exit " <<
G4endl;
156 for (
G4int i( 1 ); i < argc; ++i )
160 if (
G4String( argv[ i ] ) ==
"--help" )
164 if (
G4String( argv[ i ] ) ==
"-h" )
168 if (
G4String( argv[ i ], 2 ) ==
"-i" )
174 if (
G4String( argv[ i ], 2 ) ==
"-g" )
181 if (
G4String( argv[ i ], 2 ) ==
"-p" )
192 if (
G4String( argv[ i ], 2 ) ==
"-m" )
203 #ifdef CEXMC_USE_PERSISTENCY
204 if (
G4String( argv[ i ], 2 ) ==
"-w" )
206 cmdLineData.
wProject = argv[ i ] + 2;
215 if (
G4String( argv[ i ], 2 ) ==
"-r" )
217 cmdLineData.
rProject = argv[ i ] + 2;
226 if (
G4String( argv[ i ], 2 ) ==
"-y" )
231 if (
G4String( argv[ i ], 2 ) ==
"-o" )
233 std::string outputData( argv[ i ] + 2 );
234 if ( outputData ==
"" )
238 outputData = argv[ i ];
240 std::set< std::string > tokens;
241 boost::split( tokens, outputData, boost::is_any_of(
"," ) );
242 for ( std::set< std::string >::iterator
k( tokens.begin() );
243 k != tokens.end(); ++
k )
258 if ( *
k ==
"events" )
268 #ifdef CEXMC_USE_CUSTOM_FILTER
269 if (
G4String( argv[ i ], 2 ) ==
"-f" )
292 int main(
int argc,
char ** argv )
299 #ifdef CEXMC_USE_PERSISTENCY
300 G4bool outputDataOnly(
false );
305 if ( !
parseArgs( argc, argv, cmdLineData ) )
310 #ifdef CEXMC_USE_PERSISTENCY
316 #ifdef CEXMC_USE_CUSTOM_FILTER
322 outputDataOnly = ! cmdLineData.
outputData.empty();
332 G4cout <<
"Unknown exception caught when parsing args" <<
G4endl;
341 #ifdef CEXMC_USE_ROOT
342 CexmcHistoManager::Instance();
350 #ifdef CEXMC_USE_PERSISTENCY
351 #ifdef CEXMC_USE_CUSTOM_FILTER
352 runManager->SetCustomFilter( cmdLineData.
customFilter );
355 if ( outputDataOnly )
359 CexmcOutputDataTypeSet::const_iterator found(
365 runManager->PrintReadData( cmdLineData.
outputData );
384 Create( productionModelType ) );
386 dynamic_cast< CexmcPhysicsManager * >( physicsList ) );
390 if ( ! productionModel )
394 productionModel->GetName() <<
"' instantiated" <<
G4endl;
418 #ifdef CEXMC_USE_ROOT
419 CexmcHistoManager::Instance()->Initialize();
430 #ifdef CEXMC_USE_PERSISTENCY
433 runManager->ReadProject();
434 runManager->PrintReadRunData();
443 productionModel->PrintInitialData();
452 session =
new G4UIQt( 1, argv );
454 if ( guiMacroName !=
"" )
457 #ifdef CEXMC_USE_ROOTQT
458 CexmcHistoManager::Instance()->EnableLiveHistograms( session );
474 #ifdef CEXMC_USE_PERSISTENCY
476 runManager->SaveProject();
483 #ifdef CEXMC_USE_PERSISTENCY
484 catch ( boost::archive::archive_exception & e )
489 #ifdef CEXMC_USE_CUSTOM_FILTER
490 catch ( boost::bad_get & e )
502 #ifdef CEXMC_USE_ROOT
503 CexmcHistoManager::Destroy();