LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
MedicalBeam Class Reference

#include "MedicalBeam.hh"

Inheritance diagram for MedicalBeam:

Public Types

enum  FieldShape { SQUARE =0, CIRCLE }
 

Public Member Functions

 MedicalBeam ()
 
 ~MedicalBeam ()
 
void SetParticleDefinition (G4ParticleDefinition *pd)
 
const G4ParticleDefinition * GetParticleDefinition () const
 
void SetKineticE (G4double e)
 
G4double GetKineticE () const
 
void SetSourcePosition (const G4ThreeVector &pos)
 
G4ThreeVector GetSourcePosition () const
 
void SetFieldShape (FieldShape shape)
 
FieldShape GetFieldShape () const
 
void SetSSD (G4double ssd)
 
G4double GetSSD () const
 
void SetFieldXY (G4double fx, G4double fy)
 
G4double GetFieldX () const
 
G4double GetFieldY () const
 
void SetFieldR (G4double r)
 
G4double GetFieldR () const
 
virtual void GeneratePrimaries (G4Event *anEvent)
 

Protected Member Functions

G4ThreeVector GenerateBeamDirection () const
 

Protected Attributes

G4ParticleDefinition * particle
 
G4double kineticE
 
G4ThreeVector sourcePosition
 
G4double SSD
 
FieldShape fieldShape
 
G4double fieldXY [2]
 
G4double fieldR
 

Detailed Description

Definition at line 45 of file MedicalBeam.hh.

Member Enumeration Documentation

Enumerator
SQUARE 
CIRCLE 

Definition at line 47 of file MedicalBeam.hh.

Constructor & Destructor Documentation

MedicalBeam::MedicalBeam ( )

Definition at line 48 of file MedicalBeam.cc.

References fieldXY.

49  : particle(0),
50  kineticE(1.*MeV),
51  sourcePosition(G4ThreeVector()),
52  SSD(1.*m),
54  fieldR(10.*cm)
56 {
57  fieldXY[0]= fieldXY[1]= 10.*cm;
58 }
G4ParticleDefinition * particle
Definition: MedicalBeam.hh:50
G4double fieldXY[2]
Definition: MedicalBeam.hh:56
G4ThreeVector sourcePosition
Definition: MedicalBeam.hh:52
G4double SSD
Definition: MedicalBeam.hh:54
FieldShape fieldShape
Definition: MedicalBeam.hh:55
G4double kineticE
Definition: MedicalBeam.hh:51
G4double fieldR
Definition: MedicalBeam.hh:57
MedicalBeam::~MedicalBeam ( )

Definition at line 62 of file MedicalBeam.cc.

64 {
65 }

Member Function Documentation

G4ThreeVector MedicalBeam::GenerateBeamDirection ( ) const
protected

Definition at line 69 of file MedicalBeam.cc.

References util::abs(), fieldR, fieldShape, fieldXY, sqr(), SQUARE, SSD, x, y, and z.

Referenced by GeneratePrimaries().

71 {
72  // uniform distribution in a limitted solid angle
73  G4double dr;
75  dr= std::sqrt(sqr(fieldXY[0]/2.)+sqr(fieldXY[1]/2.));
76  } else {
77  dr= fieldR;
78  }
79 
80  G4double sin0= dr/SSD;
81  G4double cos0= std::sqrt(1.-sqr(sin0));
82 
83  G4double dcos, dsin, dphi, z;
84 
85  G4double x= DBL_MAX;
86  G4double y= DBL_MAX;
87 
88  G4double xmax, ymax;
90  xmax= fieldXY[0]/2./SSD;
91  ymax= fieldXY[1]/2./SSD;
92  } else {
93  xmax= ymax= DBL_MAX-1.;
94  }
95 
96  while(! (std::abs(x)< xmax && std::abs(y)< ymax) ) {
97  dcos= RandFlat::shoot(cos0, 1.);
98  dsin= std::sqrt(1.-sqr(dcos));
99  dphi= RandFlat::shoot(0., twopi);
100 
101  x= std::cos(dphi)*dsin*dcos;
102  y= std::sin(dphi)*dsin*dcos;
103  }
104  z= dcos;
105 
106  return G4ThreeVector(x,y,z);
107 }
Float_t x
Definition: compare.C:6
G4double fieldXY[2]
Definition: MedicalBeam.hh:56
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
constexpr auto abs(T v)
Returns the absolute value of the argument.
constexpr T sqr(T v)
G4double SSD
Definition: MedicalBeam.hh:54
FieldShape fieldShape
Definition: MedicalBeam.hh:55
G4double fieldR
Definition: MedicalBeam.hh:57
void MedicalBeam::GeneratePrimaries ( G4Event *  anEvent)
virtual

