GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ListCond.cxx
Go to the documentation of this file.
1 // $Id: TGo4ListCond.cxx 3184 2021-04-26 12:57:56Z adamczew $
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 
20 {
21  SetDimension(1);
22 }
23 
24 TGo4ListCond::TGo4ListCond(const char* name, const char* title) :
25  TGo4Condition(name, title)
26 {
27  fxValues.clear();
28  SetDimension(1);
29 }
30 
31 TGo4ListCond::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 
38 TGo4ListCond::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 
46 void TGo4ListCond::SetValues(const Int_t num, const Int_t * values)
47  {
48  fxValues.clear();
49  for(int i=0;i<num;++i)
50  {
51  fxValues.push_back(values[i]);
52  }
53 
54  }
55 void TGo4ListCond::SetValues(const Int_t start, const Int_t stop, const Int_t step)
56  {
57  fxValues.clear();
58  Int_t num = (stop - start) / step;
59  if (num <= 0) {
60  num = 0;
61  }
62  num += 1;
63 
64 
65  for (int i=0; i<num; ++i) {
66  fxValues.push_back(start + i * step);
67  }
68  }
69 
70 
71 
73 {
74 }
75 
76 Bool_t TGo4ListCond::Test(Double_t dvalue)
77 {
78  Int_t value=dvalue; // need this to avoid framework ambiguity
79  IncCounts();
80  if(!IsEnabled()){
81  if(FixedResult()) IncTrueCounts();
82  return FixedResult();
83  }
84 
85  for (size_t i=0; i<fxValues.size(); ++i) {
86  if (value == fxValues[i]) {
87 // std::cout << i << " " << fxValues[i] << " " << value << std::endl;
88  IncTrueCounts();
89  return kTRUE;
90  }
91  }
92 
93  return kFALSE;
94 }
95 
97 {
99  PrintValues();
100 }
101 
103 {
104  size_t num=fxValues.size();
105  std::cout << "fxValues[" << num << "]: {";
106  if (num > 0) {
107  std::cout << fxValues[0];
108  for (size_t i=1; i < num; ++i) {
109  std::cout << ", " << fxValues[i];
110  }
111  }
112  std::cout << "}" << std::endl;
113 }
114 
115 Bool_t TGo4ListCond::UpdateFrom(TGo4Condition * cond, Bool_t counts)
116 {
117  TGo4ListCond* from=dynamic_cast<TGo4ListCond*>(cond);
118  if(from==0) return kFALSE;
119  fxValues.clear();
120  for (size_t i=0; i<from->GetNumValues(); ++i) {
121  fxValues.push_back(from->GetValue(i));
122  }
123  return (TGo4Condition::UpdateFrom(cond, counts));
124 }
125 
126 
128 {
129  return *std::max_element(fxValues.begin(), fxValues.end());
130 }
132 {
133  return *std::min_element(fxValues.begin(), fxValues.end());
134 
135 }
137 {
138  return 0;
139 }
141 {
142  return 0;
143 }
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
virtual Double_t GetXLow()
virtual ~TGo4ListCond()
virtual void PrintCondition(Bool_t full=kTRUE)
Bool_t IsEnabled() const
Definition: TGo4Condition.h:82
virtual void SetValues()
Definition: TGo4Condition.h:93
Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
Bool_t FixedResult() const
virtual Double_t GetYLow()
Int_t GetValue(UInt_t ix) const
Definition: TGo4ListCond.h:49
virtual Bool_t Test()
virtual Double_t GetXUp()
std::vector< Int_t > fxValues
Definition: TGo4ListCond.h:83
void PrintValues()
UInt_t GetNumValues() const
Definition: TGo4ListCond.h:48
void PrintCondition(Bool_t full=kFALSE)
void SetDimension(Int_t d)
virtual Double_t GetYUp()