Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-31 07:50:35

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 PeriodicBoundaryProcess.hh
0027 /// \brief Definition of the PeriodicBoundaryProcess class
0028 
0029 /*
0030  * Based on 'G4pbc'.
0031  * Copyright (c) 2020 Amentum Pty Ltd
0032  * team@amentum.space
0033  * The original open-source version of this code
0034  * may be found at https://github.com/amentumspace/g4pbc
0035  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
0036  * associated documentation files (the "Software"), to deal in the Software without restriction,
0037  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
0038  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
0039  * is furnished to do so, subject to the following conditions:
0040  * The above copyright notice and this permission notice shall be included in all copies
0041  * or substantial portions of the Software.
0042  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
0043  * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0044  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
0045  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0046  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0047  *
0048  * team@amentum.space
0049  */
0050 #ifndef PeriodicBoundaryProcess_h
0051 #define PeriodicBoundaryProcess_h 1
0052 
0053 #include "ParticleChangeForPeriodic.hh"
0054 
0055 #include "G4Electron.hh"
0056 #include "G4VDiscreteProcess.hh"
0057 #include "globals.hh"
0058 
0059 class G4Step;
0060 
0061 enum ProcessStatus
0062 {
0063   Undefined,
0064   Reflection,
0065   Cycling,
0066   StepTooSmall,
0067   NotAtBoundary
0068 };
0069 
0070 class PeriodicBoundaryProcess : public G4VDiscreteProcess
0071 {
0072   public:
0073     explicit PeriodicBoundaryProcess(const G4String& processName = "PBC",
0074                                      G4ProcessType type = fNotDefined, bool per_x = true,
0075                                      bool per_y = true, bool per_z = true);
0076 
0077     ~PeriodicBoundaryProcess() override = default;
0078 
0079     PeriodicBoundaryProcess(const PeriodicBoundaryProcess& right) = delete;
0080 
0081     PeriodicBoundaryProcess& operator=(const PeriodicBoundaryProcess& right) = delete;
0082 
0083   public:
0084     G4bool IsApplicable(const G4ParticleDefinition&) override;
0085 
0086     G4double GetMeanFreePath(const G4Track&, G4double, G4ForceCondition* condition) override;
0087 
0088     ProcessStatus GetStatus() const;
0089 
0090     G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&) override;
0091 
0092   protected:
0093     ParticleChangeForPeriodic fParticleChange;
0094 
0095   private:
0096     void BoundaryProcessVerbose();
0097     std::map<ProcessStatus, G4String> fStatusMessages = {{Undefined, " *** Undefined *** "},
0098                                                          {NotAtBoundary, " *** NotAtBoundary *** "},
0099                                                          {Reflection, " *** Reflection *** "},
0100                                                          {Cycling, " *** Periodic *** "},
0101                                                          {StepTooSmall, " *** StepTooSmall *** "}};
0102 
0103     ProcessStatus fTheStatus = Undefined;
0104     G4ThreeVector fOldPosition;
0105     G4ThreeVector fNewPosition;
0106     G4ThreeVector fOldMomentum;
0107     G4ThreeVector fNewMomentum;
0108     G4ThreeVector fOldPolarization;
0109     G4ThreeVector fNewPolarization;
0110     G4ThreeVector fTheGlobalNormal;
0111     G4double fkCarTolerance;
0112     G4bool fPeriodicX = true;
0113     G4bool fPeriodicY = true;
0114     G4bool fPeriodicZ = true;
0115 };
0116 
0117 inline G4bool PeriodicBoundaryProcess::IsApplicable(const G4ParticleDefinition& aParticleType)
0118 {
0119   G4bool applicable = false;
0120   // applied only for electrons
0121   if (&aParticleType == G4Electron::Electron()) {
0122     applicable = true;
0123   }
0124   return applicable;
0125 }
0126 
0127 inline ProcessStatus PeriodicBoundaryProcess::GetStatus() const
0128 {
0129   return fTheStatus;
0130 }
0131 
0132 #endif