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