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 // Code developed by: 26 // Code developed by: 27 // S.Larsson 27 // S.Larsson 28 // 28 // 29 // ********************* 29 // ********************* 30 // * * 30 // * * 31 // * PurgMag.cc * 31 // * PurgMag.cc * 32 // * * 32 // * * 33 // ********************* 33 // ********************* 34 // 34 // >> 35 // $Id: PurgMag.cc,v 1.6 2010-11-18 13:10:28 allison Exp $ >> 36 // GEANT4 tag $Name: not supported by cvs2svn $ 35 // 37 // 36 // Comments: Main program for the Purgin Magne << 38 // Comments: Main program for the Purgin Magnet example. 37 // 39 // 38 40 39 #include "G4Types.hh" << 41 #include "G4RunManager.hh" 40 #include "G4RunManagerFactory.hh" << 41 #include "G4UImanager.hh" 42 #include "G4UImanager.hh" 42 #include "Randomize.hh" 43 #include "Randomize.hh" >> 44 >> 45 #ifdef G4VIS_USE 43 #include "G4VisExecutive.hh" 46 #include "G4VisExecutive.hh" >> 47 #endif >> 48 >> 49 #ifdef G4UI_USE 44 #include "G4UIExecutive.hh" 50 #include "G4UIExecutive.hh" 45 #include "G4AnalysisManager.hh" << 51 #endif >> 52 46 #include "PurgMagDetectorConstruction.hh" 53 #include "PurgMagDetectorConstruction.hh" 47 #include "PurgMagPhysicsList.hh" 54 #include "PurgMagPhysicsList.hh" 48 #include "PurgMagActionInitializer.hh" << 55 #include "PurgMagPrimaryGeneratorAction.hh" 49 << 56 #include "PurgMagRunAction.hh" 50 int main(int argc,char** argv) << 57 #include "PurgMagEventAction.hh" 51 { << 58 #include "PurgMagTrackingAction.hh" 52 // Construct the default run manager << 59 #include "PurgMagSteppingAction.hh" 53 // << 60 #include "PurgMagSteppingVerbose.hh" 54 auto* runManager = G4RunManagerFactory::Crea << 61 55 G4int nThreads = 4; << 62 int main(int argc,char** argv) { 56 runManager->SetNumberOfThreads(nThreads); << 63 >> 64 //choose the Random engine >> 65 CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); >> 66 >> 67 //PurgMag Verbose output class >> 68 G4VSteppingVerbose::SetInstance(new PurgMagSteppingVerbose); >> 69 >> 70 // Construct the default run manager >> 71 G4RunManager * runManager = new G4RunManager; 57 72 58 // set mandatory initialization classes 73 // set mandatory initialization classes 59 runManager->SetUserInitialization(new PurgMa << 74 PurgMagDetectorConstruction* detector = new PurgMagDetectorConstruction; >> 75 runManager->SetUserInitialization(detector); 60 runManager->SetUserInitialization(new PurgMa 76 runManager->SetUserInitialization(new PurgMagPhysicsList); 61 runManager->SetUserInitialization(new PurgMa << 77 62 << 78 runManager->SetUserAction(new PurgMagPrimaryGeneratorAction(detector)); >> 79 >> 80 #ifdef G4VIS_USE 63 // visualization manager 81 // visualization manager 64 G4VisManager* visManager = new G4VisExecutiv 82 G4VisManager* visManager = new G4VisExecutive; 65 visManager->Initialize(); 83 visManager->Initialize(); >> 84 #endif 66 85 >> 86 // output environment variables: >> 87 #ifdef G4ANALYSIS_USE >> 88 G4cout << G4endl << G4endl << G4endl >> 89 << " User Environment " << G4endl >> 90 << " Using AIDA 3.0 analysis " << G4endl; >> 91 # else >> 92 G4cout << G4endl << G4endl << G4endl >> 93 << " User Environment " << G4endl >> 94 << " G4ANALYSIS_USE environment variable not set, NO ANALYSIS " >> 95 << G4endl; >> 96 #endif >> 97 >> 98 // set user action classes >> 99 PurgMagRunAction* RunAct = new PurgMagRunAction(detector); >> 100 runManager->SetUserAction(RunAct); >> 101 runManager->SetUserAction(new PurgMagEventAction(RunAct)); >> 102 runManager->SetUserAction(new PurgMagTrackingAction(RunAct)); >> 103 runManager->SetUserAction(new PurgMagSteppingAction(RunAct,detector)); >> 104 67 //Initialize G4 kernel 105 //Initialize G4 kernel 68 runManager->Initialize(); 106 runManager->Initialize(); 69 << 107 70 // get the pointer to the User Interface man << 108 // get the pointer to the User Interface manager 71 G4UImanager* UImanager = G4UImanager::GetUIp << 109 G4UImanager* UImanager = G4UImanager::GetUIpointer(); 72 110 73 111 74 if (argc==1) // Define UI session for inte 112 if (argc==1) // Define UI session for interactive mode. 75 { 113 { >> 114 #ifdef G4UI_USE 76 G4UIExecutive* ui = new G4UIExecutive(ar 115 G4UIExecutive* ui = new G4UIExecutive(argc, argv); 77 UImanager->ApplyCommand("/control/execut << 116 #ifdef G4VIS_USE >> 117 UImanager->ApplyCommand("/control/execute vis.mac"); >> 118 #endif 78 ui->SessionStart(); 119 ui->SessionStart(); 79 delete ui; 120 delete ui; >> 121 #endif 80 } 122 } 81 else // Batch mode 123 else // Batch mode 82 { << 124 { 83 G4String command = "/control/execute "; 125 G4String command = "/control/execute "; 84 G4String fileName = argv[1]; 126 G4String fileName = argv[1]; 85 UImanager->ApplyCommand(command+fileName 127 UImanager->ApplyCommand(command+fileName); 86 } 128 } 87 129 88 // Save histograms << 130 89 G4AnalysisManager* man = G4AnalysisManager:: << 131 // For bg jobs with 100000 events. 90 man->Write(); << 132 /* 91 man->CloseFile(); << 133 int numberOfEvent = 100000; >> 134 runManager->BeamOn(numberOfEvent); >> 135 */ >> 136 92 137 93 // job termination 138 // job termination >> 139 #ifdef G4VIS_USE 94 delete visManager; 140 delete visManager; 95 << 141 #endif 96 delete runManager; 142 delete runManager; 97 143 98 return 0; 144 return 0; 99 } 145 } 100 146 101 147