303 #ifdef CEXMC_USE_PERSISTENCY 304 G4bool outputDataOnly(
false );
309 if ( !
parseArgs( argc, argv, cmdLineData ) )
314 #ifdef CEXMC_USE_PERSISTENCY 317 throw CexmcException( CexmcCmdLineParseException );
319 throw CexmcException( CexmcCmdLineParseException );
320 #ifdef CEXMC_USE_CUSTOM_FILTER 322 throw CexmcException( CexmcCmdLineParseException );
325 throw CexmcException( CexmcCmdLineParseException );
326 outputDataOnly = ! cmdLineData.
outputData.empty();
329 catch ( CexmcException &
e )
331 G4cout << e.what() << G4endl;
336 G4cout <<
"Unknown exception caught when parsing args" << G4endl;
340 CexmcRunManager * runManager( NULL );
341 CexmcMessenger::Instance();
343 G4VisManager * visManager( NULL );
345 #ifdef CEXMC_USE_ROOT 346 CexmcHistoManager::Instance();
351 runManager =
new CexmcRunManager( cmdLineData.
wProject,
354 #ifdef CEXMC_USE_PERSISTENCY 355 #ifdef CEXMC_USE_CUSTOM_FILTER 356 runManager->SetCustomFilter( cmdLineData.
customFilter );
359 if ( outputDataOnly )
364 cmdLineData.
outputData.find( CexmcOutputEvents ) );
366 runManager->SetUserInitialization(
367 CexmcChargeExchangePMFactory::
368 Create( CexmcPionZeroProduction ) );
369 runManager->PrintReadData( cmdLineData.
outputData );
375 G4UImanager * uiManager( G4UImanager::GetUIpointer() );
378 uiManager->ApplyCommand(
"/control/execute " +
381 CexmcProductionModelType productionModelType(
382 runManager->GetProductionModelType() );
384 if ( productionModelType == CexmcUnknownProductionModel )
385 throw CexmcException( CexmcPreinitException );
387 G4VUserPhysicsList * physicsList( CexmcChargeExchangePMFactory::
388 Create( productionModelType ) );
389 CexmcPhysicsManager * physicsManager(
390 dynamic_cast< CexmcPhysicsManager * >( physicsList ) );
391 CexmcProductionModel * productionModel(
392 physicsManager->GetProductionModel() );
394 if ( ! productionModel )
395 throw CexmcException( CexmcWeirdException );
397 G4cout << CEXMC_LINE_START <<
"Production model '" <<
398 productionModel->GetName() <<
"' instantiated" << G4endl;
400 runManager->SetUserInitialization( physicsList );
402 CexmcSetup * setup(
new CexmcSetup( runManager->GetGdmlFileName(),
403 runManager->ShouldGdmlFileBeValidated() ) );
405 runManager->SetUserInitialization( setup );
407 runManager->Initialize();
409 runManager->SetPhysicsManager( physicsManager );
411 runManager->SetUserAction(
new CexmcPrimaryGeneratorAction(
414 runManager->SetUserAction(
new CexmcEventAction( physicsManager ) );
416 runManager->SetUserAction(
new CexmcRunAction( physicsManager ) );
418 runManager->SetUserAction(
new CexmcTrackingAction( physicsManager ) );
420 runManager->SetUserAction(
new CexmcSteppingAction( physicsManager ) );
422 #ifdef CEXMC_USE_ROOT 423 CexmcHistoManager::Instance()->Initialize();
429 visManager =
new G4VisExecutive( CexmcVisManagerVerboseLevel );
430 visManager->Initialize();
434 #ifdef CEXMC_USE_PERSISTENCY 435 if ( runManager->ProjectIsRead() )
437 runManager->ReadProject();
438 runManager->PrintReadRunData();
443 uiManager->ApplyCommand(
"/control/execute " +
447 productionModel->PrintInitialData();
456 session =
new G4UIQt( 1, argv );
457 const G4String & guiMacroName( runManager->GetGuiMacroName() );
458 if ( guiMacroName !=
"" )
459 uiManager->ApplyCommand(
"/control/execute " +
461 #ifdef CEXMC_USE_ROOTQT 462 CexmcHistoManager::Instance()->EnableLiveHistograms(
session );
469 session =
new G4UIterminal(
new G4UItcsh );
479 #ifdef CEXMC_USE_PERSISTENCY 480 if ( runManager->ProjectIsSaved() )
481 runManager->SaveProject();
484 catch ( CexmcException & e )
486 G4cout << e.what() << G4endl;
488 #ifdef CEXMC_USE_PERSISTENCY 489 catch ( boost::archive::archive_exception & e )
491 G4cout << CEXMC_LINE_START <<
"Serialization error: " << e.what() <<
494 #ifdef CEXMC_USE_CUSTOM_FILTER 495 catch ( boost::bad_get & e )
497 G4cout << CEXMC_LINE_START <<
"Custom filter error: " << e.what() <<
504 G4cout <<
"Unknown exception caught" << G4endl;
507 #ifdef CEXMC_USE_ROOT 508 CexmcHistoManager::Destroy();
513 CexmcMessenger::Destroy();
static G4UIterminal * session
G4bool overrideExistingProject
CexmcOutputDataTypeSet outputData
G4bool parseArgs(int argc, char **argv, CexmcCmdLineData &cmdLineData)