12 #include "trg/trg/Clock.h"
13 #include "trg/trg/Time.h"
14 #include "trg/trg/Signal.h"
15 #include "trg/trg/Utilities.h"
19 namespace Belle2_GDL {
31 TRGClock::TRGClock(
const string& name,
39 _frequency(frequency),
40 _cycle(1000 / frequency),
45 _min(numeric_limits<int>::min() / 16),
46 _max(numeric_limits<int>::max() / 16),
50 if (
this != & Belle2_GDL::GDLSystemClock) {
62 unsigned multiplicationFactor,
63 unsigned divisionFactor)
66 _multi(multiplicationFactor),
68 _offset(source._offset),
69 _frequency(source._frequency *
70 double(multiplicationFactor) /
71 double(divisionFactor)),
72 _cycle(source._cycle /
73 double(multiplicationFactor) *
74 double(divisionFactor)),
75 _min(source._min * int(multiplicationFactor) / int(divisionFactor)),
76 _max(source._max * int(multiplicationFactor) / int(divisionFactor)),
89 const string& pre)
const
94 cout << pre <<
" multiplication factor=" <<
_multi << endl;
95 cout << pre <<
" division factor =" <<
_div << endl;
100 cout << pre <<
" offset :" <<
_offset << endl
102 << pre <<
" cycle(ns):" <<
_cycle << endl
103 << pre <<
" min pos :" <<
_min << endl
104 << pre <<
" max pos :" <<
_max << endl
105 << pre <<
" min(ns) :" <<
minTiming() << endl
106 << pre <<
" max(ns) :" <<
maxTiming() << endl;
108 cout << pre <<
" numeric limit of int (min,max="
109 << numeric_limits<int>::min() <<
","
110 << numeric_limits<int>::max() <<
")" << endl;
118 cout <<
"TRGClock::unit(" <<
_name
119 <<
") !!! out of time window : min=" <<
minTiming()
120 <<
",max=" <<
maxTiming() <<
",given value=" << t << endl;
158 const double pos0 = double(
int(pos));
159 const double dif = pos - pos0;
176 for (
int i = 0; i < 5; i++) {
181 const int maxN = 400;
182 for (
int j = 0; j < maxN; j++) {
183 if (((j - cicle / 2) % cicle) == 0)
184 s.set(j, j + cicle / 2);
189 (* _clockCounter) += s;
A class to represent a digitized signal. Unit is nano second.
const double _offset
Clock offset in nano second.
const unsigned _div
Division factor.
const std::string _name
Name.
const double _cycle
Clock cycle in nano second.
int _max
Clock max. count.
const double _frequency
Frequency in MHz.
int _min
Clock min. count.
const unsigned _multi
Multiplication factor.
const TRGClock * _source
Clock source.
TRGSignalVector * _clockCounter
Clock counter.
A class to represent a bundle of digitized signals.
A class to represent a digitized signal. Unit is nano second.
A class to represent a signal timing in the trigger system.
static std::string itostring(int i)
converts int to string. (Use boost::lexical_cast)
double absoluteTime(int clockPosition) const
returns absolute time of clock position
double phase(double timing) const
returns phase of given timing in degree (0 to 360).
const std::string & name(void) const
returns name.
double maxTiming(void) const
returns max. timing.
double overShoot(double timing) const
returns over shoot.
TRGClock(const std::string &name, double offset, double frequency)
Constructor. "offset" is in unit of ns. "frequency" is in unit of MHz.
const TRGSignalVector & clockCounter(void) const
returns the clock counter.
int position(double timing) const
returns clock position.
TRGTime minTRGTime(bool edge) const
returns min. TRGtime with clock.
virtual ~TRGClock()
Destructor.
TRGTime maxTRGTime(bool edge) const
returns max. TRGtime with clock.
double minTiming(void) const
returns min. timing.
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
Abstract base class for different kinds of events.