Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // 23 // 27 // ------------------------------------------- 24 // -------------------------------------------------------------- 28 // GEANT 4 - ULTRA experiment 25 // GEANT 4 - ULTRA experiment example 29 // ------------------------------------------- 26 // -------------------------------------------------------------- 30 // 27 // 31 // Code developed by: 28 // Code developed by: 32 // B. Tome, M.C. Espirito-Santo 29 // B. Tome, M.C. Espirito-Santo 33 // 30 // 34 // ***************************************** 31 // ******************************************************* 35 // * Ultra.cc 32 // * Ultra.cc 36 // ***************************************** 33 // ******************************************************* 37 34 38 #include "G4Types.hh" << 35 39 #include "G4RunManagerFactory.hh" << 36 #include "G4RunManager.hh" 40 #include "G4UImanager.hh" 37 #include "G4UImanager.hh" >> 38 #include "G4UIterminal.hh" >> 39 >> 40 #ifdef G4UI_USE_XM >> 41 #include "G4UIXm.hh" >> 42 #endif >> 43 41 #include "Randomize.hh" 44 #include "Randomize.hh" 42 45 >> 46 #ifdef G4VIS_USE 43 #include "G4VisExecutive.hh" 47 #include "G4VisExecutive.hh" 44 #include "G4UIExecutive.hh" << 48 #endif 45 49 46 #include "UltraActionInitializer.hh" << 50 #include "UltraRunAction.hh" 47 #include "UltraDetectorConstruction.hh" 51 #include "UltraDetectorConstruction.hh" >> 52 #include "UltraPrimaryGeneratorAction.hh" 48 #include "UltraPhysicsList.hh" 53 #include "UltraPhysicsList.hh" 49 << 54 #include "UltraEventAction.hh" >> 55 //#include "CLHEP/Random/RanluxEngine.h" 50 56 51 int main(int argc,char** argv) { 57 int main(int argc,char** argv) { 52 58 53 //choose the Random engine from CLHEP << 59 //choose the Random engine from CLHEP 54 //(lets use C++ implementation of Jame's RANLU 60 //(lets use C++ implementation of Jame's RANLUX generator) 55 << 61 56 G4Random::setTheEngine(new CLHEP::RanluxEngi << 62 CLHEP::HepRandom::setTheEngine(new CLHEP::RanluxEngine); 57 << 63 G4RunManager* runManager = new G4RunManager; 58 auto* runManager = G4RunManagerFactory::Crea << 59 G4int nThreads = 4; << 60 runManager->SetNumberOfThreads(nThreads); << 61 64 62 // UserInitialization classes - mandatory 65 // UserInitialization classes - mandatory 63 runManager->SetUserInitialization(new UltraD << 66 UltraDetectorConstruction* detector = new UltraDetectorConstruction; 64 runManager->SetUserInitialization(new UltraP << 67 UltraPhysicsList* list = new UltraPhysicsList(); >> 68 runManager->SetUserInitialization(detector); >> 69 runManager->SetUserInitialization(list); 65 70 66 // UserAction classes - optional 71 // UserAction classes - optional 67 runManager->SetUserInitialization(new UltraA << 72 UltraPrimaryGeneratorAction* PrimGenAct = new UltraPrimaryGeneratorAction(); 68 << 73 runManager->SetUserAction(PrimGenAct); 69 // Detect interactive mode (if no arguments) << 74 UltraRunAction* RunAct = new UltraRunAction(); 70 G4UIExecutive* ui = 0; << 75 runManager->SetUserAction(RunAct); 71 if ( argc == 1 ) { << 76 UltraEventAction* EvAct = new UltraEventAction(RunAct); 72 ui = new G4UIExecutive(argc, argv); << 77 runManager->SetUserAction(EvAct); 73 } << 78 74 << 79 #ifdef G4VIS_USE 75 // Initialise visualization << 80 // Visualization, if you choose to have it! 76 auto* visManager = new G4VisExecutive; << 81 G4VisManager* visManager = new G4VisExecutive; 77 visManager->Initialize(); 82 visManager->Initialize(); >> 83 #endif >> 84 >> 85 //Initialize G4 kernel >> 86 runManager->Initialize(); 78 87 79 // Get the Pointer to the UI Manager 88 // Get the Pointer to the UI Manager 80 auto* UImanager = G4UImanager::GetUIpointer( << 89 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 81 90 82 // User interactions 91 // User interactions 83 // Define (G)UI for interactive mode 92 // Define (G)UI for interactive mode 84 if(argc==1) 93 if(argc==1) 85 { 94 { 86 UImanager->ApplyCommand("/control/execute << 95 // G4UIterminal is a (dumb) terminal. 87 ui->SessionStart(); << 96 #ifdef G4UI_USE_XM 88 delete ui; << 97 G4UIsession* session = new G4UIXm(argc,argv); >> 98 #else >> 99 G4UIsession* session = new G4UIterminal(); >> 100 #endif >> 101 UImanager->ApplyCommand("/control/execute Visualisation.mac"); >> 102 session->SessionStart(); >> 103 delete session; 89 } 104 } 90 else // Batch mode << 105 else >> 106 // Batch mode 91 { 107 { 92 G4String command = "/control/execute "; 108 G4String command = "/control/execute "; 93 G4String fileName = argv[1]; 109 G4String fileName = argv[1]; 94 UImanager->ApplyCommand(command+fileName); 110 UImanager->ApplyCommand(command+fileName); 95 } 111 } 96 112 97 delete visManager; << 113 #ifdef G4VIS_USE >> 114 delete visManager; >> 115 #endif >> 116 98 delete runManager; 117 delete runManager; 99 118 100 return 0; 119 return 0; 101 } 120 } >> 121 102 122