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

#include <EDepSimUserPrimaryGeneratorAction.hh>

Inheritance diagram for EDepSim::UserPrimaryGeneratorAction:

Public Member Functions

 UserPrimaryGeneratorAction (void)
 
virtual ~UserPrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *anEvent)
 
void AddGenerator (G4VPrimaryGenerator *generator)
 
void ClearGenerators ()
 Clear the current list of generators. More...
 
const G4VPrimaryGenerator * GetGenerator (int i) const
 Get the generators used to create events. There will be at least one. More...
 
int GetGeneratorCount () const
 Get the number of generators being used to create events. More...
 
void SetAllowEmptyEvents (bool flag)
 
void SetAllowPartialEvents (bool flag)
 
void SetAddFakeGeantino (bool flag)
 

Private Attributes

std::vector< G4VPrimaryGenerator * > fPrimaryGenerators
 
bool fAllowEmptyEvents
 
bool fAddFakeGeantino
 
bool fAllowPartialEvents
 
EDepSim::UserPrimaryGeneratorMessengerfMessenger
 The messenger for this action. More...
 

Detailed Description

Definition at line 17 of file EDepSimUserPrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

EDepSim::UserPrimaryGeneratorAction::UserPrimaryGeneratorAction ( void  )
EDepSim::UserPrimaryGeneratorAction::~UserPrimaryGeneratorAction ( )
virtual

Definition at line 22 of file EDepSimUserPrimaryGeneratorAction.cc.

22  {
23  delete fMessenger;
24 }
EDepSim::UserPrimaryGeneratorMessenger * fMessenger
The messenger for this action.

Member Function Documentation

void EDepSim::UserPrimaryGeneratorAction::AddGenerator ( G4VPrimaryGenerator *  generator)
inline

Add a new EDepSim::PrimaryGenerator to the list of generators adding primary vertices to the event.

Definition at line 31 of file EDepSimUserPrimaryGeneratorAction.hh.

31  {
32  fPrimaryGenerators.push_back(generator);
33  }
generator
Definition: train.py:468
std::vector< G4VPrimaryGenerator * > fPrimaryGenerators
void EDepSim::UserPrimaryGeneratorAction::ClearGenerators ( )

Clear the current list of generators.

Definition at line 76 of file EDepSimUserPrimaryGeneratorAction.cc.

76  {
78  = fPrimaryGenerators.begin();
79  gen != fPrimaryGenerators.end();
80  ++gen) {
81  delete (*gen);
82  }
83  fPrimaryGenerators.clear();
84 }
intermediate_table::iterator iterator
gen
Definition: demo.py:24
std::vector< G4VPrimaryGenerator * > fPrimaryGenerators
void EDepSim::UserPrimaryGeneratorAction::GeneratePrimaries ( G4Event *  anEvent)
virtual

Generate all of the primaries for and event and place them into a primary vertex. This may generate several primary vertices (in no particular order).

Definition at line 26 of file EDepSimUserPrimaryGeneratorAction.cc.

26  {
27  // Make sure that at least one generater is in the list. If the list is
28  // empty, then create the default generator.
29  if (fPrimaryGenerators.size()<1) {
31  }
32 
33  for (int finiteLoop = 0; finiteLoop<1000; ++finiteLoop) {
35  = fPrimaryGenerators.begin();
37  ++generator) {
38  try {
39  (*generator)->GeneratePrimaryVertex(anEvent);
40  }
41  catch (EDepSim::NoMoreEvents&) {
42  if (fAllowPartialEvents) {
43  EDepSimLog("GeneratePrimaries: "
44  << "Ran out of primaries will filling event.");
45  continue;
46  }
47  EDepSimError("Run aborted. No more input events.");
48  G4RunManager::GetRunManager()->AbortRun();
49  return;
50  }
51  }
52  if (fAddFakeGeantino) {
53  EDepSimWarn("Add a GEANTINO vertex.");
54  // Put the vertex far way, and far in the future.
55  G4PrimaryVertex* theVertex =
56  new G4PrimaryVertex(G4ThreeVector(1E+20, 1E+20, 1E+20),
57  1E+20);
58  anEvent->AddPrimaryVertex(theVertex);
59  // Create the GEANTINO
60  G4ParticleTable* particleTable
61  = G4ParticleTable::GetParticleTable();
62  G4ParticleDefinition* def = particleTable->FindParticle("geantino");
63  G4PrimaryParticle* part
64  = new G4PrimaryParticle(def,0.0, 0.0, 1.0);
65  theVertex->SetPrimary(part);
66  break;
67  }
68  if (anEvent->GetNumberOfPrimaryVertex()>0) break;
69  if (fAllowEmptyEvents) continue;
70  EDepSimError("EDepSim::UserPrimaryGeneratorAction::GeneratePrimaries():"
71  << " Event generated without any primary verticies.");
72  EDepSimThrow("No primaries generated.");
73  }
74 }
#define EDepSimLog(outStream)
Definition: EDepSimLog.hh:717
intermediate_table::iterator iterator
EDepSim::UserPrimaryGeneratorMessenger * fMessenger
The messenger for this action.
EDepSim::PrimaryGenerator * CreateGenerator()
Create a new generator using the current generator factories.
void AddGenerator(G4VPrimaryGenerator *generator)
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
generator
Definition: train.py:468
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503
#define EDepSimWarn(outStream)
Definition: EDepSimLog.hh:576
std::vector< G4VPrimaryGenerator * > fPrimaryGenerators
const G4VPrimaryGenerator* EDepSim::UserPrimaryGeneratorAction::GetGenerator ( int  i) const
inline

