Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4AdjointPrimaryGenerator.cc
Go to the documentation of this file.
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$
27 //
29 // Class Name: G4AdjointCrossSurfChecker
30 // Author: L. Desorgher
31 // Organisation: SpaceIT GmbH
32 // Contract: ESA contract 21435/08/NL/AT
33 // Customer: ESA/ESTEC
35 
37 #include "G4PhysicalConstants.hh"
38 #include "G4Event.hh"
40 #include "G4ParticleDefinition.hh"
42 
44 //
46  : radius_spherical_source(0.)
47 {
48  theSingleParticleSource = new G4SingleParticleSource();
49 
50  theSingleParticleSource->GetEneDist()->SetEnergyDisType("Pow");
51  theSingleParticleSource->GetEneDist()->SetAlpha(-1.);
52  theSingleParticleSource->GetPosDist()->SetPosDisType("Point");
53  theSingleParticleSource->GetAngDist()->SetAngDistType("planar");
54 
55  theG4AdjointPosOnPhysVolGenerator = G4AdjointPosOnPhysVolGenerator::GetInstance();
56 }
58 //
60 {
61  delete theSingleParticleSource;
62 }
64 //
66 {
67  if (type_of_adjoint_source == "ExternalSurfaceOfAVolume") {
68 
69  //Generate position and direction relative to the external surface of sensitive volume
70  //-------------------------------------------------------------
71 
72  G4double costh_to_normal;
73  G4ThreeVector pos,direction;
74  theG4AdjointPosOnPhysVolGenerator->GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(pos, direction,costh_to_normal);
75  if (costh_to_normal <1.e-4) costh_to_normal =1.e-4;
76  theSingleParticleSource->GetAngDist()->SetParticleMomentumDirection(-direction);
77  theSingleParticleSource->GetPosDist()->SetCentreCoords(pos);
78  }
79 
80  theSingleParticleSource->GetEneDist()->SetEmin(E1);
81  theSingleParticleSource->GetEneDist()->SetEmax(E2);
82 
83  theSingleParticleSource->SetParticleDefinition(adj_part);
84  theSingleParticleSource->GeneratePrimaryVertex(anEvent);
85 }
87 //
89 {
90  radius_spherical_source = radius;
91  center_spherical_source = center_pos;
92  type_of_adjoint_source ="Spherical";
93  theSingleParticleSource->GetPosDist()->SetPosDisType("Surface");
94  theSingleParticleSource->GetPosDist()->SetPosDisShape("Sphere");
95  theSingleParticleSource->GetPosDist()->SetCentreCoords(center_pos);
96  theSingleParticleSource->GetPosDist()->SetRadius(radius);
97  theSingleParticleSource->GetAngDist()->SetAngDistType("cos");
98  theSingleParticleSource->GetAngDist()->SetMaxTheta(pi);
99  theSingleParticleSource->GetAngDist()->SetMinTheta(halfpi);
100 }
102 //
104 {
105  theG4AdjointPosOnPhysVolGenerator->DefinePhysicalVolume1(volume_name);
106  type_of_adjoint_source ="ExternalSurfaceOfAVolume";
107  theSingleParticleSource->GetPosDist()->SetPosDisType("Point");
108  theSingleParticleSource->GetAngDist()->SetAngDistType("planar");
109 }
110