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)
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());
132 JParameters_t parameters;
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) {
141 zmap [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;
169 cout.imbue(locale(cout.getloc(),
color_facets[facet]->clone()));
171 int number_of_tests = 0;
172 int number_of_failures = 0;
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;
200 const JParameters_t& parameters = p->second;
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) {
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;
I/O coloring auxiliaries.
std::istream & operator>>(std::istream &in, JAANET::JHead &header)
Read header from input.
General purpose messaging.
#define DEBUG(A)
Message macros.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
I/O formatting auxiliaries.
#define MAKE_CSTRING(A)
Make C-string.
Double_t g1(const Double_t x)
Function.
Auxiliary class to define a range between two values.
int main(int argc, char **argv)
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
Auxiliary class to handle file name, ROOT directory and object name.
TString getObjectName() const
Get object name.
TString getFullFilename() const
Get full file name, including path.
Utility class to parse command line options.
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
static const JColorFacetMap_t color_facets
Color facets.
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.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::map< int, range_type > map_type
Auxiliary data structure for floating point format specification.