Jpp  master_rocky-43-ge265d140c
the software that should make you happy
software/JAcoustics/JCreep.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 
5 
6 #include "JTools/JQuantile.hh"
7 
8 #include "JAcoustics/JEvt.hh"
9 #include "JAcoustics/JSupport.hh"
10 
11 #include "JDetector/JDetector.hh"
13 
14 #include "Jeep/JPrint.hh"
15 #include "Jeep/JParser.hh"
16 #include "Jeep/JMessage.hh"
17 
18 
19 /**
20  * \file
21  *
22  * Auxialiry program to determine average creep of strings.
23  * \author mdejong
24  */
25 int main(int argc, char **argv)
26 {
27  using namespace std;
28  using namespace JPP;
29 
31  JLimit_t& numberOfEvents = inputFile.getLimit();
32  string detectorFile;
33  bool overwriteDetector;
34  int debug;
35 
36  try {
37 
38  JParser<> zap("Auxialiry program to determine average creep of strings.");
39 
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;
45 
46  zap(argc, argv);
47  }
48  catch(const exception &error) {
49  FATAL(error.what() << endl);
50  }
51 
53 
54  if (detectorFile != "") {
55  try {
56  load(detectorFile, detector);
57  }
58  catch(const JException& error) {
59  FATAL(error);
60  }
61  }
62 
64 
65  while (inputFile.hasNext()) {
66 
67  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
68 
69  const JEvt* evt = inputFile.next();
70 
71  for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) {
72  Q[i->id].put(i->vs);
73  }
74  }
75  STATUS(endl);
76 
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;
83  }
84  }
85 
86  if (overwriteDetector) {
87 
89 
90  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
91  buffer[module->getString()][module->getFloor()] = &(*module);
92  }
93 
94  for (map<int, JQuantile>::const_iterator i = Q.begin(); i != Q.end(); ++i) {
95 
96  if (buffer.count(i->first) != 0 && buffer[i->first].count(0) != 0) {
97 
98  const double z0 = buffer[i->first][0]->getZ();
99 
100  for (auto& module : buffer[i->first]) {
101 
102  if (module.second->getFloor() != 0) {
103 
104  const double z1 = module.second->getZ();
105 
106  module.second->add(JPosition3D(0.0, 0.0, i->second.getMean(0.0) * (z1 - z0)));
107  }
108  }
109 
110  } else {
111 
112  FATAL("Missing location " << FILL(4,'0') << i->first << '.' << FILL(2,'0') << 0 << FILL() << endl);
113  }
114  }
115 
116  NOTICE("Store stretching data on file " << detectorFile << endl);
117 
118  store(detectorFile, detector);
119  }
120 }
121 
Acoustic event fit.
ROOT TTree parameter settings.
Data structure for detector geometry and calibration.
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define STATUS(A)
Definition: JMessage.hh:63
#define NOTICE(A)
Definition: JMessage.hh:64
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
I/O formatting auxiliaries.
Detector data structure.
Definition: JDetector.hh:96
Data structure for position in three dimensions.
Definition: JPosition3D.hh:38
General exception.
Definition: JException.hh:24
Utility class to parse command line options.
Definition: JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
@ status_t
status
Definition: JMessage.hh:30
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
int main(int argc, char **argv)
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:330
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Detector file.
Definition: JHead.hh:227
Acoustic event fit.
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:45