ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HadrontherapyPrimaryGeneratorAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HadrontherapyPrimaryGeneratorAction.cc
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 // Hadrontherapy advanced example for Geant4
27 // See more at: https://twiki.cern.ch/twiki/bin/view/Geant4/AdvancedExamplesHadrontherapy
28 
31 
32 #include "HadrontherapyMatrix.hh"
34 #include "G4SystemOfUnits.hh"
35 #include "G4Event.hh"
36 #include "G4ParticleGun.hh"
38 #include "G4ParticleTable.hh"
39 #include "G4ParticleDefinition.hh"
40 #include "Randomize.hh"
41 #include "G4IonTable.hh"
42 
43 
45 #include "G4ParticleTable.hh"
46 
47 #include "G4Event.hh"
48 #include "G4Timer.hh"
49 
50 #include "G4RunManager.hh"
51 
52 
53 
56 {
60 
61 }
62 
65 {
67  delete particleGun;
68 }
69 
72 {
73 
74 }
75 
78 {
79 
80  if(NewSource==true)
81  {
82  std::ifstream in(calculatedPhaseSpaceFileIN);
83  G4double e, xpos, ypos, zpos,dirx,diry,dirz;
84  G4int PDG;
86 
87  if(in.eof())
88  {
89  G4Exception("HadrontherapyPrimaryGeneratorAction", "NoParticles", FatalException, "No more particles in the file");
90  }
91 
92  while(!in.eof())
93  {
94 
95  in >> e >> xpos >> ypos >>zpos >>dirx>>diry>>dirz >> PDG;
96  dir= G4ThreeVector(dirx,diry,dirz);
98 
103 
104  G4ParticleDefinition* particleDef = nullptr;
105  if (PDG > 1000000000)
106  {
107  int a=(PDG-1000000000)-(((PDG-1000000000)/10)*10);
108  if(a>0)
109  {
110  PDG=PDG-a;
111  particleDef = G4IonTable::GetIonTable()->GetIon(PDG);
112  G4String Nome = particleDef->GetParticleName();
113  }
114 
115  else
116  {
117  particleDef = G4IonTable::GetIonTable()->GetIon(PDG);
118  G4String Nome = particleDef->GetParticleName();
119  }
120  }
121 
122  else
123  {
124  particleDef = G4ParticleTable::GetParticleTable()->FindParticle(PDG);
125  }
126 
129 
130  }
131 
132  in.close();
133 
134  }
135  else
136  {
138  }
139 
140 }
141 
142