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 /// \file runAndEvent/RE02/src/RE02PrimaryGene << 27 /// \brief Implementation of the RE02PrimaryGe << 28 // << 29 // 23 // >> 24 // $Id: RE02PrimaryGeneratorAction.cc,v 1.1 2005/11/24 01:44:18 asaim Exp $ >> 25 // GEANT4 tag $Name: geant4-08-00-patch-01 $ 30 // 26 // 31 27 32 #include "RE02PrimaryGeneratorAction.hh" 28 #include "RE02PrimaryGeneratorAction.hh" 33 29 34 #include "G4Event.hh" 30 #include "G4Event.hh" 35 #include "G4ParticleDefinition.hh" << 36 #include "G4ParticleGun.hh" 31 #include "G4ParticleGun.hh" 37 #include "G4ParticleTable.hh" 32 #include "G4ParticleTable.hh" 38 #include "G4SystemOfUnits.hh" << 33 #include "G4ParticleDefinition.hh" 39 #include "Randomize.hh" 34 #include "Randomize.hh" 40 #include "globals.hh" 35 #include "globals.hh" 41 36 42 //....oooOO0OOooo........oooOO0OOooo........oo << 43 // 37 // 44 RE02PrimaryGeneratorAction::RE02PrimaryGenerat 38 RE02PrimaryGeneratorAction::RE02PrimaryGeneratorAction() 45 : G4VUserPrimaryGeneratorAction(), fParticle << 46 { 39 { 47 G4int n_particle = 1; 40 G4int n_particle = 1; 48 fParticleGun = new G4ParticleGun(n_particle) << 41 particleGun = new G4ParticleGun(n_particle); 49 42 50 // default particle << 43 // default particle 51 G4ParticleTable* particleTable = G4ParticleT 44 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); 52 G4ParticleDefinition* particle = particleTab 45 G4ParticleDefinition* particle = particleTable->FindParticle("proton"); 53 fParticleGun->SetParticleDefinition(particle << 46 particleGun->SetParticleDefinition(particle); 54 fParticleGun->SetParticleMomentumDirection(G << 47 particleGun->SetParticleMomentumDirection(G4ThreeVector(0.0,0.0,1.)); 55 fParticleGun->SetParticleEnergy(150.0 * MeV) << 48 particleGun->SetParticleEnergy(150.0*MeV); 56 // << 49 // 57 // default beam position << 50 // default beam position 58 G4double position = -200. / 2. * cm; << 51 G4double position = -200./2.*cm; 59 // << 52 // 60 // Initial beam spot size in sigma.; This is << 53 // Initial beam spot size in sigma.; This is not a part of ParticleGun. 61 fSigmaPosition = 10. * mm; << 54 fsigmaPosition = 10.* mm; 62 << 55 63 //....oooOO0OOooo........oooOO0OOooo........ << 56 // 64 // << 57 particleGun->SetParticlePosition(G4ThreeVector(0.*cm, 0.*cm, position)); 65 fParticleGun->SetParticlePosition(G4ThreeVec << 66 } 58 } 67 59 68 //....oooOO0OOooo........oooOO0OOooo........oo << 69 // 60 // 70 RE02PrimaryGeneratorAction::~RE02PrimaryGenera 61 RE02PrimaryGeneratorAction::~RE02PrimaryGeneratorAction() 71 { 62 { 72 delete fParticleGun; << 63 delete particleGun; 73 } 64 } 74 65 75 //....oooOO0OOooo........oooOO0OOooo........oo << 76 // 66 // 77 void RE02PrimaryGeneratorAction::GeneratePrima 67 void RE02PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) 78 { << 68 { 79 G4ThreeVector position = fParticleGun->GetPa << 69 80 G4double dx = (G4UniformRand() - 0.5) * fSig << 70 G4ThreeVector position = particleGun->GetParticlePosition(); 81 G4double dy = (G4UniformRand() - 0.5) * fSig << 71 G4double dx = (G4UniformRand()-0.5)*fsigmaPosition; >> 72 G4double dy = (G4UniformRand()-0.5)*fsigmaPosition; 82 position.setX(dx); 73 position.setX(dx); 83 position.setY(dy); 74 position.setY(dy); 84 fParticleGun->SetParticlePosition(position); << 75 particleGun->SetParticlePosition(position); 85 fParticleGun->GeneratePrimaryVertex(anEvent) << 76 particleGun->GeneratePrimaryVertex(anEvent); 86 } 77 } 87 78