Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-23 08:29:29

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