Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 08:37:26

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 mctruthex.cc
0027 /// \brief Main program of the HepMC/MCTruth example
0028 
0029 #include "DetectorConstruction.hh"
0030 #include "FTFP_BERT.hh"
0031 #include "MCTruthEventAction.hh"
0032 #include "MCTruthManager.hh"
0033 #include "MCTruthTrackingAction.hh"
0034 #include "PrimaryGeneratorAction.hh"
0035 
0036 #include "G4RunManagerFactory.hh"
0037 #include "G4UImanager.hh"
0038 
0039 int main()
0040 {
0041   // Construct a serial run manager
0042   auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::SerialOnly);
0043 
0044   // set mandatory initialization classes
0045   runManager->SetUserInitialization(new DetectorConstruction);
0046   runManager->SetUserInitialization(new FTFP_BERT);
0047 
0048   // set mandatory user action class
0049   runManager->SetUserAction(new PrimaryGeneratorAction);
0050 
0051   // set MCTruth user action classes
0052   runManager->SetUserAction(new MCTruthTrackingAction);
0053   runManager->SetUserAction(new MCTruthEventAction);
0054 
0055   // Initialize G4 kernel
0056   runManager->Initialize();
0057 
0058   // get the pointer to the UI manager and set verbosities
0059   G4UImanager* UI = G4UImanager::GetUIpointer();
0060   UI->ApplyCommand("/run/verbose 1");
0061   UI->ApplyCommand("/event/verbose 1");
0062   UI->ApplyCommand("/tracking/verbose 1");
0063 
0064   // configure MCTruth handling
0065   MCTruthConfig* config = new MCTruthConfig;
0066   config->SetMinE(1000.0);
0067   config->AddParticleType(11);
0068   MCTruthManager::GetInstance()->SetConfig(config);
0069 
0070   // start a run
0071   int numberOfEvent = 1;
0072   runManager->BeamOn(numberOfEvent);
0073 
0074   // job termination
0075   delete runManager;
0076 }