54 JParser<> zap(
"Example program to test range operations.");
60 catch(
const exception &error) {
61 FATAL(error.what() << endl);
65 typedef JRange<double> JRange_t;
67 const double xmin = -1.0;
68 const double xmax = +1.0;
69 const double dx = (xmax - xmin) / 10;
74 JRange_t
A(JRange_t::DEFAULT_RANGE);
75 JRange_t B(xmin, xmax);
77 for (
double x = xmin;
x < xmax + 0.5 * dx;
x += dx) {
79 DEBUG(setw(
WIDTH) << left <<
"inside" <<
' ' << B <<
' ' << setw(5) <<
x <<
' ' << (B(
x) ?
"Y" :
"N") << endl);
86 DEBUG(setw(
WIDTH) << left <<
"range" <<
' ' <<
A << endl);
91 for (
double x = xmin - (xmax - xmin);
x < xmax + (xmax - xmin) + 0.5 * dx;
x += dx) {
95 while (x1 <= xmin) { x1 += (xmax - xmin); }
96 while (x1 > xmax) { x1 -= (xmax - xmin); }
104 const double x1 = -1.0;
105 const double x2 = +0.5;
106 const double x3 = -0.5;
107 const double x4 = +1.0;
112 DEBUG(setw(
WIDTH) << left <<
"join" <<
' ' <<
A <<
' ' << B <<
" = " <<
join(
A,B) << endl);
119 const double x1 = -1.0;
120 const double x2 = -0.5;
121 const double x3 = +0.5;
122 const double x4 = +1.0;
127 DEBUG(setw(
WIDTH) << left <<
"combine" <<
' ' <<
A <<
' ' << B <<
" = " <<
combine(
A,B) << endl);
133 const double x1 = -1.0;
134 const double x2 = -0.5;
135 const double x3 = +0.5;
136 const double x4 = +1.0;
141 DEBUG(setw(
WIDTH) << left <<
"add" <<
' ' <<
A <<
' ' << B <<
" = " <<
A + B << endl);
143 ASSERT((
A + B) == JRange_t(x1+x3,x2+x4));
148 __A__() : value(0.0) {}
149 __A__(
const double value) : value(value) {}
151 double get()
const {
return value; }
158 for (
double x = xmin; x < xmax + 0.5 * dx; x += dx) {
165 A.setRange(
make_array(buffer.begin(), buffer.end(), &__A__::value));
168 DEBUG(setw(
WIDTH) << left <<
"setRange" <<
' ' << A << endl);
169 DEBUG(setw(
WIDTH) << left <<
"setRange" <<
' ' << B << endl);
171 ASSERT(A == JRange_t(xmin,xmax));
172 ASSERT(B == JRange_t(xmin,xmax));
Auxiliary data structure for alignment of data.
Utility class to parse command line options.
T get(const JHead &header)
Get object from header.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A