Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // Code developed by: 23 // Code developed by: 27 // S.Larsson 24 // S.Larsson 28 // 25 // 29 // **************************************** 26 // ******************************************** 30 // * 27 // * * 31 // * PurgMagPrimaryGeneratorAction.cc 28 // * PurgMagPrimaryGeneratorAction.cc * 32 // * 29 // * * 33 // **************************************** 30 // ******************************************** 34 // 31 // >> 32 // $Id: PurgMagPrimaryGeneratorAction.cc,v 1.2 2004/06/18 09:17:59 gunter Exp $ >> 33 // GEANT4 tag $Name: geant4-08-00-patch-01 $ 35 // 34 // 36 35 37 //....oooOO0OOooo........oooOO0OOooo........oo 36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 38 37 39 #include "PurgMagPrimaryGeneratorAction.hh" 38 #include "PurgMagPrimaryGeneratorAction.hh" 40 39 41 #include "PurgMagDetectorConstruction.hh" 40 #include "PurgMagDetectorConstruction.hh" 42 41 43 #include "G4SystemOfUnits.hh" << 44 #include "G4UnitsTable.hh" << 45 #include "G4Event.hh" 42 #include "G4Event.hh" 46 #include "G4ParticleGun.hh" 43 #include "G4ParticleGun.hh" 47 #include "G4ParticleTable.hh" 44 #include "G4ParticleTable.hh" 48 #include "G4ParticleDefinition.hh" 45 #include "G4ParticleDefinition.hh" 49 #include "G4Electron.hh" << 46 #include "Randomize.hh" 50 << 47 #include "G4UnitsTable.hh" 51 48 52 //Print position of primaries. 49 //Print position of primaries. 53 #define POSITION 0 50 #define POSITION 0 54 51 55 //....oooOO0OOooo........oooOO0OOooo........oo 52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 56 53 57 PurgMagPrimaryGeneratorAction::PurgMagPrimaryG << 54 PurgMagPrimaryGeneratorAction::PurgMagPrimaryGeneratorAction(PurgMagDetectorConstruction* PurgMagDC) 58 :rndmVertex(false) << 55 :PurgMagDetector(PurgMagDC),rndmVertex(false) 59 { 56 { 60 //default kinematic 57 //default kinematic 61 G4int n_particle = 1; 58 G4int n_particle = 1; 62 particleGun = new G4ParticleGun(n_particle) 59 particleGun = new G4ParticleGun(n_particle); 63 60 64 G4ParticleDefinition* particle 61 G4ParticleDefinition* particle 65 = G4Electron::Definition(); << 62 = 66 << 63 >> 64 G4ParticleTable::GetParticleTable()->FindParticle("e-"); 67 particleGun->SetParticleDefinition(particle) 65 particleGun->SetParticleDefinition(particle); 68 particleGun->SetParticleEnergy(50.*MeV); 66 particleGun->SetParticleEnergy(50.*MeV); 69 67 70 //Momentum Direction 68 //Momentum Direction 71 particleGun->SetParticleMomentumDirection(G4 69 particleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,-1.)); 72 70 73 } 71 } 74 72 75 //....oooOO0OOooo........oooOO0OOooo........oo 73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 76 74 77 PurgMagPrimaryGeneratorAction::~PurgMagPrimary 75 PurgMagPrimaryGeneratorAction::~PurgMagPrimaryGeneratorAction() 78 { 76 { 79 delete particleGun; 77 delete particleGun; 80 } 78 } 81 79 82 //....oooOO0OOooo........oooOO0OOooo........oo 80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 83 81 84 void PurgMagPrimaryGeneratorAction::GeneratePr 82 void PurgMagPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) 85 { 83 { 86 //this function is called at the begining of 84 //this function is called at the begining of event 87 //Start position of primaries 85 //Start position of primaries 88 G4double z0 = 15.*cm; 86 G4double z0 = 15.*cm; 89 G4double x0 = 0.*cm; 87 G4double x0 = 0.*cm; 90 G4double y0 = 0.*cm; 88 G4double y0 = 0.*cm; 91 particleGun->SetParticlePosition(G4ThreeVect 89 particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0)); 92 particleGun->GeneratePrimaryVertex(anEvent); 90 particleGun->GeneratePrimaryVertex(anEvent); 93 91 94 #if POSITION 92 #if POSITION 95 G4cout << "\n----Particle Gun--------------- 93 G4cout << "\n----Particle Gun--------------------------------------------\n"; 96 G4cout << "\n ---> SetParticlePosition(G4Thr 94 G4cout << "\n ---> SetParticlePosition(G4ThreeVector(x0,y0,z0)) "; 97 G4cout << "\n ---> x0 = " << x0 << " "<< G4B 95 G4cout << "\n ---> x0 = " << x0 << " "<< G4BestUnit(x0,"Length"); 98 G4cout << "\n ---> y0 = " << y0 << " "<< G4B 96 G4cout << "\n ---> y0 = " << y0 << " "<< G4BestUnit(y0,"Length"); 99 G4cout << "\n ---> z0 = " << z0 << " "<< G4B 97 G4cout << "\n ---> z0 = " << z0 << " "<< G4BestUnit(z0,"Length"); 100 G4cout << "\n------------------------------- 98 G4cout << "\n-----------------------------------------------------------\n"; 101 #endif 99 #endif 102 } 100 } 103 101 104 //....oooOO0OOooo........oooOO0OOooo........oo 102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 105 103 106 104 107 105