Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
EDepSim::VConstrainedPositionGenerator Class Reference

#include <EDepSimVConstrainedPositionGenerator.hh>

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

Classes

class  PositionTest
 

Public Types

typedef std::vector< PositionTest * > PositionTests
 

Public Member Functions

 VConstrainedPositionGenerator (const G4String &name)
 
virtual ~VConstrainedPositionGenerator ()
 
virtual bool ForcePosition ()
 
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 ()
 
virtual G4LorentzVector GetPosition ()=0
 Return the candidate position for the primary vertex. More...
 
G4String GetName () const
 Return the name of the generator. More...
 

Protected Member Functions

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...
 

Private Member Functions

void FindLimits ()
 Find the limits of the volume to be sampled for a good vertex. More...
 

Private Attributes

G4String fSampleVolume
 The name of the volume to be sampled. More...
 
bool fLimitsFound
 True if the limits have been initialized. More...
 
PositionTests fPositionTests
 The vertex tests to apply. More...
 
G4ThreeVector fMinimumCorner
 The lower boundary of the volume to be sampled for the vertex. More...
 
G4ThreeVector fMaximumCorner
 The upper boundary of the volume to be sampled for the vertex. More...
 

Detailed Description

Definition at line 13 of file EDepSimVConstrainedPositionGenerator.hh.

Member Typedef Documentation

Definition at line 28 of file EDepSimVConstrainedPositionGenerator.hh.

Constructor & Destructor Documentation

EDepSim::VConstrainedPositionGenerator::VConstrainedPositionGenerator ( const G4String &  name)

Definition at line 18 of file EDepSimVConstrainedPositionGenerator.cc.

21  fLimitsFound(false) {
22  fMaximumCorner.set(1000000*meter,1000000*meter,1000000*meter);
23  fMinimumCorner.set(-1000000*meter,-1000000*meter,-1000000*meter);
24 }
static QCString name
Definition: declinfo.cpp:673
G4ThreeVector fMinimumCorner
The lower boundary of the volume to be sampled for the vertex.
G4String fSampleVolume
The name of the volume to be sampled.
bool fLimitsFound
True if the limits have been initialized.
meter_as<> meter
Type of space stored in meters, in double precision.
Definition: spacetime.h:400
G4ThreeVector fMaximumCorner
The upper boundary of the volume to be sampled for the vertex.
EDepSim::VConstrainedPositionGenerator::~VConstrainedPositionGenerator ( )
virtual

Definition at line 26 of file EDepSimVConstrainedPositionGenerator.cc.

26 {}

Member Function Documentation

void EDepSim::VConstrainedPositionGenerator::CheckMaxX ( double  x)

Check that the vertex X position is less than some value.

Definition at line 193 of file EDepSimVConstrainedPositionGenerator.cc.

193  {
194  if (fMaximumCorner.x() > x) fMaximumCorner.setX(x);
195  fPositionTests.push_back(new InternalMaximumCoordinate(0,x));
196 }
G4ThreeVector fMaximumCorner
The upper boundary of the volume to be sampled for the vertex.
PositionTests fPositionTests
The vertex tests to apply.
list x
Definition: train.py:276
void EDepSim::VConstrainedPositionGenerator::CheckMaxY ( double  y)

Check that the vertex Y position is less than some value.

Definition at line 198 of file EDepSimVConstrainedPositionGenerator.cc.

198  {
199  if (fMaximumCorner.y() > y) fMaximumCorner.setY(y);
200  fPositionTests.push_back(new InternalMaximumCoordinate(1,y));
201 }
G4ThreeVector fMaximumCorner
The upper boundary of the volume to be sampled for the vertex.
PositionTests fPositionTests
The vertex tests to apply.
void EDepSim::VConstrainedPositionGenerator::CheckMaxZ ( double  z)

Check that the vertex Z position is less than some value.

Definition at line 203 of file EDepSimVConstrainedPositionGenerator.cc.

203  {
204  if (fMaximumCorner.z() > z) fMaximumCorner.setZ(z);
205  fPositionTests.push_back(new InternalMaximumCoordinate(2,z));
206 }
G4ThreeVector fMaximumCorner
The upper boundary of the volume to be sampled for the vertex.
PositionTests fPositionTests
The vertex tests to apply.
void EDepSim::VConstrainedPositionGenerator::CheckMinX ( double  x)

Check that the vertex X position is greater than some value.

Definition at line 178 of file EDepSimVConstrainedPositionGenerator.cc.

178  {
179  if (fMinimumCorner.x() < x) fMinimumCorner.setX(x);
180  fPositionTests.push_back(new InternalMinimumCoordinate(0,x));
181 }
G4ThreeVector fMinimumCorner
The lower boundary of the volume to be sampled for the vertex.
PositionTests fPositionTests
The vertex tests to apply.
list x
Definition: train.py:276
void EDepSim::VConstrainedPositionGenerator::CheckMinY ( double  y)

Check that the vertex Y position is greater than some value.

Definition at line 183 of file EDepSimVConstrainedPositionGenerator.cc.

