Back to home page

EIC code displayed by LXR

 
 

    


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

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 /// \file eventgenerator/pythia/py8decayer/pythia8_decayer.cc
0028 /// \brief Main program of the pythia8_decayer example
0029 
0030 #include "ActionInitialization.hh"
0031 #include "DetConstruction.hh"
0032 #include "FTFP_BERT.hh"
0033 #include "Py8DecayerPhysics.hh"
0034 #include "SingleParticleGun.hh"
0035 
0036 #include "G4GeometryManager.hh"
0037 #include "G4PhysListFactoryAlt.hh"
0038 #include "G4PhysListRegistry.hh"
0039 #include "G4RunManagerFactory.hh"
0040 #include "G4SystemOfUnits.hh"
0041 #include "Randomize.hh"
0042 
0043 // allow ourselves to extend the short names for physics ctor addition/replace
0044 // along the same lines as EMX, EMY, etc
0045 #include "G4PhysListRegistry.hh"
0046 
0047 // allow ourselves to give the user extra info about available physics ctors
0048 #include "G4PhysicsConstructorFactory.hh"
0049 
0050 // forward declaration
0051 void PrintAvailable(G4int verb = 1);
0052 
0053 int main(int argc, char** argv)
0054 {
0055   // pick physics list
0056   std::string physListName = "FTFP_BERT+PY8DK";
0057 
0058   for (G4int i = 1; i < argc; i = i + 2) {
0059     G4String g4argv(argv[i]);  // convert only once
0060     if (g4argv == "-p") physListName = argv[i + 1];
0061   }
0062 
0063   // Choose the Random engine
0064   //
0065   G4Random::setTheEngine(new CLHEP::RanecuEngine);
0066 
0067   // Construct the default run manager;
0068   // it'll operate in the Tasking mode, and will use 5 thread
0069   //
0070   // If one wishes to operate in the so called serial (sequential) mode,
0071   // one can use G4RunManagerType::SerialOnly
0072   //
0073   auto runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default, 5);
0074 
0075   // Set mandatory initialization classes
0076   //
0077   // Geometry
0078   //
0079   runManager->SetUserInitialization(new DetConstruction);
0080   //
0081   // Physics
0082   //
0083   // G4VModularPhysicsList* physicsList = new FTFP_BERT();
0084   // physicsList->RegisterPhysics(new Py8DecayerPhysics());
0085 
0086   g4alt::G4PhysListFactory plFactory;
0087   G4VModularPhysicsList* physicsList = nullptr;
0088   plFactory.SetDefaultReferencePhysList("NO_DEFAULT_PHYSLIST");
0089 
0090   // set a short name for the plugin
0091   G4PhysListRegistry* plReg = G4PhysListRegistry::Instance();
0092   plReg->AddPhysicsExtension("PY8DK", "Py8DecayerPhysics");
0093 
0094   physicsList = plFactory.GetReferencePhysList(physListName);
0095 
0096   if (!physicsList) {
0097     PrintAvailable(1);
0098 
0099     // if we can't get what the user asked for...
0100     //    don't go on to use something else, that's confusing
0101     G4ExceptionDescription ed;
0102     ed << "The factory for the physicslist [" << physListName << "] does not exist!" << G4endl;
0103     G4Exception("extensibleFactory", "extensibleFactory001", FatalException, ed);
0104     exit(42);
0105   }
0106 
0107   runManager->SetUserInitialization(physicsList);
0108   //
0109   // Set user action classes, e.g. prim.generator (tau- gun), etc.
0110   // NOTE: setting particle gun (prim. generator) is done in
0111   //       ActionInit class (see src/ActionInitialization.cc)
0112   //
0113   runManager->SetUserInitialization(new ActionInitialization());
0114   //
0115   // General initialization for the run
0116   //
0117   runManager->Initialize();
0118 
0119   //
0120   // Run 5 events
0121   // NOTE: they will run on 5 different threads, as indicated earlier in the code
0122   //
0123   runManager->BeamOn(5);
0124 
0125   // Job termination
0126   // Free the store: user actions, physics_list and detector_description are
0127   //                 owned and deleted by the run manager, so they should not
0128   //                 be deleted in the main() program !
0129   delete runManager;
0130 
0131   return 0;
0132 }
0133 
0134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0135 
0136 void PrintAvailable(G4int verbosity)
0137 {
0138   G4cout << G4endl;
0139   G4cout << "extensibleFactory: here are the available physics lists:" << G4endl;
0140   g4alt::G4PhysListFactory factory;
0141   factory.PrintAvailablePhysLists();
0142 
0143   // if user asked for extra verbosity then print physics ctors as well
0144   if (verbosity > 1) {
0145     G4cout << G4endl;
0146     G4cout << "extensibleFactory: "
0147            << "here are the available physics ctors that can be added:" << G4endl;
0148     G4PhysicsConstructorRegistry* g4pctorFactory = G4PhysicsConstructorRegistry::Instance();
0149     g4pctorFactory->PrintAvailablePhysicsConstructors();
0150   }
0151 }
0152 
0153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......