Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /* 26 /* 27 * =========================================== 27 * ============================================================================= 28 * 28 * 29 * Filename: cexmc.cc 29 * Filename: cexmc.cc 30 * 30 * 31 * Description: main 31 * Description: main 32 * 32 * 33 * Version: 1.0 33 * Version: 1.0 34 * Created: 10.10.2009 23:24:39 34 * Created: 10.10.2009 23:24:39 35 * Revision: none 35 * Revision: none 36 * Compiler: gcc 36 * Compiler: gcc 37 * 37 * 38 * Author: Alexey Radkov (), 38 * Author: Alexey Radkov (), 39 * Company: PNPI 39 * Company: PNPI 40 * 40 * 41 * =========================================== 41 * ============================================================================= 42 */ 42 */ 43 43 44 #include <set> 44 #include <set> 45 #ifdef CEXMC_USE_PERSISTENCY 45 #ifdef CEXMC_USE_PERSISTENCY 46 #include <boost/algorithm/string.hpp> 46 #include <boost/algorithm/string.hpp> 47 #include <boost/archive/archive_exception.hpp> 47 #include <boost/archive/archive_exception.hpp> 48 #ifdef CEXMC_USE_CUSTOM_FILTER 48 #ifdef CEXMC_USE_CUSTOM_FILTER 49 #include <boost/variant/get.hpp> 49 #include <boost/variant/get.hpp> 50 #endif 50 #endif 51 #endif 51 #endif 52 #include <G4UImanager.hh> 52 #include <G4UImanager.hh> 53 #include <G4String.hh> 53 #include <G4String.hh> >> 54 #ifdef G4UI_USE 54 #include <G4UIsession.hh> 55 #include <G4UIsession.hh> 55 #include <G4UIterminal.hh> 56 #include <G4UIterminal.hh> 56 #ifdef G4UI_USE_TCSH 57 #ifdef G4UI_USE_TCSH 57 #include <G4UItcsh.hh> 58 #include <G4UItcsh.hh> 58 #endif 59 #endif 59 #ifdef G4UI_USE_QT 60 #ifdef G4UI_USE_QT 60 #include <G4UIQt.hh> 61 #include <G4UIQt.hh> 61 #endif 62 #endif >> 63 #endif >> 64 #ifdef G4VIS_USE 62 #include <G4VisExecutive.hh> 65 #include <G4VisExecutive.hh> >> 66 #endif 63 #include "CexmcRunManager.hh" 67 #include "CexmcRunManager.hh" 64 #include "CexmcHistoManager.hh" 68 #include "CexmcHistoManager.hh" 65 #include "CexmcSetup.hh" 69 #include "CexmcSetup.hh" 66 #include "CexmcPhysicsList.hh" 70 #include "CexmcPhysicsList.hh" 67 #include "CexmcPhysicsManager.hh" 71 #include "CexmcPhysicsManager.hh" 68 #include "CexmcPrimaryGeneratorAction.hh" 72 #include "CexmcPrimaryGeneratorAction.hh" 69 #include "CexmcTrackingAction.hh" 73 #include "CexmcTrackingAction.hh" 70 #include "CexmcSteppingAction.hh" 74 #include "CexmcSteppingAction.hh" 71 #include "CexmcEventAction.hh" 75 #include "CexmcEventAction.hh" 72 #include "CexmcRunAction.hh" 76 #include "CexmcRunAction.hh" 73 #include "CexmcMessenger.hh" 77 #include "CexmcMessenger.hh" 74 #include "CexmcException.hh" 78 #include "CexmcException.hh" 75 #include "CexmcBasicPhysicsSettings.hh" 79 #include "CexmcBasicPhysicsSettings.hh" 76 #include "CexmcCommon.hh" 80 #include "CexmcCommon.hh" 77 81 78 82 79 namespace 83 namespace 80 { 84 { 81 const G4String CexmcVisManagerVerboseLeve 85 const G4String CexmcVisManagerVerboseLevel( "errors" ); 82 } 86 } 83 87 84 88 85 struct CexmcCmdLineData 89 struct CexmcCmdLineData 86 { 90 { 87 CexmcCmdLineData() : isInteractive( false 91 CexmcCmdLineData() : isInteractive( false ), startQtSession( false ), 88 preinitMacro( "" ), i 92 preinitMacro( "" ), initMacro( "" ), rProject( "" ), 89 wProject( "" ), overr 93 wProject( "" ), overrideExistingProject( false ), 90 customFilter( "" ) 94 customFilter( "" ) 91 {} 95 {} 92 96 93 G4bool isInteractive; 97 G4bool isInteractive; 94 G4bool startQtSession; 98 G4bool startQtSession; 95 G4String preinitMacro; 99 G4String preinitMacro; 96 G4String initMacro; 100 G4String initMacro; 97 G4String rProject; 101 G4String rProject; 98 G4String wProject; 102 G4String wProject; 99 G4bool overrideExistingPr 103 G4bool overrideExistingProject; 100 CexmcOutputDataTypeSet outputData; 104 CexmcOutputDataTypeSet outputData; 101 G4String customFilter; 105 G4String customFilter; 102 }; 106 }; 103 107 104 108 105 void printUsage( void ) 109 void printUsage( void ) 106 { 110 { 107 #ifdef CEXMC_PROG_NAME 111 #ifdef CEXMC_PROG_NAME 108 const char * progName( CEXMC_PROG_NAME ); 112 const char * progName( CEXMC_PROG_NAME ); 109 #else 113 #else 110 const char * progName( "cexmc" ); 114 const char * progName( "cexmc" ); 111 #endif 115 #endif 112 116 113 G4cout << "Usage: " << progName << " [-i] 117 G4cout << "Usage: " << progName << " [-i] " 114 #ifdef G4UI_USE_QT 118 #ifdef G4UI_USE_QT 115 "[-g] " 119 "[-g] " 116 #endif 120 #endif 117 "[-p preinit_macro] 121 "[-p preinit_macro] [-m init_macro] " 118 #ifdef CEXMC_USE_PERSISTENCY 122 #ifdef CEXMC_USE_PERSISTENCY 119 "[[-y] -w project]" 123 "[[-y] -w project]" << G4endl << 120 " [-r project " 124 " [-r project " 121 #ifdef CEXMC_USE_CUSTOM_FILTER 125 #ifdef CEXMC_USE_CUSTOM_FILTER 122 "[-f filter_script] 126 "[-f filter_script] " 123 #endif 127 #endif 124 "[-o list]]" 128 "[-o list]]" 125 #endif 129 #endif 126 << G4endl; 130 << G4endl; 127 G4cout << "or " << progName << " [--he 131 G4cout << "or " << progName << " [--help | -h]" << G4endl; 128 G4cout << " -i - run in interact 132 G4cout << " -i - run in interactive mode" << G4endl; 129 #ifdef G4UI_USE_QT 133 #ifdef G4UI_USE_QT 130 G4cout << " -g - start graphical 134 G4cout << " -g - start graphical interface (Qt), implies " 131 "interactive mod 135 "interactive mode " << G4endl; 132 #endif 136 #endif 133 G4cout << " -p - use specified p 137 G4cout << " -p - use specified preinit macro file " << G4endl; 134 G4cout << " -m - use specified i 138 G4cout << " -m - use specified init macro file " << G4endl; 135 #ifdef CEXMC_USE_PERSISTENCY 139 #ifdef CEXMC_USE_PERSISTENCY 136 G4cout << " -w - save data in sp 140 G4cout << " -w - save data in specified project files" << G4endl; 137 G4cout << " -r - read data from 141 G4cout << " -r - read data from specified project files" << 138 G4endl; 142 G4endl; 139 #ifdef CEXMC_USE_CUSTOM_FILTER 143 #ifdef CEXMC_USE_CUSTOM_FILTER 140 G4cout << " -f - use specified c 144 G4cout << " -f - use specified custom filter script" << G4endl; 141 #endif 145 #endif 142 G4cout << " -o - comma-separated 146 G4cout << " -o - comma-separated list of data to output, " 143 "possible values 147 "possible values:" << G4endl << 144 " run, geom, even 148 " run, geom, events" << G4endl; 145 G4cout << " -y - force project o 149 G4cout << " -y - force project override" << G4endl; 146 #endif 150 #endif 147 G4cout << " --help | -h - print this mess 151 G4cout << " --help | -h - print this message and exit " << G4endl; 148 } 152 } 149 153 150 154 151 G4bool parseArgs( int argc, char ** argv, C 155 G4bool parseArgs( int argc, char ** argv, CexmcCmdLineData & cmdLineData ) 152 { 156 { 153 if ( argc < 2 ) 157 if ( argc < 2 ) 154 return false; 158 return false; 155 159 156 for ( G4int i( 1 ); i < argc; ++i ) 160 for ( G4int i( 1 ); i < argc; ++i ) 157 { 161 { 158 do 162 do 159 { 163 { 160 if ( G4String( argv[ i ] ) == "--h 164 if ( G4String( argv[ i ] ) == "--help" ) 161 { 165 { 162 return false; 166 return false; 163 } 167 } 164 if ( G4String( argv[ i ] ) == "-h" 168 if ( G4String( argv[ i ] ) == "-h" ) 165 { 169 { 166 return false; 170 return false; 167 } 171 } 168 if ( G4String( argv[ i ], 2 ) == " 172 if ( G4String( argv[ i ], 2 ) == "-i" ) 169 { 173 { 170 cmdLineData.isInteractive = tr 174 cmdLineData.isInteractive = true; 171 break; 175 break; 172 } 176 } 173 #ifdef G4UI_USE_QT 177 #ifdef G4UI_USE_QT 174 if ( G4String( argv[ i ], 2 ) == " 178 if ( G4String( argv[ i ], 2 ) == "-g" ) 175 { 179 { 176 cmdLineData.isInteractive = tr 180 cmdLineData.isInteractive = true; 177 cmdLineData.startQtSession = t 181 cmdLineData.startQtSession = true; 178 break; 182 break; 179 } 183 } 180 #endif 184 #endif 181 if ( G4String( argv[ i ], 2 ) == " 185 if ( G4String( argv[ i ], 2 ) == "-p" ) 182 { 186 { 183 cmdLineData.preinitMacro = arg 187 cmdLineData.preinitMacro = argv[ i ] + 2; 184 if ( cmdLineData.preinitMacro 188 if ( cmdLineData.preinitMacro == "" ) 185 { 189 { 186 if ( ++i >= argc ) 190 if ( ++i >= argc ) 187 throw CexmcException( 191 throw CexmcException( CexmcCmdLineParseException ); 188 cmdLineData.preinitMacro = 192 cmdLineData.preinitMacro = argv[ i ]; 189 } 193 } 190 break; 194 break; 191 } 195 } 192 if ( G4String( argv[ i ], 2 ) == " 196 if ( G4String( argv[ i ], 2 ) == "-m" ) 193 { 197 { 194 cmdLineData.initMacro = argv[ 198 cmdLineData.initMacro = argv[ i ] + 2; 195 if ( cmdLineData.initMacro == 199 if ( cmdLineData.initMacro == "" ) 196 { 200 { 197 if ( ++i >= argc ) 201 if ( ++i >= argc ) 198 throw CexmcException( 202 throw CexmcException( CexmcCmdLineParseException ); 199 cmdLineData.initMacro = ar 203 cmdLineData.initMacro = argv[ i ]; 200 } 204 } 201 break; 205 break; 202 } 206 } 203 #ifdef CEXMC_USE_PERSISTENCY 207 #ifdef CEXMC_USE_PERSISTENCY 204 if ( G4String( argv[ i ], 2 ) == " 208 if ( G4String( argv[ i ], 2 ) == "-w" ) 205 { 209 { 206 cmdLineData.wProject = argv[ i 210 cmdLineData.wProject = argv[ i ] + 2; 207 if ( cmdLineData.wProject == " 211 if ( cmdLineData.wProject == "" ) 208 { 212 { 209 if ( ++i >= argc ) 213 if ( ++i >= argc ) 210 throw CexmcException( 214 throw CexmcException( CexmcCmdLineParseException ); 211 cmdLineData.wProject = arg 215 cmdLineData.wProject = argv[ i ]; 212 } 216 } 213 break; 217 break; 214 } 218 } 215 if ( G4String( argv[ i ], 2 ) == " 219 if ( G4String( argv[ i ], 2 ) == "-r" ) 216 { 220 { 217 cmdLineData.rProject = argv[ i 221 cmdLineData.rProject = argv[ i ] + 2; 218 if ( cmdLineData.rProject == " 222 if ( cmdLineData.rProject == "" ) 219 { 223 { 220 if ( ++i >= argc ) 224 if ( ++i >= argc ) 221 throw CexmcException( 225 throw CexmcException( CexmcCmdLineParseException ); 222 cmdLineData.rProject = arg 226 cmdLineData.rProject = argv[ i ]; 223 } 227 } 224 break; 228 break; 225 } 229 } 226 if ( G4String( argv[ i ], 2 ) == " 230 if ( G4String( argv[ i ], 2 ) == "-y" ) 227 { 231 { 228 cmdLineData.overrideExistingPr 232 cmdLineData.overrideExistingProject = true; 229 break; 233 break; 230 } 234 } 231 if ( G4String( argv[ i ], 2 ) == " 235 if ( G4String( argv[ i ], 2 ) == "-o" ) 232 { 236 { 233 std::string outputData( argv[ 237 std::string outputData( argv[ i ] + 2 ); 234 if ( outputData == "" ) 238 if ( outputData == "" ) 235 { 239 { 236 if ( ++i >= argc ) 240 if ( ++i >= argc ) 237 throw CexmcException( 241 throw CexmcException( CexmcCmdLineParseException ); 238 outputData = argv[ i ]; 242 outputData = argv[ i ]; 239 } 243 } 240 std::set< std::string > token 244 std::set< std::string > tokens; 241 boost::split( tokens, outputDa 245 boost::split( tokens, outputData, boost::is_any_of( "," ) ); 242 for ( std::set< std::string >: 246 for ( std::set< std::string >::iterator k( tokens.begin() ); 243 247 k != tokens.end(); ++k ) 244 { 248 { 245 do 249 do 246 { 250 { 247 if ( *k == "run" ) 251 if ( *k == "run" ) 248 { 252 { 249 cmdLineData.output 253 cmdLineData.outputData.insert( CexmcOutputRun ); 250 break; 254 break; 251 } 255 } 252 if ( *k == "geom" ) 256 if ( *k == "geom" ) 253 { 257 { 254 cmdLineData.output 258 cmdLineData.outputData.insert( 255 259 CexmcOutputGeometry ); 256 break; 260 break; 257 } 261 } 258 if ( *k == "events" ) 262 if ( *k == "events" ) 259 { 263 { 260 cmdLineData.output 264 cmdLineData.outputData.insert( CexmcOutputEvents ); 261 break; 265 break; 262 } 266 } 263 throw CexmcException( 267 throw CexmcException( CexmcCmdLineParseException ); 264 } while ( false ); 268 } while ( false ); 265 } 269 } 266 break; 270 break; 267 } 271 } 268 #ifdef CEXMC_USE_CUSTOM_FILTER 272 #ifdef CEXMC_USE_CUSTOM_FILTER 269 if ( G4String( argv[ i ], 2 ) == " 273 if ( G4String( argv[ i ], 2 ) == "-f" ) 270 { 274 { 271 cmdLineData.customFilter = arg 275 cmdLineData.customFilter = argv[ i ] + 2; 272 if ( cmdLineData.customFilter 276 if ( cmdLineData.customFilter == "" ) 273 { 277 { 274 if ( ++i >= argc ) 278 if ( ++i >= argc ) 275 throw CexmcException( 279 throw CexmcException( CexmcCmdLineParseException ); 276 cmdLineData.customFilter = 280 cmdLineData.customFilter = argv[ i ]; 277 } 281 } 278 break; 282 break; 279 } 283 } 280 #endif 284 #endif 281 #endif 285 #endif 282 286 283 throw CexmcException( CexmcCmdLine 287 throw CexmcException( CexmcCmdLineParseException ); 284 288 285 } while ( false ); 289 } while ( false ); 286 } 290 } 287 291 288 return true; 292 return true; 289 } 293 } 290 294 291 295 292 int main( int argc, char ** argv ) 296 int main( int argc, char ** argv ) 293 { 297 { 294 << 298 #ifdef G4UI_USE 295 G4UIsession * session( NULL ); 299 G4UIsession * session( NULL ); 296 << 300 #endif 297 301 298 CexmcCmdLineData cmdLineData; 302 CexmcCmdLineData cmdLineData; 299 #ifdef CEXMC_USE_PERSISTENCY 303 #ifdef CEXMC_USE_PERSISTENCY 300 G4bool outputDataOnly( false ); 304 G4bool outputDataOnly( false ); 301 #endif 305 #endif 302 306 303 try 307 try 304 { 308 { 305 if ( ! parseArgs( argc, argv, cmdLineD 309 if ( ! parseArgs( argc, argv, cmdLineData ) ) 306 { 310 { 307 printUsage(); 311 printUsage(); 308 return 0; 312 return 0; 309 } 313 } 310 #ifdef CEXMC_USE_PERSISTENCY 314 #ifdef CEXMC_USE_PERSISTENCY 311 if ( cmdLineData.rProject != "" && 315 if ( cmdLineData.rProject != "" && 312 cmdLineData.rProject == cmdLineDa 316 cmdLineData.rProject == cmdLineData.wProject ) 313 throw CexmcException( CexmcCmdLine 317 throw CexmcException( CexmcCmdLineParseException ); 314 if ( cmdLineData.rProject == "" && ! c 318 if ( cmdLineData.rProject == "" && ! cmdLineData.outputData.empty() ) 315 throw CexmcException( CexmcCmdLine 319 throw CexmcException( CexmcCmdLineParseException ); 316 #ifdef CEXMC_USE_CUSTOM_FILTER 320 #ifdef CEXMC_USE_CUSTOM_FILTER 317 if ( cmdLineData.rProject == "" && ! c 321 if ( cmdLineData.rProject == "" && ! cmdLineData.customFilter.empty() ) 318 throw CexmcException( CexmcCmdLine 322 throw CexmcException( CexmcCmdLineParseException ); 319 #endif 323 #endif 320 if ( cmdLineData.wProject != "" && ! c 324 if ( cmdLineData.wProject != "" && ! cmdLineData.outputData.empty() ) 321 throw CexmcException( CexmcCmdLine 325 throw CexmcException( CexmcCmdLineParseException ); 322 outputDataOnly = ! cmdLineData.outputD 326 outputDataOnly = ! cmdLineData.outputData.empty(); 323 #endif 327 #endif 324 } 328 } 325 catch ( CexmcException & e ) 329 catch ( CexmcException & e ) 326 { 330 { 327 G4cout << e.what() << G4endl; 331 G4cout << e.what() << G4endl; 328 return 1; 332 return 1; 329 } 333 } 330 catch ( ... ) 334 catch ( ... ) 331 { 335 { 332 G4cout << "Unknown exception caught wh 336 G4cout << "Unknown exception caught when parsing args" << G4endl; 333 return 1; 337 return 1; 334 } 338 } 335 339 336 CexmcRunManager * runManager( NULL ); 340 CexmcRunManager * runManager( NULL ); 337 CexmcMessenger::Instance(); 341 CexmcMessenger::Instance(); 338 << 342 #ifdef G4VIS_USE 339 G4VisManager * visManager( NULL ); 343 G4VisManager * visManager( NULL ); 340 << 344 #endif 341 #ifdef CEXMC_USE_ROOT 345 #ifdef CEXMC_USE_ROOT 342 CexmcHistoManager::Instance(); 346 CexmcHistoManager::Instance(); 343 #endif 347 #endif 344 348 345 try 349 try 346 { 350 { 347 runManager = new CexmcRunManager( cmdL 351 runManager = new CexmcRunManager( cmdLineData.wProject, 348 cmdL 352 cmdLineData.rProject, 349 cmdL 353 cmdLineData.overrideExistingProject ); 350 #ifdef CEXMC_USE_PERSISTENCY 354 #ifdef CEXMC_USE_PERSISTENCY 351 #ifdef CEXMC_USE_CUSTOM_FILTER 355 #ifdef CEXMC_USE_CUSTOM_FILTER 352 runManager->SetCustomFilter( cmdLineDa 356 runManager->SetCustomFilter( cmdLineData.customFilter ); 353 #endif 357 #endif 354 358 355 if ( outputDataOnly ) 359 if ( outputDataOnly ) 356 { 360 { 357 /* we will need an arbitrary physi 361 /* we will need an arbitrary physics list to get access to particle 358 * table if events output was orde 362 * table if events output was ordered */ 359 CexmcOutputDataTypeSet::const_iter 363 CexmcOutputDataTypeSet::const_iterator found( 360 cmdLineData.output 364 cmdLineData.outputData.find( CexmcOutputEvents ) ); 361 if ( found != cmdLineData.outputDa 365 if ( found != cmdLineData.outputData.end() ) 362 runManager->SetUserInitializat 366 runManager->SetUserInitialization( 363 CexmcChargeExc 367 CexmcChargeExchangePMFactory:: 364 Cr 368 Create( CexmcPionZeroProduction ) ); 365 runManager->PrintReadData( cmdLine 369 runManager->PrintReadData( cmdLineData.outputData ); 366 delete runManager; 370 delete runManager; 367 return 0; 371 return 0; 368 } 372 } 369 #endif 373 #endif 370 374 371 G4UImanager * uiManager( G4UImanager: 375 G4UImanager * uiManager( G4UImanager::GetUIpointer() ); 372 376 373 if ( cmdLineData.preinitMacro != "" ) 377 if ( cmdLineData.preinitMacro != "" ) 374 uiManager->ApplyCommand( "/control 378 uiManager->ApplyCommand( "/control/execute " + 375 cmdLineDa 379 cmdLineData.preinitMacro ); 376 380 377 CexmcProductionModelType productionMo 381 CexmcProductionModelType productionModelType( 378 runMan 382 runManager->GetProductionModelType() ); 379 383 380 if ( productionModelType == CexmcUnkno 384 if ( productionModelType == CexmcUnknownProductionModel ) 381 throw CexmcException( CexmcPreinit 385 throw CexmcException( CexmcPreinitException ); 382 386 383 G4VUserPhysicsList * physicsList( C 387 G4VUserPhysicsList * physicsList( CexmcChargeExchangePMFactory:: 384 388 Create( productionModelType ) ); 385 CexmcPhysicsManager * physicsManager 389 CexmcPhysicsManager * physicsManager( 386 dynamic_cast< CexmcPhy 390 dynamic_cast< CexmcPhysicsManager * >( physicsList ) ); 387 CexmcProductionModel * productionMode 391 CexmcProductionModel * productionModel( 388 physic 392 physicsManager->GetProductionModel() ); 389 393 390 if ( ! productionModel ) 394 if ( ! productionModel ) 391 throw CexmcException( CexmcWeirdEx 395 throw CexmcException( CexmcWeirdException ); 392 396 393 G4cout << CEXMC_LINE_START << "Product 397 G4cout << CEXMC_LINE_START << "Production model '" << 394 productionModel->GetName() << 398 productionModel->GetName() << "' instantiated" << G4endl; 395 399 396 runManager->SetUserInitialization( phy 400 runManager->SetUserInitialization( physicsList ); 397 401 398 CexmcSetup * setup( new CexmcSetup( 402 CexmcSetup * setup( new CexmcSetup( runManager->GetGdmlFileName(), 399 runManager 403 runManager->ShouldGdmlFileBeValidated() ) ); 400 404 401 runManager->SetUserInitialization( set 405 runManager->SetUserInitialization( setup ); 402 406 403 runManager->Initialize(); 407 runManager->Initialize(); 404 408 405 runManager->SetPhysicsManager( physics 409 runManager->SetPhysicsManager( physicsManager ); 406 410 407 runManager->SetUserAction( new CexmcPr 411 runManager->SetUserAction( new CexmcPrimaryGeneratorAction( 408 412 physicsManager ) ); 409 413 410 runManager->SetUserAction( new CexmcEv 414 runManager->SetUserAction( new CexmcEventAction( physicsManager ) ); 411 415 412 runManager->SetUserAction( new CexmcRu 416 runManager->SetUserAction( new CexmcRunAction( physicsManager ) ); 413 417 414 runManager->SetUserAction( new CexmcTr 418 runManager->SetUserAction( new CexmcTrackingAction( physicsManager ) ); 415 419 416 runManager->SetUserAction( new CexmcSt 420 runManager->SetUserAction( new CexmcSteppingAction( physicsManager ) ); 417 421 418 #ifdef CEXMC_USE_ROOT 422 #ifdef CEXMC_USE_ROOT 419 CexmcHistoManager::Instance()->Initial 423 CexmcHistoManager::Instance()->Initialize(); 420 #endif 424 #endif 421 425 422 << 426 #ifdef G4VIS_USE 423 if ( cmdLineData.isInteractive ) 427 if ( cmdLineData.isInteractive ) 424 { 428 { 425 visManager = new G4VisExecutive( C 429 visManager = new G4VisExecutive( CexmcVisManagerVerboseLevel ); 426 visManager->Initialize(); 430 visManager->Initialize(); 427 } 431 } 428 << 432 #endif 429 433 430 #ifdef CEXMC_USE_PERSISTENCY 434 #ifdef CEXMC_USE_PERSISTENCY 431 if ( runManager->ProjectIsRead() ) 435 if ( runManager->ProjectIsRead() ) 432 { 436 { 433 runManager->ReadProject(); 437 runManager->ReadProject(); 434 runManager->PrintReadRunData(); 438 runManager->PrintReadRunData(); 435 } 439 } 436 #endif 440 #endif 437 441 438 if ( cmdLineData.initMacro != "" ) 442 if ( cmdLineData.initMacro != "" ) 439 uiManager->ApplyCommand( "/control 443 uiManager->ApplyCommand( "/control/execute " + 440 cmdLineDa 444 cmdLineData.initMacro ); 441 445 442 if ( cmdLineData.isInteractive ) 446 if ( cmdLineData.isInteractive ) 443 productionModel->PrintInitialData( 447 productionModel->PrintInitialData(); 444 448 445 << 449 #ifdef G4UI_USE 446 if ( cmdLineData.isInteractive ) 450 if ( cmdLineData.isInteractive ) 447 { 451 { 448 if ( cmdLineData.startQtSession ) 452 if ( cmdLineData.startQtSession ) 449 { 453 { 450 #ifdef G4UI_USE_QT 454 #ifdef G4UI_USE_QT 451 /* no need to pass all command 455 /* no need to pass all command line options to QApplication */ 452 session = new G4UIQt( 1, argv 456 session = new G4UIQt( 1, argv ); 453 const G4String & guiMacroName 457 const G4String & guiMacroName( runManager->GetGuiMacroName() ); 454 if ( guiMacroName != "" ) 458 if ( guiMacroName != "" ) 455 uiManager->ApplyCommand( " 459 uiManager->ApplyCommand( "/control/execute " + 456 g 460 guiMacroName ); 457 #ifdef CEXMC_USE_ROOTQT 461 #ifdef CEXMC_USE_ROOTQT 458 CexmcHistoManager::Instance()- 462 CexmcHistoManager::Instance()->EnableLiveHistograms( session ); 459 #endif 463 #endif 460 #endif 464 #endif 461 } 465 } 462 else 466 else 463 { 467 { 464 #ifdef G4UI_USE_TCSH 468 #ifdef G4UI_USE_TCSH 465 session = new G4UIterminal( ne 469 session = new G4UIterminal( new G4UItcsh ); 466 #else 470 #else 467 session = new G4UIterminal; 471 session = new G4UIterminal; 468 #endif 472 #endif 469 } 473 } 470 if ( session ) 474 if ( session ) 471 session->SessionStart(); 475 session->SessionStart(); 472 } 476 } >> 477 #endif 473 478 474 #ifdef CEXMC_USE_PERSISTENCY 479 #ifdef CEXMC_USE_PERSISTENCY 475 if ( runManager->ProjectIsSaved() ) 480 if ( runManager->ProjectIsSaved() ) 476 runManager->SaveProject(); 481 runManager->SaveProject(); 477 #endif 482 #endif 478 } 483 } 479 catch ( CexmcException & e ) 484 catch ( CexmcException & e ) 480 { 485 { 481 G4cout << e.what() << G4endl; 486 G4cout << e.what() << G4endl; 482 } 487 } 483 #ifdef CEXMC_USE_PERSISTENCY 488 #ifdef CEXMC_USE_PERSISTENCY 484 catch ( boost::archive::archive_exception 489 catch ( boost::archive::archive_exception & e ) 485 { 490 { 486 G4cout << CEXMC_LINE_START << "Seriali 491 G4cout << CEXMC_LINE_START << "Serialization error: " << e.what() << 487 G4endl; 492 G4endl; 488 } 493 } 489 #ifdef CEXMC_USE_CUSTOM_FILTER 494 #ifdef CEXMC_USE_CUSTOM_FILTER 490 catch ( boost::bad_get & e ) 495 catch ( boost::bad_get & e ) 491 { 496 { 492 G4cout << CEXMC_LINE_START << "Custom 497 G4cout << CEXMC_LINE_START << "Custom filter error: " << e.what() << 493 G4endl; 498 G4endl; 494 } 499 } 495 #endif 500 #endif 496 #endif 501 #endif 497 catch ( ... ) 502 catch ( ... ) 498 { 503 { 499 G4cout << "Unknown exception caught" < 504 G4cout << "Unknown exception caught" << G4endl; 500 } 505 } 501 506 502 #ifdef CEXMC_USE_ROOT 507 #ifdef CEXMC_USE_ROOT 503 CexmcHistoManager::Destroy(); 508 CexmcHistoManager::Destroy(); 504 #endif 509 #endif 505 << 510 #ifdef G4VIS_USE 506 CexmcMessenger::Destroy(); << 507 << 508 delete session; << 509 delete visManager; 511 delete visManager; >> 512 #endif >> 513 CexmcMessenger::Destroy(); 510 delete runManager; 514 delete runManager; >> 515 #ifdef G4UI_USE >> 516 delete session; >> 517 #endif 511 518 512 return 0; 519 return 0; 513 } 520 } 514 521 515 522