183  {
184  if (fMinimumCorner.y() < y) fMinimumCorner.setY(y);
185  fPositionTests.push_back(new InternalMinimumCoordinate(1,y));
186 }
G4ThreeVector fMinimumCorner
The lower boundary of the volume to be sampled for the vertex.
PositionTests fPositionTests
The vertex tests to apply.
void EDepSim::VConstrainedPositionGenerator::CheckMinZ ( double  z)

Check that the vertex Z position is greater than some value.

Definition at line 188 of file EDepSimVConstrainedPositionGenerator.cc.

188  {
189  if (fMinimumCorner.z() < z) fMinimumCorner.setZ(z);
190  fPositionTests.push_back(new InternalMinimumCoordinate(2,z));
191 }
G4ThreeVector fMinimumCorner
The lower boundary of the volume to be sampled for the vertex.
PositionTests fPositionTests
The vertex tests to apply.
void EDepSim::VConstrainedPositionGenerator::CheckNotVolumeMaterial ( const G4String &  name)

Check that the vertex is not inside of a material specified by name.

Definition at line 173 of file EDepSimVConstrainedPositionGenerator.cc.

174  {
175  fPositionTests.push_back(new InternalNotVolumeMaterial(name));
176 }
static QCString name
Definition: declinfo.cpp:673
PositionTests fPositionTests
The vertex tests to apply.
void EDepSim::VConstrainedPositionGenerator::CheckNotVolumeName ( const G4String &  name)

Check that the vertex is not inside of a volume specified by name. Name may be a sub-string contained in the full volume name.

Definition at line 163 of file EDepSimVConstrainedPositionGenerator.cc.

164  {
165  fPositionTests.push_back(new InternalNotVolumeName(name));
166 }
static QCString name
Definition: declinfo.cpp:673
PositionTests fPositionTests
The vertex tests to apply.
void EDepSim::VConstrainedPositionGenerator::CheckVolumeMaterial ( const G4String &  name)

Check that the vertex is inside of a material specified by name.

Definition at line 168 of file EDepSimVConstrainedPositionGenerator.cc.

169  {
170  fPositionTests.push_back(new InternalVolumeMaterial(name));
171 }
static QCString name
Definition: declinfo.cpp:673
PositionTests fPositionTests
The vertex tests to apply.
void EDepSim::VConstrainedPositionGenerator::CheckVolumeName ( const G4String &  name)

Check that the vertex is inside of a volume specified by name. Name may be a sub-string contanied in the full volume name.

Definition at line 158 of file EDepSimVConstrainedPositionGenerator.cc.

159  {
160  fPositionTests.push_back(new InternalVolumeName(name));
161 }
static QCString name
Definition: declinfo.cpp:673
PositionTests fPositionTests
The vertex tests to apply.
void EDepSim::VConstrainedPositionGenerator::ClearPositionTests ( void  )
inline

Clear the current set of vertex checks.

Definition at line 34 of file EDepSimVConstrainedPositionGenerator.hh.

34 {fPositionTests.clear();}
PositionTests fPositionTests
The vertex tests to apply.
void EDepSim::VConstrainedPositionGenerator::FindLimits ( )
private

Find the limits of the volume to be sampled for a good vertex.

Definition at line 221 of file EDepSimVConstrainedPositionGenerator.cc.

