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> 85 const G4String CexmcVisManagerVerboseLevel(
"errors" );
111 #ifdef CEXMC_PROG_NAME 112 const char * progName( CEXMC_PROG_NAME );
114 const char * progName(
"cexmc" );
117 G4cout <<
"Usage: " << progName <<
" [-i] " 121 "[-p preinit_macro] [-m init_macro] " 122 #ifdef CEXMC_USE_PERSISTENCY 123 "[[-y] -w project]" <<
G4endl <<
125 #ifdef CEXMC_USE_CUSTOM_FILTER 126 "[-f filter_script] " 131 G4cout <<
"or " << progName <<
" [--help | -h]" <<
G4endl;
134 G4cout <<
" -g - start graphical interface (Qt), implies " 135 "interactive mode " <<
G4endl;
137 G4cout <<
" -p - use specified preinit macro file " <<
G4endl;
138 G4cout <<
" -m - use specified init macro file " <<
G4endl;
139 #ifdef CEXMC_USE_PERSISTENCY 140 G4cout <<
" -w - save data in specified project files" <<
G4endl;
141 G4cout <<
" -r - read data from specified project files" <<
143 #ifdef CEXMC_USE_CUSTOM_FILTER 144 G4cout <<
" -f - use specified custom filter script" <<
G4endl;
146 G4cout <<
" -o - comma-separated list of data to output, " 147 "possible values:" << G4endl <<
148 " run, geom, events" <<
G4endl;
151 G4cout <<
" --help | -h - print this message and exit " <<
G4endl;
160 for (
G4int i( 1 ); i < argc; ++i )
164 if (
G4String( argv[ i ] ) ==
"--help" )
168 if (
G4String( argv[ i ] ) ==
"-h" )
172 if (
G4String( argv[ i ], 2 ) ==
"-i" )
178 if (
G4String( argv[ i ], 2 ) ==
"-g" )
185 if (
G4String( argv[ i ], 2 ) ==
"-p" )
196 if (
G4String( argv[ i ], 2 ) ==
"-m" )
207 #ifdef CEXMC_USE_PERSISTENCY 208 if (
G4String( argv[ i ], 2 ) ==
"-w" )
210 cmdLineData.
wProject = argv[ i ] + 2;
219 if (
G4String( argv[ i ], 2 ) ==
"-r" )
221 cmdLineData.
rProject = argv[ i ] + 2;
230 if (
G4String( argv[ i ], 2 ) ==
"-y" )
235 if (
G4String( argv[ i ], 2 ) ==
"-o" )
238 if ( outputData ==
"" )
242 outputData = argv[ i ];
244 std::set< std::string > tokens;
245 boost::split( tokens, outputData, boost::is_any_of(
"," ) );
246 for ( std::set< std::string >::iterator k( tokens.begin() );
247 k != tokens.end(); ++k )
262 if ( *k ==
"events" )
272 #ifdef CEXMC_USE_CUSTOM_FILTER 273 if (
G4String( argv[ i ], 2 ) ==
"-f" )
296 int main(
int argc,
char ** argv )
303 #ifdef CEXMC_USE_PERSISTENCY 304 G4bool outputDataOnly(
false );
309 if ( !
parseArgs( argc, argv, cmdLineData ) )
314 #ifdef CEXMC_USE_PERSISTENCY 320 #ifdef CEXMC_USE_CUSTOM_FILTER 326 outputDataOnly = ! cmdLineData.
outputData.empty();
336 G4cout <<
"Unknown exception caught when parsing args" <<
G4endl;
345 #ifdef CEXMC_USE_ROOT 346 CexmcHistoManager::Instance();
354 #ifdef CEXMC_USE_PERSISTENCY 355 #ifdef CEXMC_USE_CUSTOM_FILTER 356 runManager->SetCustomFilter( cmdLineData.
customFilter );
359 if ( outputDataOnly )
363 CexmcOutputDataTypeSet::const_iterator found(
369 runManager->PrintReadData( cmdLineData.
outputData );
388 Create( productionModelType ) );
390 dynamic_cast< CexmcPhysicsManager * >( physicsList ) );
394 if ( ! productionModel )
398 productionModel->GetName() <<
"' instantiated" <<
G4endl;
422 #ifdef CEXMC_USE_ROOT 423 CexmcHistoManager::Instance()->Initialize();
434 #ifdef CEXMC_USE_PERSISTENCY 437 runManager->ReadProject();
438 runManager->PrintReadRunData();
447 productionModel->PrintInitialData();
456 session =
new G4UIQt( 1, argv );
458 if ( guiMacroName !=
"" )
461 #ifdef CEXMC_USE_ROOTQT 462 CexmcHistoManager::Instance()->EnableLiveHistograms( session );
479 #ifdef CEXMC_USE_PERSISTENCY 481 runManager->SaveProject();
488 #ifdef CEXMC_USE_PERSISTENCY 489 catch ( boost::archive::archive_exception & e )
494 #ifdef CEXMC_USE_CUSTOM_FILTER 495 catch ( boost::bad_get & e )
507 #ifdef CEXMC_USE_ROOT 508 CexmcHistoManager::Destroy();
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
const char * what(void) const
void SetPhysicsManager(CexmcPhysicsManager *physicsManager_)
G4String GetGuiMacroName(void) const
G4bool ProjectIsRead(void) const
G4bool ShouldGdmlFileBeValidated(void) const
CexmcProductionModelType GetProductionModelType(void) const
static void Destroy(void)
CexmcOutputDataTypeSet outputData
virtual G4UIsession * SessionStart()
G4bool overrideExistingProject
G4bool ProjectIsSaved(void) const
static G4UImanager * GetUIpointer()
G4GLOB_DLL std::ostream G4cout
int main(int argc, char **argv)
static G4UIterminal * session
G4String GetGdmlFileName(void) const
G4bool parseArgs(int argc, char **argv, CexmcCmdLineData &cmdLineData)
virtual void Initialize()
std::set< CexmcOutputDataType > CexmcOutputDataTypeSet
virtual CexmcProductionModel * GetProductionModel(void)=0
static CexmcMessenger * Instance(void)
G4int ApplyCommand(const char *aCommand)
virtual void SetUserAction(G4UserRunAction *userAction)