Definition at line 111 of file MedicalBeam.cc.

References GenerateBeamDirection(), kineticE, particle, sourcePosition, and sqr().

113 {
114  if(particle==0) return;
115 
116  // create a new vertex
117  G4PrimaryVertex* vertex= new G4PrimaryVertex(sourcePosition, 0.*ns);
118 
119  // momentum
120  G4double mass= particle-> GetPDGMass();
121  G4double p= std::sqrt(sqr(mass+kineticE)-sqr(mass));
122  G4ThreeVector pmon= p*GenerateBeamDirection();
123  G4PrimaryParticle* primary= new G4PrimaryParticle(particle,
124  pmon.x(),
125  pmon.y(),
126  pmon.z());
127  // set primary to vertex
128  vertex-> SetPrimary(primary);
129 
130  // set vertex to event
131  anEvent-> AddPrimaryVertex(vertex);
132 }
G4ParticleDefinition * particle
Definition: MedicalBeam.hh:50
G4ThreeVector sourcePosition
Definition: MedicalBeam.hh:52
constexpr T sqr(T v)
G4double kineticE
Definition: MedicalBeam.hh:51
G4ThreeVector GenerateBeamDirection() const
Definition: MedicalBeam.cc:69
vertex reconstruction
G4double MedicalBeam::GetFieldR ( ) const
inline

Definition at line 139 of file MedicalBeam.hh.

References fieldR.

Referenced by BOOST_PYTHON_MODULE().

140 { return fieldR; }
G4double fieldR
Definition: MedicalBeam.hh:57
MedicalBeam::FieldShape MedicalBeam::GetFieldShape ( ) const
inline

Definition at line 118 of file MedicalBeam.hh.

References fieldShape.

Referenced by BOOST_PYTHON_MODULE().

119 { return fieldShape; }
FieldShape fieldShape
Definition: MedicalBeam.hh:55
G4double MedicalBeam::GetFieldX ( ) const
inline

Definition at line 130 of file MedicalBeam.hh.

References fieldXY.

Referenced by BOOST_PYTHON_MODULE().

131 { return fieldXY[0]; }
G4double fieldXY[2]
Definition: MedicalBeam.hh:56
G4double MedicalBeam::GetFieldY ( ) const
inline

Definition at line 133 of file MedicalBeam.hh.

References fieldXY.

Referenced by BOOST_PYTHON_MODULE().

134 { return fieldXY[1]; }
G4double fieldXY[2]
Definition: MedicalBeam.hh:56
G4double MedicalBeam::GetKineticE ( ) const
inline

Definition at line 106 of file MedicalBeam.hh.

References kineticE.

Referenced by BOOST_PYTHON_MODULE().

107 { return kineticE; }
G4double kineticE
Definition: MedicalBeam.hh:51
const G4ParticleDefinition * MedicalBeam::GetParticleDefinition ( ) const
inline

Definition at line 100 of file MedicalBeam.hh.

References particle.

101 { return particle; }
G4ParticleDefinition * particle
Definition: MedicalBeam.hh:50
G4ThreeVector MedicalBeam::GetSourcePosition ( ) const
inline

Definition at line 112 of file MedicalBeam.hh.

References sourcePosition.

Referenced by BOOST_PYTHON_MODULE().

113 { return sourcePosition; }
G4ThreeVector sourcePosition
Definition: MedicalBeam.hh:52
G4double MedicalBeam::GetSSD ( ) const
inline

