Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
FissionFragment.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // -------------------------------------------------------------
27 // GEANT4 FF_Neutron_HP
28 //
29 // Command line options:
30 // -i ARG : run in batch mode from script file ARG
31 // -o ARG : write output to file ARG
32 // (defaults to FF_Neutron_HP.out)
33 // -n ARG : multithreading with ARG number of threads
34 // (only works if Geant4 was compiled with
35 // multithreading enables)
36 //
37 // =============== Begin Documentation Comments ===============
53 // ================ End Documentation Comments ================
54 //
55 // Modified:
56 //
57 // 23-06-14 BWendt
58 // Added check for NeutronHP fission generator environment variable
59 //
60 // -------------------------------------------------------------
61 
62 #include "globals.hh"
63 
64 #ifdef G4MULTITHREADED
65 #include "G4MTRunManager.hh"
66 #else
67 #include "G4RunManager.hh"
68 #endif // G4MULTITHREADED
69 
70 #include "G4UImanager.hh"
71 #include "QGSP_BIC_HP.hh"
72 #include "Randomize.hh"
73 
76 
77 #include "G4VisExecutive.hh"
78 #include "G4UIExecutive.hh"
79 
80 
81 // Entry point
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 int main(int argc, char* argv[])
84 {
85  int result;
86  unsigned int numberOfThreads = 1;
87 
88  G4String scriptFileName = "";
89  G4String outputFileName = "FF_Neutron_HP.out";
90  G4UImanager* UIManager = NULL;
91 
92  char makeFissionFragments[] = "G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS";
93  char useWendtFission[] = "G4NEUTRON_HP_USE_WENDT_FISSION_MODEL";
94 
95  char Force[] = "G4FORCENUMBEROFTHREADS";
96  if(getenv(Force) != NULL) {
97  char doNotForce[]="G4FORCENUMBEROFTHREADS=1";
98  putenv(doNotForce);
99  }
100 
101  // Indicate the example is starting
102  G4cout << "#### Starting: " << argv[0] << " ####" << G4endl;
103 
104  // Verify that NeutronHP is going to create fission fragments
105  // Throw and error if it isn't.
106  if(getenv(makeFissionFragments) == NULL)
107  {
108  G4cerr << G4endl << "!!!!" << G4endl;
109  G4cerr << "!!!! Error in example" << argv[0] << G4endl;
110  G4cerr << "!!!! The \"" << makeFissionFragments << "\" "
111  "environment variable is not set!" << G4endl;
112  G4cerr << "!!!! Please set it in order to use this example." << G4endl;
113  G4cerr << "!!!!" << G4endl << G4endl;
114 
115  return EXIT_FAILURE;
116  }
117 
118  // We are trying to use the Wendt fission model in Neutron_HP
119  // Warn the user if the appropriate environment variable is not set up
120  if(getenv(useWendtFission) == NULL)
121  {
122  G4cout << G4endl << "!!!!" << G4endl;
123  G4cout << "!!!! Warning in example" << argv[0] << G4endl;
124  G4cout << "!!!! The \"" << useWendtFission << "\" "
125  "environment variable is not set!" << G4endl;
126  G4cout << "!!!! Please set it if you wish to use this fission model, "
127  "otherwise the default fission model will be used" << G4endl;
128  G4cout << "!!!!" << G4endl << G4endl;
129  }
130 
131  // Parse the command line arguments, if any
132  for(int i = 1;
133  i < argc;
134  i += 2)
135  {
136  // Ensure that this is actually a command
137  if(argv[i][0] != '-')
138  {
139  G4cerr << G4endl << "!!!!" << G4endl;
140  G4cerr << "!!!! Error in argument " << i + 1 << G4endl;
141  G4cerr << "!!!! A command-line option was expected, but \""
142  << argv[i] << "\" was found" << G4endl;
143  G4cerr << "!!!! " << argv[0] << " will now terminate" << G4endl;
144  G4cerr << "!!!!" << G4endl << G4endl;
145 
146  return EXIT_FAILURE;
147  }
148 
149  // Ensure that the command-line option has an associated argument
150  if(!(i + 1 < argc))
151  {
152  G4cerr << G4endl << "!!!!" << G4endl;
153  G4cerr << "!!!! Error in argument " << i + 2 << G4endl;
154  G4cerr << "!!!! An argument was expected, but \"" << argv[i + 1]
155  << "\" was found" << G4endl;
156  G4cerr << "!!!! Ensure that a space is used to separate the "
157  "option and argument" << G4endl;
158  G4cerr << "!!!! " << argv[0] << " will now terminate" << G4endl;
159  G4cerr << "!!!!" << G4endl << G4endl;
160 
161  return EXIT_FAILURE;
162  }
163 
164  switch(argv[i][1])
165  {
166  case 'i':
167  scriptFileName = "/control/execute ";
168  scriptFileName.append(argv[i + 1]);
169  break;
170 
171  case 'o':
172  outputFileName = argv[i + 1];
173  break;
174 
175  case 'n':
176  result = sscanf(argv[i + 1],
177  "%u",
178  &numberOfThreads);
179  if(result != 1)
180  {
181  G4cerr << G4endl << "!!!!" << G4endl;
182  G4cerr << "!!!! Error in argument " << i + 2 << G4endl;
183  G4cerr << "!!!! An positive number was expected, but \""
184  << argv[i + 1] << "\" was found" << G4endl;
185  G4cerr << "!!!! " << argv[0] << " will now terminate"
186  << G4endl;
187  G4cerr << "!!!!" << G4endl << G4endl;
188 
189  return EXIT_FAILURE;
190  }
191  break;
192 
193  default:
194  G4cout << G4endl << "!!!!" << G4endl;
195  G4cout << "!!!! Warning for command " << i + 1 << G4endl;
196  G4cout << "!!!! \"" << argv[i] << "\" is not a valid command"
197  << G4endl;
198  G4cout << "!!!! " << argv[0] << " will ignore \"" << argv[i]
199  << "\" and \"" << argv[i + 1] << "\"" << G4endl;
200  G4cout << "!!!!" << G4endl << G4endl;
201  }
202  }
203 
204  // Instantiate G4UIExecutive if interactive mode
205  G4UIExecutive* ui = nullptr;
206  if (scriptFileName.length() == 0) {
207  ui = new G4UIExecutive(argc, argv);
208  }
209 
210  // Set the Random engine
211  // A seed of 62737819 produced a maximum number of 67 events on the
212  // author's system before timing out the nightly test
213  const G4long seed = 62737819;
214 #ifndef NDEBUG
215  G4cout << "MT RNG Seed: " << seed << G4endl;
216 #endif // NDEBUG
217  G4Random::setTheEngine(new CLHEP::MTwistEngine(seed));
218 
219 // The 'runManger' type must be declared here at initialization to provide for
220 // 'SetNumberOfThreads()' method required for multithreading
221 #ifdef G4MULTITHREADED
222  // Initialize the multithreaded run manager
223  G4MTRunManager* const runManager = new G4MTRunManager();
224  runManager->SetNumberOfThreads(numberOfThreads);
225 
226  G4cout << "Multithreading enabled" << G4endl;
227  G4cout << " Threads requested: " << numberOfThreads << G4endl;
228  G4cout << " Threads started: " << runManager->GetNumberOfThreads()
229  << G4endl;
230 #else
231  // Multithreading not available
232  G4RunManager* const runManager = new G4RunManager();
233 #endif // G4MULTITHREADED
234 
235  // Set mandatory initialization classes
237  runManager->SetUserInitialization(new QGSP_BIC_HP());
239 
240  // Initialize the Geant4 kernel
241  runManager->Initialize();
242 
243  // Initialize visualization
244  G4VisManager* visManager = new G4VisExecutive();
245  visManager->Initialize();
246 
247  // Get the pointer to the User Interface manager
248  UIManager = G4UImanager::GetUIpointer();
249 
250  if(!ui)
251  {
252  // Batch mode
253  UIManager->ApplyCommand(scriptFileName);
254  } else
255  {
256  // Interactive mode
257  ui->SessionStart();
258  delete ui;
259  }
260 
261  // Job termination
262  // Free the store: user actions, physics_list and detector_description are
263  // owned and deleted by the run manager, so they should not be deleted
264  // in the main() program !
265  delete visManager;
266  delete runManager;
267 
268  return 0;
269 }
270 
271 
void SetNumberOfThreads(G4int n)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
G4int GetNumberOfThreads() const
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
long G4long
Definition: G4Types.hh:80
long seed
Definition: chem4.cc:68
int main(int argc, char **argv)
Definition: genwindef.cc:359
G4GLOB_DLL std::ostream G4cerr
G4double G4ParticleHPJENDLHEData::G4double result
TQGSP_BIC_HP< G4VModularPhysicsList > QGSP_BIC_HP
Definition: QGSP_BIC_HP.hh:63
G4GLOB_DLL std::ostream G4cout
void Initialize()
Definition of the FFDetectorConstruction class.
G4String & append(const G4String &)
Definition of the FFActionInitialization class.
virtual void Initialize()