Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:16:37

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 //                 GEANT4 - GAMMAKNIFE example
0028 // ----------------------------------------------------------------------------
0029 // AUTHORS:
0030 // G. Cuttone (a), J. Pipek (b) F.Romano* (a), M.G.Sabini (c)
0031 //
0032 // PAST AUTHORS:
0033 // G.A.P. Cirrone (a), G.Russo (d), M.Russo (a)
0034 //
0035 // (a) Laboratori Nazionali del Sud - INFN, Catania, Italy
0036 // (b) Faculty of Nuclear Sciences and Physical Engineering, Czech Technical University, Czech Republic
0037 // (c) Dipartimento di Immagini, Ospedale Cannizzaro, Catania, Italy
0038 // (d) Fondazione Istituto San Raffaele G.Giglio, Cefalù (Palermo), Italy
0039 //
0040 //
0041 // *Corresponding author, email to francesco.romano@lns.infn.it
0042 // ----------------------------------------------------------------------------
0043 
0044 #include "G4Types.hh"
0045 #include "G4RunManagerFactory.hh"
0046 
0047 #include "G4UImanager.hh"
0048 #include "G4UIterminal.hh"
0049 #include "G4UItcsh.hh"
0050 
0051 #include "G4VisExecutive.hh"
0052 
0053 #include "G4UIExecutive.hh"
0054 
0055 #include "GammaKnifeDetectorConstruction.hh"
0056 #include "GammaKnifePhysicsList.hh"
0057 #include "GammaKnifePrimaryGeneratorAction.hh"
0058 #include "GammaKnifeRunAction.hh"
0059 #include "GammaKnifeActionInitialization.hh"
0060 
0061 #include "Randomize.hh"
0062 #include "G4RunManager.hh"
0063 #include "G4UImessenger.hh"
0064 #include "G4ScoringManager.hh"
0065 #include "globals.hh"
0066 #include "GammaKnifeController.hh"
0067 #include "G4PhysListFactory.hh"
0068 
0069 #include <ctime>
0070 
0071 int main(int argc ,char ** argv)
0072 {
0073 
0074   G4int seconds =  time(NULL);
0075   G4Random::setTheSeed(seconds);
0076 
0077   auto* runManager = G4RunManagerFactory::CreateRunManager();
0078   G4int nThreads = 4;
0079   runManager->SetNumberOfThreads(nThreads);
0080 
0081   G4ScoringManager::GetScoringManager(); // This enables scoring
0082 
0083   // Initialize the geometry
0084   GammaKnifeDetectorConstruction* detector = new GammaKnifeDetectorConstruction();
0085   runManager -> SetUserInitialization(detector);
0086 
0087   // Initialize the physics
0088   G4PhysListFactory factory;
0089   G4VModularPhysicsList* phys = 0;
0090   G4String physName = "";
0091 
0092   // Physics List name defined via environment variable
0093   char* path = std::getenv("PHYSLIST");
0094   if (path) { physName = G4String(path); }
0095 
0096   if(physName != "" && factory.IsReferencePhysList(physName))
0097     {
0098       phys = factory.GetReferencePhysList(physName);
0099     }
0100 
0101   if(!phys) { phys = new GammaKnifePhysicsList(); }
0102 
0103   runManager->SetUserInitialization(phys);
0104 
0105 
0106   GammaKnifeActionInitialization* actionInitialization= new GammaKnifeActionInitialization();
0107   runManager->SetUserInitialization(actionInitialization);
0108 
0109   GammaKnifeController* controller = new GammaKnifeController( detector );
0110   controller->ReadFile("MachineAngle.in"); // pre-load default
0111 
0112   // Initialize G4 kernel
0113   //
0114   runManager->Initialize();
0115 
0116   // Visualization manager
0117   G4VisManager* visManager = new G4VisExecutive;
0118   visManager -> Initialize();
0119 
0120   // Get the pointer to the User Interface manager
0121   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0122 
0123   if (argc!=1) {
0124     // batch mode
0125     G4String command = "/control/execute ";
0126     G4String fileName = argv[1];
0127     UImanager->ApplyCommand(command+fileName);
0128   }
0129   else {
0130     // interactive mode : define UI session
0131 
0132     G4UIExecutive* ui = new G4UIExecutive(argc, argv);
0133 
0134     UImanager->ApplyCommand("/control/execute defaultMacro.mac");
0135 
0136     ui->SessionStart();
0137     delete ui;
0138 
0139   }
0140   delete controller;
0141   delete visManager;
0142   delete runManager;
0143  
0144 
0145   return 0;
0146 }