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

#include <EDepSimPrimaryGenerator.hh>

Inheritance diagram for EDepSim::PrimaryGenerator:

Public Member Functions

 PrimaryGenerator (EDepSim::VKinematicsGenerator *kine, EDepSim::VCountGenerator *count, EDepSim::VPositionGenerator *position, EDepSim::VTimeGenerator *time)
 
virtual ~PrimaryGenerator ()
 
virtual void GeneratePrimaryVertex (G4Event *evt)
 
G4String GetName ()
 Return the name of this generator. More...
 
const EDepSim::VKinematicsGeneratorGetKinematicsGenerator () const
 Return the kinematics generator;. More...
 
const EDepSim::VCountGeneratorGetCountGenerator () const
 Return the count generator. More...
 
const EDepSim::VPositionGeneratorGetPositionGenerator () const
 Return the position generator. More...
 
const EDepSim::VTimeGeneratorGetTimeGenerator () const
 Return the time generator. More...
 

Private Attributes

EDepSim::VKinematicsGeneratorfKinematics
 
EDepSim::VCountGeneratorfCount
 
EDepSim::VPositionGeneratorfPosition
 
EDepSim::VTimeGeneratorfTime
 

Detailed Description

Definition at line 20 of file EDepSimPrimaryGenerator.hh.

Constructor & Destructor Documentation

EDepSim::PrimaryGenerator::PrimaryGenerator ( EDepSim::VKinematicsGenerator kine,
EDepSim::VCountGenerator count,
EDepSim::VPositionGenerator position,
EDepSim::VTimeGenerator time 
)

Definition at line 24 of file EDepSimPrimaryGenerator.cc.

28  : fKinematics(kine), fCount(count), fPosition(position), fTime(time) {
29 }
EDepSim::VTimeGenerator * fTime
EDepSim::VPositionGenerator * fPosition
EDepSim::VKinematicsGenerator * fKinematics
EDepSim::VCountGenerator * fCount
EDepSim::PrimaryGenerator::~PrimaryGenerator ( void  )
virtual

Definition at line 31 of file EDepSimPrimaryGenerator.cc.

31 {}

Member Function Documentation

void EDepSim::PrimaryGenerator::GeneratePrimaryVertex ( G4Event *  evt)
virtual

A pure virtual method to generate the actual primary particles which must be implemented in each derived class.

Definition at line 33 of file EDepSimPrimaryGenerator.cc.

33  {
34 
35  int count = fCount->GetCount();
36  int brake = 0;
37  EDepSimVerbose("# Generate " << count << " vertices w/ " << GetName());
38  while (count > 0 && brake<1000) {
39  // Stash the most recent primary vertex. This is saving the last
40  // existing primary vertex before the call to the
41  // EDepSim::VKinematicsGenerator::GeneratePrimaryVertex().
42  G4PrimaryVertex* vtx = evt->GetPrimaryVertex();
43  for (;vtx && vtx->GetNext(); vtx = vtx->GetNext());
44  // Generate a candidate position and time for the event vertex.
45  G4LorentzVector vertex = fPosition->GetPosition();
46  vertex.setT(fTime->GetTime(vertex));
47  // Generate the new kinematics. This will add new primary vertices to
48  // the G4Event.
51  if (generatorStatus == EDepSim::VKinematicsGenerator::kFail) {
52  ++brake; // Apply the brakes
53  continue;
54  }
55  if (generatorStatus == EDepSim::VKinematicsGenerator::kEndEvent) {
56  break;
57  }
58  // If the vertex should be forced, then make sure that it is. This
59  // updates the position and time for all of the vertices that were
60  // added to the event by the previous EDepSim::VKinematicsGenerator
61  // call. Get the first new vertex.
62  if (!vtx) vtx = evt->GetPrimaryVertex();
63  else vtx = vtx->GetNext();
64  // Update the vertex for the new vertices.
65  for (;vtx; vtx = vtx->GetNext()) {
66  // Update the vertex info (and make sure it exists). This sets
67  // the generator name.
68  EDepSim::VertexInfo* vInfo
69  = dynamic_cast<EDepSim::VertexInfo*>(vtx->GetUserInformation());
70  if (!vInfo) {
71  vInfo = new EDepSim::VertexInfo();
72  vtx->SetUserInformation(vInfo);
73  }
74  vInfo->SetName(GetName());
75  if (fPosition->ForcePosition()) {
76  EDepSimVerbose("# Force position to"
77  << " x: " << vertex.x()/cm << " cm"
78  << " y: " << vertex.y()/cm << " cm"
79  << " z: " << vertex.z()/cm << " cm");
80  vtx->SetPosition(vertex.x(), vertex.y(), vertex.z());
81  }
82  if (fTime->ForceTime()) {
83  EDepSimVerbose("# Force time to "
84  << vertex.t()/ns << " ns");
85  vtx->SetT0(vertex.t());
86  }
87  }
88  brake = 0; // Remove the brakes.
89  --count;
90 
91  // Check if the generator flagged that this vertex must end an event.
92  if (generatorStatus == EDepSim::VKinematicsGenerator::kLastVertex) {
93  break;
94  }
95  }
96 }
static constexpr double cm
Definition: Units.h:68
virtual int GetCount()=0
virtual bool ForcePosition()=0
GeneratorStatus
A status value that can be returned by GeneratePrimaryVertex.
EDepSim::VTimeGenerator * fTime
virtual G4LorentzVector GetPosition()=0
Return the candidate position for the primary vertex.
#define EDepSimVerbose(outStream)
Definition: EDepSimLog.hh:787
virtual bool ForceTime()=0
Return true if this time should be forced for the primary vertex.
G4String GetName()
Return the name of this generator.
virtual double GetTime(const G4LorentzVector &vertex)=0
Return the time of the primary vertex.
virtual GeneratorStatus GeneratePrimaryVertex(G4Event *evt, const G4LorentzVector &position)=0
EDepSim::VPositionGenerator * fPosition
The generation failed and should be tried again.
TCEvent evt
Definition: DataStructs.cxx:7
EDepSim::VKinematicsGenerator * fKinematics
EDepSim::VCountGenerator * fCount
QAsciiDict< Entry > ns
void SetName(const G4String &name)
vertex reconstruction
const EDepSim::VCountGenerator* EDepSim::PrimaryGenerator::GetCountGenerator ( ) const
inline

