25int main(
int argc,
char **argv)
30 JMultipleFileScanner<JEvt> inputFile;
31 JLimit_t& numberOfEvents = inputFile.getLimit();
33 bool overwriteDetector;
38 JParser<> zap(
"Auxialiry program to determine average creep of strings.");
40 zap[
'f'] = make_field(inputFile,
"input file (output of JKatoomba[.sh])");
41 zap[
'n'] = make_field(numberOfEvents) = JLimit::max();
42 zap[
'a'] = make_field(detectorFile,
"detector file.") =
"";
43 zap[
'A'] = make_field(overwriteDetector,
"overwrite detector file provided through '-a' with average stretching.");
44 zap[
'd'] = make_field(debug) = 2;
48 catch(
const exception &error) {
49 FATAL(error.what() << endl);
54 if (detectorFile !=
"") {
56 load(detectorFile, detector);
58 catch(
const JException& error) {
63 map<int, JQuantile> Q;
65 while (inputFile.hasNext()) {
67 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r'); DEBUG(endl);
69 const JEvt* evt = inputFile.next();
71 for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) {
77 if (debug >= status_t) {
78 for (map<int, JQuantile>::const_iterator i = Q.begin(); i != Q.end(); ++i) {
79 cout << setw(4) << i->first <<
' '
80 << setw(6) << i->second.getCount() <<
' '
81 << FIXED(9,6) << i->second.getMean (0.0) <<
' '
82 << FIXED(9,6) << i->second.getSTDev(0.0) << endl;
86 if (overwriteDetector) {
88 map<int, map<int, JModule*> > buffer;
90 for (JDetector::iterator module = detector.begin();
module != detector.end(); ++module) {
91 buffer[
module->getString()][module->getFloor()] = &(*module);
94 for (map<int, JQuantile>::const_iterator i = Q.begin(); i != Q.end(); ++i) {
96 if (buffer.count(i->first) != 0 && buffer[i->first].count(0) != 0) {
98 const double z0 = buffer[i->first][0]->getZ();
100 for (
auto& module : buffer[i->first]) {
102 if (module.second->getFloor() != 0) {
104 const double z1 =
module.second->getZ();
106 module.second->add(JPosition3D(0.0, 0.0, i->second.getMean(0.0) * (z1 - z0)));
112 FATAL(
"Missing location " << FILL(4,
'0') << i->first <<
'.' << FILL(2,
'0') << 0 << FILL() << endl);
116 NOTICE(
"Store stretching data on file " << detectorFile << endl);
118 store(detectorFile, detector);