Public Member Functions | Private Attributes | List of all members
EDepSim::DensityPositionGenerator Class Reference

#include <EDepSimDensityPositionGenerator.hh>

Inheritance diagram for EDepSim::DensityPositionGenerator:
EDepSim::VConstrainedPositionGenerator EDepSim::VPositionGenerator

Public Member Functions

 DensityPositionGenerator (const G4String &name)
 
virtual ~DensityPositionGenerator ()
 
virtual G4LorentzVector GetPosition ()
 Return a candidate vertex. More...
 
virtual bool ForcePosition ()
 
- Public Member Functions inherited from EDepSim::VConstrainedPositionGenerator
 VConstrainedPositionGenerator (const G4String &name)
 
virtual ~VConstrainedPositionGenerator ()
 
void SetVolumeName (const G4String &volume)
 Set the name of the volume to be sampled for a vertex. More...
 
void ClearPositionTests (void)
 Clear the current set of vertex checks. More...
 
void CheckVolumeName (const G4String &name)
 
void CheckNotVolumeName (const G4String &name)
 
void CheckVolumeMaterial (const G4String &name)
 Check that the vertex is inside of a material specified by name. More...
 
void CheckNotVolumeMaterial (const G4String &name)
 Check that the vertex is not inside of a material specified by name. More...
 
void CheckMinX (double x)
 Check that the vertex X position is greater than some value. More...
 
void CheckMaxX (double x)
 Check that the vertex X position is less than some value. More...
 
void CheckMinY (double y)
 Check that the vertex Y position is greater than some value. More...
 
void CheckMaxY (double y)
 Check that the vertex Y position is less than some value. More...
 
void CheckMinZ (double z)
 Check that the vertex Z position is greater than some value. More...
 
void CheckMaxZ (double z)
 Check that the vertex Z position is less than some value. More...
 
- Public Member Functions inherited from EDepSim::VPositionGenerator
 VPositionGenerator (const G4String &name)
 
virtual ~VPositionGenerator ()
 
G4String GetName () const
 Return the name of the generator. More...
 

Private Attributes

double fMaximumDensity
 The maximum density in the detector. More...
 

Additional Inherited Members

- Public Types inherited from EDepSim::VConstrainedPositionGenerator
typedef std::vector< PositionTest * > PositionTests
 
- Protected Member Functions inherited from EDepSim::VConstrainedPositionGenerator
virtual bool ValidPosition (const G4LorentzVector &vtx)
 Return true if the vertex is valid. This is used in the derived class. More...
 
G4LorentzVector TrialPosition ()
 Generate a trial position uniformly in the sample box. More...
 

Detailed Description

Definition at line 8 of file EDepSimDensityPositionGenerator.hh.

Constructor & Destructor Documentation

EDepSim::DensityPositionGenerator::DensityPositionGenerator ( const G4String &  name)
EDepSim::DensityPositionGenerator::~DensityPositionGenerator ( )
virtual

Definition at line 16 of file EDepSimDensityPositionGenerator.cc.

16 {}

Member Function Documentation

bool EDepSim::DensityPositionGenerator::ForcePosition ( )
virtual

Flag if the vertex should be forced to the candidate vertex returned by GetPosition().

Reimplemented from EDepSim::VConstrainedPositionGenerator.

Definition at line 55 of file EDepSimDensityPositionGenerator.cc.

55  {
56  return true;
57 }
G4LorentzVector EDepSim::DensityPositionGenerator::GetPosition ( )
virtual

Return a candidate vertex.

Implements EDepSim::VPositionGenerator.

Definition at line 18 of file EDepSimDensityPositionGenerator.cc.

18  {
19  if (fMaximumDensity < 0) {
20  const G4MaterialTable* mTable = G4Material::GetMaterialTable();
21  for (G4MaterialTable::const_iterator m = mTable->begin();
22  m != mTable->end();
23  ++m) {
24  fMaximumDensity = std::max(fMaximumDensity, (*m)->GetDensity());
25  }
26  }
27  // Get the navigator.
28  G4Navigator* navigator
29  = G4TransportationManager::GetTransportationManager()
30  ->GetNavigatorForTracking();
31  for (int finiteLoop = 0; finiteLoop<100000; ++finiteLoop) {
32  G4LorentzVector vtx = TrialPosition();
33 
34  // Get the volume that contains the point.
35  G4VPhysicalVolume* volume = navigator->LocateGlobalPointAndSetup(vtx);
36 
37  // Skip this vertex if it's not in a legal volume.
38  if (!volume) continue;
39 
40  // Get the density.
41  double density
42  = volume->GetLogicalVolume()->GetMaterial()->GetDensity();
43 
44  // Skip this vertex if it misses the sampling.
45  if (density < fMaximumDensity*G4UniformRand()) continue;
46 
47  // The vertex meets the density sampling, so check if it is valid.
48  if (ValidPosition(vtx)) return vtx;
49  }
50  EDepSimError("EDepSim::DensityPositionGenerator::GetPosition:"
51  << " No valid position found");
52  throw;
53 }
virtual bool ValidPosition(const G4LorentzVector &vtx)
Return true if the vertex is valid. This is used in the derived class.
double fMaximumDensity
The maximum density in the detector.
static const std::string volume[nvol]
intermediate_table::const_iterator const_iterator
G4LorentzVector TrialPosition()
Generate a trial position uniformly in the sample box.
static int max(int a, int b)
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503

Member Data Documentation

double EDepSim::DensityPositionGenerator::fMaximumDensity
private

The maximum density in the detector.

Definition at line 22 of file EDepSimDensityPositionGenerator.hh.


The documentation for this class was generated from the following files: