12#include "trg/trg/Clock.h"
13#include "trg/trg/Signal.h"
36 if ((& t0.
clock()) != (& t1.clock()))
37 cout <<
"TRGSignal !!! signal is made with two different clocks"
39 <<
" t0.clock=" << t0.
clock().
name() << endl
40 <<
" t1.clock=" << t1.clock().name() << endl;
96 const unsigned n = t._history.size();
97 for (
unsigned i = 0; i < n; i++) {
117 _history.push_back(t.clock().maxTRGTime(
false));
121 _history.push_back(t.clock().minTRGTime(
true));
140 const string& pre)
const
144 tmp.resize(
_name.size());
145 transform(
_name.cbegin(),
_name.cend(), tmp.begin(), ::toupper);
147 const bool ctr = tmp.find(
"CLOCKCOUNTER") != string::npos;
151 if (msg.find(
"clock") != string::npos ||
152 msg.find(
"detail") != string::npos) {
159 for (
unsigned i = 0; i <
_history.size(); i++)
170 vector<int> sc1 = left.stateChanges();
171 sc0.insert(sc0.end(), sc1.begin(), sc1.end());
174 std::sort(sc0.begin(), sc0.end());
179 for (
unsigned i = 0; i < sc0.size(); i++) {
180 const int j = sc0[i];
188 string name =
"(" +
_name +
")&(" + left._name +
")";
191 for (
unsigned i = 0; i < sc2.size(); i++) {
192 const int j = sc2[i];
196 }
else if (
active and ((!
state(j)) or (! left.state(j)))) {
260 t._history.insert(t._history.end(),
261 left._history.begin(),
262 left._history.end());
263 t._name =
"(" + t._name +
")|(" + left._name +
")";
276 left._history.begin(),
277 left._history.end());
296 const unsigned n = history.size();
299 for (
unsigned i = 0; i < n; i++) {
300 const bool edge = history[i].edge();
304 tmp.push_back(history[i]);
308 tmp.push_back(history[i]);
326 for (
unsigned i = 0; i < n; i++) {
327 const bool edge =
_history[i].edge();
330 const int t0 =
_history[i - 1].time();
332 if ((t1 - t0) <
int(
width))
351 std::vector<int> list;
353 for (
unsigned i = 0; i < n; i++)
364 for (
unsigned i = 0; i < n; i++)
368 for (
unsigned i = 0; i < n; i++) {
369 const bool edge =
_history[i].edge();
372 const int t0 =
_history[i - 1].time();
374 const unsigned w = t1 - t0;
392 for (
unsigned i = 0; i < n; i++) {
393 const bool edge =
_history[i].edge();
396 const int t0 =
_history[i - 1].time();
398 const unsigned w = t1 - t0;
412 return unset(t0, t1);
419 cout <<
"TRGSignal::set ... t0, t1=" << t0 <<
"," << t1 << endl;
456 cout <<
"TRGSignal::consistencyCheck !!! "
457 <<
"history has odd number entires : n=" << n << endl;
458 dump(
"detail",
"!!! ");
465 unsigned errTiming = 0;
466 for (
unsigned i = 0; i < n; i++) {
473 if (t0.
edge() !=
true)
475 if (t1.edge() !=
false)
476 err |= (1 << (i + 1));
478 if ((t0.
time() == t1.time()) || (t0.
time() > t1.time()))
479 errTiming |= (1 << (i + 1));
482 if (err || errTiming) {
484 cout <<
"TRGSignal::consistencyCheck !!! err in edge history"
488 cout <<
"TRGSignal::consistencyCheck !!! err in time history"
491 dump(
"detail",
"!!! ");
502 for (
unsigned i = 0; i <
_history.size(); i++)
533 if (
_history.size() != a._history.size())
536 for (
unsigned i = 0; i <
_history.size(); i++) {
A class to represent a digitized signal. Unit is nano second.
A class to represent a digitized signal. Unit is nano second.
const TRGSignal & set(double t0, double t1)
makes a pulse with leading edge at t0 and with trailing edge at t1.
const TRGClock * _clock
Clock.
std::vector< TRGTime > _history
Timing history.
A class to represent a signal timing in the trigger system.
TRGSignal & operator|=(const TRGSignal &)
returns OR result.
static std::vector< TRGTime > orOperation(const std::vector< TRGTime > &)
Or operation.
TRGSignal & operator&=(const TRGSignal &)
returns AND result.
TRGSignal operator&(const TRGSignal &) const
returns AND result.
const TRGClock & clock(void) const
returns clock.
TRGSignal & widen(unsigned width)
returns widen signals. Signals wider than "width" will be untouched.
const std::string & name(void) const
returns name.
std::vector< int > stateChanges(void) const
returns a list of clock position of state change.
int min(void) const
returns min. clock point.
const TRGSignal & unset(int t0, int t1)
clear(or unset) with leading edge at clock t0 and with trailing edge at clock t1.
unsigned width(unsigned i=0) const
returns width of i'th signal (i=0,1,2,...).
int max(void) const
returns max. clock point.
TRGSignal(const TRGClock &=Belle2_GDL::GDLSystemClock)
Constructor.
int time(void) const
returns timing in clock position.
bool state(int clockPosition) const
returns true if signal is active in given clock position.
virtual ~TRGSignal()
Destructor.
bool active(void) const
returns true if there is a signal.
bool edge(void) const
returns edge information.
bool operator==(const TRGSignal &) const
returns true if two are the same.
static bool sortByTime(const TRGTime &a, const TRGTime &b)
returns true if a is older than b.
void sort(void)
Sort operation.
TRGSignal operator|(const TRGSignal &) const
returns OR result.
bool consistencyCheck(void) const
Self-consitency check. True is return if something wrong.
const TRGSignal & invert(void)
makes signal inverted.
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
Abstract base class for different kinds of events.