int main(int argc, char **argv) { cout << "T2K test\n"; ND::TND280Log::Configure(); G4String outputFilename; G4String physicsList = "QGSP_BERT"; // Set the mandatory initialization classes // Construct the default run manager G4RunManager* runManager = ND280CreateRunManager(physicsList); #ifdef G4VIS_USE // Visualization. G4VisManager* visManager = new G4VisExecutive; visManager->Initialize(); #endif // Create the persistency manager. ND280PersistencyManager* persistencyManager = ND280RootPersistencyManager::GetInstance(); // Get the pointer to the UI manager G4UImanager* UI = G4UImanager::GetUIpointer(); // Set the defaults for the simulation. UI->ApplyCommand("/t2k/control nd280mc-defaults 1.0"); if (persistencyManager) { G4String command = "/db/open "; outputFilename = "t2k-nd280"; UI->ApplyCommand(command+outputFilename); } G4String macro(argv[1]); G4String command = "/control/execute "; UI->ApplyCommand(command+macro); // job G4String #ifdef G4VIS_USE delete visManager; #endif if (persistencyManager) { persistencyManager->Close(); delete persistencyManager; } delete runManager; return 0; }
int main(int argc, char** argv) { string gdml = argv[1]; string setup = argv[2]; const char* args[] = {"cmd"}; for(int i=1; i<argc;++i) { if ( argv[i][0]=='-' ) { string n = argv[i]+1; if ( ::strncmp(n.c_str(),"gdml",4) == 0 ) gdml = get_arg(argc,argv,++i); else if ( ::strncmp(n.c_str(),"guisetup",3) == 0 ) setup = get_arg(argc,argv,++i); } } if ( gdml.empty() || setup.empty() ) { cout << " usage: g4gdmlDisplay -gdml <file-name> -guisetup <g4 macro>" << endl; return EINVAL; } G4RunManager * run = new G4RunManager; run->SetUserInitialization(new Geant4GDMLDetector(gdml)); run->SetUserInitialization(new EmptyPhysicsList()); // // Initialize G4 kernel run->Initialize(); // // Initialize visualization G4VisManager* vis = new G4VisExecutive; vis->Initialize(); // // Get the pointer to the User Interface manager G4UImanager* uiman = G4UImanager::GetUIpointer(); G4UIExecutive* ui = new G4UIExecutive(1,(char**)args); uiman->ApplyCommand("/control/execute "+setup); ui->SessionStart(); // end ... delete ui; delete vis; delete run; return 0; }
int main(int argc, char **argv) { G4String macro = ""; G4bool showAll = false; for (G4int i = 1; i < argc; i++) { if (G4String(argv[i]) == "-m") macro = argv[++i]; else if (G4String(argv[i]) == "-a") showAll = true; else { PrintUsage(); return 1; } } // Remove? // Choose the Random engine CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); G4int seed = time(0); G4cout << "\nseed = " << seed << G4endl; CLHEP::HepRandom::setTheSeed(seed); G4Random::setTheSeed(seed); // Construct the default run manager // #ifdef G4MULTITHREADED G4MTRunManager *runManager = new G4MTRunManager(); runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores()); //runManager->SetNumberOfThreads(1); #else G4RunManager *runManager = new G4RunManager(); #endif // Set mandatory initialization classes // // Detector construction runManager->SetUserInitialization(new BIDetectorConstruction()); G4cout << "Here" << G4endl; // Physics list //G4VModularPhysicsList *physicsList = new FTFP_BERT; //G4VModularPhysicsList *physicsList = new QGSP_BERT_HP; G4VModularPhysicsList *physicsList = new Shielding; //G4VModularPhysicsList *physicsList = new BIPhysicsList; physicsList->SetVerboseLevel(0); //physicsList->SetCutValue(1.*um, "proton"); //physicsList->SetCuts(); //physicsList->SetDefaultCutValue(100.*um); runManager->SetUserInitialization(physicsList); // Primary generator action and User action intialization runManager->SetUserInitialization(new BIActionInitialization()); // Initialize G4 kernel // runManager->Initialize(); #ifdef G4VIS_USE // Initialize visualization G4VisManager *visManager = new G4VisExecutive; visManager->Initialize(); if (!showAll) { //Show only proton G4TrajectoryParticleFilter *filterp = new G4TrajectoryParticleFilter; filterp->Add("proton"); visManager->RegisterModel(filterp); } #endif // Get the pointer to the User Interface manager G4UImanager *UImanager = G4UImanager::GetUIpointer(); if (macro != "") { // batch mode G4String command = "/control/execute "; UImanager->ApplyCommand(command + macro); } else { // interactive mode : define UI session #ifdef G4UI_USE G4UIExecutive *ui = new G4UIExecutive(argc, argv); #ifdef G4VIS_USE UImanager->ApplyCommand("/control/execute init_vis.mac"); #else UImanager->ApplyCommand("/control/execute init.mac"); #endif if (ui->IsGUI()) { UImanager->ApplyCommand("/control/execute icons.mac"); } ui->SessionStart(); delete ui; #endif } // Job termination // Free the store: user actions, physics_list and detector_description are // owned and deleted by the run manager, so they should not be deleted // in the main() program ! #ifdef G4VIS_USE delete visManager; #endif delete runManager; return 0; }
StatusCode SimG4Svc::initialize(){ // Initialize necessary Gaudi components if (Service::initialize().isFailure()){ error()<<"Unable to initialize Service()"<<endmsg; return StatusCode::FAILURE; } m_toolSvc = service("ToolSvc"); if (!m_toolSvc) { error()<<"Unable to locate Tool Service"<<endmsg; return StatusCode::FAILURE; } if (!m_detectorTool.retrieve()) { error()<<"Unable to retrieve detector construction"<<endmsg; return StatusCode::FAILURE; } if (!m_physicsListTool.retrieve()) { error()<<"Unable to retrieve physics list"<<endmsg; return StatusCode::FAILURE; } if (!m_actionsTool.retrieve()) { error()<<"Unable to retrieve list of user actions"<<endmsg; return StatusCode::FAILURE; } if (!m_magneticFieldTool.retrieve()) { error()<<"Unable to retrieve the magnetic field"<<endmsg; return StatusCode::FAILURE; } // Initialize Geant run manager // Load physics list, deleted in ~G4RunManager() m_runManager.SetUserInitialization(m_physicsListTool->physicsList()); // Take geometry (from DD4Hep), deleted in ~G4RunManager() m_runManager.SetUserInitialization(m_detectorTool->detectorConstruction()); if (m_g4Commands.size()) { // Get the pointer to the User Interface manager G4UImanager* UImanager = G4UImanager::GetUIpointer(); for (auto command: m_g4Commands) { UImanager->ApplyCommand(command); } } m_runManager.Initialize(); // Attach user actions m_runManager.SetUserInitialization(m_actionsTool->userActionInitialization()); // Create regions for(auto& toolname: m_regionToolNames) { ISimG4RegionTool* tool = nullptr; if(m_toolSvc->retrieveTool(toolname, tool).isFailure()) { error()<<"Unable to retrieve region tool "<<toolname<<endmsg; return StatusCode::FAILURE; } m_regionTools.push_back(tool); } for(auto& tool: m_regionTools) { tool->create(); } if( !m_runManager.start()) { error() << "Unable to initialize GEANT correctly." << endmsg; return StatusCode::FAILURE; } return StatusCode::SUCCESS; }
int main(int argc,char** argv) { time_t lt; lt = time(NULL); ptr = gmtime(<); printf(asctime(ptr)); // Greenwich Mean time (GMT) printf(ctime(<)); //local time CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); G4long seed = time(NULL); CLHEP::HepRandom::setTheSeed(seed); G4RunManager* runManager = new G4RunManager; ProDetectorConstruction* detectorCon = new ProDetectorConstruction(); runManager->SetUserInitialization(detectorCon); PhysicsList* physics = new PhysicsList(); runManager->SetUserInitialization(physics); ProAnalysis * anly = new ProAnalysis(); // UserAction classes - optional G4VUserPrimaryGeneratorAction* generator = new ProPrimaryGeneratorAction(detectorCon); runManager->SetUserAction(generator); ProRunAction* RunAct = new ProRunAction(anly); runManager->SetUserAction(RunAct); ProEventAction* EvAct = new ProEventAction(RunAct,anly); runManager->SetUserAction(EvAct); runManager->Initialize(); #ifdef G4VIS_USE G4VisManager* visManager = new G4VisExecutive; visManager->Initialize(); #endif G4UImanager* uiManager = G4UImanager::GetUIpointer(); if(argc != 1){ G4String command = "/control/execute "; G4String fileName = argv[1]; uiManager->ApplyCommand(command+fileName); } else { #ifdef G4UI_USE G4UIExecutive* ui = new G4UIExecutive(argc,argv); #ifdef G4VIS_USE uiManager->ApplyCommand("/control/execute vis.mac"); #endif ui->SessionStart(); delete ui; #endif } //******************************************************************* G4cout<<" This is a Collimator Test which let neutrons having 180MeV " <<" pass through collimator, and two collimator detectors are " <<" used to record neutrons information" <<G4endl; //******************************************************************* #ifdef G4VIS_USE delete visManager; #endif delete anly; delete runManager; return 0; }