LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 46 of file MedicalBeam.hh.

Member Enumeration Documentation

Enumerator
SQUARE 
CIRCLE 

Definition at line 48 of file MedicalBeam.hh.

Constructor & Destructor Documentation

MedicalBeam::MedicalBeam ( )

Definition at line 49 of file MedicalBeam.cc.

References fieldXY.

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

Definition at line 63 of file MedicalBeam.cc.

65 {
66 }

Member Function Documentation

G4ThreeVector MedicalBeam::GenerateBeamDirection ( ) const
protected

Definition at line 70 of file MedicalBeam.cc.

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

Referenced by GeneratePrimaries().

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

Definition at line 112 of file MedicalBeam.cc.

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

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

Definition at line 140 of file MedicalBeam.hh.

References fieldR.

Referenced by BOOST_PYTHON_MODULE().

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

Definition at line 119 of file MedicalBeam.hh.

References fieldShape.

Referenced by BOOST_PYTHON_MODULE().

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

Definition at line 131 of file MedicalBeam.hh.

References fieldXY.

Referenced by BOOST_PYTHON_MODULE().

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

Definition at line 134 of file MedicalBeam.hh.

References fieldXY.

Referenced by BOOST_PYTHON_MODULE().

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

Definition at line 107 of file MedicalBeam.hh.

References kineticE.

Referenced by BOOST_PYTHON_MODULE().

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

Definition at line 101 of file MedicalBeam.hh.

References particle.

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

Definition at line 113 of file MedicalBeam.hh.

References sourcePosition.

Referenced by BOOST_PYTHON_MODULE().

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

Definition at line 125 of file MedicalBeam.hh.

References SSD.

Referenced by BOOST_PYTHON_MODULE().

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

Definition at line 137 of file MedicalBeam.hh.

References fieldR.

Referenced by BOOST_PYTHON_MODULE().

138 { fieldR= r; }
G4double fieldR
Definition: MedicalBeam.hh:58
void MedicalBeam::SetFieldShape ( MedicalBeam::FieldShape  shape)
inline

Definition at line 116 of file MedicalBeam.hh.

References fieldShape.

Referenced by BOOST_PYTHON_MODULE().

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

Definition at line 128 of file MedicalBeam.hh.

References fieldXY.

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

Definition at line 104 of file MedicalBeam.hh.

References e, and kineticE.

Referenced by BOOST_PYTHON_MODULE().

105 { kineticE= e; }
G4double kineticE
Definition: MedicalBeam.hh:52
Float_t e
Definition: plot.C:34
void MedicalBeam::SetParticleDefinition ( G4ParticleDefinition *  pd)
inline

Definition at line 98 of file MedicalBeam.hh.

References particle.

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

Definition at line 110 of file MedicalBeam.hh.

References sourcePosition.

Referenced by BOOST_PYTHON_MODULE().

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

Definition at line 122 of file MedicalBeam.hh.

References SSD.

Referenced by BOOST_PYTHON_MODULE().

123 { SSD= ssd; }
G4double SSD
Definition: MedicalBeam.hh:55

Member Data Documentation

G4double MedicalBeam::fieldR
protected

Definition at line 58 of file MedicalBeam.hh.

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

FieldShape MedicalBeam::fieldShape
protected

Definition at line 56 of file MedicalBeam.hh.

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

G4double MedicalBeam::fieldXY[2]
protected

Definition at line 57 of file MedicalBeam.hh.

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

G4double MedicalBeam::kineticE
protected

Definition at line 52 of file MedicalBeam.hh.

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

G4ParticleDefinition* MedicalBeam::particle
protected

Definition at line 51 of file MedicalBeam.hh.

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

G4ThreeVector MedicalBeam::sourcePosition
protected

Definition at line 53 of file MedicalBeam.hh.

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

G4double MedicalBeam::SSD
protected

Definition at line 55 of file MedicalBeam.hh.

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


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