35 struct JParameters_t {
37 static const char SKIPLINE =
'#';
43 number_of_entries (0),
44 number_of_outliers(0),
45 range(JRange<double>::DEFAULT_RANGE())
56 friend inline std::istream&
operator>>(std::istream&
in, JParameters_t&
object)
58 return in >>
object.number_of_entries >>
object.number_of_outliers >>
object.range;
69 friend inline std::ostream&
operator<<(std::ostream& out,
const JParameters_t&
object)
74 return out << setw(5) <<
object.number_of_entries <<
' '
75 << setw(3) <<
object.number_of_outliers <<
' '
76 <<
FIXED(15,3) <<
object.range.getLowerLimit() <<
' '
77 <<
FIXED(15,3) <<
object.range.getUpperLimit();
80 int number_of_entries;
81 int number_of_outliers;
93 int main(
int argc,
char **argv)
98 JRootObjectID inputFile;
99 string parametersFile;
106 JParser<> zap(
"Auxiliary program to apply test criteria to file.");
108 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
109 zap[
'P'] =
make_field(parametersFile,
"ASCII formatted input file with test criteria");
116 catch(
const exception &error) {
117 FATAL(error.what() << endl);
127 ifstream
in(parametersFile.c_str());
134 for (
string buffer;
getline(
in, buffer); ) {
136 if (!buffer.empty() && buffer[0] != JParameters_t::SKIPLINE) {
138 istringstream
is(buffer);
140 if (is >> key >> parameters) {
150 FATAL(
"Error opening file: " << parametersFile << endl);
154 for (map_type::const_iterator i = zmap.begin(); i != zmap.end(); ++i) {
155 cout << setw(48) << left << i->first <<
' ' << i->second << endl;
163 FATAL(
"File: " << inputFile.getFullFilename() <<
" not opened." << endl);
169 cout.imbue(locale(cout.getloc(),
color_facets[facet]->clone()));
171 int number_of_tests = 0;
172 int number_of_failures = 0;
174 const TRegexp regexp(inputFile.getObjectName());
176 TIter iter(dir->GetListOfKeys());
178 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
180 const TString tag(key->GetName());
182 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
186 if (tag.Contains(regexp) &&
isTObject(key) && strcmp(key->GetClassName(),TGraph::Class_Name()) == 0) {
188 TGraph*
g1 =
dynamic_cast<TGraph*
>(key->ReadObj());
190 DEBUG(key->GetName() <<
' ' << (g1 != NULL) << endl);
194 map_type::const_iterator p = zmap.find(g1->GetName());
196 if (p != zmap.end()) {
198 counts[p->first] += 1;
202 const int number_of_entries = g1->GetN();
204 int number_of_outliers = 0;
206 for (
int i = 0; i != g1->GetN(); ++i) {
207 if (!parameters.range(g1->GetY()[i])) {
208 ++number_of_outliers;
212 const bool status = (number_of_entries >= parameters.number_of_entries &&
213 number_of_outliers <= parameters.number_of_outliers);
215 cout << (status ?
GREEN :
RED) <<
"Test " << g1->GetName() <<
' '
216 << (status ?
"passed" :
"failed") <<
' '
217 << (number_of_entries >= parameters.number_of_entries ?
"" :
"too few entries") <<
' '
218 << (number_of_outliers <= parameters.number_of_outliers ?
"" :
"too many outliers") <<
'.'
221 if (out != NULL && !status) {
223 const JRange<double>
range(g1->GetX(), g1->GetX() + g1->GetN());
225 g1->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(g1->GetName() <<
":upper"),
MAKE_CSTRING(parameters.range.getUpperLimit()),
range.getLowerLimit(),
range.getUpperLimit()));
226 g1->GetListOfFunctions()->Add(
new TF1(
MAKE_CSTRING(g1->GetName() <<
":lower"),
MAKE_CSTRING(parameters.range.getLowerLimit()),
range.getLowerLimit(),
range.getUpperLimit()));
227 out->WriteTObject(g1);
230 number_of_tests += 1;
231 number_of_failures += (status ? 0 : 1);
238 if (i->second == 0) {
240 cout <<
RED <<
"Test " << i->first <<
" missing data." <<
RESET << endl;
242 number_of_tests += 1;
243 number_of_failures += 1;
247 cout << (number_of_tests > 0 && number_of_failures == 0 ?
GREEN :
RED) <<
"Number of tests/failures " << number_of_tests <<
"/" << number_of_failures <<
RESET << endl;
Utility class to parse command line options.
int main(int argc, char *argv[])
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
#define MAKE_CSTRING(A)
Make C-string.
Auxiliary data structure for floating point format specification.
static const JColorFacetMap_t color_facets
Color facets.
I/O formatting auxiliaries.
I/O coloring auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
General purpose messaging.
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
const array_type< JKey_t > & get_keys(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &data)
Method to create array of keys of map.
#define DEBUG(A)
Message macros.
Double_t g1(const Double_t x)
Function.