Jpp  18.2.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDynamics.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 #include <limits>
5 
6 #include "JDetector/JDetector.hh"
8 
10 #include "JSupport/JMeta.hh"
11 
12 #include "JDynamics/JDynamics.hh"
13 
14 #include "Jeep/JPrint.hh"
15 #include "Jeep/JParser.hh"
16 #include "Jeep/JMessage.hh"
17 
18 
19 /**
20  * \file
21  *
22  * Example program to apply dynamic position and orientation calibration.
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 = calibrationFile.getLimit();
32  string detectorFile;
33  string outputFile;
34  double Tmax_s;
35  double t1_s;
36  int debug;
37 
38  try {
39 
40  JParser<> zap("Example program to apply dynamic position and orientation calibration.");
41 
42  zap['f'] = make_field(calibrationFile, "output of JBallarat[.sh] / JKatoomba[.sh]");
43  zap['n'] = make_field(numberOfEvents) = JLimit::max();
44  zap['a'] = make_field(detectorFile);
45  zap['o'] = make_field(outputFile);
46  zap['M'] = make_field(getMechanics, "mechanics data") = JPARSER::initialised();
47  zap['T'] = make_field(Tmax_s) = 0.0;
48  zap['t'] = make_field(t1_s);
49  zap['d'] = make_field(debug) = 2;
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  detector.comment.add(JMeta(argc, argv));
68 
69  JDynamics dynamics(detector, Tmax_s);
70 
71  STATUS("loading calibration from file(s)" << endl);
72 
73  for (JMultipleFileScanner<>::const_iterator i = calibrationFile.begin(); i != calibrationFile.end(); ++i) {
74  STATUS(*i << endl);
75  }
76 
77  dynamics.load(calibrationFile);
78 
79  STATUS("OK" << endl);
80 
81  STATUS("Coverage position " << FIXED(5,1) << 100.0 * dynamics.position .getCoverage(detector, t1_s) << "%" << endl);
82  STATUS("Coverage orientation " << FIXED(5,1) << 100.0 * dynamics.orientation.getCoverage(detector, t1_s) << "%" << endl);
83 
84  dynamics.update(t1_s);
85 
86  store(outputFile.c_str(), dynamics);
87 }
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:1514
General exception.
Definition: JException.hh:24
int main(int argc, char *argv[])
Definition: Main.cc:15
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:242
#define STATUS(A)
Definition: JMessage.hh:63
JPosition position
position calibration
Definition: JDynamics.hh:615
Detector data structure.
Definition: JDetector.hh:89
JOrientation orientation
orientation calibration
Definition: JDynamics.hh:614
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
Data structure for detector geometry and calibration.
void load(JObjectIterator_t &input)
Load calibration data.
Definition: JDynamics.hh:523
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
I/O formatting auxiliaries.
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
ROOT I/O of application specific meta data.
Dynamic detector calibration.
double getCoverage(const JDetector &detector, const double t1_s) const
Get coverage.
Definition: JDynamics.hh:221
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...
bool update(const double t1_s)
Get detector calibrated at given time.
Definition: JDynamics.hh:538
Dynamic detector calibration.
Definition: JDynamics.hh:81
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 JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
do set_variable DETECTOR_TXT $WORKDIR detector
double getCoverage(const JDetector &detector, const double t1_s) const
Get coverage.
Definition: JDynamics.hh:389
int debug
debug level