G4AdjointPrimaryGenerator.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id$
00027 //
00029 //      Class Name:     G4AdjointCrossSurfChecker
00030 //      Author:         L. Desorgher
00031 //      Organisation:   SpaceIT GmbH
00032 //      Contract:       ESA contract 21435/08/NL/AT
00033 //      Customer:       ESA/ESTEC
00035 
00036 #include "G4AdjointPrimaryGenerator.hh"
00037 #include "G4PhysicalConstants.hh"
00038 #include "G4Event.hh"
00039 #include "G4SingleParticleSource.hh"
00040 #include "G4ParticleDefinition.hh"
00041 #include "G4AdjointPosOnPhysVolGenerator.hh" 
00042 
00044 //
00045 G4AdjointPrimaryGenerator::G4AdjointPrimaryGenerator()
00046   : radius_spherical_source(0.)
00047 {
00048   theSingleParticleSource  = new G4SingleParticleSource();
00049  
00050   theSingleParticleSource->GetEneDist()->SetEnergyDisType("Pow");
00051   theSingleParticleSource->GetEneDist()->SetAlpha(-1.);
00052   theSingleParticleSource->GetPosDist()->SetPosDisType("Point");
00053   theSingleParticleSource->GetAngDist()->SetAngDistType("planar");
00054 
00055   theG4AdjointPosOnPhysVolGenerator = G4AdjointPosOnPhysVolGenerator::GetInstance();
00056 }
00058 //
00059 G4AdjointPrimaryGenerator::~G4AdjointPrimaryGenerator()
00060 {
00061   delete theSingleParticleSource;
00062 }
00064 //
00065 void G4AdjointPrimaryGenerator::GenerateAdjointPrimaryVertex(G4Event* anEvent,G4ParticleDefinition* adj_part,G4double E1,G4double E2)
00066 {
00067    if (type_of_adjoint_source == "ExternalSurfaceOfAVolume") {
00068         
00069         //Generate position and direction relative to the external surface of sensitive volume
00070         //-------------------------------------------------------------
00071 
00072         G4double costh_to_normal;
00073         G4ThreeVector pos,direction;
00074         theG4AdjointPosOnPhysVolGenerator->GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(pos, direction,costh_to_normal);
00075         if (costh_to_normal <1.e-4) costh_to_normal =1.e-4;
00076         theSingleParticleSource->GetAngDist()->SetParticleMomentumDirection(-direction);
00077         theSingleParticleSource->GetPosDist()->SetCentreCoords(pos);
00078    }    
00079 
00080    theSingleParticleSource->GetEneDist()->SetEmin(E1); 
00081    theSingleParticleSource->GetEneDist()->SetEmax(E2);  
00082         
00083    theSingleParticleSource->SetParticleDefinition(adj_part);
00084    theSingleParticleSource->GeneratePrimaryVertex(anEvent);
00085 }
00087 //
00088 void G4AdjointPrimaryGenerator::SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector center_pos)
00089 { 
00090   radius_spherical_source = radius;
00091   center_spherical_source = center_pos;
00092   type_of_adjoint_source ="Spherical"; 
00093   theSingleParticleSource->GetPosDist()->SetPosDisType("Surface");
00094   theSingleParticleSource->GetPosDist()->SetPosDisShape("Sphere");
00095   theSingleParticleSource->GetPosDist()->SetCentreCoords(center_pos);
00096   theSingleParticleSource->GetPosDist()->SetRadius(radius);
00097   theSingleParticleSource->GetAngDist()->SetAngDistType("cos");
00098   theSingleParticleSource->GetAngDist()->SetMaxTheta(pi);
00099   theSingleParticleSource->GetAngDist()->SetMinTheta(halfpi);
00100 }
00102 //
00103 void G4AdjointPrimaryGenerator::SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String& volume_name)
00104 {
00105   theG4AdjointPosOnPhysVolGenerator->DefinePhysicalVolume1(volume_name);
00106   type_of_adjoint_source ="ExternalSurfaceOfAVolume";
00107   theSingleParticleSource->GetPosDist()->SetPosDisType("Point");
00108   theSingleParticleSource->GetAngDist()->SetAngDistType("planar"); 
00109 }
00110 

Generated on Mon May 27 17:47:37 2013 for Geant4 by  doxygen 1.4.7