| [1197] | 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 | // $Id: G4AdjointPrimaryGenerator.cc,v 1.2 2009/11/18 17:57:59 gcosmo Exp $
|
|---|
| [1228] | 27 | // GEANT4 tag $Name: geant4-09-03 $
|
|---|
| [1197] | 28 | //
|
|---|
| 29 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 30 | // Class Name: G4AdjointCrossSurfChecker
|
|---|
| 31 | // Author: L. Desorgher
|
|---|
| 32 | // Organisation: SpaceIT GmbH
|
|---|
| 33 | // Contract: ESA contract 21435/08/NL/AT
|
|---|
| 34 | // Customer: ESA/ESTEC
|
|---|
| 35 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 36 |
|
|---|
| 37 | #include "G4AdjointPrimaryGenerator.hh"
|
|---|
| 38 | #include "G4Event.hh"
|
|---|
| 39 | #include "G4SingleParticleSource.hh"
|
|---|
| 40 | #include "G4ParticleDefinition.hh"
|
|---|
| 41 | #include "G4AdjointPosOnPhysVolGenerator.hh"
|
|---|
| 42 |
|
|---|
| 43 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|---|
| 44 | //
|
|---|
| 45 | G4AdjointPrimaryGenerator::G4AdjointPrimaryGenerator()
|
|---|
| 46 | {
|
|---|
| 47 | theSingleParticleSource = new G4SingleParticleSource();
|
|---|
| 48 |
|
|---|
| 49 | theSingleParticleSource->GetEneDist()->SetEnergyDisType("Pow");
|
|---|
| 50 | theSingleParticleSource->GetEneDist()->SetAlpha(-1.);
|
|---|
| 51 | theSingleParticleSource->GetPosDist()->SetPosDisType("Point");
|
|---|
| 52 | theSingleParticleSource->GetAngDist()->SetAngDistType("planar");
|
|---|
| 53 |
|
|---|
| 54 | theG4AdjointPosOnPhysVolGenerator = G4AdjointPosOnPhysVolGenerator::GetInstance();
|
|---|
| 55 | }
|
|---|
| 56 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|---|
| 57 | //
|
|---|
| 58 | G4AdjointPrimaryGenerator::~G4AdjointPrimaryGenerator()
|
|---|
| 59 | {
|
|---|
| 60 | delete theSingleParticleSource;
|
|---|
| 61 | }
|
|---|
| 62 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|---|
| 63 | //
|
|---|
| 64 | void G4AdjointPrimaryGenerator::GenerateAdjointPrimaryVertex(G4Event* anEvent,G4ParticleDefinition* adj_part,G4double E1,G4double E2)
|
|---|
| 65 | {
|
|---|
| 66 | if (type_of_adjoint_source == "ExternalSurfaceOfAVolume") {
|
|---|
| 67 |
|
|---|
| 68 | //Generate position and direction relative to the external surface of sensitive volume
|
|---|
| 69 | //-------------------------------------------------------------
|
|---|
| 70 |
|
|---|
| 71 | G4double costh_to_normal;
|
|---|
| 72 | G4ThreeVector pos,direction;
|
|---|
| 73 | theG4AdjointPosOnPhysVolGenerator->GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(pos, direction,costh_to_normal);
|
|---|
| 74 | if (costh_to_normal <1.e-4) costh_to_normal =1.e-4;
|
|---|
| 75 | theSingleParticleSource->GetAngDist()->SetParticleMomentumDirection(-direction);
|
|---|
| 76 | theSingleParticleSource->GetPosDist()->SetCentreCoords(pos);
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | theSingleParticleSource->GetEneDist()->SetEmin(E1);
|
|---|
| 80 | theSingleParticleSource->GetEneDist()->SetEmax(E2);
|
|---|
| 81 |
|
|---|
| 82 | theSingleParticleSource->SetParticleDefinition(adj_part);
|
|---|
| 83 | theSingleParticleSource->GeneratePrimaryVertex(anEvent);
|
|---|
| 84 | }
|
|---|
| 85 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|---|
| 86 | //
|
|---|
| 87 | void G4AdjointPrimaryGenerator::SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector center_pos)
|
|---|
| 88 | {
|
|---|
| 89 | radius_spherical_source = radius;
|
|---|
| 90 | center_spherical_source = center_pos;
|
|---|
| 91 | type_of_adjoint_source ="Spherical";
|
|---|
| 92 | theSingleParticleSource->GetPosDist()->SetPosDisType("Surface");
|
|---|
| 93 | theSingleParticleSource->GetPosDist()->SetPosDisShape("Sphere");
|
|---|
| 94 | theSingleParticleSource->GetPosDist()->SetCentreCoords(center_pos);
|
|---|
| 95 | theSingleParticleSource->GetPosDist()->SetRadius(radius);
|
|---|
| 96 | theSingleParticleSource->GetAngDist()->SetAngDistType("cos");
|
|---|
| 97 | theSingleParticleSource->GetAngDist()->SetMaxTheta(pi);
|
|---|
| 98 | theSingleParticleSource->GetAngDist()->SetMinTheta(halfpi);
|
|---|
| 99 | }
|
|---|
| 100 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|---|
| 101 | //
|
|---|
| 102 | void G4AdjointPrimaryGenerator::SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String& volume_name)
|
|---|
| 103 | {
|
|---|
| 104 | theG4AdjointPosOnPhysVolGenerator->DefinePhysicalVolume1(volume_name);
|
|---|
| 105 | type_of_adjoint_source ="ExternalSurfaceOfAVolume";
|
|---|
| 106 | theSingleParticleSource->GetPosDist()->SetPosDisType("Point");
|
|---|
| 107 | theSingleParticleSource->GetAngDist()->SetAngDistType("planar");
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|