test_RunData.cxx
Go to the documentation of this file.
1 // test_RunData.cxx
2 //
3 // David Adams
4 // May 2018
5 //
6 // Test RunData.
7 
8 #include <string>
9 #include <iostream>
10 #include <fstream>
12 
13 #undef NDEBUG
14 #include <cassert>
15 
16 using std::string;
17 using std::cout;
18 using std::endl;
19 
20 //**********************************************************************
21 
22 int test_RunData(bool useExistingFcl =false) {
23  const string myname = "test_RunData: ";
24 #ifdef NDEBUG
25  cout << myname << "NDEBUG must be off." << endl;
26  abort();
27 #endif
28  string line = "-----------------------------";
29 
30  cout << myname << line << endl;
31  cout << myname << "Creating bad data." << endl;
32  RunData dat;
33  cout << dat << endl;
34  assert( ! dat.haveRun() );
35  assert( ! dat.haveCryostat() );
36  assert( ! dat.haveApas() );
37 
38  cout << myname << line << endl;
39  cout << myname << "Make data good." << endl;
40  dat.setRun(123);
41  assert( dat.haveRun() );
42  assert( dat.run() == 123 );
43  cout << myname << "Add cryostat." << endl;
44  assert( ! dat.haveCryostat() );
45  dat.setCryostat("coldbox");
46  assert( dat.haveCryostat() );
47  assert( dat.cryostat() == "coldbox" );
48  cout << myname << "Add APAs." << endl;
49  assert( ! dat.haveApas() );
50  RunData::IndexVector myapas = {1, 2};
51  dat.setApas(myapas);
52  assert( dat.haveApas() );
53  assert( dat.apas().size() == 2 );
54  assert( dat.apas() == myapas );
55  cout << myname << "Add gain." << endl;
56  assert( ! dat.haveGain() );
57  dat.setGain(14);
58  assert( dat.haveGain() );
59  assert( dat.gain() == float(14.0) );
60  cout << myname << "Add shaping." << endl;
61  assert( ! dat.haveShaping() );
62  dat.setShaping(2.0);
63  assert( dat.haveShaping() );
64  assert( dat.shaping() == float(2.0) );
65  cout << myname << "Add leakage." << endl;
66  assert( ! dat.haveLeakage() );
67  dat.setLeakage(2.0);
68  assert( dat.haveLeakage() );
69  assert( dat.leakage() == float(2.0) );
70  cout << myname << "Add HV frac." << endl;
71  assert( ! dat.haveHvfrac() );
72  dat.setHvfrac(0.5);
73  assert( dat.haveHvfrac() );
74  assert( dat.hvfrac() == float(0.5) );
75  cout << myname << "Add pulser amplitude" << endl;
76  assert( ! dat.havePulserAmplitude() );
77  dat.setPulserAmplitude(16);
78  assert( dat.havePulserAmplitude() );
79  assert( dat.pulserAmplitude() == 16 );
80  cout << myname << "Add pulser period" << endl;
81  assert( ! dat.havePulserPeriod() );
82  dat.setPulserPeriod(1234);
83  assert( dat.havePulserPeriod() );
84  assert( dat.pulserPeriod() == 1234 );
85 
86  cout << dat << endl;
87 
88  cout << myname << line << endl;
89  cout << myname << "Done." << endl;
90  return 0;
91 }
92 
93 //**********************************************************************
94 
95 int main(int argc, char* argv[]) {
96  bool useExistingFcl = false;
97  if ( argc > 1 ) {
98  string sarg(argv[1]);
99  if ( sarg == "-h" ) {
100  cout << "Usage: " << argv[0] << " [ARG]" << endl;
101  cout << " If ARG = true, existing FCL file is used." << endl;
102  return 0;
103  }
104  useExistingFcl = sarg == "true" || sarg == "1";
105  }
106  return test_RunData(useExistingFcl);
107 }
108 
109 //**********************************************************************
bool havePulserPeriod() const
Definition: RunData.h:59
void setApas(const IndexVector &val)
Definition: RunData.h:66
Index pulserAmplitude() const
Definition: RunData.h:41
void setGain(float val)
Definition: RunData.h:67
std::string string
Definition: nybbler.cc:12
const IndexVector & apas() const
Definition: RunData.h:35
Index run() const
Definition: RunData.h:33
bool haveShaping() const
Definition: RunData.h:53
int main(int argc, char *argv[])
int test_RunData(bool useExistingFcl=false)
float gain() const
Definition: RunData.h:36
bool haveApas() const
Definition: RunData.h:51
Index pulserPeriod() const
Definition: RunData.h:43
std::vector< Index > IndexVector
Definition: RunData.h:27
bool haveRun() const
Definition: RunData.h:49
bool haveCryostat() const
Definition: RunData.h:50
float shaping() const
Definition: RunData.h:37
void setHvfrac(float val)
Definition: RunData.h:71
bool haveLeakage() const
Definition: RunData.h:55
float hvfrac() const
Definition: RunData.h:40
bool haveGain() const
Definition: RunData.h:52
Name cryostat() const
Definition: RunData.h:34
void setLeakage(float val)
Definition: RunData.h:70
void line(double t, double *p, double &x, double &y, double &z)
void setCryostat(Name val)
Definition: RunData.h:65
void setRun(Index val)
Definition: RunData.h:64
void setPulserAmplitude(Index val)
Definition: RunData.h:72
void setShaping(float val)
Definition: RunData.h:68
bool haveHvfrac() const
Definition: RunData.h:56
void setPulserPeriod(Index val)
Definition: RunData.h:74
QTextStream & endl(QTextStream &s)
bool havePulserAmplitude() const
Definition: RunData.h:57
float leakage() const
Definition: RunData.h:39