Back to home page

EIC code displayed by LXR

 
 

    


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

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 //
0028 //
0029 // --------------------------------------------------------------
0030 //      GEANT 4 - examplePar02
0031 // --------------------------------------------------------------
0032 // Comments
0033 //
0034 // Example of a main program making use of track smearing.
0035 //
0036 // Note: for the time being, the program runs only in sequential mode,
0037 //       because the histogram manager - i.e. the class Par02Output -
0038 //       is a singleton...
0039 //
0040 //-------------------------------------------------------------------
0041 
0042 #include "Par02ActionInitialization.hh"
0043 #include "Par02DetectorConstruction.hh"
0044 #include "Par02PhysicsList.hh"
0045 
0046 #include "G4RunManagerFactory.hh"
0047 #include "G4Types.hh"
0048 #include "G4UIExecutive.hh"
0049 #include "G4UImanager.hh"
0050 #include "G4VisExecutive.hh"
0051 
0052 int main(int argc, char** argv)
0053 {
0054   // Instantiate G4UIExecutive if interactive mode
0055   G4UIExecutive* ui = nullptr;
0056   if (argc == 1) {
0057     ui = new G4UIExecutive(argc, argv);
0058   }
0059 
0060   //-------------------------------
0061   // Initialization of Run manager
0062   //-------------------------------
0063   auto* runManager = G4RunManagerFactory::CreateRunManager();
0064   runManager->SetNumberOfThreads(4);
0065 
0066   // Detector/mass geometry:
0067   auto detector = new Par02DetectorConstruction();
0068   runManager->SetUserInitialization(detector);
0069 
0070   // PhysicsList (including G4FastSimulationManagerProcess)
0071   auto physicsList = new Par02PhysicsList;
0072   runManager->SetUserInitialization(physicsList);
0073 
0074   //-------------------------------
0075   // UserAction classes
0076   //-------------------------------
0077   runManager->SetUserInitialization(new Par02ActionInitialization);
0078 
0079   // Initialize Run manager
0080   runManager->Initialize();
0081 
0082   //----------------
0083   // Visualization:
0084   //----------------
0085   G4cout << "Instantiating Visualization Manager......." << G4endl;
0086   G4VisManager* visManager = new G4VisExecutive;
0087   visManager->Initialize();
0088 
0089   if (ui) {
0090     //--------------------------
0091     // Define (G)UI
0092     //--------------------------
0093     ui->SessionStart();
0094     delete ui;
0095   }
0096   else {
0097     G4String command = "/control/execute ";
0098     G4String fileName = argv[1];
0099     G4UImanager* UImanager = G4UImanager::GetUIpointer();
0100     UImanager->ApplyCommand(command + fileName);
0101   }
0102 
0103   // Free the store: user actions, physics_list and detector_description are
0104   //                 owned and deleted by the run manager, so they should not
0105   //                 be deleted in the main() program !
0106 
0107   delete visManager;
0108   delete runManager;
0109 
0110   return 0;
0111 }