Belle II Software  release-08-01-10
Clock.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #ifndef TRGClock_FLAG_
10 #define TRGClock_FLAG_
11 
12 #include <string>
13 #include "trg/trg/SignalVector.h"
14 
15 namespace Belle2 {
20  class TRGClock;
21  class TRGTime;
23 }
24 
25 namespace Belle2_GDL {
26 
27  //...This should be moved to GDL module...
28  extern const Belle2::TRGClock GDLSystemClock;
29 }
30 
31 namespace Belle2 {
38  class TRGClock {
39 
40  public:
41 
43  TRGClock(const std::string& name,
44  double offset,
45  double frequency);
46 
48  TRGClock(const std::string& name,
49  const TRGClock&,
50  unsigned multiplicationFactor,
51  unsigned divisionFactor = 1);
52 
54  virtual ~TRGClock();
55 
56  public:// Selectors
57 
59  const std::string& name(void) const;
60 
62  int position(double timing) const;
63 
65  int positionInSourceClock(double timing) const;
66 
68  double absoluteTime(int clockPosition) const;
69 
71  double overShoot(double timing) const;
72 
74  int unit(double period) const;
75 
77  double offset(void) const;
78 
80  double frequency(void) const;
81 
83  double phase(double timing) const;
84 
86  const TRGSignalVector& clockCounter(void) const;
87 
90  void dump(const std::string& message = "",
91  const std::string& pre = "") const;
92 
93  public://
94 
96  int min(void) const;
97 
99  int max(void) const;
100 
102  double minTiming(void) const;
103 
105  double maxTiming(void) const;
106 
108  TRGTime minTRGTime(bool edge) const;
109 
111  TRGTime maxTRGTime(bool edge) const;
112 
113  private:
114 
116  const std::string _name;
117 
120 
122  const unsigned _multi;
123 
125  const unsigned _div;
126 
128  const double _offset;
129 
131  const double _frequency;
132 
134  const double _cycle;
135 
137  int _min;
138 
140  int _max;
141 
144  };
145 
146 //-----------------------------------------------------------------------------
147 
148  inline
149  double
150  TRGClock::offset(void) const
151  {
152  return _offset;
153  }
154 
155  inline
156  const std::string&
157  TRGClock::name(void) const
158  {
159  return _name;
160  }
161 
162  inline
163  double
165  {
166 // return _min * _cycle + _offset;
167  return _min * _cycle;
168  }
169 
170  inline
171  double
173  {
174 // return _max * _cycle + _offset;
175  return _max * _cycle;
176  }
177 
178  inline
179  int
180  TRGClock::unit(double a) const
181  {
182  return int(a / _cycle) + 1;
183  }
184 
185  inline
186  double
188  {
189  return _frequency;
190  }
191 
192  inline
193  int
194  TRGClock::min(void) const
195  {
196  return _min;
197  }
198 
199  inline
200  int
201  TRGClock::max(void) const
202  {
203  return _max;
204  }
205 
206  inline
207  int
209  {
210  return _source->position(a);
211  }
212 
214 } // namespace Belle2
215 
216 #endif /* TRGClock_FLAG_ */
A class to represent a digitized signal. Unit is nano second.
Definition: Clock.h:38
const double _offset
Clock offset in nano second.
Definition: Clock.h:128
const unsigned _div
Division factor.
Definition: Clock.h:125
const std::string _name
Name.
Definition: Clock.h:116
const double _cycle
Clock cycle in nano second.
Definition: Clock.h:134
int _max
Clock max. count.
Definition: Clock.h:140
const double _frequency
Frequency in MHz.
Definition: Clock.h:131
int _min
Clock min. count.
Definition: Clock.h:137
const unsigned _multi
Multiplication factor.
Definition: Clock.h:122
const TRGClock * _source
Clock source.
Definition: Clock.h:119
TRGSignalVector * _clockCounter
Clock counter.
Definition: Clock.h:143
A class to represent a bundle of digitized signals.
Definition: SignalVector.h:26
A class to represent a signal timing in the trigger system.
Definition: Time.h:25
double absoluteTime(int clockPosition) const
returns absolute time of clock position
Definition: Clock.cc:128
double phase(double timing) const
returns phase of given timing in degree (0 to 360).
Definition: Clock.cc:154
const std::string & name(void) const
returns name.
Definition: Clock.h:157
int min(void) const
returns min. clock point.
Definition: Clock.h:194
double offset(void) const
returns offset of the clock zero position in nano second.
Definition: Clock.h:150
int max(void) const
returns max. clock point.
Definition: Clock.h:201
double maxTiming(void) const
returns max. timing.
Definition: Clock.h:172
double overShoot(double timing) const
returns over shoot.
Definition: Clock.cc:134
int unit(double period) const
returns min # of clocks to cover given time period.
Definition: Clock.h:180
TRGClock(const std::string &name, double offset, double frequency)
Constructor. "offset" is in unit of ns. "frequency" is in unit of MHz.
Definition: Clock.cc:31
int positionInSourceClock(double timing) const
returns clock position in the source clock.
Definition: Clock.h:208
const TRGSignalVector & clockCounter(void) const
returns the clock counter.
Definition: Clock.cc:166
int position(double timing) const
returns clock position.
Definition: Clock.cc:114
double frequency(void) const
returns frequency in MHz.
Definition: Clock.h:187
TRGTime minTRGTime(bool edge) const
returns min. TRGtime with clock.
Definition: Clock.cc:140
virtual ~TRGClock()
Destructor.
Definition: Clock.cc:81
TRGTime maxTRGTime(bool edge) const
returns max. TRGtime with clock.
Definition: Clock.cc:147
double minTiming(void) const
returns min. timing.
Definition: Clock.h:164
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
Definition: Clock.cc:88
Abstract base class for different kinds of events.