Back to home page

EIC code displayed by LXR

 
 

    


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

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