Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 08:30:28

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 PeriodicBoundaryPhysics.cc
0027 /// \brief Implementation of the PeriodicBoundaryPhysics class
0028 
0029 #include "PeriodicBoundaryPhysics.hh"
0030 
0031 #include "PeriodicBoundaryProcess.hh"
0032 
0033 #include "G4PhysicsConstructorFactory.hh"
0034 #include "G4ProcessManager.hh"
0035 #include "globals.hh"
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 
0038 G4_DECLARE_PHYSCONSTR_FACTORY(PeriodicBoundaryPhysics);
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0040 
0041 PeriodicBoundaryPhysics::PeriodicBoundaryPhysics(const G4String& name, G4bool per_x, G4bool per_y,
0042                                                  G4bool per_z)
0043   : G4VPhysicsConstructor(name), fPeriodicX(per_x), fPeriodicY(per_y), fPeriodicZ(per_z)
0044 {
0045   verboseLevel = 0;
0046 }
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 void PeriodicBoundaryPhysics::ConstructParticle() {}
0051 
0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0053 
0054 void PeriodicBoundaryPhysics::ConstructProcess()
0055 {
0056   if (verboseLevel > 0) G4cout << "Constructing cyclic boundary physics process" << G4endl;
0057 
0058   auto* pbc =
0059     new PeriodicBoundaryProcess("Cyclic", fNotDefined, fPeriodicX, fPeriodicY, fPeriodicZ);
0060 
0061   if (verboseLevel > 0) {
0062     pbc->SetVerboseLevel(verboseLevel);
0063   }
0064 
0065   auto aParticleIterator = GetParticleIterator();
0066 
0067   aParticleIterator->reset();
0068 
0069   G4ProcessManager* processManager = nullptr;
0070 
0071   while ((*aParticleIterator)()) {
0072     G4ParticleDefinition* particle = aParticleIterator->value();
0073 
0074     G4String particleName = particle->GetParticleName();
0075 
0076     processManager = particle->GetProcessManager();
0077 
0078     if (!processManager) {
0079       ThrowException(particleName);
0080       return;
0081     }
0082 
0083     AddDiscreteProcess(pbc, *particle, processManager);
0084   }
0085 }
0086 
0087 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0088 
0089 void PeriodicBoundaryPhysics::ThrowException(const G4String& particleName)
0090 {
0091   std::ostringstream o;
0092   o << "Particle " << particleName << "without a Process Manager";
0093   G4Exception("G4PeriodicBoundaryPhysics::ConstructProcess()", "", FatalException, o.str().c_str());
0094 }
0095 
0096 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0097 
0098 void PeriodicBoundaryPhysics::AddDiscreteProcess(PeriodicBoundaryProcess* periodicBoundaryProcess,
0099                                                  G4ParticleDefinition& particle,
0100                                                  G4ProcessManager* processManager)
0101 {
0102   if (periodicBoundaryProcess->IsApplicable(particle)) {
0103     processManager->AddDiscreteProcess(periodicBoundaryProcess);
0104   }
0105 }
0106 
0107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......