GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4ListCond.cxx
Go to the documentation of this file.
1// $Id$
2//-----------------------------------------------------------------------
3// The GSI Online Offline Object Oriented (Go4) Project
4// Experiment Data Processing at EE department, GSI
5//-----------------------------------------------------------------------
6// Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7// Planckstr. 1, 64291 Darmstadt, Germany
8// Contact: http://go4.gsi.de
9//-----------------------------------------------------------------------
10// This software can be used under the license agreements as stated
11// in Go4License.txt file which is part of the distribution.
12//-----------------------------------------------------------------------
13
14#include "TGo4ListCond.h"
15
16#include <algorithm>
17
23
24TGo4ListCond::TGo4ListCond(const char *name, const char *title) :
25 TGo4Condition(name, title)
26{
27 fxValues.clear();
28 SetDimension(1);
29}
30
31TGo4ListCond::TGo4ListCond(const char *name, const char *title, const Int_t num, const Int_t * input) :
32 TGo4Condition(name, title)//, fiNum(num)
33{
34 SetDimension(1);
35 SetValues(num,input);
36}
37
38TGo4ListCond::TGo4ListCond(const char *name, const char *title, const Int_t start, const Int_t stop, const Int_t step) :
39 TGo4Condition(name, title)
40{
41 SetDimension(1);
42 SetValues(start,stop,step);
43
44}
45
46void TGo4ListCond::SetValues(const Int_t num, const Int_t *values)
47{
48 fxValues.clear();
49 for (int i = 0; i < num; ++i) {
50 fxValues.push_back(values[i]);
51 }
52}
53void TGo4ListCond::SetValues(const Int_t start, const Int_t stop, const Int_t step)
54{
55 fxValues.clear();
56 Int_t num = (stop - start) / step;
57 if (num <= 0) {
58 num = 0;
59 }
60 num += 1;
61
62 for (int i = 0; i < num; ++i) {
63 fxValues.push_back(start + i * step);
64 }
65}
66
68
69Bool_t TGo4ListCond::Test(Double_t dvalue)
70{
71 Int_t value = dvalue; // need this to avoid framework ambiguity
72 IncCounts();
73 if (!IsEnabled()) {
74 if (FixedResult())
76 return FixedResult();
77 }
78
79 for (size_t i = 0; i < fxValues.size(); ++i) {
80 if (value == fxValues[i]) {
81 // std::cout << i << " " << fxValues[i] << " " << value << std::endl;
83 return kTRUE;
84 }
85 }
86
87 return kFALSE;
88}
89
95
97{
98 size_t num = fxValues.size();
99 std::cout << "fxValues[" << num << "]: {";
100 if (num > 0) {
101 std::cout << fxValues[0];
102 for (size_t i = 1; i < num; ++i) {
103 std::cout << ", " << fxValues[i];
104 }
105 }
106 std::cout << "}" << std::endl;
107}
108
109Bool_t TGo4ListCond::UpdateFrom(TGo4Condition *cond, Bool_t counts)
110{
111 TGo4ListCond *from = dynamic_cast<TGo4ListCond *>(cond);
112 if (!from)
113 return kFALSE;
114 fxValues.clear();
115 for (size_t i = 0; i < from->GetNumValues(); ++i)
116 fxValues.push_back(from->GetValue(i));
117 return TGo4Condition::UpdateFrom(cond, counts);
118}
119
120Double_t TGo4ListCond::GetXUp() const
121{
122 return *std::max_element(fxValues.begin(), fxValues.end());
123}
124
125Double_t TGo4ListCond::GetXLow() const
126{
127 return *std::min_element(fxValues.begin(), fxValues.end());
128}
129
130Double_t TGo4ListCond::GetYUp() const
131{
132 return 0;
133}
134
135Double_t TGo4ListCond::GetYLow() const
136{
137 return 0;
138}
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
Copy values from cond to this.
void IncCounts()
Increment the test counter.
Bool_t FixedResult() const
Returns the value set by Disable(value).
void SetDimension(Int_t d)
void IncTrueCounts()
Increment the "test was true" counter.
virtual void PrintCondition(Bool_t full=kTRUE)
Prints counters and boolean members.
Bool_t IsEnabled() const
Returns true if condition is enabled.
Double_t GetXLow() const override
For base class displays: minimum value of test list.
virtual ~TGo4ListCond()
void PrintCondition(Bool_t full=kFALSE) override
Prints counters and boolean members.
Double_t GetYUp() const override
For base class displays: not used for 1d list.
virtual void SetValues()
Set values needed, i.e.
Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts) override
Copy values from cond to this.
UInt_t GetNumValues() const
Int_t GetValue(UInt_t ix) const
Double_t GetYLow() const override
For base class displays: not used for 1d list.
virtual Bool_t Test()
Test if condition is true.
std::vector< Int_t > fxValues
Factory method to generate the subclass implementation for painter TODO: do we need graphical represe...
Double_t GetXUp() const override
For base class displays: maximum value of test list.