#ifndef __JTRIGGER__JPRESCALER__ #define __JTRIGGER__JPRESCALER__ #include #include #include #include /** * \author mdejong */ namespace JTRIGGER {} namespace JPP { using namespace JTRIGGER; } namespace JTRIGGER { /** * Auxiliary class for prescaling. */ class JPrescaler : public TObject { public: /** * Default constructor. */ JPrescaler() : prescale(0), counter (0) {} /** * Constructor. * * \param value prescale value (0 is off) */ JPrescaler(const long long int value) : prescale(value), counter (0) {} /** * Virtual destructor. */ virtual ~JPrescaler() {} /** * Equality * * \param prescaler prescaler * \return true if equals; else false */ bool equals(const JPrescaler& prescaler) const { return prescale == prescaler.prescale; } /** * Test operator. * * This operator increments the internal counter and * checks whether this counter complies with the prescale value. * * \return true if this turn not prescaled; else false */ bool operator()() const { ++counter; return prescale != 0 && counter%prescale == 0; } /** * Check status. * * \return true if this turn not prescaled; else false */ operator bool() const { return prescale != 0 && counter%prescale == 0; } ClassDef(JPrescaler, 2); long long int prescale; mutable long long int counter; }; }; #endif