Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:20:10

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 #include "DetectorConstruction.hh"
0028 #include "ActionInitialization.hh"
0029 
0030 #include "G4RunManagerFactory.hh"
0031 
0032 #include "G4UImanager.hh"
0033 #include "FTFP_BERT.hh"
0034 #include "FTFPCMS_BERT_EMM.hh"
0035 #include "G4PhysListFactory.hh"
0036 
0037 #include "G4VisExecutive.hh"
0038 #include "G4UIExecutive.hh"
0039 
0040 #include "Randomize.hh"
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 int main(int argc,char** argv)
0045 {
0046   // Detect interactive mode (if no arguments) and define UI session
0047   //
0048   G4UIExecutive* ui = 0;
0049   if ( argc == 1 ) {
0050     ui = new G4UIExecutive(argc, argv);
0051   }
0052 
0053   // Initialization of Run manager
0054   auto* runManager =
0055     G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
0056 
0057   // Set mandatory initialization classes
0058   //
0059   // Detector construction
0060   runManager->SetUserInitialization(new DetectorConstruction());
0061 
0062   // Physics List name defined via environment variable
0063   // or the default FTFP_BERT is used
0064   G4VModularPhysicsList* physicsList = nullptr;
0065   G4String physName = "";
0066   char* PLenv = std::getenv("PHYSLIST");
0067   if (PLenv)
0068     physName = G4String(PLenv);
0069   if ("FTFP_BERT_EMM" == physName || "FTFPCMS_BERT_EMM" == physName)
0070     physicsList = new FTFPCMS_BERT_EMM;
0071   else if ("" == physName)
0072   {
0073     physName = "FTFP_BERT";
0074     physicsList = new FTFP_BERT;
0075   }
0076   if (!physicsList)
0077   {
0078     G4PhysListFactory factory;
0079     physicsList = factory.GetReferencePhysList(physName);
0080   }
0081   if (!physicsList)
0082   {
0083     G4ExceptionDescription msg;
0084     msg  << "Unknown physics list defined in environment variable PHYSLIST: " << PLenv << "\n";
0085     msg<< "Consider extension of main to take it into account.\n";
0086     G4Exception("HGCal_testbeam::main()", "UnknownPhysicsList", FatalException, msg);
0087   }
0088   physicsList->SetVerboseLevel(1);
0089   runManager->SetUserInitialization(physicsList);
0090 
0091   // User action initialization
0092   runManager->SetUserInitialization(new ActionInitialization());
0093 
0094 
0095   // Get the pointer to the User Interface manager
0096   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0097 
0098   // Process macro or start UI session
0099   //
0100   if ( ! ui ) {
0101     // batch mode
0102     G4String command = "/control/execute ";
0103     G4String fileName = argv[1];
0104     UImanager->ApplyCommand(command+fileName);
0105   }
0106   else {
0107     // Initialize visualization
0108     G4VisManager *visManager = new G4VisExecutive;
0109     // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
0110     // G4VisManager* visManager = new G4VisExecutive("Quiet");
0111     visManager->Initialize();
0112     // interactive mode
0113     //UImanager->ApplyCommand("/control/execute init_vis.mac");
0114     UImanager->ApplyCommand("/control/execute init_vis.mac");
0115     ui->SessionStart();
0116     delete ui;
0117     delete visManager;
0118   }
0119 
0120   // Job termination
0121   // Free the store: user actions, physics_list and detector_description are
0122   // owned and deleted by the run manager, so they should not be deleted
0123   // in the main() program !
0124 
0125   delete runManager;
0126 }
0127 
0128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....