Return the count generator.

Definition at line 41 of file EDepSimPrimaryGenerator.hh.

41  {
42  return fCount;
43  }
EDepSim::VCountGenerator * fCount
const EDepSim::VKinematicsGenerator* EDepSim::PrimaryGenerator::GetKinematicsGenerator ( ) const
inline

Return the kinematics generator;.

Definition at line 36 of file EDepSimPrimaryGenerator.hh.

36  {
37  return fKinematics;
38  }
EDepSim::VKinematicsGenerator * fKinematics
G4String EDepSim::PrimaryGenerator::GetName ( void  )

Return the name of this generator.

Definition at line 98 of file EDepSimPrimaryGenerator.cc.

98  {
99  G4String name = fKinematics->GetName();
100  name += ":" + fCount->GetName();
101  name += "@" + fPosition->GetName();
102  name += "-" + fTime->GetName();
103  return name;
104 }
static QCString name
Definition: declinfo.cpp:673
EDepSim::VTimeGenerator * fTime
G4String GetName() const
Return the name of the generator.
EDepSim::VPositionGenerator * fPosition
EDepSim::VKinematicsGenerator * fKinematics
G4String GetName() const
Return the name of the generator.
EDepSim::VCountGenerator * fCount
G4String GetName() const
Return the name of the generator.
G4String GetName() const
Return the name of the generator.
const EDepSim::VPositionGenerator* EDepSim::PrimaryGenerator::GetPositionGenerator ( ) const
inline

Return the position generator.

Definition at line 46 of file EDepSimPrimaryGenerator.hh.

46  {
47  return fPosition;
48  }
EDepSim::VPositionGenerator * fPosition
const EDepSim::VTimeGenerator* EDepSim::PrimaryGenerator::GetTimeGenerator ( ) const
inline

Return the time generator.

Definition at line 51 of file EDepSimPrimaryGenerator.hh.

51  {
52  return fTime;
53  }
EDepSim::VTimeGenerator * fTime

Member Data Documentation

EDepSim::VCountGenerator* EDepSim::PrimaryGenerator::fCount
private

The count generator determines the number of primary vertices that will be added to a G4Event.

Definition at line 69 of file EDepSimPrimaryGenerator.hh.

EDepSim::VKinematicsGenerator* EDepSim::PrimaryGenerator::fKinematics
private

The kinematics generator that will return the primary particles being simulated by this generator. The kinematics generator adds the primary vertex to the G4Event along with the primary particles that eminate from the vertex. The generator is passed a 4-vector position which gives the position that EDepSim::VPrimaryGenerator would like an interaction generated for. The kinematics generator can choose to ignore this information and create the vertex at any location, but it might be overriden by EDepSim::VPrimaryGenerator (depending on which EDepSim::VVertexGenerator is used).

Definition at line 65 of file EDepSimPrimaryGenerator.hh.

EDepSim::VPositionGenerator* EDepSim::PrimaryGenerator::fPosition
private

The position generator picks candidate positions for the primary vertices. The candidate vertices generated by the position generator are passed to the kinematics generator as an advisory position. If the position generator returns true from EDepSim::VPositionGenerator::ForcePosition(), then the vertex from the kinematics generator will be overridden by the EDepSim::VPrimaryGenerator.

Definition at line 77 of file EDepSimPrimaryGenerator.hh.

EDepSim::VTimeGenerator* EDepSim::PrimaryGenerator::fTime
private

The time generator picks candidate times for the primary vertices. The candidate times are passed to the kinematics generator as advisory times. If the time generator returns true from EDepSim::VTimeGenerator::ForceTime(), then the vertex from the kinematics generator will be overridden by the EDepSim::VPrimaryGenerator.

Definition at line 84 of file EDepSimPrimaryGenerator.hh.


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