//////////////////////////////////////////////////////////////////// /// \class RAT::Coincidence_Gen /// /// \brief Top Level Event Producer - coincidences of different interactions separated in /// time and space in same event /// /// \author Jeanne Wilson -- contact person /// /// REVISION HISTORY: /// - 16-July-2008 : J.R. Wilson - first version /// - June 2013, Zack Blair - added more options for time distributions /// - Nov 2014, Matt Strait - doxygen fixes /// - 07-Feb-2017 : N Barros - Adapted for newly introduced BeginOfRun and EndOfRun /// - 17-Mar-2017 : N Barros - Fixed a bug that caused a seg fault in the saved state array. /// /// \details This generator simulates 2 different decays at different positions and /// different times in the same specified event window. It can be used for the purposes of /// studying pile-up as it will efficiently produce a sample in which each event is a /// coincidence. There is also the option of restricting the events generated to those with /// summed primary particle energy in a given range. //////////////////////////////////////////////////////////////////// #ifndef __RAT_Coincidence_Gen__ #define __RAT_Coincidence_Gen__ #include #include #include class G4Event; class GLG4PosGen; namespace RAT { class CoincidenceMessenger; class Coincidence_Gen : public GLG4Gen { public: Coincidence_Gen(); virtual ~Coincidence_Gen(); virtual void GenerateEvent(G4Event *event); virtual void ResetTime(double offset=0.0); virtual bool IsRepeatable() const { return true; }; /** Basic state - first interaction type and position */ virtual void SetState(G4String state); virtual G4String GetState() const; /** time window over which 2 events considered coincident */ virtual void SetTimeWindow(double window); virtual double GetTimeWindow() const { return fTimeWindow; }; /** restriction on total (generated) energy of pair */ virtual void SetEnergyRange(G4String newValues); virtual double SetLoEnergyLimit() const { return fLoEnergyLimit; }; virtual double SetHiEnergyLimit() const { return fHiEnergyLimit; }; /** Overall time state - time from one coincidence event to next */ virtual void SetTimeState(G4String state); virtual G4String GetTimeState() const; /** position generator for base interaction */ virtual void SetPosState(G4String state); virtual G4String GetPosState() const; /** vertex generator for base interaction */ virtual void SetVertexState(G4String state); virtual G4String GetVertexState() const; /** add an extra interaction */ virtual void AddExtra(G4String state); /** return state of added interaction nint */ virtual G4String GetExtraState(int nint) const; /** return how many extra states have been added */ virtual int GetNExtra() const { return fNExtra; }; /** set position generator for most recently added extra interaction */ virtual void SetExtraPosState(G4String state); /** get name of position generator for extra interaction, nint */ virtual G4String GetExtraPosState(int nint) const; /** set vertex generator for most recently added extra interaction */ virtual void SetExtraVertexState(G4String state); /** get name of vertex generator for extra interaction nint */ virtual G4String GetExtraVertexState(int nint) const; /** Set exponential time constants to separate decays. * Default is to give each vertex a random time in the event window but if this option is called * the user must set a time constant, T, for each added vertex. * First vertex is at t = 0, the rest have times selected from exponentials exp(-t/T) * each exponential applies to the time since last vertex */ virtual void SetExponentials(G4String state); // Set fixed timing distribution for subsequent decays within coincidence // Default is to give decays random time within the window, but if this option is called // the user must set a time between decays for each added vertex // First vertex is at t = 0, the rest have times defined by the user // Each argument gives the inverse time to the next decay virtual void SetFixedTimes(G4String state); // Set Gaussian timing for separate decays // Default is to give decays random time within the window, but if this option is called // the user must set a mean time between decays for each added vertex // and a standard deviation from the mean // First vertex is at t = 0, the rest have times generated by a random normal number virtual void SetGaussians(G4String state); // Set quadratic timing distribution for separate decays // Default is to give decays random time within the window, but if this option is called // the user must give coefficients for a quadratic probability distribution function // Input should be of the form a1 b1 c1 a2 b2 c2 ... // This will form probability distribution function a1t^2 + b1t + c1 for the first decay, similar for subsequent decays // First vertex is at t=0 virtual void SetQuadratic(G4String state); virtual void BeginOfRun(); virtual void EndOfRun(); protected: /** Generator initialization, specified by the user */ G4String fStateStr; /* Additional generators */ std::vector fStateStrExtra; /** NFB: The following are now defined in G4GLGen **/ /** The overall time generator - time from one double event to next */ //GLG4TimeGen *fTimeGen; /** The initial position generator */ //GLG4PosGen* fPosGen; /** The initial vertex generator */ //GLG4VertexGen *fVertexGen; /** The additional position generators */ std::vector fPosGenExtra; /** The additional vertex generators */ std::vector fVertexGenExtra; /** the length of the time window for coincidences */ double fTimeWindow; /** choose exponential timing structure (either all vertices have random times, or all are given decay constants*/ bool fIsExpTiming; /** the value of an exponential decay factor for subsequent decays - default is zero, only used if set */ std::vector fExponent; // choose exact timing structure (all vertices occur at user specified times, or all occur at random times, or all are given decay constants) bool fIsFixedTiming; // the exact timing of subsequent decays - only used if set std::vector fFixed; // choose gaussian timing structure bool fIsGaussianTiming; // mean times and standard deviations for gaussian timing in subsequent decays std::vector fGaussMean; std::vector fGaussStdDev; // choose quadratic timing structure bool fIsQuadraticTiming; // coefficients for quadratic in subsequent decays std::vector fQuadA; std::vector fQuadB; std::vector fQuadC; /** the number of extra interactions */ int fNExtra; /** the range restrictions on the total energy generated for the total event */ double fLoEnergyLimit; double fHiEnergyLimit; /** Allows the user to change parameters via the command line. */ CoincidenceMessenger* fMessenger; }; } // namespace RAT #endif