Jpp  18.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JPlatypus.cc File Reference

Application to make a global fit of the detector geometry to acoustic data. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <algorithm>
#include <limits>
#include <type_traits>
#include <functional>
#include <future>
#include <mutex>
#include <thread>
#include <queue>
#include "TROOT.h"
#include "TFile.h"
#include "JLang/JPredicate.hh"
#include "JLang/JComparator.hh"
#include "JLang/JComparison.hh"
#include "JLang/JFileStream.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JTripod.hh"
#include "JDetector/JTransmitter.hh"
#include "JDetector/JModule.hh"
#include "JDetector/JHydrophone.hh"
#include "JTools/JHashMap.hh"
#include "JTools/JRange.hh"
#include "JTools/JQuantile.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JAcoustics/JSoundVelocity.hh"
#include "JAcoustics/JEmitter.hh"
#include "JAcoustics/JAcousticsToolkit.hh"
#include "JAcoustics/JHit.hh"
#include "JAcoustics/JFitParameters.hh"
#include "JAcoustics/JKatoomba.hh"
#include "JAcoustics/JSuperEvt.hh"
#include "JAcoustics/JSuperEvtToolkit.hh"
#include "JAcoustics/JSupport.hh"
#include "Jeep/JContainer.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

Application to make a global fit of the detector geometry to acoustic data.


Author
mdejong

Definition in file JPlatypus.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 219 of file JPlatypus.cc.

220 {
221  using namespace std;
222  using namespace JPP;
223 
224  typedef JContainer< vector<JTripod> > tripods_container;
225  typedef JContainer< vector<JTransmitter> > transmitters_container;
226  typedef JContainer< vector<JHydrophone> > hydrophones_container;
227 
229  string detectorFile;
230  JLimit_t& numberOfEvents = inputFile.getLimit();
231  JSoundVelocity V = getSoundVelocity; // default sound velocity
232  tripods_container tripods; // tripods
233  transmitters_container transmitters; // transmitters
234  hydrophones_container hydrophones; // hydrophones
235  size_t jobs; // number of parallel jobs
236  int debug;
237 
238  try {
239 
240  JParser<> zap("Application to fit position calibration model to acoustic data.");
241 
242  zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
243  zap['n'] = make_field(numberOfEvents) = JLimit::max();
244  zap['a'] = make_field(detectorFile);
246  zap['V'] = make_field(V, "sound velocity") = JPARSER::initialised();
247  zap['T'] = make_field(tripods, "tripod data");
248  zap['Y'] = make_field(transmitters, "transmitter data") = JPARSER::initialised();
249  zap['H'] = make_field(hydrophones, "hydrophone data") = JPARSER::initialised();
250  zap['M'] = make_field(getMechanics, "mechanics data") = JPARSER::initialised();
251  zap['N'] = make_field(jobs, "number of parallel jobs") = 1;
252  zap['d'] = make_field(debug) = 1;
253 
254  zap(argc, argv);
255  }
256  catch(const exception &error) {
257  FATAL(error.what() << endl);
258  }
259 
260  ROOT::EnableThreadSafety();
261 
262  const int sleep_us = 100; // sleep time [us]
263 
265 
266  try {
267  load(detectorFile, detector);
268  }
269  catch(const JException& error) {
270  FATAL(error);
271  }
272 
273  for (tripods_container::const_iterator i = tripods.begin(); i != tripods.end(); ++i) {
274  JPlatypus::emitters[i->getID()] = JEmitter(i->getID(),
275  i->getUTMPosition() - detector.getUTMPosition());
276  }
277 
278  for (transmitters_container::const_iterator i = transmitters.begin(); i != transmitters.end(); ++i) {
279  try {
280  JPlatypus::emitters[i->getID()] = JEmitter(i->getID(),
281  i->getPosition() + detector.getModule(i->getLocation()).getPosition());
282  }
283  catch(const exception&) {
284  continue; // if no module available, discard transmitter
285  }
286  }
287 
288  V.set(detector.getUTMZ()); // sound velocity at detector depth
289 
290  JGeometry geometry(detector, hydrophones);
291  JKatoomba_t katoomba(geometry, V, JPlatypus::parameters.option);
292 
295 
296  katoomba.estimator.reset(getMEstimator(JPlatypus::parameters.mestimator));
297 
298  try {
299 
300  JPlatypus platypus(katoomba, jobs);
301 
302  while (inputFile.hasNext()) {
303 
304  STATUS("event: " << setw(8) << inputFile.getCounter() << '\r'); DEBUG(endl);
305 
306  const JSuperEvt* evt = inputFile.next();
307 
308  while (platypus.backlog() > jobs) {
309  this_thread::sleep_for(chrono::microseconds(sleep_us));
310  }
311 
312  platypus.enqueue(*evt);
313  }
314  STATUS(endl);
315  }
316  catch(const exception& error) {
317  FATAL("main " << error.what());
318  }
319 
320  JFileOutputStream(3) << SCIENTIFIC(1,10) << JPlatypus::Q.getMean(numeric_limits<float>::max()) << endl;
321 }
Worker class for complete fit procedure of acoustic model.
Definition: JKatoomba_t.hh:29
Utility class to parse command line options.
Definition: JParser.hh:1514
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
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
then fatal Number of tripods
Definition: JFootprint.sh:45
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
static const JSoundVelocity getSoundVelocity(1541.0,-17.0e-3,-2000.0)
Function object for velocity of sound.
Detector file.
Definition: JHead.hh:226
Acoustic emitter.
Definition: JEmitter.hh:27
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition: JContainer.hh:39
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
Streaming of output.
Definition: JFileStream.hh:46
JPosition3D getPosition(const Vec &pos)
Get position.
Implementation for depth dependend velocity of sound.
#define FATAL(A)
Definition: JMessage.hh:67
Acoustic super event fit.
Definition: JSuperEvt.hh:30
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.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
JMEstimator * getMEstimator(const int type)
Get M-Estimator.
Definition: JMEstimator.hh:203
do set_variable DETECTOR_TXT $WORKDIR detector
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
Template definition of fit function of acoustic model.
Definition: JKatoomba.hh:105
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62