Jpp  15.0.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintDynamics.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 #include <fstream>
5 
6 #include "JDetector/JDetector.hh"
8 
9 #include "JDynamics/JDynamics.hh"
10 
11 #include "JAcoustics/JEvt.hh"
12 #include "JAcoustics/JSupport.hh"
13 
15 #include "JSupport/JMeta.hh"
16 
17 #include "Jeep/JParser.hh"
18 #include "Jeep/JMessage.hh"
19 
20 
21 /**
22  * \file
23  * Example program to print dynamic detector calibration.
24  *
25  * \author mdejong
26  */
27 int main(int argc, char **argv)
28 {
29  using namespace std;
30  using namespace JPP;
31 
32  const char* const short_t = "short";
33  const char* const long_t = "long";
34 
36  string detectorFile;
37  string outputFile;
38  string format;
39  int debug;
40 
41  try {
42 
43  JParser<> zap("Example program to print dynamic detector calibration.");
44 
45  zap['a'] = make_field(detectorFile);
46  zap['+'] = make_field(calibrationFile);
47  zap['o'] = make_field(outputFile) = "dynamics.txt";
48  zap['F'] = make_field(format) = short_t, long_t;
49  zap['d'] = make_field(debug) = 1;
50 
51  zap(argc, argv);
52  }
53  catch(const exception &error) {
54  FATAL(error.what() << endl);
55  }
56 
57 
59 
60  try {
61  load(detectorFile, detector);
62  }
63  catch(const JException& error) {
64  FATAL(error);
65  }
66 
67 
68  getMechanics.load(detector.getID());
69 
70 
71  JDynamics dynamics(detector, 0.0);
72 
73  dynamics.load(calibrationFile);
74 
75 
76  ofstream out(outputFile.c_str());
77 
78  JComment comment;
79 
80  comment.add("documentation: https://common.pages.km3net.de/jpp/Position_calibration.PDF");
81 
82  if (format == short_t)
83  comment.add("format: string number; UTC [s]; Tx; Ty");
84  else
85  comment.add("format: https://indico.cern.ch/event/1014814/contributions/4259426/attachments/2201529/3724129/KM3NeT_position_file_format.pdf");
86 
87  comment.add(JMeta(argc, argv));
88 
89  for (JMultipleFileScanner<JMeta> in(calibrationFile); in.hasNext(); ) {
90  comment.add(*in.next());
91  }
92 
93  out << comment;
94  out << setw(4) << detector.getID() << ' ' << detector.getUTMGrid() << ' ' << detector.getUTMPosition() << endl;
95 
96  if (format == short_t) {
97 
98  for (JDynamics::JPosition::const_iterator string = dynamics.position.begin(); string != dynamics.position.end(); ++string) {
99  for (typename JDynamics::JPosition::function_type::const_iterator i = string->second.begin(); i != string->second.end(); ++i) {
100  out << setw(4) << string->first << ';'
101  << FIXED(20,5) << i->getX() << ';'
102  << FIXED( 9,6) << i->getY().tx << ';'
103  << FIXED( 9,6) << i->getY().ty << endl;
104  }
105  }
106  }
107 
108 
109  if (format == long_t) {
110 
111  if (!dynamics.position.empty()) {
112 
113  for (typename JDynamics::JPosition::function_type::const_iterator i = dynamics.position.begin()->second.begin(); i != dynamics.position.begin()->second.end(); ++i) {
114 
115  const double t1 = i->getX();
116 
117  dynamics.update(t1);
118 
119  out << FIXED(20,5) << t1 << ' '
120  << FIXED(20,5) << t1 << ' '
121  << setw(4) << detector.size() << endl;
122 
123  for (JDetector::const_iterator module = dynamics.begin(); module != dynamics.end(); ++module) {
124 
125  out << setw(4) << module->getString() << ' '
126  << setw(2) << module->getFloor() << ' '
127  << setw(10) << module->getID() << endl;
128 
129  out << FIXED(9,2) << module->getX() << ' '
130  << FIXED(9,2) << module->getY() << ' '
131  << FIXED(9,2) << module->getZ() << ' '
132  << FIXED(9,2) << -1.0 << ' '
133  << FIXED(9,2) << -1.0 << ' '
134  << FIXED(9,2) << -1.0 << endl;
135  }
136  }
137  }
138  }
139 
140  out.close();
141 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
int main(int argc, char *argv[])
Definition: Main.cc:15
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:243
collection_type::const_iterator const_iterator
Definition: JPolfit.hh:157
ROOT TTree parameter settings.
JPosition position
position calibration
Definition: JDynamics.hh:576
Detector data structure.
Definition: JDetector.hh:89
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
const JDetector & update(const double t1_s)
Get detector calibrated at given time.
Definition: JDynamics.hh:500
Data structure for detector geometry and calibration.
void load(JObjectIterator_t &input)
Load calibration data.
Definition: JDynamics.hh:485
data_type::const_iterator const_iterator
Definition: JDynamics.hh:295
const_iterator end() const
end of calibration data
Definition: JDynamics.hh:348
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
ROOT I/O of application specific meta data.
Dynamic detector calibration.
void load(const std::string &file_name)
Load mechanical model parameters from file.
Definition: JMechanics.hh:142
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Auxiliary class for comment.
Definition: JComment.hh:41
bool empty() const
empty
Definition: JDynamics.hh:345
Dynamic detector calibration.
Definition: JDynamics.hh:61
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
const_iterator begin() const
begin of calibration data
Definition: JDynamics.hh:347
JComment & add(const std::string &comment)
Add comment.
Definition: JComment.hh:100
do set_variable DETECTOR_TXT $WORKDIR detector
Acoustic event fit.
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
Definition: JCanberra.sh:41