Back to home page

EIC code displayed by LXR

 
 

    


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