#include #include #include "JSupport/JMultipleFileScanner.hh" #include "JTools/JQuantile.hh" #include "JAcoustics/JEvt.hh" #include "JAcoustics/JSupport.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxialiry program to determine average creep of strings. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JMultipleFileScanner inputFile; JLimit_t& numberOfEvents = inputFile.getLimit(); string detectorFile; bool overwriteDetector; int debug; try { JParser<> zap("Auxialiry program to determine average creep of strings."); zap['f'] = make_field(inputFile, "input file (output of JKatoomba[.sh])"); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['a'] = make_field(detectorFile, "detector file.") = ""; zap['A'] = make_field(overwriteDetector, "overwrite detector file provided through '-a' with average stretching."); zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetector detector; if (detectorFile != "") { try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } } map Q; while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); const JEvt* evt = inputFile.next(); for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) { Q[i->id].put(i->vs); } } STATUS(endl); if (debug >= status_t) { for (map::const_iterator i = Q.begin(); i != Q.end(); ++i) { cout << setw(4) << i->first << ' ' << setw(6) << i->second.getCount() << ' ' << FIXED(9,6) << i->second.getMean (0.0) << ' ' << FIXED(9,6) << i->second.getSTDev(0.0) << endl; } } if (overwriteDetector) { map > buffer; for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) { buffer[module->getString()][module->getFloor()] = &(*module); } for (map::const_iterator i = Q.begin(); i != Q.end(); ++i) { if (buffer.count(i->first) != 0 && buffer[i->first].count(0) != 0) { const double z0 = buffer[i->first][0]->getZ(); for (auto& module : buffer[i->first]) { if (module.second->getFloor() != 0) { const double z1 = module.second->getZ(); module.second->add(JPosition3D(0.0, 0.0, i->second.getMean(0.0) * (z1 - z0))); } } } else { FATAL("Missing location " << FILL(4,'0') << i->first << '.' << FILL(2,'0') << 0 << FILL() << endl); } } NOTICE("Store stretching data on file " << detectorFile << endl); store(detectorFile, detector); } }