Jpp  17.3.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrescaler.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JPRESCALER__
2 #define __JTRIGGER__JPRESCALER__
3 
4 #include <istream>
5 #include <ostream>
6 
7 #include <TROOT.h>
8 #include <TObject.h>
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace JTRIGGER {}
16 namespace JPP { using namespace JTRIGGER; }
17 
18 namespace JTRIGGER {
19 
20  /**
21  * Auxiliary class for prescaling.
22  */
23  class JPrescaler :
24  public TObject
25  {
26  public:
27  /**
28  * Default constructor.
29  */
31  prescale(0),
32  counter (0)
33  {}
34 
35 
36  /**
37  * Constructor.
38  *
39  * \param value prescale value (0 is off)
40  */
41  JPrescaler(const long long int value) :
42  prescale(value),
43  counter (0)
44  {}
45 
46 
47  /**
48  * Virtual destructor.
49  */
50  virtual ~JPrescaler()
51  {}
52 
53 
54  /**
55  * Equality
56  *
57  * \param prescaler prescaler
58  * \return true if equals; else false
59  */
60  bool equals(const JPrescaler& prescaler) const
61  {
62  return prescale == prescaler.prescale;
63  }
64 
65 
66  /**
67  * Test operator.
68  *
69  * This operator increments the internal counter and
70  * checks whether this counter complies with the prescale value.
71  *
72  * \return true if this turn not prescaled; else false
73  */
74  bool operator()() const
75  {
76  ++counter;
77 
78  return prescale != 0 && counter%prescale == 0;
79  }
80 
81 
82  /**
83  * Check status.
84  *
85  * \return true if this turn not prescaled; else false
86  */
87  operator bool() const
88  {
89  return prescale != 0 && counter%prescale == 0;
90  }
91 
92 
93  ClassDef(JPrescaler, 2);
94 
95 
96  long long int prescale;
97  mutable long long int counter;
98  };
99 };
100 
101 
102 #endif
JPrescaler()
Default constructor.
Definition: JPrescaler.hh:30
Auxiliary class for prescaling.
Definition: JPrescaler.hh:23
ClassDef(JPrescaler, 2)
Definition: JRoot.hh:19
long long int prescale
Definition: JPrescaler.hh:96
bool equals(const JPrescaler &prescaler) const
Equality.
Definition: JPrescaler.hh:60
JPrescaler(const long long int value)
Constructor.
Definition: JPrescaler.hh:41
virtual ~JPrescaler()
Virtual destructor.
Definition: JPrescaler.hh:50
bool operator()() const
Test operator.
Definition: JPrescaler.hh:74
long long int counter
Definition: JPrescaler.hh:97