Geant4.10
 All Data Structures 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: G4AdjointPrimaryGenerator.cc 76257 2013-11-08 11:31:00Z gcosmo $
27 //
28 /////////////////////////////////////////////////////////////////////////////
29 // Class Name: G4AdjointCrossSurfChecker
30 // Author: L. Desorgher
31 // Organisation: SpaceIT GmbH
32 // Contract: ESA contract 21435/08/NL/AT
33 // Customer: ESA/ESTEC
34 /////////////////////////////////////////////////////////////////////////////
35 
37 #include "G4PhysicalConstants.hh"
38 #include "G4Event.hh"
40 #include "G4ParticleDefinition.hh"
42 
43 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
44 //
46  : radius_spherical_source(0.)
47 {
48  center_spherical_source = G4ThreeVector(0.,0.,0.);
49  type_of_adjoint_source="Spherical";
50  theSingleParticleSource = new G4SingleParticleSource();
51 
52  theSingleParticleSource->GetEneDist()->SetEnergyDisType("Pow");
53  theSingleParticleSource->GetEneDist()->SetAlpha(-1.);
54  theSingleParticleSource->GetPosDist()->SetPosDisType("Point");
55  theSingleParticleSource->GetAngDist()->SetAngDistType("planar");
56 
57  theG4AdjointPosOnPhysVolGenerator = G4AdjointPosOnPhysVolGenerator::GetInstance();
58 }
59 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
60 //
62 {
63  delete theSingleParticleSource;
64 }
65 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
66 //
68 {
69  if (type_of_adjoint_source == "ExternalSurfaceOfAVolume") {
70 
71  //Generate position and direction relative to the external surface of sensitive volume
72  //-------------------------------------------------------------
73 
74  G4double costh_to_normal=1.;
75  G4ThreeVector pos =G4ThreeVector(0.,0.,0.);
76  G4ThreeVector direction = G4ThreeVector(0.,0.,1.);
77  theG4AdjointPosOnPhysVolGenerator->GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(pos, direction,costh_to_normal);
78  if (costh_to_normal <1.e-4) costh_to_normal =1.e-4;
79  theSingleParticleSource->GetAngDist()->SetParticleMomentumDirection(-direction);
80  theSingleParticleSource->GetPosDist()->SetCentreCoords(pos);
81  }
82 
83  theSingleParticleSource->GetEneDist()->SetEmin(E1);
84  theSingleParticleSource->GetEneDist()->SetEmax(E2);
85 
86  theSingleParticleSource->SetParticleDefinition(adj_part);
87  theSingleParticleSource->GeneratePrimaryVertex(anEvent);
88 }
89 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
90 //
92 {
93  if (type_of_adjoint_source == "ExternalSurfaceOfAVolume") {
94 
95  //Generate position and direction relative to the external surface of sensitive volume
96  //-------------------------------------------------------------
97 
98  G4double costh_to_normal=1.;
99  G4ThreeVector pos =G4ThreeVector(0.,0.,0.);
100  G4ThreeVector direction = G4ThreeVector(0.,0.,1.);
101  theG4AdjointPosOnPhysVolGenerator->GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(pos, direction,costh_to_normal);
102  if (costh_to_normal <1.e-4) costh_to_normal =1.e-4;
103  theSingleParticleSource->GetAngDist()->SetParticleMomentumDirection(direction);
104  theSingleParticleSource->GetPosDist()->SetCentreCoords(pos);
105  }
106 
107  theSingleParticleSource->GetEneDist()->SetEmin(E1);
108  theSingleParticleSource->GetEneDist()->SetEmax(E2);
109 
110  theSingleParticleSource->SetParticleDefinition(fwd_part);
111  theSingleParticleSource->GeneratePrimaryVertex(anEvent);
112 }
113 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
114 //
116 {
117  radius_spherical_source = radius;
118  center_spherical_source = center_pos;
119  type_of_adjoint_source ="Spherical";
120  theSingleParticleSource->GetPosDist()->SetPosDisType("Surface");
121  theSingleParticleSource->GetPosDist()->SetPosDisShape("Sphere");
122  theSingleParticleSource->GetPosDist()->SetCentreCoords(center_pos);
123  theSingleParticleSource->GetPosDist()->SetRadius(radius);
124  theSingleParticleSource->GetAngDist()->SetAngDistType("cos");
125  theSingleParticleSource->GetAngDist()->SetMaxTheta(pi);
126  theSingleParticleSource->GetAngDist()->SetMinTheta(halfpi);
127 }
128 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
129 //
131 {
132  theG4AdjointPosOnPhysVolGenerator->DefinePhysicalVolume1(volume_name);
133  type_of_adjoint_source ="ExternalSurfaceOfAVolume";
134  theSingleParticleSource->GetPosDist()->SetPosDisType("Point");
135  theSingleParticleSource->GetAngDist()->SetAngDistType("planar");
136 }
137 
void SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector pos)
G4SPSEneDistribution * GetEneDist()
CLHEP::Hep3Vector G4ThreeVector
void GenerateAdjointPrimaryVertex(G4Event *anEvt, G4ParticleDefinition *adj_part, G4double E1, G4double E2)
G4SPSPosDistribution * GetPosDist()
void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String &volume_name)
void SetCentreCoords(G4ThreeVector)
void SetEnergyDisType(G4String)
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
G4SPSAngDistribution * GetAngDist()
void GenerateFwdPrimaryVertex(G4Event *anEvt, G4ParticleDefinition *adj_part, G4double E1, G4double E2)
void GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(G4ThreeVector &p, G4ThreeVector &direction)
void DefinePhysicalVolume1(const G4String &aName)
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
static G4AdjointPosOnPhysVolGenerator * GetInstance()
void GeneratePrimaryVertex(G4Event *evt)
double G4double
Definition: G4Types.hh:76