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 RE05/src/RE05PrimaryGeneratorAction. 28 /// \brief Implementation of the RE05PrimaryGe 29 // 30 31 #include "RE05PrimaryGeneratorAction.hh" 32 33 #include "RE05PrimaryGeneratorMessenger.hh" 34 35 #include "G4AutoLock.hh" 36 #include "G4Event.hh" 37 #include "G4HEPEvtInterface.hh" 38 #include "G4ParticleDefinition.hh" 39 #include "G4ParticleGun.hh" 40 #include "G4ParticleTable.hh" 41 #include "G4SystemOfUnits.hh" 42 43 namespace 44 { 45 G4Mutex RE05PrimGenDestrMutex = G4MUTEX_INITIA 46 G4Mutex RE05PrimGenMutex = G4MUTEX_INITIALIZER 47 } // namespace 48 49 G4VPrimaryGenerator* RE05PrimaryGeneratorActio 50 51 //....oooOO0OOooo........oooOO0OOooo........oo 52 53 RE05PrimaryGeneratorAction::RE05PrimaryGenerat 54 : G4VUserPrimaryGeneratorAction(), fParticle 55 { 56 G4AutoLock lock(&RE05PrimGenDestrMutex); 57 if (!fHEPEvt) { 58 const char* filename = "pythia_event.data" 59 fHEPEvt = new G4HEPEvtInterface(filename, 60 } 61 lock.unlock(); 62 63 G4int n_particle = 1; 64 G4ParticleGun* particleGun = new G4ParticleG 65 G4ParticleTable* particleTable = G4ParticleT 66 G4String particleName; 67 G4ParticleDefinition* particle = particleTab 68 particleGun->SetParticleDefinition(particle) 69 particleGun->SetParticleMomentumDirection(G4 70 particleGun->SetParticleEnergy(100. * GeV); 71 particleGun->SetParticlePosition(G4ThreeVect 72 fParticleGun = particleGun; 73 74 fMessenger = new RE05PrimaryGeneratorMesseng 75 fUseHEPEvt = true; 76 } 77 78 //....oooOO0OOooo........oooOO0OOooo........oo 79 80 RE05PrimaryGeneratorAction::~RE05PrimaryGenera 81 { 82 G4AutoLock lock(&RE05PrimGenDestrMutex); 83 if (fHEPEvt) { 84 delete fHEPEvt; 85 fHEPEvt = 0; 86 } 87 delete fParticleGun; 88 delete fMessenger; 89 } 90 91 //....oooOO0OOooo........oooOO0OOooo........oo 92 93 void RE05PrimaryGeneratorAction::GeneratePrima 94 { 95 if (fUseHEPEvt) { 96 G4AutoLock lock(&RE05PrimGenMutex); 97 fHEPEvt->GeneratePrimaryVertex(anEvent); 98 } 99 else { 100 fParticleGun->GeneratePrimaryVertex(anEven 101 } 102 } 103 104 //....oooOO0OOooo........oooOO0OOooo........oo 105