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

Application to perform acoustic pre-calibration. More...

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include <limits>
#include <sys/stat.h>
#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/JSTDObjectWriter.hh"
#include "JSystem/JStat.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 "JDetector/JLocationRouter.hh"
#include "JFit/JGradient.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_t.hh"
#include "JAcoustics/JEvent.hh"
#include "JAcoustics/JSuperEvt.hh"
#include "JAcoustics/JSuperEvtToolkit.hh"
#include "JAcoustics/JSupport.hh"
#include "JAcoustics/JTransmission_t.hh"
#include "JAcoustics/JFremantle_t.hh"
#include "JAcoustics/JPlatypus_t.hh"
#include "Jeep/JTimer.hh"
#include "Jeep/JeepToolkit.hh"
#include "Jeep/JContainer.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Classes

struct  JACOUSTICS::JFilenames
 Auxiliary data structure for handling file names. More...
 
struct  JACOUSTICS::JSetup
 Auxiliary data structure for setup of complete system. More...
 
struct  JACOUSTICS::JSydney
 Main class for pre-calibration using acoustics data. More...
 
struct  JACOUSTICS::JSydney::ids_t
 List of identifiers. More...
 
struct  JACOUSTICS::JSydney::fits_t
 Auxiliary data structure for group of lists of identifiers of to-be-fitted objects. More...
 
struct  JACOUSTICS::JSydney::JModuleEditor
 Auxiliary class to edit (z) position of module. More...
 
struct  JACOUSTICS::JSydney::JStringEditor
 Auxiliary class to edit (x,y,z) position of string. More...
 
struct  JACOUSTICS::JSydney::JDyneemaEditor
 Auxiliary class to edit length of Dyneema ropes. More...
 
struct  JACOUSTICS::JSydney::JTripodEditor
 Auxiliary class to edit (x,y,z) position of tripod. More...
 
struct  JACOUSTICS::JSydney::JAnchorEditor
 Auxiliary class to edit rotation of anchor. More...
 
struct  JACOUSTICS::JSydney::JParameters_t
 Extended data structure for parameters of stage. More...
 

Namespaces

 JACOUSTICS
 Auxiliary classes and methods for acoustic position calibration.
 

Typedefs

typedef JContainer
< std::vector< JTripod > > 
JACOUSTICS::tripods_container
 
typedef JContainer
< std::vector< JTransmitter > > 
JACOUSTICS::transmitters_container
 
typedef JContainer
< std::vector< JHydrophone > > 
JACOUSTICS::hydrophones_container
 
typedef JContainer< std::set
< JTransmission_t > > 
JACOUSTICS::disable_container
 

Functions

int main (int argc, char **argv)
 

Variables

static const std::string JACOUSTICS::initialise_t = "initialise"
 initialise More...
 
static const std::string JACOUSTICS::fix_t = "fix"
 fix objects More...
 
static const std::string JACOUSTICS::string_t = "string"
 string More...
 
static const std::string JACOUSTICS::tripod_t = "tripod"
 tripod More...
 
static const std::string JACOUSTICS::stage_t = "stage"
 fit stage More...
 

Detailed Description

Application to perform acoustic pre-calibration.

Author
mdejong

Definition in file JSydney.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 1038 of file JSydney.cc.

