Jpp  test_elongated_shower_pde
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 "JTools/JQuantile.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 29 of file JPrintDynamics.cc.

30 {
31  using namespace std;
32  using namespace JPP;
33 
34  const char* const short_t = "short";
35  const char* const long_t = "long";
36  const char* const fft_t = "fft";
37 
39  string detectorFile;
40  string outputFile;
41  string format;
42  double Tmax_s;
43  int debug;
44 
45  try {
46 
47  JParser<> zap("Example program to print dynamic detector calibration.");
48 
49  zap['a'] = make_field(detectorFile);
50  zap['+'] = make_field(calibrationFile);
51  zap['o'] = make_field(outputFile) = "";
52  zap['F'] = make_field(format) = short_t, long_t, fft_t;
53  zap['T'] = make_field(Tmax_s) = 1000.0;
54  zap['d'] = make_field(debug) = 1;
55 
56  zap(argc, argv);
57  }
58  catch(const exception &error) {
59  FATAL(error.what() << endl);
60  }
61 
62 
64 
65  try {
66  load(detectorFile, detector);
67  }
68  catch(const JException& error) {
69  FATAL(error);
70  }
71 
72 
73  getMechanics.load(detector.getID());
74 
75 
76  JDynamics dynamics(detector, 0.0);
77 
78  dynamics.load(calibrationFile);
79 
80  filebuf buffer;
81 
82  if (outputFile != "") {
83  buffer.open(outputFile.c_str(), ios::out);
84  }
85 
86  ostream os(buffer.is_open() ? &buffer : cout.rdbuf());
87 
88  JComment comment;
89 
90  comment.add("documentation: https://common.pages.km3net.de/jpp/Position_calibration.PDF");
91 
92  if (format == short_t)
93  comment.add("format: string number; UTC [s]; Tx; Ty");
94  else if (format == long_t)
95  comment.add("format: https://indico.cern.ch/event/1014814/contributions/4259426/attachments/2201529/3724129/KM3NeT_position_file_format.pdf");
96  else if (format == fft_t)
97  comment.add("format: <T>");
98 
99  DEBUG(comment);
100 
101  comment.add(JMeta(argc, argv));
102  /*
103  for (JMultipleFileScanner<JMeta> in(calibrationFile); in.hasNext(); ) {
104  comment.add(*in.next());
105  }
106  */
107 
108  if (format == short_t) {
109 
110  os << comment;
111  os << setw(4) << detector.getID() << ' ' << detector.getUTMGrid() << ' ' << detector.getUTMPosition() << endl;
112 
113  for (JDynamics::JPosition::const_iterator string = dynamics.position.begin(); string != dynamics.position.end(); ++string) {
114  for (typename JDynamics::JPosition::function_type::const_iterator i = string->second.begin(); i != string->second.end(); ++i) {
115  os << setw(4) << string->first << ';'
116  << FIXED(20,5) << i->getX() << ';'
117  << FIXED( 9,6) << i->getY().tx << ';'
118  << FIXED( 9,6) << i->getY().ty << endl;
119  }
120  }
121  }
122 
123  if (format == long_t) {
124 
125  os << comment;
126  os << setw(4) << detector.getID() << ' ' << detector.getUTMGrid() << ' ' << detector.getUTMPosition() << endl;
127 
128  for (typename JDynamics::JPosition::function_type::const_iterator i = dynamics.position.begin()->second.begin(); i != dynamics.position.begin()->second.end(); ++i) {
129 
130  const double t1 = i->getX();
131 
132  dynamics.update(t1);
133 
134  os << FIXED(20,5) << t1 << ' '
135  << FIXED(20,5) << t1 << ' '
136  << setw(4) << detector.size() << endl;
137 
138  for (JDetector::const_iterator module = dynamics.begin(); module != dynamics.end(); ++module) {
139 
140  os << setw(4) << module->getString() << ' '
141  << setw(2) << module->getFloor() << ' '
142  << setw(10) << module->getID() << endl;
143 
144  os << FIXED(9,2) << module->getX() << ' '
145  << FIXED(9,2) << module->getY() << ' '
146  << FIXED(9,2) << module->getZ() << ' '
147  << FIXED(9,2) << -1.0 << ' '
148  << FIXED(9,2) << -1.0 << ' '
149  << FIXED(9,2) << -1.0 << endl;
150  }
151  }
152  }
153 
154  if (format == fft_t) {
155 
156  double xmin = numeric_limits<double>::max();
157  double xmax = numeric_limits<double>::lowest();
158 
159  for (JDynamics::JPosition::const_iterator string = dynamics.position.begin(); string != dynamics.position.end(); ++string) {
160  if (!string->second.empty()) {
161  xmin = min(xmin, string->second.getXmin());
162  xmax = max(xmax, string->second.getXmax());
163  }
164  }
165 
166  for (double x = xmin; x <= xmax; x += Tmax_s) {
167 
168  JQuantile Q;
169 
170  for (JDynamics::JPosition::const_iterator string = dynamics.position.begin(); string != dynamics.position.end(); ++string) {
171  if (!string->second.empty()) {
172  Q.put(string->second(x).getLength());
173  }
174  }
175 
176  os << FIXED(9,5) << Q.getMean() << endl;
177  }
178  }
179 
180  buffer.close();
181 }
JDetector detector
Definition: JRunAnalyzer.hh:23
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
Q(UTCMax_s-UTCMin_s)-livetime_s
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:243
collection_type::const_iterator const_iterator
Definition: JPolfit.hh:162
Auxiliary data structure for running average, standard deviation and quantiles.
Definition: JQuantile.hh:43
Detector data structure.
Definition: JDetector.hh:89
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
string outputFile
double getMean() const
Get mean value.
Definition: JQuantile.hh:252
data_type::const_iterator const_iterator
Definition: JDynamics.hh:304
Detector file.
Definition: JHead.hh:224
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
void put(const double x, const double w=1.0)
Put value.
Definition: JQuantile.hh:133
void load(const std::string &file_name)
Load mechanical model parameters from file.
Definition: JMechanics.hh:142
int debug
debug level
Definition: JSirene.cc:68
#define FATAL(A)
Definition: JMessage.hh:67
Auxiliary class for comment.
Definition: JComment.hh:41
Dynamic detector calibration.
Definition: JDynamics.hh:62
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.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
JComment & add(const std::string &comment)
Add comment.
Definition: JComment.hh:100
then usage $script< detector file >< tripodfile >< stage > input file nInput files correspond to the output of JAcousticsEventBuilder[.sh] nFirst stage eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY eval JPrintDetector a $DETECTOR O CAN source JAcoustics sh $DETECTOR_ID typeset A CONFIGURATION for key in Tmax_s