Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21:48

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 //
0028 //  CaTS (Calorimetry and Tracking Simulation)
0029 //
0030 //  Authors : Hans Wenzel
0031 //            Soon Yung Jun
0032 //            (Fermi National Accelerator Laboratory)
0033 //
0034 // History
0035 //   October 18th, 2021 : first implementation
0036 //
0037 // ********************************************************************
0038 //
0039 /// \file PhysicsConfigurator.cc
0040 /// \brief Implementation of the CaTS::PhysicsConfigurator class
0041 
0042 // Geant4 headers
0043 #include "G4String.hh"
0044 #include "G4VModularPhysicsList.hh"
0045 #include "G4PhysListFactoryAlt.hh"
0046 #include "G4PhysicsConstructorRegistry.hh"
0047 #include "G4PhysListRegistry.hh"
0048 #include "G4OpticalParameters.hh"
0049 #include "G4NeutronTrackingCut.hh"
0050 #include "G4StepLimiter.hh"
0051 #include "G4StepLimiterPhysics.hh"
0052 #include "G4SystemOfUnits.hh"
0053 // project Headers
0054 #include "PhysicsConfigurator.hh"
0055 #include "ConfigurationManager.hh"
0056 // c++ headers
0057 #include <stdlib.h> 
0058 PhysicsConfigurator* PhysicsConfigurator::instance = 0;
0059 
0060 G4VModularPhysicsList* PhysicsConfigurator::Construct(G4String physName)
0061 {
0062   //
0063   // Access to registries and factories
0064   //
0065   G4PhysicsConstructorRegistry* g4pcr =
0066     G4PhysicsConstructorRegistry::Instance();
0067   G4PhysListRegistry* g4plr = G4PhysListRegistry::Instance();
0068   G4bool verbose = ConfigurationManager::getInstance()->isEnable_verbose();
0069   if(verbose)
0070   {
0071     G4cout << "Available Physics Constructors:  "
0072            << g4pcr->AvailablePhysicsConstructors().size() << G4endl;
0073     G4cout << "Available Physics Lists:         "
0074            << g4plr->AvailablePhysLists().size() << G4endl;
0075     G4cout << "Available Physics Extensions:    "
0076            << g4plr->AvailablePhysicsExtensions().size() << G4endl;
0077     G4cout << "Available Physics Lists Em:      "
0078            << g4plr->AvailablePhysListsEM().size() << G4endl;
0079     g4plr->SetVerbose(1);
0080   }
0081   else
0082   {
0083     g4plr->SetVerbose(0);
0084   }
0085   g4plr->AddPhysicsExtension("OPTICAL", "G4OpticalPhysics");
0086   g4plr->AddPhysicsExtension("STEPLIMIT", "G4StepLimiterPhysics");
0087   g4plr->AddPhysicsExtension("NEUTRONLIMIT", "G4NeutronTrackingCut");
0088   if(verbose)
0089   {
0090     g4pcr->PrintAvailablePhysicsConstructors();
0091     g4plr->PrintAvailablePhysLists();
0092   }
0093   g4alt::G4PhysListFactory factory;
0094   G4VModularPhysicsList* phys = nullptr;
0095   if(verbose)
0096     G4cout << "Physics configuration: " << physName << G4endl;
0097   //
0098   // currently using the Constructor names doesn't work otherwise it would be:
0099   // G4String physName = "FTFP_BERT+G4OpticalPhysics+G4StepLimiterPhysics";
0100   // using the name doesn't work either
0101   // G4String physName = "FTFP_BERT+Optical+stepLimiter";
0102   // reference PhysicsList via its name
0103   //
0104   if(factory.IsReferencePhysList(physName))
0105   {
0106     phys = factory.GetReferencePhysList(physName);
0107   }
0108   else
0109   {
0110     G4cout << "Not a reference physics list" << G4endl;
0111     g4plr->PrintAvailablePhysLists();
0112     exit(EXIT_FAILURE);
0113   }
0114   if(verbose)
0115   {
0116     G4cout << phys->GetPhysicsTableDirectory() << G4endl;
0117   }
0118   G4OpticalParameters::Instance()->SetProcessActivation("Cerenkov", true);
0119   G4OpticalParameters::Instance()->SetProcessActivation("Scintillation", true);
0120   G4OpticalParameters::Instance()->SetProcessActivation("OpAbsorption", true);
0121   G4OpticalParameters::Instance()->SetProcessActivation("OpRayleigh", true);
0122   G4OpticalParameters::Instance()->SetProcessActivation("OpMieHG", false);
0123   G4OpticalParameters::Instance()->SetProcessActivation("OpWLS", true);
0124   G4OpticalParameters::Instance()->SetProcessActivation("OpWLS2", false);
0125 
0126   G4OpticalParameters::Instance()->SetCerenkovStackPhotons(false);
0127   G4OpticalParameters::Instance()->SetScintStackPhotons(false);
0128   G4OpticalParameters::Instance()->SetScintTrackSecondariesFirst(
0129     true);  // only relevant if we actually stack and trace the optical photons
0130   G4OpticalParameters::Instance()->SetCerenkovTrackSecondariesFirst(
0131     true);  // only relevant if we actually stack and trace the optical photons
0132   G4OpticalParameters::Instance()->SetCerenkovMaxPhotonsPerStep(100);
0133   G4OpticalParameters::Instance()->SetCerenkovMaxBetaChange(10.0);
0134   if(verbose)
0135   {
0136     phys->DumpList();
0137   }
0138   return phys;
0139 }
0140 
0141 PhysicsConfigurator* PhysicsConfigurator::getInstance()
0142 {
0143   if(instance == 0)
0144     instance = new PhysicsConfigurator();
0145   return instance;
0146 }