source: trunk/examples/extended/medical/DICOM/src/DicomPrimaryGeneratorAction.cc

Last change on this file was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 3.5 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26// The code was written by :
27//      *Louis Archambault louis.archambault@phy.ulaval.ca,
28//      *Luc Beaulieu beaulieu@phy.ulaval.ca
29//      +Vincent Hubert-Tremblay at tigre.2@sympatico.ca
30//
31//
32// *Centre Hospitalier Universitaire de Quebec (CHUQ),
33// Hotel-Dieu de Quebec, departement de Radio-oncologie
34// 11 cote du palais. Quebec, QC, Canada, G1R 2J6
35// tel (418) 525-4444 #6720
36// fax (418) 691 5268
37//
38// + Université Laval, Québec (QC) Canada
39//*******************************************************
40
41#include "DicomPrimaryGeneratorAction.hh"
42
43#include "G4Event.hh"
44#include "G4ParticleGun.hh"
45#include "G4ParticleTable.hh"
46#include "RegularDicomDetectorConstruction.hh"
47#include "G4ParticleDefinition.hh"
48#include "Randomize.hh"
49#include "CLHEP/Random/RandFlat.h"
50
51DicomPrimaryGeneratorAction::DicomPrimaryGeneratorAction()
52{
53  G4int nParticle = 1;
54  particleGun  = new G4ParticleGun(nParticle);               
55}
56
57DicomPrimaryGeneratorAction::~DicomPrimaryGeneratorAction()
58{
59  delete particleGun;
60}
61
62void DicomPrimaryGeneratorAction::GeneratePrimaries(G4Event *anEvent)
63{
64  G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
65  G4String particleName;
66  G4ParticleDefinition* particle
67    = particleTable->FindParticle(particleName="e-");
68  particleGun->SetParticleDefinition(particle);
69  // put the e- in the x direction of the patient (z in the accelerator axs) to hit patient in the central slice of the phantom
70  G4ThreeVector dir(0,1,0);
71  //G4ThreeVector dir(2.*CLHEP::RandFlat::shoot()-1.,2.*CLHEP::RandFlat::shoot()-1.,-CLHEP::RandFlat::shoot());
72  dir /= dir.mag();
73  particleGun->SetParticleMomentumDirection(dir);       
74  particleGun->SetParticleEnergy(5.*MeV);
75  //put it at SAD = 1 m on xy plane of central slice
76  particleGun->SetParticlePosition(G4ThreeVector(0.,-99.9*cm,87.5*mm));
77  //particleGun->SetParticlePosition(G4ThreeVector(0.,0.,-22.));
78  particleGun->GeneratePrimaryVertex(anEvent);
79}
80
Note: See TracBrowser for help on using the repository browser.