Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:08:36

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 /// \file HepMCEx01.cc
0027 /// \brief Main program of the HepMC/HepMCEx01 example
0028 
0029 // --------------------------------------------------------------
0030 //      GEANT 4 - example derived from novice exampleN04
0031 // --------------------------------------------------------------
0032 
0033 #include "ExN04DetectorConstruction.hh"
0034 #include "ExN04EventAction.hh"
0035 #include "ExN04PrimaryGeneratorAction.hh"
0036 #include "ExN04RunAction.hh"
0037 #include "ExN04StackingAction.hh"
0038 #include "ExN04SteppingAction.hh"
0039 #include "ExN04SteppingVerbose.hh"
0040 #include "ExN04TrackingAction.hh"
0041 #include "FTFP_BERT.hh"
0042 
0043 #include "G4RunManagerFactory.hh"
0044 #include "G4Types.hh"
0045 #include "G4UIExecutive.hh"
0046 #include "G4UImanager.hh"
0047 #include "G4VisExecutive.hh"
0048 
0049 int main(int argc, char** argv)
0050 {
0051   // Instantiate G4UIExecutive if there are no arguments (interactive mode)
0052   G4UIExecutive* ui = nullptr;
0053   if (argc == 1) {
0054     ui = new G4UIExecutive(argc, argv);
0055   }
0056 
0057   // User Verbose output class
0058   //
0059   G4VSteppingVerbose* verbosity = new ExN04SteppingVerbose;
0060   G4VSteppingVerbose::SetInstance(verbosity);
0061 
0062   // Serial only Run manager
0063   //
0064   auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::SerialOnly);
0065 
0066   // User Initialization classes (mandatory)
0067   //
0068   G4VUserDetectorConstruction* detector = new ExN04DetectorConstruction;
0069   runManager->SetUserInitialization(detector);
0070   //
0071   G4VUserPhysicsList* physics = new FTFP_BERT;
0072   runManager->SetUserInitialization(physics);
0073 
0074   runManager->Initialize();
0075 
0076   // User Action classes
0077   //
0078   G4VUserPrimaryGeneratorAction* gen_action = new ExN04PrimaryGeneratorAction;
0079   runManager->SetUserAction(gen_action);
0080   //
0081   G4UserRunAction* run_action = new ExN04RunAction;
0082   runManager->SetUserAction(run_action);
0083   //
0084   G4UserEventAction* event_action = new ExN04EventAction;
0085   runManager->SetUserAction(event_action);
0086   //
0087   G4UserStackingAction* stacking_action = new ExN04StackingAction;
0088   runManager->SetUserAction(stacking_action);
0089   //
0090   G4UserTrackingAction* tracking_action = new ExN04TrackingAction;
0091   runManager->SetUserAction(tracking_action);
0092   //
0093   G4UserSteppingAction* stepping_action = new ExN04SteppingAction;
0094   runManager->SetUserAction(stepping_action);
0095 
0096   G4VisManager* visManager = new G4VisExecutive;
0097   visManager->Initialize();
0098 
0099   // get the pointer to the User Interface manager
0100   G4UImanager* UImanager = G4UImanager::GetUIpointer();
0101 
0102   if (!ui)  // batch mode
0103   {
0104     visManager->SetVerboseLevel("quiet");
0105     G4String command = "/control/execute ";
0106     G4String fileName = argv[1];
0107     UImanager->ApplyCommand(command + fileName);
0108   }
0109   else {  // interactive mode : define UI session
0110     ui->SessionStart();
0111     delete ui;
0112   }
0113 
0114   // Free the store: user actions, physics_list and detector_description are
0115   //                 owned and deleted by the run manager, so they should not
0116   //                 be deleted in the main() program !
0117 
0118   delete verbosity;
0119   delete visManager;
0120   delete runManager;
0121 }