 |
Belle II Software
release-05-01-25
|
17 #include "trg/trg/Clock.h"
18 #include "trg/trg/Signal.h"
41 if ((& t0.clock()) != (& t1.clock()))
42 cout <<
"TRGSignal !!! signal is made with two different clocks"
44 <<
" t0.clock=" << t0.clock().name() << endl
45 <<
" t1.clock=" << t1.clock().name() << endl;
101 const unsigned n = t._history.size();
102 for (
unsigned i = 0; i < n; i++) {
122 _history.push_back(t.clock().maxTRGTime(
false));
126 _history.push_back(t.clock().minTRGTime(
true));
145 const string& pre)
const
149 tmp.resize(
_name.size());
150 transform(
_name.cbegin(),
_name.cend(), tmp.begin(), ::toupper);
152 const bool ctr = tmp.find(
"CLOCKCOUNTER") != string::npos;
156 if (msg.find(
"clock") != string::npos ||
157 msg.find(
"detail") != string::npos) {
164 for (
unsigned i = 0; i <
_history.size(); i++)
175 vector<int> sc1 = left.stateChanges();
176 sc0.insert(sc0.end(), sc1.begin(), sc1.end());
179 std::sort(sc0.begin(), sc0.end());
184 for (
unsigned i = 0; i < sc0.size(); i++) {
185 const int j = sc0[i];
193 string name =
"(" +
_name +
")&(" + left._name +
")";
196 for (
unsigned i = 0; i < sc2.size(); i++) {
197 const int j = sc2[i];
201 }
else if (
active & ((!
state(j)) | (! left.state(j)))) {
265 t._history.insert(t._history.end(),
266 left._history.begin(),
267 left._history.end());
268 t._name =
"(" + t._name +
")|(" + left._name +
")";
281 left._history.begin(),
282 left._history.end());
301 const unsigned n = history.size();
304 for (
unsigned i = 0; i < n; i++) {
305 const bool edge = history[i].edge();
309 tmp.push_back(history[i]);
313 tmp.push_back(history[i]);
331 for (
unsigned i = 0; i < n; i++) {
332 const bool edge =
_history[i].edge();
335 const int t0 =
_history[i - 1].time();
337 if ((t1 - t0) <
int(
width))
356 std::vector<int> list;
358 for (
unsigned i = 0; i < n; i++)
369 for (
unsigned i = 0; i < n; i++)
373 for (
unsigned i = 0; i < n; i++) {
374 const bool edge =
_history[i].edge();
377 const int t0 =
_history[i - 1].time();
379 const unsigned w = t1 - t0;
397 for (
unsigned i = 0; i < n; i++) {
398 const bool edge =
_history[i].edge();
401 const int t0 =
_history[i - 1].time();
403 const unsigned w = t1 - t0;
417 return unset(t0, t1);
424 cout <<
"TRGSignal::set ... t0, t1=" << t0 <<
"," << t1 << endl;
461 cout <<
"TRGSignal::consistencyCheck !!! "
462 <<
"history has odd number entires : n=" << n << endl;
463 dump(
"detail",
"!!! ");
470 unsigned errTiming = 0;
471 for (
unsigned i = 0; i < n; i++) {
478 if (t0.edge() !=
true)
480 if (t1.edge() !=
false)
481 err |= (1 << (i + 1));
483 if ((t0.time() == t1.time()) || (t0.time() > t1.time()))
484 errTiming |= (1 << (i + 1));
487 if (err || errTiming) {
489 cout <<
"TRGSignal::consistencyCheck !!! err in edge history"
493 cout <<
"TRGSignal::consistencyCheck !!! err in time history"
496 dump(
"detail",
"!!! ");
507 for (
unsigned i = 0; i <
_history.size(); i++)
538 if (
_history.size() != a._history.size())
541 for (
unsigned i = 0; i <
_history.size(); i++) {
unsigned width(unsigned i=0) const
returns width of i'th signal (i=0,1,2,...).
A class to represent a digitized signal. Unit is nano second.
std::vector< int > stateChanges(void) const
returns a list of clock position of state change.
TRGSignal operator&(const TRGSignal &) const
returns AND result.
TRGSignal & operator|=(const TRGSignal &)
returns OR result.
const TRGSignal & unset(int t0, int t1)
clear(or unset) with leading edge at clock t0 and with trailing edge at clock t1.
bool consistencyCheck(void) const
Self-consitency check. True is return if something wrong.
int min(void) const
returns min. clock point.
bool state(int clockPosition) const
returns true if signal is active in given clock position.
const std::string & name(void) const
returns name.
bool active(void) const
returns true if there is a signal.
std::vector< TRGTime > _history
Timing history.
void dump(const std::string &message="", const std::string &pre="") const
dumps contents.
const TRGClock * _clock
Clock.
const TRGClock & clock(void) const
returns clock.
void sort(void)
Sort operation.
static bool sortByTime(const TRGTime &a, const TRGTime &b)
returns true if a is older than b.
Abstract base class for different kinds of events.
TRGSignal operator|(const TRGSignal &) const
returns OR result.
const TRGSignal & set(double t0, double t1)
makes a pulse with leading edge at t0 and with trailing edge at t1.
bool operator==(const TRGSignal &) const
returns true if two are the same.
int max(void) const
returns max. clock point.
TRGSignal(const TRGClock &=Belle2_GDL::GDLSystemClock)
Constructor.
const TRGSignal & invert(void)
makes signal inverted.
A class to represent a signal timing in the trigger system.
virtual ~TRGSignal()
Destructor.
static std::vector< TRGTime > orOperation(const std::vector< TRGTime > &)
Or operation.
A class to represent a digitized signal. Unit is nano second.
TRGSignal & operator&=(const TRGSignal &)
returns AND result.
TRGSignal & widen(unsigned width)
returns widen signals. Signals wider than "width" will be untouched.