Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:03

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file molecular.cc
0028 /// \brief Molecular level simulation of DNA
0029 
0030 #include "ActionInitialization.hh"
0031 #include "DetectorConstruction.hh"
0032 #include "PhysicsList.hh"
0033 
0034 #include "G4DNAChemistryManager.hh"
0035 #include "G4MoleculeGun.hh"
0036 #include "G4RunManagerFactory.hh"
0037 #include "G4UIExecutive.hh"
0038 #include "G4UImanager.hh"
0039 #include "G4VisExecutive.hh"
0040 
0041 #include <ctime>
0042 
0043 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0044 
0045 namespace
0046 {
0047 void PrintUsage()
0048 {
0049   G4cout << " Usage: " << G4endl;
0050   G4cout << " molecular [-m macro ] [-t nThreads] [-p PhysicsList]" << G4endl;
0051   G4cout << "   -p is the G4DNA Physics List option. Default (0) is"
0052          << " G4EmDNAPhysics" << G4endl;
0053   G4cout << "   note: -t option is available only for multi-threaded mode." << G4endl;
0054 }
0055 }  // namespace
0056 
0057 int main(int argc, char** argv)
0058 {
0059   if (argc > 7) {
0060     PrintUsage();
0061     return 1;
0062   }
0063 
0064   G4String macro;
0065   G4int phys_option = 2;
0066 
0067   G4int nThreads = 2;
0068   for (G4int ii = 1; ii < argc; ii = ii + 2) {
0069     if (G4String(argv[ii]) == "-m") {
0070       macro = argv[ii + 1];
0071     }
0072     else if (G4String(argv[ii]) == "-p") {
0073       phys_option = G4UIcommand::ConvertToInt(argv[ii + 1]);
0074     }
0075     else if (G4String(argv[ii]) == "-t") {
0076       nThreads = G4UIcommand::ConvertToInt(argv[ii + 1]);
0077     }
0078     else {
0079       PrintUsage();
0080       return 1;
0081     }
0082   }
0083 
0084   G4UIExecutive* ui = nullptr;
0085   if (!macro.size()) {
0086     ui = new G4UIExecutive(argc, argv);
0087   }
0088 
0089   /*
0090   time_t timeStart;
0091   time(&timeStart);
0092   long seed = timeStart;
0093   G4Random::setTheSeed(seed);
0094   */
0095 
0096   auto* runManager = G4RunManagerFactory::CreateRunManager();
0097   if (nThreads > 0) {
0098     runManager->SetNumberOfThreads(nThreads);
0099   }
0100 
0101   runManager->SetUserInitialization(new DetectorConstruction());
0102   G4VModularPhysicsList* physicsList = new PhysicsList(phys_option);
0103   runManager->SetUserInitialization(physicsList);
0104   runManager->SetUserInitialization(new ActionInitialization());
0105   G4DNAChemistryManager::Instance()->Initialize();
0106 
0107   G4VisExecutive* visManager = nullptr;
0108 
0109   // Get the pointer to the User Interface manager
0110   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0111   if (!macro.empty()) {
0112     // batch mode
0113     G4String command = "/control/execute ";
0114     UImanager->ApplyCommand(command + macro);
0115   }
0116   else {
0117     visManager = new G4VisExecutive;
0118     visManager->Initialize();
0119     UImanager->ApplyCommand("/control/execute vis.mac");
0120     ui->SessionStart();
0121     delete ui;
0122     delete visManager;
0123   }
0124   delete runManager;
0125   return 0;
0126 }
0127 
0128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....