1 #ifndef _TINA_TINAMATH_HXX 2 #define _TINA_TINAMATH_HXX 31 unsigned cCoarse()
const {
return _cCoarse; }
33 friend bool operator==(
const Event &evL,
const Event &evR) {
34 return (evL._cCoarse == evR._cCoarse) && (evL._cFract == evR._cFract) ;
44 double td(
double rdFreq,
unsigned cFracts,
unsigned ccEpochs) {
45 return (1.0/rdFreq)*((double)_cEpoch*(
double)ccEpochs + (double)_cCoarse + ((
double(_cFract)/(double(cFracts)))));
47 Event(
unsigned cEpoch=0,
unsigned cCoarse=0,
unsigned cFract=0 ):_cEpoch(cEpoch), _cCoarse(cCoarse), _cFract(cFract) { }
70 _evCur=_evPrev=
Event();
73 unsigned cEpochCur()
const {
return _cEpochCur; }
82 unsigned cDiff()
const {
return _evCur._cCoarse - _evPrev._cCoarse; }
84 void sampleTick(
const Event &ev) {
89 EventStream(
unsigned cEpochs,
unsigned cFracts,
unsigned ccScale,
double rdFreq):_ccEpochs(cEpochs), _ccFracts(cFracts), _ccScale(ccScale), _crdFreq(rdFreq) {
96 typedef std::deque<double> Movav;
97 typedef std::deque<double>::const_iterator IcMovav;
98 typedef std::map<double, unsigned> Histogram;
99 typedef std::map<double, unsigned>::iterator ItHist;
106 void sample(
double rd) {
107 if (rd < _rdMin) _rdMin=rd;
108 if (rd > _rdMax) _rdMax=rd;
109 ItHist it=_hi.lower_bound(rd);
120 if (_ma.size() == 50) _ma.pop_front();
126 for (IcMovav ic=_ma.begin(); ic !=_ma.end(); ++ic) {
129 return rd/((double)_ma.size());
132 std::ostream &print(std::ostream & os) {
133 for (ItHist it=_hi.begin(); it !=_hi.end(); ++it) {
134 os << std::setprecision(9);
135 os << it->first <<
" " << it->second <<
'\n';
139 Statistics(
double rdMin,
double rdWidth,
unsigned c) {
142 for (i=0, rd=rdMin; i<c; i++, rd+=rdWidth) {
145 _rdMin=(std::numeric_limits<double>::max)();
146 _rdMax=(-1.0)*(std::numeric_limits<double>::max)();
154 if (_evPrev == _evCur)
return 0.0;
156 double tdCur, tdPrev, tdDiff, tdPeriod;
158 tdCur=_evCur.td(_crdFreq, _ccFracts, _ccEpochs);
159 tdPrev=_evPrev.td(_crdFreq, _ccFracts, _ccEpochs);
161 tdPeriod=tdDiff/(double)_ccScale;
165 inline double rdPpm(
double rdFreq,
double rdRef) {
166 return (1.00-(rdRef/rdFreq)) * 1E06;
stream of Events from the timing hardware
Definition: tinamath.hxx:54
An Event as captured by the timing hardware.
Definition: tinamath.hxx:24
double rdFreq()
current frequency, 0 = not available
Definition: tinamath.hxx:153
Definition: tinamath.hxx:95
namespace for the ines Timing Analyzer (Tina) interface
Definition: protocols.cxx:7