Definition at line 124 of file MedicalBeam.hh.

References SSD.

Referenced by BOOST_PYTHON_MODULE().

125 { return SSD; }
G4double SSD
Definition: MedicalBeam.hh:54
void MedicalBeam::SetFieldR ( G4double  r)
inline

Definition at line 136 of file MedicalBeam.hh.

References fieldR, and r.

Referenced by BOOST_PYTHON_MODULE().

137 { fieldR= r; }
TRandom r
Definition: spectrum.C:23
G4double fieldR
Definition: MedicalBeam.hh:57
void MedicalBeam::SetFieldShape ( MedicalBeam::FieldShape  shape)
inline

Definition at line 115 of file MedicalBeam.hh.

References fieldShape.

Referenced by BOOST_PYTHON_MODULE().

116 { fieldShape= shape; }
FieldShape fieldShape
Definition: MedicalBeam.hh:55
void MedicalBeam::SetFieldXY ( G4double  fx,
G4double  fy 
)
inline

Definition at line 127 of file MedicalBeam.hh.

References fieldXY.

128 { fieldXY[0]= fx; fieldXY[1]= fy; }
G4double fieldXY[2]
Definition: MedicalBeam.hh:56
void MedicalBeam::SetKineticE ( G4double  e)
inline

Definition at line 103 of file MedicalBeam.hh.

References e, and kineticE.

Referenced by BOOST_PYTHON_MODULE().

104 { kineticE= e; }
G4double kineticE
Definition: MedicalBeam.hh:51
Float_t e
Definition: plot.C:35
void MedicalBeam::SetParticleDefinition ( G4ParticleDefinition *  pd)
inline

Definition at line 97 of file MedicalBeam.hh.

References particle.

98 { particle= pd; }
G4ParticleDefinition * particle
Definition: MedicalBeam.hh:50
void MedicalBeam::SetSourcePosition ( const G4ThreeVector &  pos)
inline

Definition at line 109 of file MedicalBeam.hh.

References sourcePosition.

Referenced by BOOST_PYTHON_MODULE().

110 { sourcePosition= pos; }
G4ThreeVector sourcePosition
Definition: MedicalBeam.hh:52
void MedicalBeam::SetSSD ( G4double  ssd)
inline

Definition at line 121 of file MedicalBeam.hh.

References SSD.

Referenced by BOOST_PYTHON_MODULE().

122 { SSD= ssd; }
G4double SSD
Definition: MedicalBeam.hh:54

Member Data Documentation

G4double MedicalBeam::fieldR
protected

Definition at line 57 of file MedicalBeam.hh.

Referenced by GenerateBeamDirection(), GetFieldR(), and SetFieldR().

FieldShape MedicalBeam::fieldShape
protected

Definition at line 55 of file MedicalBeam.hh.

Referenced by GenerateBeamDirection(), GetFieldShape(), and SetFieldShape().

G4double MedicalBeam::fieldXY[2]
protected

Definition at line 56 of file MedicalBeam.hh.

Referenced by GenerateBeamDirection(), GetFieldX(), GetFieldY(), MedicalBeam(), and SetFieldXY().

G4double MedicalBeam::kineticE
protected

Definition at line 51 of file MedicalBeam.hh.

Referenced by GeneratePrimaries(), GetKineticE(), and SetKineticE().

G4ParticleDefinition* MedicalBeam::particle
protected

Definition at line 50 of file MedicalBeam.hh.

Referenced by GeneratePrimaries(), GetParticleDefinition(), and SetParticleDefinition().

G4ThreeVector MedicalBeam::sourcePosition
protected

Definition at line 52 of file MedicalBeam.hh.

Referenced by GeneratePrimaries(), GetSourcePosition(), and SetSourcePosition().

G4double MedicalBeam::SSD
protected

Definition at line 54 of file MedicalBeam.hh.

Referenced by GenerateBeamDirection(), GetSSD(), and SetSSD().


The documentation for this class was generated from the following files: