299 #ifdef CEXMC_USE_PERSISTENCY 300 G4bool outputDataOnly(
false );
305 if ( !
parseArgs( argc, argv, cmdLineData ) )
310 #ifdef CEXMC_USE_PERSISTENCY 313 throw CexmcException( CexmcCmdLineParseException );
315 throw CexmcException( CexmcCmdLineParseException );
316 #ifdef CEXMC_USE_CUSTOM_FILTER 318 throw CexmcException( CexmcCmdLineParseException );
321 throw CexmcException( CexmcCmdLineParseException );
322 outputDataOnly = ! cmdLineData.
outputData.empty();
325 catch ( CexmcException &
e )
327 G4cout << e.what() << G4endl;
332 G4cout <<
"Unknown exception caught when parsing args" << G4endl;
336 CexmcRunManager * runManager( NULL );
337 CexmcMessenger::Instance();
339 G4VisManager * visManager( NULL );
341 #ifdef CEXMC_USE_ROOT 342 CexmcHistoManager::Instance();
347 runManager =
new CexmcRunManager( cmdLineData.
wProject,
350 #ifdef CEXMC_USE_PERSISTENCY 351 #ifdef CEXMC_USE_CUSTOM_FILTER 352 runManager->SetCustomFilter( cmdLineData.
customFilter );
355 if ( outputDataOnly )
360 cmdLineData.
outputData.find( CexmcOutputEvents ) );
362 runManager->SetUserInitialization(
363 CexmcChargeExchangePMFactory::
364 Create( CexmcPionZeroProduction ) );
365 runManager->PrintReadData( cmdLineData.
outputData );
371 G4UImanager * uiManager( G4UImanager::GetUIpointer() );
374 uiManager->ApplyCommand(
"/control/execute " +
377 CexmcProductionModelType productionModelType(
378 runManager->GetProductionModelType() );
380 if ( productionModelType == CexmcUnknownProductionModel )
381 throw CexmcException( CexmcPreinitException );
383 G4VUserPhysicsList * physicsList( CexmcChargeExchangePMFactory::
384 Create( productionModelType ) );
385 CexmcPhysicsManager * physicsManager(
386 dynamic_cast< CexmcPhysicsManager * >( physicsList ) );
387 CexmcProductionModel * productionModel(
388 physicsManager->GetProductionModel() );
390 if ( ! productionModel )
391 throw CexmcException( CexmcWeirdException );
393 G4cout << CEXMC_LINE_START <<
"Production model '" <<
394 productionModel->GetName() <<
"' instantiated" << G4endl;
396 runManager->SetUserInitialization( physicsList );
398 CexmcSetup * setup(
new CexmcSetup( runManager->GetGdmlFileName(),
399 runManager->ShouldGdmlFileBeValidated() ) );
401 runManager->SetUserInitialization( setup );
403 runManager->Initialize();
405 runManager->SetPhysicsManager( physicsManager );
407 runManager->SetUserAction(
new CexmcPrimaryGeneratorAction(
410 runManager->SetUserAction(
new CexmcEventAction( physicsManager ) );
412 runManager->SetUserAction(
new CexmcRunAction( physicsManager ) );
414 runManager->SetUserAction(
new CexmcTrackingAction( physicsManager ) );
416 runManager->SetUserAction(
new CexmcSteppingAction( physicsManager ) );
418 #ifdef CEXMC_USE_ROOT 419 CexmcHistoManager::Instance()->Initialize();
425 visManager =
new G4VisExecutive( CexmcVisManagerVerboseLevel );
426 visManager->Initialize();
430 #ifdef CEXMC_USE_PERSISTENCY 431 if ( runManager->ProjectIsRead() )
433 runManager->ReadProject();
434 runManager->PrintReadRunData();
439 uiManager->ApplyCommand(
"/control/execute " +
443 productionModel->PrintInitialData();
452 session =
new G4UIQt( 1, argv );
453 const G4String & guiMacroName( runManager->GetGuiMacroName() );
454 if ( guiMacroName !=
"" )
455 uiManager->ApplyCommand(
"/control/execute " +
457 #ifdef CEXMC_USE_ROOTQT 458 CexmcHistoManager::Instance()->EnableLiveHistograms(
session );
465 session =
new G4UIterminal(
new G4UItcsh );
474 #ifdef CEXMC_USE_PERSISTENCY 475 if ( runManager->ProjectIsSaved() )
476 runManager->SaveProject();
479 catch ( CexmcException & e )
481 G4cout << e.what() << G4endl;
483 #ifdef CEXMC_USE_PERSISTENCY 484 catch ( boost::archive::archive_exception & e )
486 G4cout << CEXMC_LINE_START <<
"Serialization error: " << e.what() <<
489 #ifdef CEXMC_USE_CUSTOM_FILTER 490 catch ( boost::bad_get & e )
492 G4cout << CEXMC_LINE_START <<
"Custom filter error: " << e.what() <<
499 G4cout <<
"Unknown exception caught" << G4endl;
502 #ifdef CEXMC_USE_ROOT 503 CexmcHistoManager::Destroy();
508 CexmcMessenger::Destroy();
static G4UIterminal * session
G4bool overrideExistingProject
CexmcOutputDataTypeSet outputData
G4bool parseArgs(int argc, char **argv, CexmcCmdLineData &cmdLineData)