ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4AdjointPrimaryGenerator.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4AdjointPrimaryGenerator.cc
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 //
28 // Class Name: G4AdjointCrossSurfChecker
29 // Author: L. Desorgher
30 // Organisation: SpaceIT GmbH
31 // Contract: ESA contract 21435/08/NL/AT
32 // Customer: ESA/ESTEC
34 
36 #include "G4PhysicalConstants.hh"
37 #include "G4Event.hh"
39 #include "G4ParticleDefinition.hh"
41 #include "G4Navigator.hh"
43 #include "G4VPhysicalVolume.hh"
44 #include "G4Material.hh"
45 #include "Randomize.hh"
46 /*
47 #include "G4AdjointCSManager.hh"
48 #include "G4MaterialCutsCouple.hh"
49 */
51 //
53  : radius_spherical_source(0.),fLinearNavigator(0),theAccumulatedDepthVector(0)
54 {
56  type_of_adjoint_source="Spherical";
58 
63 
65 
66 }
68 //
70 {
72 }
74 //
76 {
77  if (type_of_adjoint_source == "ExternalSurfaceOfAVolume") {
78 
79  //Generate position and direction relative to the external surface of sensitive volume
80  //-------------------------------------------------------------
81 
82  G4double costh_to_normal=1.;
83  G4ThreeVector pos =G4ThreeVector(0.,0.,0.);
84  G4ThreeVector direction = G4ThreeVector(0.,0.,1.);
86  if (costh_to_normal <1.e-4) costh_to_normal =1.e-4;
87  //compute now the position along the ray backward direction
88 
91  }
92 
95 
98 
99 
100 
101 }
103 //
105 {
106  if (type_of_adjoint_source == "ExternalSurfaceOfAVolume") {
107 
108  //Generate position and direction relative to the external surface of sensitive volume
109  //-------------------------------------------------------------
110 
111  G4double costh_to_normal=1.;
112  G4ThreeVector pos =G4ThreeVector(0.,0.,0.);
113  G4ThreeVector direction = G4ThreeVector(0.,0.,1.);
115  if (costh_to_normal <1.e-4) costh_to_normal =1.e-4;
118  }
119 
122 
125 }
127 //
129 {
131  center_spherical_source = center_pos;
132  type_of_adjoint_source ="Spherical";
140 }
142 //
144 {
146  type_of_adjoint_source ="ExternalSurfaceOfAVolume";
149 }
150 
152 //
154  G4ThreeVector glob_pos,
155  G4ThreeVector direction,
156  G4double,
161  G4ThreeVector position = glob_pos;
162  G4double safety=1.;
163  G4VPhysicalVolume* thePhysVolume =
165  G4double newStep =fLinearNavigator->ComputeStep(position,direction,1.e50,
166  safety);
169  //if (theAccumulatedCSDepthVector) delete theAccumulatedCSDepthVector;
170  //theAccumulatedCSDepthVector = new G4PhysicsOrderedFreeVector();
171 
172  G4double acc_depth=0.;
173  G4double acc_length=0.;
174  //G4double acc_cs_depth=0.;
175  //theAccumulatedCSDepthVector->InsertValues(acc_cs_depth, acc_length);
176  theAccumulatedDepthVector->InsertValues(acc_length,acc_depth);
177 
178  while (newStep > 0. && thePhysVolume) {
179  acc_length+=newStep;
180  /*
181  const G4MaterialCutsCouple* theMatCutsCouple=
182  thePhysVolume->GetLogicalVolume()->GetMaterialCutsCouple();
183 
184 
185  acc_cs_depth+=newStep*G4AdjointCSManager::GetAdjointCSManager()->GetTotalAdjointCS(aPartDef,
186  ekin,
187  theMatCutsCouple);
188  theAccumulatedCSDepthVector->InsertValues(acc_cs_depth, acc_length);*/
189 
190  acc_depth+=newStep*thePhysVolume->GetLogicalVolume()->GetMaterial()->GetDensity();
191  theAccumulatedDepthVector->InsertValues(acc_length,acc_depth);
192  position=position+newStep*direction;
193  thePhysVolume =
194  fLinearNavigator->LocateGlobalPointAndSetup(position,0,false);
195  newStep =fLinearNavigator->ComputeStep(position,direction,1.e50,
196  safety);
197  }
198 
199 
200 }
202 //
204 {G4double rand = G4UniformRand();
206  /*
207  G4double acc_cs_depth=theAccumulatedCSDepthVector->GetEnergy(distance);
208  weight_corr=std::exp(-acc_cs_depth);*/
209  weight_corr=1.;
210  return distance;
211 }
212 
213 
214 
215