221  {
222  if (fLimitsFound) return;
223  fLimitsFound = true;
224 
225  if (fSampleVolume == "") {
226  EDepSimError("EDepSim::VConstrainedPositionGenerator:: "
227  "The sample volume must be set");
228  }
229 
230  // Find the volume for sampling by something that is big enough to cover
231  // all of the possible vertex locations.
232  G4Navigator* navigator
233  = G4TransportationManager::GetTransportationManager()
234  ->GetNavigatorForTracking();
235 
236  std::queue<QueueElement> volumes;
237  volumes.push(QueueElement(navigator->GetWorldVolume(),
238  G4ThreeVector(0,0,0),
239  G4RotationMatrix()));
240  while (!volumes.empty()) {
241  G4VPhysicalVolume* phyVolume = volumes.front().volume;
242  G4ThreeVector translation
243  = volumes.front().translation + phyVolume->GetObjectTranslation();
244  G4RotationMatrix rotation = volumes.front().rotation;
245  rotation.transform(phyVolume->GetObjectRotationValue());
246  volumes.pop();
247 
248  if (phyVolume->GetName().find(fSampleVolume) != std::string::npos) {
249  G4VisExtent volExtent
250  = phyVolume->GetLogicalVolume()->GetSolid()->GetExtent();
251  G4ThreeVector volMin;
252  G4ThreeVector volMax;
253  volMin.set(volExtent.GetXmin(),
254  volExtent.GetYmin(),
255  volExtent.GetZmin());
256  volMax.set(volExtent.GetXmax(),
257  volExtent.GetYmax(),
258  volExtent.GetZmax());
259  volMin = rotation*volMin + translation;
260  volMax = rotation*volMax + translation;
261  if (fMaximumCorner.x()>volMax.x()) fMaximumCorner.setX(volMax.x());
262  if (fMaximumCorner.y()>volMax.y()) fMaximumCorner.setY(volMax.y());
263  if (fMaximumCorner.z()>volMax.z()) fMaximumCorner.setZ(volMax.z());
264  if (fMinimumCorner.x()<volMin.x()) fMinimumCorner.setX(volMin.x());
265  if (fMinimumCorner.y()<volMin.y()) fMinimumCorner.setY(volMin.y());
266  if (fMinimumCorner.z()<volMin.z()) fMinimumCorner.setZ(volMin.z());
267  break;
268  }
269 
270  G4LogicalVolume* logVolume = phyVolume->GetLogicalVolume();
271  for (std::size_t i=0; i< logVolume->GetNoDaughters(); ++i) {
272  volumes.push(QueueElement(logVolume->GetDaughter(i),
273  translation,
274  rotation));
275  }
276  }
277 
278  EDepSimLog("Sampling volume extent:");
279  EDepSimLog(" X: " << G4BestUnit(fMinimumCorner[0],"Length")
280  << "to " << G4BestUnit(fMaximumCorner[0],"Length"));
281  EDepSimLog(" Y: " << G4BestUnit(fMinimumCorner[1],"Length")
282  << "to " << G4BestUnit(fMaximumCorner[1],"Length"));
283  EDepSimLog(" Z: " << G4BestUnit(fMinimumCorner[2],"Length")
284  << "to " << G4BestUnit(fMaximumCorner[2],"Length"));
285 }
#define EDepSimLog(outStream)
Definition: EDepSimLog.hh:717
G4ThreeVector fMinimumCorner
The lower boundary of the volume to be sampled for the vertex.
G4String fSampleVolume
The name of the volume to be sampled.
bool fLimitsFound
True if the limits have been initialized.
G4ThreeVector fMaximumCorner
The upper boundary of the volume to be sampled for the vertex.
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503
bool EDepSim::VConstrainedPositionGenerator::ForcePosition ( )
virtual

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

Implements EDepSim::VPositionGenerator.

Reimplemented in EDepSim::DensityPositionGenerator, and EDepSim::UniformPositionGenerator.

Definition at line 28 of file EDepSimVConstrainedPositionGenerator.cc.

28  {
29  return true;
30 }
void EDepSim::VConstrainedPositionGenerator::SetVolumeName ( const G4String &  volume)
inline

Set the name of the volume to be sampled for a vertex.

Definition at line 31 of file EDepSimVConstrainedPositionGenerator.hh.

G4String fSampleVolume
The name of the volume to be sampled.
static const std::string volume[nvol]
G4LorentzVector EDepSim::VConstrainedPositionGenerator::TrialPosition ( )
protected

Generate a trial position uniformly in the sample box.

Definition at line 287 of file EDepSimVConstrainedPositionGenerator.cc.

287  {
288  FindLimits();
289  G4LorentzVector vtx;
290  for (int i=0; i<3; ++i) {
291  vtx[i] = (fMaximumCorner[i] - fMinimumCorner[i])*G4UniformRand()
292  + fMinimumCorner[i];
293  }
294  vtx[3] = 0;
295  return vtx;
296 }
G4ThreeVector fMinimumCorner
The lower boundary of the volume to be sampled for the vertex.
void FindLimits()
Find the limits of the volume to be sampled for a good vertex.
G4ThreeVector fMaximumCorner
The upper boundary of the volume to be sampled for the vertex.
bool EDepSim::VConstrainedPositionGenerator::ValidPosition ( const G4LorentzVector &  vtx)
protectedvirtual

Return true if the vertex is valid. This is used in the derived class.

Definition at line 32 of file EDepSimVConstrainedPositionGenerator.cc.

33  {
35  test != fPositionTests.end();
36  ++test) {
37  if (!(*test)->Apply(vtx)) return false;
38  }
39  return true;
40 }
intermediate_table::iterator iterator
PositionTests fPositionTests
The vertex tests to apply.

Member Data Documentation

bool EDepSim::VConstrainedPositionGenerator::fLimitsFound
private

True if the limits have been initialized.

Definition at line 80 of file EDepSimVConstrainedPositionGenerator.hh.

G4ThreeVector EDepSim::VConstrainedPositionGenerator::fMaximumCorner
private

The upper boundary of the volume to be sampled for the vertex.

Definition at line 92 of file EDepSimVConstrainedPositionGenerator.hh.

G4ThreeVector EDepSim::VConstrainedPositionGenerator::fMinimumCorner
private

The lower boundary of the volume to be sampled for the vertex.

Definition at line 89 of file EDepSimVConstrainedPositionGenerator.hh.

PositionTests EDepSim::VConstrainedPositionGenerator::fPositionTests
private

The vertex tests to apply.

Definition at line 86 of file EDepSimVConstrainedPositionGenerator.hh.

G4String EDepSim::VConstrainedPositionGenerator::fSampleVolume
private

The name of the volume to be sampled.

Definition at line 77 of file EDepSimVConstrainedPositionGenerator.hh.


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