Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:19:57

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 // experimental_microdosimetry.cc
0027 // Authors: Susanna Guatelli and Francesco Romano
0028 // susanna@uow.edu.au, francesco.romano@ct.infn.it
0029 
0030 #include "G4RunManager.hh"
0031 #include "DetectorConstruction.hh"
0032 #include "PhysicsList.hh"
0033 #include "G4UImanager.hh"
0034 #include "G4VisExecutive.hh"
0035 #include "G4RunManagerFactory.hh"
0036 #include "AnalysisManager.hh"
0037 #include "ActionInitialization.hh"
0038 #include "AnalysisManager.hh"
0039 #include "G4UIExecutive.hh"
0040 
0041 #include "DetectorMessenger.hh"
0042 #include "AnalysisMessenger.hh"
0043 
0044 int main(int argc, char** argv)
0045 {
0046 
0047   auto* pRunManager = G4RunManagerFactory::CreateRunManager();
0048   G4int nThreads = 4;
0049   pRunManager->SetNumberOfThreads(nThreads);
0050   
0051   AnalysisMessenger* anMess = new AnalysisMessenger();
0052   AnalysisManager* analysis = new AnalysisManager(anMess);
0053   
0054   // Construct geometry
0055   
0056   DetectorMessenger* detMess = new DetectorMessenger(analysis);
0057   DetectorConstruction* detector = new DetectorConstruction(analysis, detMess);  
0058     
0059   pRunManager -> SetUserInitialization(detector);
0060 
0061   G4VUserPhysicsList* physics = new PhysicsList();
0062   
0063   pRunManager -> SetUserInitialization(physics); 
0064 
0065    // User action initialization  
0066 
0067   ActionInitialization* actions = new ActionInitialization(analysis, detMess);
0068   pRunManager->SetUserInitialization(actions);
0069 
0070   G4VisManager* visManager = new G4VisExecutive();
0071   visManager->Initialize();
0072  
0073   // Get the pointer to the User Interface manager
0074   //
0075   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0076 
0077   if(argc == 1){
0078 
0079     /*this sets up the user interface to run in interactive mode */
0080     G4UIExecutive* ui = new G4UIExecutive(argc, argv); 
0081     G4cout << " UI session starts ..." << G4endl;
0082     UImanager -> ApplyCommand("/control/execute vis.mac");
0083     //now, we run in interactive mode so tell the UI manager to read the vis.mac macro file and 
0084     //UI->ApplyCommand("/control/execute vis.mac"); 
0085     ui -> SessionStart();
0086     delete ui;
0087 
0088   } else { 
0089     //otherwise we run in batch mode
0090     G4String command = "/control/execute ";//create first part of command
0091     G4String fileName = argv[1];//second part is the file name that was typed at the command line 
0092     UImanager->ApplyCommand(command+fileName);//join the two and pass to the UI manager for interpretation
0093   }
0094 
0095   delete visManager;
0096   delete analysis; 
0097   delete pRunManager;
0098   delete detMess;
0099   delete anMess;
0100   
0101   return 0;
0102 }