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 /// \file exoticphysics/dmparticle/dmparticle. 26 /// \file exoticphysics/dmparticle/dmparticle.cc 27 /// \brief Main program of the exoticphysics/d 27 /// \brief Main program of the exoticphysics/dmparticle example 28 // 28 // 29 // 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 32 33 #include "ActionInitialization.hh" << 33 #include "G4Types.hh" >> 34 >> 35 #include "G4RunManager.hh" >> 36 #include "G4MTRunManager.hh" >> 37 #include "G4UImanager.hh" >> 38 #include "G4UIcommand.hh" >> 39 #include "Randomize.hh" >> 40 34 #include "DetectorConstruction.hh" 41 #include "DetectorConstruction.hh" 35 #include "PhysicsList.hh" 42 #include "PhysicsList.hh" >> 43 #include "ActionInitialization.hh" 36 44 37 #include "G4RunManagerFactory.hh" << 38 #include "G4Types.hh" << 39 #include "G4UIExecutive.hh" << 40 #include "G4UIcommand.hh" << 41 #include "G4UImanager.hh" << 42 #include "G4VisExecutive.hh" 45 #include "G4VisExecutive.hh" 43 #include "Randomize.hh" << 46 #include "G4UIExecutive.hh" 44 47 45 //....oooOO0OOooo........oooOO0OOooo........oo 48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 46 49 47 int main(int argc, char** argv) << 50 int main(int argc,char** argv) 48 { 51 { 49 // Instantiate G4UIExecutive if interactive 52 // Instantiate G4UIExecutive if interactive mode 50 G4UIExecutive* ui = nullptr; 53 G4UIExecutive* ui = nullptr; 51 if (argc == 1) { << 54 if ( argc == 1 ) { 52 ui = new G4UIExecutive(argc, argv); 55 ui = new G4UIExecutive(argc, argv); 53 } 56 } 54 57 55 // choose the Random engine << 58 //choose the Random engine 56 CLHEP::HepRandom::setTheEngine(new CLHEP::Ra 59 CLHEP::HepRandom::setTheEngine(new CLHEP::Ranlux64Engine); 57 60 58 G4UImanager* UI = G4UImanager::GetUIpointer( << 61 G4UImanager* UI = G4UImanager::GetUIpointer(); 59 PhysicsList* phys = new PhysicsList(); 62 PhysicsList* phys = new PhysicsList(); 60 63 61 // defined mass of LDM particles 64 // defined mass of LDM particles 62 if (argc > 2) { << 65 if(argc > 2) { 63 G4String s = argv[2]; 66 G4String s = argv[2]; 64 UI->ApplyCommand("/control/verbose 1"); 67 UI->ApplyCommand("/control/verbose 1"); 65 UI->ApplyCommand("/testex/phys/setLDMPhoto 68 UI->ApplyCommand("/testex/phys/setLDMPhotonMass " + s + " GeV"); 66 } 69 } 67 if (argc > 3) { << 70 if(argc > 3) { 68 G4String s = argv[3]; 71 G4String s = argv[3]; 69 UI->ApplyCommand("/testex/phys/setLDMHiMas 72 UI->ApplyCommand("/testex/phys/setLDMHiMass " + s + " GeV"); 70 } 73 } 71 << 74 72 // Construct the default run manager 75 // Construct the default run manager 73 auto* runManager = G4RunManagerFactory::Crea << 76 #ifdef G4MULTITHREADED 74 G4int nThreads = std::min(G4Threading::G4Get << 77 G4MTRunManager* runManager = new G4MTRunManager; >> 78 G4int nThreads = std::min(G4Threading::G4GetNumberOfCores(),2); 75 runManager->SetNumberOfThreads(nThreads); 79 runManager->SetNumberOfThreads(nThreads); 76 G4cout << "===== dmparticle is started with << 80 G4cout << "===== dmparticle is started with " 77 << " threads =====" << G4endl; << 81 << runManager->GetNumberOfThreads() << " threads =====" << G4endl; >> 82 #else >> 83 G4RunManager* runManager = new G4RunManager(); >> 84 #endif 78 85 79 // set mandatory initialization classes 86 // set mandatory initialization classes 80 DetectorConstruction* det = new DetectorCons 87 DetectorConstruction* det = new DetectorConstruction(); 81 runManager->SetUserInitialization(phys); << 88 runManager->SetUserInitialization( phys ); 82 runManager->SetUserInitialization(det); << 89 runManager->SetUserInitialization( det); 83 << 90 84 // set user action classes 91 // set user action classes 85 runManager->SetUserInitialization(new Action << 92 runManager->SetUserInitialization( new ActionInitialization(det)); 86 93 87 G4VisManager* visManager = new G4VisExecutiv 94 G4VisManager* visManager = new G4VisExecutive; 88 visManager->Initialize(); 95 visManager->Initialize(); 89 96 90 if (!ui) // batch mode << 97 if (!ui) // batch mode 91 { << 98 { 92 G4String command = "/control/execute "; << 99 G4String command = "/control/execute "; 93 G4String fileName = argv[1]; << 100 G4String fileName = argv[1]; 94 UI->ApplyCommand(command + fileName); << 101 UI->ApplyCommand(command+fileName); 95 } << 102 } 96 else // define visualization and UI termina << 103 else //define visualization and UI terminal for interactive mode 97 { << 104 { 98 ui->SessionStart(); << 105 ui->SessionStart(); 99 delete ui; << 106 delete ui; 100 } << 107 } 101 // job termination 108 // job termination 102 delete visManager; 109 delete visManager; 103 delete runManager; 110 delete runManager; 104 return 0; 111 return 0; 105 } 112 } 106 113 107 //....oooOO0OOooo........oooOO0OOooo........oo 114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 115 >> 116 108 117