1039 {
1040  using namespace std;
1041  using namespace JPP;
1042 
1043  JMultipleFileScanner<JEvent> inputFile;
1044  JLimit_t& numberOfEvents = inputFile.getLimit();
1045  JFilenames filenames; // file names
1046  JFitParameters parameters; // fit parameters
1047  string script; // script file
1048  JSoundVelocity V = getSoundVelocity; // default sound velocity
1049  disable_container disable; // disable tansmissions
1050  size_t jobs; // number of parallel jobs
1051  int debug;
1052 
1053  try {
1054 
1055  JParser<> zap("Application to perform acoustic pre-calibration.");
1056 
1057  zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
1058  zap['n'] = make_field(numberOfEvents) = JLimit::max();
1059  zap['a'] = make_field(filenames.detector);
1060  zap['@'] = make_field(parameters) = JPARSER::initialised();
1061  zap['s'] = make_field(script, "steering script");
1062  zap['V'] = make_field(V, "sound velocity") = JPARSER::initialised();
1063  zap['T'] = make_field(filenames.tripod, "tripod file");
1064  zap['Y'] = make_field(filenames.transmitter, "transmitter file") = JPARSER::initialised();
1065  zap['H'] = make_field(filenames.hydrophone, "hydrophone file") = JPARSER::initialised();
1066  zap['M'] = make_field(getMechanics, "mechanics data") = JPARSER::initialised();
1067  zap['!'] = make_field(disable, "disable transmission") = JPARSER::initialised();
1068  zap['N'] = make_field(jobs, "number of parallel jobs") = 1;
1069  zap['d'] = make_field(debug) = 1;
1070 
1071  zap(argc, argv);
1072  }
1073  catch(const exception &error) {
1074  FATAL(error.what() << endl);
1075  }
1076 
1077  if (jobs == 0) {
1078  FATAL("Invalid number of jobs " << jobs << endl);
1079  }
1080 
1081  JSydney sydney(filenames, V, jobs, debug);
1082 
1083  set<int> receivers;
1084  set<int> emitters;
1085 
1086  for (JDetector::const_iterator i = sydney.setup.detector .begin(); i != sydney.setup.detector .end(); ++i) {
1087  if (i->getFloor() != 0 || sydney.setup.hydrophones.hasString(i->getString())) {
1088  receivers.insert(i->getID());
1089  }
1090  }
1091 
1092  for (tripods_container::const_iterator i = sydney.setup.tripods .begin(); i != sydney.setup.tripods .end(); ++i) {
1093  {
1094  emitters.insert(i->getID());
1095  }
1096  }
1097 
1098  for (transmitters_container::const_iterator i = sydney.setup.transmitters.begin(); i != sydney.setup.transmitters.end(); ++i) {
1099  if (sydney.setup.detector.hasModule(i->getLocation())) {
1100  emitters.insert(i->getID());
1101  }
1102  }
1103 
1104  typedef vector<JEvent> buffer_type;
1105 
1106  buffer_type zbuf;
1107 
1108  while (inputFile.hasNext()) {
1109 
1110  const JEvent* evt = inputFile.next();
1111 
1112  if (emitters.count(evt->getID())) {
1113  zbuf.push_back(*evt);
1114  }
1115  }
1116 
1117  const JRange<double> unit(0.0, 1.0);
1118 
1119  sort(zbuf.begin(), zbuf.end()); // sort according first time-of-emission
1120 
1121  for (buffer_type::iterator p = zbuf.begin(), q; p != zbuf.end(); p = q) {
1122 
1123  for (q = p; ++q != zbuf.end() && q->begin()->getToE() <= p->rbegin()->getToE() + parameters.Tmax_s; ) {}
1124 
1125  JEvent::overlap(p, q, parameters.deadTime_s); // empty overlapping events
1126 
1127  JSydney::ievt_type buffer;
1128 
1129  for (buffer_type::iterator evt = p; evt != q; ++evt) {
1130 
1131  sort(evt->begin(), evt->end(), JKatoomba<>::compare);
1132 
1133  JEvent::iterator __end = unique(evt->begin(), evt->end(), make_comparator(&JTransmission::getID, JComparison::eq()));
1134 
1135  for (JEvent::iterator i = evt->begin(); i != __end; ) {
1136 
1137  if (disable.count(JTransmission_t(evt->getID(), i->getID())) == 0 &&
1138  disable.count(JTransmission_t(-1, i->getID())) == 0) {
1139 
1140  if (receivers.count(i->getID()) && i->getQ() >= parameters.Qmin * (unit(parameters.Qmin) ? i->getW() : 1.0)) {
1141  ++i; continue;
1142  }
1143  }
1144 
1145  iter_swap(i, --__end);
1146  }
1147 
1148  buffer.push_back(JEvent(evt->getOID(), buffer.size(), evt->getID(), evt->begin(), __end));
1149  }
1150 
1151  if (getNumberOfEmitters(buffer.begin(), buffer.end()) >= parameters.Nmin) {
1152  sydney.idat.push_back(buffer);
1153  }
1154  }
1155 
1156  sydney.run(script);
1157 }
Utility class to parse command line options.
Definition: JParser.hh:1514
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:242
*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
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
Auxiliary data structure for handling file names.
Definition: JSydney.cc:89
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
size_t getNumberOfEmitters(T __begin, T __end)
Get number of emitters.
JFIT::JEvent JEvent
Definition: JHistory.hh:353
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.
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
const std::string & getOID() const
Get detector identifier.
Implementation for depth dependend velocity of sound.
#define FATAL(A)
Definition: JMessage.hh:67
General purpose class for object reading from a list of file names.
Main class for pre-calibration using acoustics data.
Definition: JSydney.cc:126
Acoustic event.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
bool overlap(const JRange< T, JComparator_t > &first, const JRange< T, JComparator_t > &second)
Test overlap between ranges.
Definition: JRange.hh:641
int getID() const
Get emitter identifier.
Acoustic transmission identifier.
script
Definition: JAcoustics.sh:2
Template definition of fit function of acoustic model.
Definition: JKatoomba_t.hh:75
int debug
debug level