Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-23 07:41:13

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 F04PhysicsList.cc
0027 /// \brief Implementation of the F04PhysicsList class
0028 
0029 #include "F04PhysicsList.hh"
0030 
0031 #include "F04PhysicsListMessenger.hh"
0032 
0033 #include "G4LossTableManager.hh"
0034 #include "G4OpticalPhysics.hh"
0035 #include "G4ParticleTable.hh"
0036 #include "G4ParticleTypes.hh"
0037 #include "G4ProcessManager.hh"
0038 #include "G4StepLimiterPhysics.hh"
0039 
0040 #include "F04StepMax.hh"
0041 #include "FTFP_BERT.hh"
0042 #include "QGSP_BERT.hh"
0043 
0044 #include "G4DecayTable.hh"
0045 #include "G4DecayWithSpin.hh"
0046 #include "G4Electron.hh"
0047 #include "G4Gamma.hh"
0048 #include "G4MuMinusCapturePrecompound.hh"
0049 #include "G4MuonDecayChannelWithSpin.hh"
0050 #include "G4MuonMinusCapture.hh"
0051 #include "G4MuonRadiativeDecayChannelWithSpin.hh"
0052 #include "G4PionDecayMakeSpin.hh"
0053 #include "G4Positron.hh"
0054 #include "G4ProcessTable.hh"
0055 #include "G4SystemOfUnits.hh"
0056 
0057 G4ThreadLocal F04StepMax* F04PhysicsList::fStepMaxProcess = nullptr;
0058 
0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0060 
0061 F04PhysicsList::F04PhysicsList(const G4String& physName) : G4VModularPhysicsList()
0062 {
0063   G4LossTableManager::Instance();
0064 
0065   defaultCutValue = 1. * mm;
0066 
0067   fMessenger = new F04PhysicsListMessenger(this);
0068 
0069   SetVerboseLevel(1);
0070 
0071   //    G4PhysListFactory factory;
0072   G4VModularPhysicsList* phys = nullptr;
0073   if (physName == "QGSP_BERT") {
0074     phys = new QGSP_BERT;
0075   }
0076   else {
0077     phys = new FTFP_BERT;
0078   }
0079 
0080   //    if (factory.IsReferencePhysList(physName))
0081   //       phys =factory.GetReferencePhysList(physName);
0082 
0083   // Physics List is defined via environment variable PHYSLIST
0084   //    if (!phys) phys = factory.ReferencePhysList();
0085 
0086   if (!phys)
0087     G4Exception("F04PhysicsList::F04PhysicsList", "InvalidSetup", FatalException,
0088                 "PhysicsList does not exist");
0089 
0090   for (G4int i = 0;; ++i) {
0091     auto elem = const_cast<G4VPhysicsConstructor*>(phys->GetPhysics(i));
0092     if (elem == nullptr) break;
0093     G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl;
0094     RegisterPhysics(elem);
0095   }
0096 
0097   RegisterPhysics(new G4StepLimiterPhysics());
0098   RegisterPhysics(new G4OpticalPhysics());
0099 }
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0102 
0103 F04PhysicsList::~F04PhysicsList()
0104 {
0105   delete fMessenger;
0106 }
0107 
0108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0109 
0110 void F04PhysicsList::ConstructParticle()
0111 {
0112   G4VModularPhysicsList::ConstructParticle();
0113 
0114   G4GenericIon::GenericIonDefinition();
0115 
0116   auto muonPlusDecayTable = new G4DecayTable();
0117   muonPlusDecayTable->Insert(new G4MuonDecayChannelWithSpin("mu+", 0.986));
0118   muonPlusDecayTable->Insert(new G4MuonRadiativeDecayChannelWithSpin("mu+", 0.014));
0119   G4MuonPlus::MuonPlusDefinition()->SetDecayTable(muonPlusDecayTable);
0120 
0121   auto muonMinusDecayTable = new G4DecayTable();
0122   muonMinusDecayTable->Insert(new G4MuonDecayChannelWithSpin("mu-", 0.986));
0123   muonMinusDecayTable->Insert(new G4MuonRadiativeDecayChannelWithSpin("mu-", 0.014));
0124   G4MuonMinus::MuonMinusDefinition()->SetDecayTable(muonMinusDecayTable);
0125 }
0126 
0127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0128 
0129 void F04PhysicsList::ConstructProcess()
0130 {
0131   G4VModularPhysicsList::ConstructProcess();
0132 
0133   fStepMaxProcess = new F04StepMax();
0134 
0135   auto decayWithSpin = new G4DecayWithSpin();
0136 
0137   G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
0138 
0139   G4VProcess* decay;
0140   decay = processTable->FindProcess("Decay", G4MuonPlus::MuonPlus());
0141 
0142   G4ProcessManager* pmanager;
0143   pmanager = G4MuonPlus::MuonPlus()->GetProcessManager();
0144 
0145   if (pmanager) {
0146     if (decay) pmanager->RemoveProcess(decay);
0147     pmanager->AddProcess(decayWithSpin);
0148     // set ordering for PostStepDoIt and AtRestDoIt
0149     pmanager->SetProcessOrdering(decayWithSpin, idxPostStep);
0150     pmanager->SetProcessOrdering(decayWithSpin, idxAtRest);
0151   }
0152 
0153   decay = processTable->FindProcess("Decay", G4MuonMinus::MuonMinus());
0154 
0155   pmanager = G4MuonMinus::MuonMinus()->GetProcessManager();
0156 
0157   if (pmanager) {
0158     if (decay) pmanager->RemoveProcess(decay);
0159     pmanager->AddProcess(decayWithSpin);
0160     // set ordering for PostStepDoIt and AtRestDoIt
0161     pmanager->SetProcessOrdering(decayWithSpin, idxPostStep);
0162     pmanager->SetProcessOrdering(decayWithSpin, idxAtRest);
0163   }
0164 
0165   G4VProcess* process = processTable->FindProcess("muMinusCaptureAtRest", G4MuonMinus::MuonMinus());
0166 
0167   if (pmanager) {
0168     if (process) pmanager->RemoveProcess(process);
0169     process = new G4MuonMinusCapture(new G4MuMinusCapturePrecompound());
0170     pmanager->AddRestProcess(process);
0171   }
0172 
0173   auto poldecay = new G4PionDecayMakeSpin();
0174 
0175   decay = processTable->FindProcess("Decay", G4PionPlus::PionPlus());
0176 
0177   pmanager = G4PionPlus::PionPlus()->GetProcessManager();
0178 
0179   if (pmanager) {
0180     if (decay) pmanager->RemoveProcess(decay);
0181     pmanager->AddProcess(poldecay);
0182     // set ordering for PostStepDoIt and AtRestDoIt
0183     pmanager->SetProcessOrdering(poldecay, idxPostStep);
0184     pmanager->SetProcessOrdering(poldecay, idxAtRest);
0185   }
0186 
0187   decay = processTable->FindProcess("Decay", G4PionMinus::PionMinus());
0188 
0189   pmanager = G4PionMinus::PionMinus()->GetProcessManager();
0190 
0191   if (pmanager) {
0192     if (decay) pmanager->RemoveProcess(decay);
0193     pmanager->AddProcess(poldecay);
0194     // set ordering for PostStepDoIt and AtRestDoIt
0195     pmanager->SetProcessOrdering(poldecay, idxPostStep);
0196     pmanager->SetProcessOrdering(poldecay, idxAtRest);
0197   }
0198 
0199   AddStepMax();
0200 }
0201 
0202 /*
0203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0204 
0205 void F04PhysicsList::RemoveFromPhysicsList(const G4String& name)
0206 {
0207     G4bool success = false;
0208     for (G4PhysConstVector::iterator p  = physicsVector->begin();
0209                                      p != physicsVector->end(); ++p) {
0210         G4VPhysicsConstructor* e = (*p);
0211         if (e->GetPhysicsName() == name) {
0212            physicsVector->erase(p);
0213            success = true;
0214            break;
0215         }
0216     }
0217     if (!success) {
0218        std::ostringstream message;
0219        message << "PhysicsList::RemoveFromPhysicsList "<< name << "not found";
0220        G4Exception(message.str().c_str());
0221     }
0222 }
0223 
0224 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0225 
0226 void F04PhysicsList::ClearPhysics()
0227 {
0228     for (G4PhysConstVector::iterator p  = physicsVector->begin();
0229                                      p != physicsVector->end(); ++p) {
0230         delete (*p);
0231     }
0232     physicsVector->clear();
0233 }
0234 */
0235 
0236 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0237 
0238 void F04PhysicsList::SetStepMax(G4double step)
0239 {
0240   fMaxChargedStep = step;
0241   fStepMaxProcess->SetStepMax(fMaxChargedStep);
0242 }
0243 
0244 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0245 
0246 F04StepMax* F04PhysicsList::GetStepMaxProcess() const
0247 {
0248   return fStepMaxProcess;
0249 }
0250 
0251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0252 
0253 void F04PhysicsList::AddStepMax()
0254 {
0255   // Step limitation seen as a process
0256 
0257   auto particleIterator = GetParticleIterator();
0258   particleIterator->reset();
0259   while ((*particleIterator)()) {
0260     G4ParticleDefinition* particle = particleIterator->value();
0261     G4ProcessManager* pmanager = particle->GetProcessManager();
0262 
0263     if (fStepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived()) {
0264       if (pmanager) pmanager->AddDiscreteProcess(fStepMaxProcess);
0265     }
0266   }
0267 }