Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 /// \file Par02PrimaryGeneratorAction.cc 28 /// \brief Implementation of the Par02PrimaryG 29 30 #include "Par02PrimaryGeneratorAction.hh" 31 32 #include "Par02PrimaryParticleInformation.hh" 33 34 #include "G4Event.hh" 35 #include "G4ParticleDefinition.hh" 36 #include "G4ParticleGun.hh" 37 #include "G4ParticleTable.hh" 38 #include "G4SystemOfUnits.hh" 39 #include "globals.hh" 40 41 //....oooOO0OOooo........oooOO0OOooo........oo 42 43 Par02PrimaryGeneratorAction::Par02PrimaryGener 44 { 45 G4int n_particle = 1; 46 fParticleGun = new G4ParticleGun(n_particle) 47 48 G4ParticleTable* particleTable = G4ParticleT 49 G4String particleName; 50 G4ParticleDefinition* particle = particleTab 51 fParticleGun->SetParticleDefinition(particle 52 53 fParticleGun->SetParticleMomentumDirection(G 54 fParticleGun->SetParticleEnergy(100.0 * GeV) 55 fParticleGun->SetParticlePosition(G4ThreeVec 56 } 57 58 //....oooOO0OOooo........oooOO0OOooo........oo 59 60 Par02PrimaryGeneratorAction::~Par02PrimaryGene 61 { 62 delete fParticleGun; 63 } 64 65 //....oooOO0OOooo........oooOO0OOooo........oo 66 67 void Par02PrimaryGeneratorAction::GeneratePrim 68 { 69 fParticleGun->GeneratePrimaryVertex(anEvent) 70 71 // Loop over the vertices, and then over pri 72 // and for each primary particle create an i 73 // which to store "Monte Carlo true" informa 74 // This approach could appear unnecessarily 75 // of a trivial particle gun generator, but 76 // realistic case of a Monte Carlo event gen 77 G4int count_particles = 0; 78 for (G4int ivtx = 0; ivtx < anEvent->GetNumb 79 for (G4int ipp = 0; ipp < anEvent->GetPrim 80 G4PrimaryParticle* primary_particle = an 81 if (primary_particle) { 82 primary_particle->SetUserInformation(n 83 count_particles, primary_particle->G 84 count_particles++; 85 } 86 } 87 } 88 } 89 90 //....oooOO0OOooo........oooOO0OOooo........oo 91 92 G4ParticleGun* Par02PrimaryGeneratorAction::Ge 93 { 94 return fParticleGun; 95 } 96 97 //....oooOO0OOooo........oooOO0OOooo........oo 98