Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:41:06

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 //                 GEANT 4 - Solid Target Cyclotron example
0028 // --------------------------------------------------------------
0029 //
0030 // Code developed currently by:
0031 //  F. Poignant & S.Guatelli 
0032 // Code also developed in the past by:
0033 //  S. Penfold
0034 //
0035 // file STCyclotron.cc
0036 //
0037 #include "G4RunManagerFactory.hh"
0038 #include "G4UImanager.hh" 
0039 #include "G4VisExecutive.hh"
0040 #include "G4UIExecutive.hh"
0041 #include "STCyclotronActionInitialization.hh"
0042 #include "STCyclotronDetectorConstruction.hh"
0043 #include "STCyclotronPhysicsList.hh"
0044 #include "STCyclotronPrimaryGeneratorAction.hh"
0045 #include "STCyclotronRunAction.hh"
0046 
0047 int main(int argc, char** argv)
0048 {
0049 // Construct the default run manager
0050  //
0051   auto* runManager = G4RunManagerFactory::CreateRunManager();
0052   G4int nThreads = 4;
0053   runManager -> SetNumberOfThreads(nThreads);
0054   
0055   //Set mandatory initialization classes
0056   STCyclotronDetectorConstruction* det = new STCyclotronDetectorConstruction();
0057   runManager->SetUserInitialization(det);  
0058  
0059   STCyclotronPhysicsList* physList = new STCyclotronPhysicsList(det);
0060   runManager->SetUserInitialization(physList);
0061 
0062   // User action initialization
0063   STCyclotronActionInitialization* actions = new STCyclotronActionInitialization(det);
0064   runManager->SetUserInitialization(actions);
0065 
0066   //Set the random number seed
0067 /* 
0068   G4long seed=time(0);
0069   CLHEP::HepRandom::setTheSeed(seed);
0070   G4cout << "***********************" << G4endl;
0071   G4cout << "*** Seed: " << CLHEP::HepRandom::getTheSeed() << " ***" << G4endl;
0072   G4cout << "***********************" << G4endl;
0073   //getchar();
0074  */
0075  
0076   G4VisManager* visManager = new G4VisExecutive("Quiet");
0077   visManager->Initialize();
0078 
0079   // Get the pointer to the User Interface manager
0080   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0081   //initialize : beam parameters + simulation parameters (geometry)
0082   UImanager->ApplyCommand("/control/execute Macro/init_parameters.mac");
0083 
0084   if (argc!=1) {
0085     // batch mode
0086     //to apply the command : sahmri_simulation run.mac
0087     G4String command = "/control/execute ";
0088     G4String fileName = argv[1];
0089     UImanager->ApplyCommand(command+fileName);
0090   }
0091   
0092   else {
0093     // interactive mode : define UI session
0094 
0095     G4UIExecutive* ui = new G4UIExecutive(argc, argv);
0096 
0097     UImanager->ApplyCommand("/control/execute Macro/Vis/init_vis.mac"); 
0098     //UImanager->ApplyCommand("/control/execute Macro/init.mac"); 
0099 
0100     if (ui->IsGUI())
0101       UImanager->ApplyCommand("/control/execute Macro/GUI/gui.mac");
0102      ui->SessionStart();
0103     delete ui;
0104   }
0105 
0106   delete visManager;
0107   delete runManager;
0108 
0109   return 0;
0110 
0111 }