Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Dicom2PrimaryGeneratorAction Class Reference

The primary generator action class with particle gun. More...

#include <Doxymodules_medical.h>

Inheritance diagram for Dicom2PrimaryGeneratorAction:
G4VUserPrimaryGeneratorAction

Public Member Functions

 Dicom2PrimaryGeneratorAction ()
 
virtual ~Dicom2PrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *)
 
const G4ParticleGunGetParticleGun () const
 

Private Attributes

G4ParticleGunfParticleGun
 
G4BoxfEnvelopeBox
 
G4VPhysicalVolumefEnvelopeVol
 
G4ThreeVector fPosCenter
 
G4ThreeVector fPosDelta
 
G4double fGeomFactor
 

Detailed Description

The primary generator action class with particle gun.

The default kinematic is a 6 MeV gamma, randomly distribued in front of the phantom across 80% of the (X,Y) phantom size.

Definition at line 71 of file Doxymodules_medical.h.

Constructor & Destructor Documentation

◆ Dicom2PrimaryGeneratorAction()

Dicom2PrimaryGeneratorAction::Dicom2PrimaryGeneratorAction ( )

Definition at line 49 of file Dicom2PrimaryGeneratorAction.cc.

52 fEnvelopeBox(nullptr),
53 fEnvelopeVol(nullptr),
54 fPosCenter(G4ThreeVector(0.0)),
55 fPosDelta(G4ThreeVector(0.0)),
56 fGeomFactor(0.8)
57{
58 // default particle kinematic
59 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
60 G4String particleName;
61 G4ParticleDefinition* particle
62 = particleTable->FindParticle(particleName="e-");
63 fParticleGun->SetParticleDefinition(particle);
64 fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
65 fParticleGun->SetParticleEnergy(10.*MeV);
66}

◆ ~Dicom2PrimaryGeneratorAction()

Dicom2PrimaryGeneratorAction::~Dicom2PrimaryGeneratorAction ( )
virtual

Definition at line 70 of file Dicom2PrimaryGeneratorAction.cc.

71{
72 delete fParticleGun;
73}

Member Function Documentation

◆ GeneratePrimaries()

void Dicom2PrimaryGeneratorAction::GeneratePrimaries ( G4Event anEvent)
virtual

Definition at line 77 of file Dicom2PrimaryGeneratorAction.cc.

78{
79 //this function is called at the begining of ecah event
80 //
81
82 // In order to avoid dependence of PrimaryGeneratorAction
83 // on DetectorConstruction class we get phantomContainer volume
84 // from G4LogicalVolumeStore.
85 if (!fEnvelopeBox)
86 {
87 G4LogicalVolume* envLV
88 = G4LogicalVolumeStore::GetInstance()->GetVolume("phantomContainer");
89 if(envLV)
90 fEnvelopeBox = dynamic_cast<G4Box*>(envLV->GetSolid());
91 }
92
93 if(!fEnvelopeVol)
94 {
95 fEnvelopeVol = G4PhysicalVolumeStore::GetInstance()->GetVolume("phantomContainer");
96 }
97
98 // get the center of the phantom
99 if(fEnvelopeVol)
100 {
101 fPosCenter = fEnvelopeVol->GetObjectTranslation();
102 }
103 else
104 {
105 G4ExceptionDescription msg;
106 msg << "Envelope physical volume not found.\n";
107 msg << "The gun will be place at the center.";
108 G4Exception("Dicom2PrimaryGeneratorAction::GeneratePrimaries()",
109 "DICOM20002",JustWarning, msg);
110 }
111
112 // get the size of the phantom
113 if(fEnvelopeBox)
114 {
115 fPosDelta = G4ThreeVector(2.0 * fEnvelopeBox->GetXHalfLength(),
116 2.0 * fEnvelopeBox->GetYHalfLength(),
117 2.0 * fEnvelopeBox->GetZHalfLength());
118 }
119 else
120 {
121 G4ExceptionDescription msg;
122 msg << "Envelope volume of box shape not found.\n";
123 msg << "The gun will be place at the center.";
124 G4Exception("Dicom2PrimaryGeneratorAction::GeneratePrimaries()",
125 "DICOM20003",JustWarning, msg);
126 }
127
128 // start at center
129 G4ThreeVector pos = fPosCenter;
130 // get a random displacement
131 G4ThreeVector delta(fPosDelta.x() * (G4UniformRand()-0.5),
132 fPosDelta.y() * (G4UniformRand()-0.5),
133 fPosDelta.z() * (G4UniformRand()-0.5));
134 // scale by geom factor
135 delta *= fGeomFactor;
136
137 //G4cout << "Starting position: " << G4BestUnit(pos + delta, "Length")
138 // << ", pos = " << G4BestUnit(fPosCenter, "Length")
139 // << ", size = " << G4BestUnit(fPosDelta, "Length")
140 // << ", delta = " << G4BestUnit(delta, "Length")
141 // << G4endl;
142
143 fParticleGun->SetParticlePosition(pos + delta);
144 fParticleGun->SetParticleMomentumDirection(G4RandomDirection());
145 fParticleGun->GeneratePrimaryVertex(anEvent);
146}

◆ GetParticleGun()

const G4ParticleGun * Dicom2PrimaryGeneratorAction::GetParticleGun ( ) const
inline

Definition at line 57 of file Dicom2PrimaryGeneratorAction.hh.

57{ return fParticleGun; }

Member Data Documentation

◆ fParticleGun

G4ParticleGun* Dicom2PrimaryGeneratorAction::fParticleGun
private

Definition at line 60 of file Dicom2PrimaryGeneratorAction.hh.

◆ fEnvelopeBox

G4Box* Dicom2PrimaryGeneratorAction::fEnvelopeBox
private

Definition at line 61 of file Dicom2PrimaryGeneratorAction.hh.

◆ fEnvelopeVol

G4VPhysicalVolume* Dicom2PrimaryGeneratorAction::fEnvelopeVol
private

Definition at line 62 of file Dicom2PrimaryGeneratorAction.hh.

◆ fPosCenter

G4ThreeVector Dicom2PrimaryGeneratorAction::fPosCenter
private

Definition at line 63 of file Dicom2PrimaryGeneratorAction.hh.

◆ fPosDelta

G4ThreeVector Dicom2PrimaryGeneratorAction::fPosDelta
private

Definition at line 64 of file Dicom2PrimaryGeneratorAction.hh.

◆ fGeomFactor

G4double Dicom2PrimaryGeneratorAction::fGeomFactor
private

Definition at line 65 of file Dicom2PrimaryGeneratorAction.hh.


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

Applications | User Support | Publications | Collaboration