Get the generators used to create events. There will be at least one.

Definition at line 39 of file EDepSimUserPrimaryGeneratorAction.hh.

39  {
40  return fPrimaryGenerators[i];
41  }
std::vector< G4VPrimaryGenerator * > fPrimaryGenerators
int EDepSim::UserPrimaryGeneratorAction::GetGeneratorCount ( ) const
inline

Get the number of generators being used to create events.

Definition at line 44 of file EDepSimUserPrimaryGeneratorAction.hh.

44  {
45  return fPrimaryGenerators.size();
46  }
std::vector< G4VPrimaryGenerator * > fPrimaryGenerators
void EDepSim::UserPrimaryGeneratorAction::SetAddFakeGeantino ( bool  flag)
inline

Set a flag that events without a real vertex should have a fake GEANTINO generated. This only has an effect with SetAllowEmptyEvents() has been called with true.

Definition at line 60 of file EDepSimUserPrimaryGeneratorAction.hh.

void EDepSim::UserPrimaryGeneratorAction::SetAllowEmptyEvents ( bool  flag)
inline

Set a flag that events that don't contain a real vertex are allowed. If the flag is true, then empty events are allowed.

Definition at line 50 of file EDepSimUserPrimaryGeneratorAction.hh.

void EDepSim::UserPrimaryGeneratorAction::SetAllowPartialEvents ( bool  flag)
inline

Set a flag that events that it's to run out of events in the kinematics file. If the flag is true, then partial events are allowed.

Definition at line 55 of file EDepSimUserPrimaryGeneratorAction.hh.

Member Data Documentation

bool EDepSim::UserPrimaryGeneratorAction::fAddFakeGeantino
private

A flag that any empty event should be filled with a fake GEANTINO vertex. This only has an affect with fAllowEmptyEvents is true.

Definition at line 74 of file EDepSimUserPrimaryGeneratorAction.hh.

bool EDepSim::UserPrimaryGeneratorAction::fAllowEmptyEvents
private

A flag that empty events are allowed. If this is set to be true, the generator will return events even if there are no real vertices.

Definition at line 70 of file EDepSimUserPrimaryGeneratorAction.hh.

bool EDepSim::UserPrimaryGeneratorAction::fAllowPartialEvents
private

A flag to allow an event to be generated even if the input kinematics has run out of data. This is useful when a single spill of interactions has been generated and you want to generate a single event containing every interaction in the kinematic input file.

Definition at line 80 of file EDepSimUserPrimaryGeneratorAction.hh.

EDepSim::UserPrimaryGeneratorMessenger* EDepSim::UserPrimaryGeneratorAction::fMessenger
private

The messenger for this action.

Definition at line 83 of file EDepSimUserPrimaryGeneratorAction.hh.

std::vector<G4VPrimaryGenerator*> EDepSim::UserPrimaryGeneratorAction::fPrimaryGenerators
private

A vector of generator sets to use to generate events. Each of these primary factories will be called in sequence.

Definition at line 66 of file EDepSimUserPrimaryGeneratorAction.hh.


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