Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-14 08:09:02

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 MedicalBeam.hh
0028 /// @brief Define beam profile as primary generator
0029 
0030 #ifndef MEDICAL_BEAM_H
0031 #define MEDICAL_BEAM_H
0032 
0033 #include "G4ThreeVector.hh"
0034 #include "G4VUserPrimaryGeneratorAction.hh"
0035 #include "globals.hh"
0036 
0037 class G4ParticleDefinition;
0038 
0039 class MedicalBeam : public G4VUserPrimaryGeneratorAction
0040 {
0041   public:
0042     enum FieldShape
0043     {
0044       kSQUARE = 0,
0045       kCIRCLE
0046     };
0047 
0048     MedicalBeam();
0049     ~MedicalBeam();
0050 
0051     // set/get functions...
0052     void SetParticleDefinition(G4ParticleDefinition* pd);
0053     const G4ParticleDefinition* GetParticleDefinition() const;
0054 
0055     void SetKineticE(G4double e);
0056     G4double GetKineticE() const;
0057 
0058     void SetSourcePosition(const G4ThreeVector& pos);
0059     G4ThreeVector GetSourcePosition() const;
0060 
0061     void SetFieldShape(FieldShape shape);
0062     FieldShape GetFieldShape() const;
0063 
0064     void SetSSD(G4double ssd);
0065     G4double GetSSD() const;
0066 
0067     void SetFieldXY(G4double fx, G4double fy);
0068     G4double GetFieldX() const;
0069     G4double GetFieldY() const;
0070 
0071     void SetFieldR(G4double r);
0072     G4double GetFieldR() const;
0073 
0074     // methods...
0075     virtual void GeneratePrimaries(G4Event* anEvent);
0076 
0077   private:
0078     // local methods...
0079     G4ThreeVector GenerateBeamDirection() const;
0080 
0081     G4ParticleDefinition* fparticle;
0082     G4double fkineticE;
0083     G4ThreeVector fsourcePosition;
0084 
0085     G4double fSSD;  // (SSD= Source Skin Depth)
0086     FieldShape ffieldShape;
0087     G4double ffieldXY[2];
0088     G4double ffieldR;
0089 };
0090 
0091 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0092 inline void MedicalBeam::SetParticleDefinition(G4ParticleDefinition* pd)
0093 {
0094   fparticle = pd;
0095 }
0096 
0097 inline const G4ParticleDefinition* MedicalBeam::GetParticleDefinition() const
0098 {
0099   return fparticle;
0100 }
0101 
0102 inline void MedicalBeam::SetKineticE(G4double e)
0103 {
0104   fkineticE = e;
0105 }
0106 
0107 inline G4double MedicalBeam::GetKineticE() const
0108 {
0109   return fkineticE;
0110 }
0111 
0112 inline void MedicalBeam::SetSourcePosition(const G4ThreeVector& pos)
0113 {
0114   fsourcePosition = pos;
0115 }
0116 
0117 inline G4ThreeVector MedicalBeam::GetSourcePosition() const
0118 {
0119   return fsourcePosition;
0120 }
0121 
0122 inline void MedicalBeam::SetFieldShape(MedicalBeam::FieldShape shape)
0123 {
0124   ffieldShape = shape;
0125 }
0126 
0127 inline MedicalBeam::FieldShape MedicalBeam::GetFieldShape() const
0128 {
0129   return ffieldShape;
0130 }
0131 
0132 inline void MedicalBeam::SetSSD(G4double ssd)
0133 {
0134   fSSD = ssd;
0135 }
0136 
0137 inline G4double MedicalBeam::GetSSD() const
0138 {
0139   return fSSD;
0140 }
0141 
0142 inline void MedicalBeam::SetFieldXY(G4double fx, G4double fy)
0143 {
0144   ffieldXY[0] = fx;
0145   ffieldXY[1] = fy;
0146 }
0147 
0148 inline G4double MedicalBeam::GetFieldX() const
0149 {
0150   return ffieldXY[0];
0151 }
0152 
0153 inline G4double MedicalBeam::GetFieldY() const
0154 {
0155   return ffieldXY[1];
0156 }
0157 
0158 inline void MedicalBeam::SetFieldR(G4double r)
0159 {
0160   ffieldR = r;
0161 }
0162 
0163 inline G4double MedicalBeam::GetFieldR() const
0164 {
0165   return ffieldR;
0166 }
0167 
0168 #endif