Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:08

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