/* * MixedEventGenerator.hh * * Created on: Oct 30, 2014 * Author: aksel * * Changelog: 16-Feb-2017 : N. Barros - Introduced BeginOfRun and EndOfRun */ #ifndef MIXEDEVENTGENERATOR_H_ #define MIXEDEVENTGENERATOR_H_ #include #include namespace RAT { class MixedEventGenerator: public GLG4Gen { public: MixedEventGenerator(); MixedEventGenerator(GLG4Gen *aGenerator, G4double aRate); MixedEventGenerator(G4PrimaryVertex *aVertex); void GenerateEvent(G4Event *event); G4PrimaryVertex *GetVertex(){return fPrimaryVertex;} G4double GetTime()const {return fTime;} G4String GetState() const{return fState;} bool IsRepeatable() const {return true;}; void NextEvent(); G4double NextTime()const {if (sQueue.empty()) return kInfinity; else return sQueue.top()->GetTime()-sOffset;} G4bool operator()(const MixedEventGenerator *a, const MixedEventGenerator *b)const { ///< Compares priority, higher times have lower priority return a->GetTime()>b->GetTime();} void ResetTime(double offset=0.0); void SetState(G4String state); void SetVertexState(G4String state); void SetPosState(G4String state) ; void SubtractTime(double offset){fOffset+=offset; sOffset=fOffset; } static G4double sCoincidenceTime; static G4int sInitialized; ///> this is used to ensure that only a single MixedEventGenerator object is created. static G4double sOffset; virtual void BeginOfRun(); virtual void EndOfRun(); private: static std::priority_queue,MixedEventGenerator> sQueue; G4double fRate; G4int fAtomCount; ///< The number of atoms of a particular isotope. For cosmogenics, this allows modelling the decay. -1 means no decay. GLG4Gen *fGenerator; G4double fOffset ; ///< time of the previous event G4PrimaryVertex *fPrimaryVertex; ///< The vertex that corresponds to fNextTime G4double fTime; ///< The time of the current event, with fTime=0 at the beginning of the run G4String fState ; G4bool fShouldDeleteThis; ///< Set false if this MixedEventGenerator is owned by GlG4PrimaryGenerator G4bool runInitDone; ///< Controls whether BeginOfRun was called for this instance already }; } /* namespace RAT */ #endif /* MIXEDEVENTGENERATOR_H_ */