39 struct JParameters_t {
41 static const char SKIPLINE =
'#';
49 range(JRange<double>::DEFAULT_RANGE),
61 friend inline std::istream&
operator>>(std::istream&
in, JParameters_t&
object)
64 return in >>
object.working >>
object.expected_rate >>
object.range >>
object.number_of_outliers;
75 friend inline std::ostream&
operator<<(std::ostream& out,
const JParameters_t&
object)
80 return out << setw(6) <<
object.working <<
' '
81 <<
FIXED(2,6) <<
object.expected_rate <<
' '
82 <<
FIXED(2,6) <<
object.range.getLowerLimit() <<
' '
83 <<
FIXED(2,6) <<
object.range.getUpperLimit() <<
' '
84 << setw(4) <<
object.number_of_outliers;
90 int number_of_outliers;
102 TIter iter(dir->GetListOfKeys());
104 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
106 if (key->IsFolder()){
108 dir->cd(key->GetName());
110 TDirectory *subdir = gDirectory;
119 buffer.push_back(objectID);
139 int main(
int argc,
char **argv)
145 string parametersFile;
149 int number_of_failures = 0;
154 JParser<> zap(
"Auxiliary program to apply test criteria to 2D histograms monitoring acoustic rate per emitter.");
156 zap[
'f'] =
make_field(inputFile,
"output root file from JAcousticsMonitor_short");
157 zap[
'P'] =
make_field(parametersFile,
"ASCII formatted input file with test criteria (acoustic_monitor_00000XXX.txt)");
164 catch(
const exception &error) {
165 FATAL(error.what() << endl);
169 out.imbue(locale(out.getloc(),
color_facets[facet]->clone()));
170 out <<
"ACOUSTIC MONITORING \nRun: " << run << endl;
171 out <<
"\n(Note: red highlights are the reason for the warning)" << endl;
178 ifstream
in(parametersFile.c_str());
185 for (
string buffer;
getline(
in, buffer); ) {
187 if (!buffer.empty() && buffer[0] != JParameters_t::SKIPLINE) {
189 istringstream
is(buffer);
191 if (is >> key >> parameters) { zmap[key] =
parameters; }
198 FATAL(
"Error opening file: " << parametersFile << endl);
203 TFile*
f = TFile::Open(inputFile.c_str());
210 if(objectIDs.empty()) {
211 ++number_of_failures;
212 out <<
RED <<
"No acoustic data." << endl;
218 for (map_type::const_iterator i = zmap.begin(); i != zmap.end(); ++i) {
220 if (i->first[0] ==
'0') {
continue; }
222 out <<
"\nEmitter: " << i->first << endl;
224 const TRegexp regexp(i->first);
231 const TString& objectName = objectID->getFullObjectName();
234 if (objectName.Index(regexp) != -1) {
237 if (!i->second.working) {
238 out << (i->second.working != 0 ?
RED :
GREEN);
239 out <<
"Emitter " << i->first <<
" started working." << endl;
247 int number_of_bins = 0;
248 int number_of_outliers = 0;
250 double min_rate = i->second.expected_rate * i->second.range.getLowerLimit();
251 double max_rate = i->second.expected_rate * i->second.range.getUpperLimit();
252 int outliers = i->second.number_of_outliers;
254 if (h2 == NULL && dynamic_cast<TH2*>(p) != NULL) { h2 =
dynamic_cast<TH2*
>(p); };
258 for (Int_t ix = 1; ix <= h2->GetXaxis()->GetNbins(); ++ix) {
259 for (Int_t iy = 1; iy <= h2->GetYaxis()->GetNbins(); ++iy) {
261 const Double_t z = h2->GetBinContent(ix, iy);
262 string du =
to_string(h2->GetXaxis()->GetBinLabel(ix));
263 string floor =
to_string(h2->GetYaxis()->GetBinLabel(iy));
265 du.insert(du.begin(), 4 - du.length(),
'0');
266 floor.insert(floor.begin(), 3 - floor.length(),
'0');
267 const string id = du +
'.' + floor;
270 if (zmap.find(
id)!=zmap.end()) { working = zmap.find(
id)->second.working; }
275 if (z < min_rate || z > max_rate) {
277 ++number_of_outliers;
280 if (floor ==
"000" && z == 0) {
281 out <<
"DU " << du <<
", floor " << floor <<
" : Acoustic rate out of range -> " << z <<
" Hz." <<
RED <<
"Hydrophone stopped working." << endl;
283 ++number_of_failures;
285 out <<
"DU " << du <<
", floor " << floor <<
" : Acoustic rate out of range -> " << z <<
" Hz." << endl;
288 }
else if (!working) {
290 out <<
"DU " << du <<
", floor " << floor <<
" : Working again -> " << z <<
" Hz." << endl;
294 }
else {
FATAL(
"Object at " << objectName <<
" is not TH2." << endl); }
296 out << (number_of_outliers > outliers ?
RED :
GREEN) <<
"Number of outliers = " << number_of_outliers <<
"/" << number_of_bins << endl;
299 if (number_of_outliers > outliers) {
301 ++number_of_failures;
302 out << (number_of_outliers > outliers ?
RED :
GREEN) <<
"Test failed." << endl;
306 out << (outliers > number_of_outliers ?
GREEN :
RED) <<
"Test passed." << endl;
313 }
else if (objectID + 1 == objectIDs.cend()) {
316 if (i->second.working) {
317 ++number_of_failures;
318 out << (i->second.working != 0 ?
RED :
GREEN) <<
"Emitter " << i->first <<
" stopped working." << endl;
321 out <<
"Emitter " << i->first <<
" is expected to not work." << endl;
327 cout << number_of_failures << endl;
Utility class to parse command line options.
int main(int argc, char *argv[])
o $QUALITY_ROOT d $DEBUG!JPlot1D f
*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
Auxiliary class to handle file name, ROOT directory and object name.
Auxiliary data structure for floating point format specification.
#define MAKE_STRING(A)
Make string.
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.
std::string to_string(const T &value)
Convert value to string.
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS 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.
void readDir(TDirectory *dir, std::vector< TString > &v)