//////////////////////////////////////////////////////////////////// /// \class GLG4Gen /// /// \author Phil Jones /// \author Nuno Barros -- contact person /// /// REVISION HISTORY:\n /// inherited as part of the generic GLG4 software /// 31-Oct-2016 : N Barros - Introduced BeginOfRun and EndOfRun methods. /// 10-Feb-2017 : N Barros - Added instances of time, position and vertex generator pointers the GLG4Gen /// - Expanded GLG4Gen::BeginOfRun to propagate to underlying generators /// //////////////////////////////////////////////////////////////////// #ifndef __GLG4Gen_h__ #define __GLG4Gen_h__ #include #include #include class G4Event; class G4Track; class G4PrimaryVertex; class GLG4TimeGen; class GLG4VertexGen; class GLG4PosGen; // Base class for event generators class GLG4Gen { public: GLG4Gen(const G4String &name = "") : fNextTime(0.0),fTimeGen(0),fVertexGen(0),fPosGen(0), fName(name) { }; virtual ~GLG4Gen(); virtual void GenerateEvent(G4Event *event)=0; virtual double NextTime() const { return fNextTime; }; virtual void SubtractTime(double time) { fNextTime -= time; }; virtual G4String GetName() {return fName;} virtual void SetName(G4String name) {fName = name;} virtual void ResetTime(double offset=0.0)=0; virtual bool IsRepeatable() const =0; virtual void SetState(G4String state)=0; virtual G4String GetState() const =0; virtual void BeginOfRun(); virtual void EndOfRun(); // Optional methods for setting specific aspects of // event generator if applicable virtual void SetTimeState(G4String state) { (void)state; }; virtual G4String GetTimeState() const { return ""; }; virtual void SetVertexState(G4String state) { (void)state; }; virtual G4String GetVertexState() const { return ""; }; virtual void SetPosState(G4String state) { (void)state; }; virtual G4String GetPosState() const { return ""; }; protected: double fNextTime; GLG4TimeGen *fTimeGen; GLG4VertexGen *fVertexGen; GLG4PosGen *fPosGen; G4String fName; }; // Generic generator formed by combining separate time, vertex, and position // generators. class GLG4Gen_Combo : public GLG4Gen { public: GLG4Gen_Combo(); virtual ~GLG4Gen_Combo(); virtual void GenerateEvent(G4Event *event); virtual void ResetTime(double offset=0.0); virtual bool IsRepeatable() const { return true; }; virtual void SetState(G4String state); virtual G4String GetState() const; virtual void SetTimeState(G4String state); virtual G4String GetTimeState() const; virtual void SetVertexState(G4String state); virtual G4String GetVertexState() const; virtual void SetPosState(G4String state); virtual G4String GetPosState() const; protected: G4String fStateStr; }; // Creates a one-shot generator used to defer a long-lived track // to a later event. class GLG4Gen_DeferTrack : public GLG4Gen { public: GLG4Gen_DeferTrack(const G4Track *track); virtual ~GLG4Gen_DeferTrack(); virtual void GenerateEvent(G4Event *event); virtual void ResetTime(double offset=0.0) { __unused_parameter(offset); }; virtual bool IsRepeatable() const { return false; }; virtual void BeginOfRun() { }; virtual void EndOfRun() { }; virtual void SetState(G4String state); virtual G4String GetState() const; protected: G4PrimaryVertex *fVertex; }; #endif