Advertisement
luizrosalba

GEANT4 - PrimaryGeneratorAction.cpp

Nov 17th, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.19 KB | None | 0 0
  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. /// \file electromagnetic/TestEm5/src/PrimaryGeneratorAction.cc
  27. /// \brief Implementation of the PrimaryGeneratorAction class
  28. //
  29. // $Id: PrimaryGeneratorAction.cc 77583 2013-11-26 10:28:15Z gcosmo $
  30. //
  31. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  32. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  33.  
  34. #include "PrimaryGeneratorAction.hh"
  35.  
  36. #include "DetectorConstruction.hh"
  37. #include "PrimaryGeneratorMessenger.hh"
  38.  
  39. #include "G4Event.hh"
  40. #include "G4ParticleTable.hh"
  41.  
  42. #include "G4ParticleDefinition.hh"
  43. #include "G4SystemOfUnits.hh"
  44. #include "Randomize.hh"
  45. #include "G4AtomicTransitionManager.hh"
  46. #include "G4VAtomDeexcitation.hh"
  47.  
  48. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  49.  
  50. PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* DC)
  51. :G4VUserPrimaryGeneratorAction(),
  52. fParticleGun(0),fDetector(DC),fRndmBeam(0),fGunMessenger(0)
  53. {
  54. G4int n_particle = 1;
  55. // fParticleGun = new G4ParticleGun(n_particle);
  56.  
  57.  
  58.  
  59.  
  60. /// descomentar para GPS
  61. fParticleGun = new G4GeneralParticleSource();
  62. SetDefaultKinematic();
  63.  
  64. //create a messenger for this class
  65. fGunMessenger = new PrimaryGeneratorMessenger(this);
  66.  
  67. }
  68.  
  69. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  70.  
  71. PrimaryGeneratorAction::~PrimaryGeneratorAction()
  72. {
  73. delete fParticleGun;
  74. delete fGunMessenger;
  75. }
  76.  
  77. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  78.  
  79. void PrimaryGeneratorAction::SetDefaultKinematic()
  80. {
  81.  
  82. /// USANDO A NOVA BIBLOTECA G4AtomicTransitionManager
  83.  
  84.  
  85. // default particle kinematic
  86. //
  87.  
  88. /// descomentar para GPS
  89. G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
  90.  
  91. //G4ParticleDefinition* particle
  92. // = particleTable->FindParticle("e-");
  93.  
  94.  
  95. /// descomentar para GPS
  96. G4ParticleDefinition* particle
  97. = G4ParticleTable::GetParticleTable()->FindParticle("gamma");
  98.  
  99.  
  100. /// descomentar para GPS
  101. fParticleGun->SetParticleDefinition(particle);
  102. G4SPSEneDistribution* eneDist = fParticleGun->GetCurrentSource()->GetEneDist();
  103.  
  104.  
  105.  
  106.  
  107. eneDist->SetMonoEnergy(15.0*keV);
  108.  
  109.  
  110.  
  111. //eneDist->SetEnergyDisType("Brem");
  112. // 30 MeV Photonen
  113. // eneDist->SetTemp(7.00e10);
  114. //eneDist->SetEmax(30.0*keV);
  115. //eneDist->SetEmin(1.0*keV);
  116. // eneDist->SetTemp(7.00e7);
  117.  
  118.  
  119. // eneDist->SetEnergyDisType("Gauss");
  120. // eneDist->SetMonoEnergy(15*keV);
  121. // eneDist->SetBeamSigmaInE(5*keV);
  122. // eneDist->Calculate();
  123.  
  124. //eneDist->SetMonoEnergy(30.0*keV);
  125.  
  126.  
  127.  
  128. /// descomentar para GPS
  129. G4SPSPosDistribution* posDist = fParticleGun->GetCurrentSource()->GetPosDist();
  130. posDist->SetPosDisType("Point");
  131. posDist->SetCentreCoords(G4ThreeVector(1.0*cm, -0.4142*cm ,0.*cm));
  132. G4SPSAngDistribution* angDist = fParticleGun->GetCurrentSource()->GetAngDist();
  133.  
  134. /// descomentar para GPS
  135. angDist->SetParticleMomentumDirection(G4ParticleMomentum(-1.0*cm, 0.4142*cm ,0.*cm));
  136. // angDist->SetParticleMomentumDirection(G4ParticleMomentum(0.0*cm, 1.0*cm,0.*cm));
  137.  
  138.  
  139.  
  140. //angDist->SetAngDistType("iso");
  141.  
  142.  
  143.  
  144. /// modelo 3
  145. //fParticleGun -> SetParticleMomentumDirection(G4ThreeVector(5.4, 2.34,0.)); // cos 65
  146. // modelo 1
  147. //fParticleGun -> SetParticleMomentumDirection(G4ThreeVector(-0.25*cm, -0.0 ,0.)); // cos 65
  148.  
  149. //fParticleGun -> SetParticleEnergy(energia_max *keV);
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156. }
  157.  
  158. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
  159.  
  160. void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
  161. {
  162. //this function is called at the begining of event
  163. //
  164. //randomize the beam, if requested.
  165. /*if (fRndmBeam > 0.)
  166. {
  167.  
  168. G4ThreeVector oldPosition = fParticleGun->GetParticlePosition();
  169. G4double rbeam = 0.5*(fDetector->GetAbsorberSizeYZ())*fRndmBeam;
  170. G4double x0 = oldPosition.x();
  171. G4double y0 = oldPosition.y() + (2*G4UniformRand()-1.)*rbeam;
  172. G4double z0 = oldPosition.z() + (2*G4UniformRand()-1.)*rbeam;
  173. fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
  174. fParticleGun->GeneratePrimaryVertex(anEvent);
  175. fParticleGun->SetParticlePosition(oldPosition);
  176.  
  177. }
  178. else */
  179.  
  180. fParticleGun->GeneratePrimaryVertex(anEvent);
  181. }
  182.  
  183. //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement