Jpp  15.0.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPrintDynamics.cc File Reference

Example program to print dynamic detector calibration. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDynamics/JDynamics.hh"
#include "JAcoustics/JEvt.hh"
#include "JAcoustics/JSupport.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JMeta.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to print dynamic detector calibration.

Author
mdejong

Definition in file JPrintDynamics.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 27 of file JPrintDynamics.cc.

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
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:243
collection_type::const_iterator const_iterator
Definition: JPolfit.hh:157
Detector data structure.
Definition: JDetector.hh:89
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
data_type::const_iterator const_iterator
Definition: JDynamics.hh:295
Detector file.
Definition: JHead.hh:196
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
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
#define FATAL(A)
Definition: JMessage.hh:67
Auxiliary class for comment.
Definition: JComment.hh:41
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.
JComment & add(const std::string &comment)
Add comment.
Definition: JComment.hh:100
do set_variable DETECTOR_TXT $WORKDIR detector
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