Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-31 08:26: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 ParticleChangeForPeriodic.hh
0027 /// \brief Definition of the ParticleChangeForPeriodic 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  *
0049  */
0050 #ifndef ParticleChangeForPeriodic_hh
0051 #define ParticleChangeForPeriodic_hh 1
0052 
0053 #include "G4VParticleChange.hh"
0054 #include "globals.hh"
0055 
0056 class G4DynamicParticle;
0057 
0058 class ParticleChangeForPeriodic : public G4VParticleChange
0059 {
0060   public:
0061     ParticleChangeForPeriodic();
0062 
0063     ~ParticleChangeForPeriodic() override = default;
0064 
0065     G4Step* UpdateStepForPostStep(G4Step* Step) override;
0066 
0067     void InitializeForPostStep(const G4Track&);
0068 
0069     void AddSecondary(G4DynamicParticle* aParticle);
0070 
0071     const G4ThreeVector& GetProposedMomentumDirection() const;
0072 
0073     void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz);
0074 
0075     void ProposeMomentumDirection(const G4ThreeVector& Pfinal);
0076 
0077     const G4ThreeVector& GetProposedPolarization() const;
0078 
0079     void ProposePolarization(const G4ThreeVector& dir);
0080 
0081     void ProposePolarization(G4double Px, G4double Py, G4double Pz);
0082 
0083     const G4ThreeVector& GetProposedPosition() const;
0084 
0085     void ProposePosition(const G4ThreeVector& pos);
0086 
0087     void ProposePosition(G4double x, G4double y, G4double z);
0088 
0089     const G4Track* GetCurrentTrack() const;
0090 
0091     void DumpInfo() const override;
0092 
0093     ParticleChangeForPeriodic(const ParticleChangeForPeriodic& right) = delete;
0094 
0095     ParticleChangeForPeriodic& operator=(const ParticleChangeForPeriodic& right) = delete;
0096 
0097   private:
0098     const G4Track* fTrack{};
0099     G4ThreeVector fProposedMomentumDirection;
0100     G4ThreeVector fProposedPolarization;
0101     G4ThreeVector fProposedPosition;
0102 };
0103 
0104 inline const G4ThreeVector& ParticleChangeForPeriodic::GetProposedMomentumDirection() const
0105 {
0106   return fProposedMomentumDirection;
0107 }
0108 
0109 inline void ParticleChangeForPeriodic::ProposeMomentumDirection(const G4ThreeVector& dir)
0110 {
0111   fProposedMomentumDirection = dir;
0112 }
0113 
0114 inline void ParticleChangeForPeriodic::ProposeMomentumDirection(G4double Px, G4double Py,
0115                                                                 G4double Pz)
0116 {
0117   fProposedMomentumDirection.setX(Px);
0118   fProposedMomentumDirection.setY(Py);
0119   fProposedMomentumDirection.setZ(Pz);
0120 }
0121 
0122 inline const G4ThreeVector& ParticleChangeForPeriodic::GetProposedPolarization() const
0123 {
0124   return fProposedPolarization;
0125 }
0126 
0127 inline void ParticleChangeForPeriodic::ProposePolarization(const G4ThreeVector& dir)
0128 {
0129   fProposedPolarization = dir;
0130 }
0131 
0132 inline void ParticleChangeForPeriodic::ProposePolarization(G4double Px, G4double Py, G4double Pz)
0133 {
0134   fProposedPolarization.setX(Px);
0135   fProposedPolarization.setY(Py);
0136   fProposedPolarization.setZ(Pz);
0137 }
0138 
0139 inline const G4ThreeVector& ParticleChangeForPeriodic::GetProposedPosition() const
0140 {
0141   return fProposedPosition;
0142 }
0143 
0144 inline void ParticleChangeForPeriodic::ProposePosition(const G4ThreeVector& dir)
0145 {
0146   fProposedPosition = dir;
0147 }
0148 
0149 inline void ParticleChangeForPeriodic::ProposePosition(G4double Px, G4double Py, G4double Pz)
0150 {
0151   fProposedPosition.setX(Px);
0152   fProposedPosition.setY(Py);
0153   fProposedPosition.setZ(Pz);
0154 }
0155 
0156 inline void ParticleChangeForPeriodic::InitializeForPostStep(const G4Track& track)
0157 {
0158   theStatusChange = track.GetTrackStatus();
0159   theLocalEnergyDeposit = 0.0;
0160   theNonIonizingEnergyDeposit = 0.0;
0161   InitializeSecondaries();
0162   theParentWeight = track.GetWeight();
0163   isParentWeightProposed = false;
0164   fProposedMomentumDirection = track.GetMomentumDirection();
0165   fProposedPolarization = track.GetPolarization();
0166   fProposedPosition = track.GetPosition();
0167   fTrack = &track;
0168 }
0169 
0170 inline const G4Track* ParticleChangeForPeriodic::GetCurrentTrack() const
0171 {
0172   return fTrack;
0173 }
0174 #endif