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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 ===============
 38 //!
 39 //! \file       FissionFragment.cc
 40 //! \author     B. Wendt (brycen.linn.wendt@cern.ch)
 41 //! \date       June 06, 2014
 42 //!
 43 //! \brief      Main program of the FissionFragment example
 44 //!
 45 //! \details    Application demonstrating the Fission Fragment model as used
 46 //!                 within the neutron_hp model. It demostrates the capability
 47 //!                 for fission product containment by the cladding in a water
 48 //!                 moderated sub-critical assembly.
 49 //!             It could also be further extended to calculate the effective
 50 //!                 multiplication factor of the subcritical assembly for
 51 //!                 various loading schemes.
 52 //!
 53 //  ================ End Documentation Comments ================
 54 //
 55 //  Modified:
 56 //
 57 //  05-08-20                                              ARibon
 58 //  Replaced deprecated HP environmental variables with UI commands
 59 //  23-06-14                                              BWendt
 60 //  Added check for NeutronHP fission generator environment variable
 61 //
 62 // -------------------------------------------------------------
 63 
 64 #include "FFActionInitialization.hh"
 65 #include "FFDetectorConstruction.hh"
 66 #include "QGSP_BIC_HP.hh"
 67 
 68 #include "G4ParticleHPManager.hh"
 69 #include "G4RunManagerFactory.hh"
 70 #include "G4UIExecutive.hh"
 71 #include "G4UImanager.hh"
 72 #include "G4VisExecutive.hh"
 73 #include "Randomize.hh"
 74 #include "globals.hh"
 75 
 76 // Entry point
 77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 78 int main(int argc, char* argv[])
 79 {
 80   int result;
 81   unsigned int numberOfThreads = 1;
 82 
 83   G4String scriptFileName = "";
 84   G4String outputFileName = "FF_Neutron_HP.out";
 85   G4UImanager* UIManager = NULL;
 86 
 87   // Activate production of fission fragments in neutronHP
 88   G4ParticleHPManager::GetInstance()->SetProduceFissionFragments(true);
 89 
 90   char Force[] = "G4FORCENUMBEROFTHREADS";
 91   if (std::getenv(Force) != NULL) {
 92     char doNotForce[] = "G4FORCENUMBEROFTHREADS=1";
 93     putenv(doNotForce);
 94   }
 95 
 96   // Indicate the example is starting
 97   G4cout << "####   Starting: " << argv[0] << "    ####" << G4endl;
 98 
 99   //  Parse the command line arguments, if any
100   for (int i = 1; i < argc; i += 2) {
101     // Ensure that this is actually a command
102     if (argv[i][0] != '-') {
103       G4cerr << G4endl << "!!!!" << G4endl;
104       G4cerr << "!!!! Error in argument " << i + 1 << G4endl;
105       G4cerr << "!!!! A command-line option was expected, but \"" << argv[i] << "\" was found"
106              << G4endl;
107       G4cerr << "!!!! " << argv[0] << " will now terminate" << G4endl;
108       G4cerr << "!!!!" << G4endl << G4endl;
109 
110       return EXIT_FAILURE;
111     }
112 
113     // Ensure that the command-line option has an associated argument
114     if (!(i + 1 < argc)) {
115       G4cerr << G4endl << "!!!!" << G4endl;
116       G4cerr << "!!!! Error in argument " << i + 2 << G4endl;
117       G4cerr << "!!!! An argument was expected, but \"" << argv[i + 1] << "\" was found" << G4endl;
118       G4cerr << "!!!! Ensure that a space is used to separate the "
119                 "option and argument"
120              << G4endl;
121       G4cerr << "!!!! " << argv[0] << " will now terminate" << G4endl;
122       G4cerr << "!!!!" << G4endl << G4endl;
123 
124       return EXIT_FAILURE;
125     }
126 
127     switch (argv[i][1]) {
128       case 'i':
129         scriptFileName = "/control/execute ";
130         scriptFileName.append(argv[i + 1]);
131         break;
132 
133       case 'o':
134         outputFileName = argv[i + 1];
135         break;
136 
137       case 'n':
138         result = sscanf(argv[i + 1], "%u", &numberOfThreads);
139         if (result != 1) {
140           G4cerr << G4endl << "!!!!" << G4endl;
141           G4cerr << "!!!! Error in argument " << i + 2 << G4endl;
142           G4cerr << "!!!! An positive number was expected, but \"" << argv[i + 1] << "\" was found"
143                  << G4endl;
144           G4cerr << "!!!! " << argv[0] << " will now terminate" << G4endl;
145           G4cerr << "!!!!" << G4endl << G4endl;
146 
147           return EXIT_FAILURE;
148         }
149         break;
150 
151       default:
152         G4cout << G4endl << "!!!!" << G4endl;
153         G4cout << "!!!! Warning for command " << i + 1 << G4endl;
154         G4cout << "!!!! \"" << argv[i] << "\" is not a valid command" << G4endl;
155         G4cout << "!!!! " << argv[0] << " will ignore \"" << argv[i] << "\" and \"" << argv[i + 1]
156                << "\"" << G4endl;
157         G4cout << "!!!!" << G4endl << G4endl;
158     }
159   }
160 
161   // Instantiate G4UIExecutive if interactive mode
162   G4UIExecutive* ui = nullptr;
163   if (scriptFileName.length() == 0) {
164     ui = new G4UIExecutive(argc, argv);
165   }
166 
167   // Set the Random engine
168   // A seed of 62737819 produced a maximum number of 67 events on the
169   // author's system before timing out the nightly test
170   const G4long seed = 62737819;
171 #ifndef NDEBUG
172   G4cout << "MT RNG Seed: " << seed << G4endl;
173 #endif  // NDEBUG
174   G4Random::setTheEngine(new CLHEP::MTwistEngine(seed));
175 
176   // Initialize the multithreaded run manager
177   auto* runManager = G4RunManagerFactory::CreateRunManager();
178   runManager->SetNumberOfThreads(numberOfThreads);
179   G4cout << "    Threads requested:    " << numberOfThreads << G4endl;
180   G4cout << "    Threads started:      " << runManager->GetNumberOfThreads() << G4endl;
181 
182   // Set mandatory initialization classes
183   runManager->SetUserInitialization(new FFDetectorConstruction());
184   runManager->SetUserInitialization(new QGSP_BIC_HP());
185   runManager->SetUserInitialization(new FFActionInitialization());
186 
187   // Initialize the Geant4 kernel
188   runManager->Initialize();
189 
190   // Initialize visualization
191   G4VisManager* visManager = new G4VisExecutive();
192   visManager->Initialize();
193 
194   // Get the pointer to the User Interface manager
195   UIManager = G4UImanager::GetUIpointer();
196 
197   if (!ui) {
198     // Batch mode
199     UIManager->ApplyCommand(scriptFileName);
200   }
201   else {
202     // Interactive mode
203     ui->SessionStart();
204     delete ui;
205   }
206 
207   // Job termination
208   // Free the store: user actions, physics_list and detector_description are
209   // owned and deleted by the run manager, so they should not be deleted
210   // in the main() program !
211   delete visManager;
212   delete runManager;
213 
214   return 0;
215 }
216