Jpp  18.4.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 "km3net-dataformat/definitions/module_status.hh"
#include "JLang/JPredicate.hh"
#include "JLang/JComparator.hh"
#include "JLang/JComparison.hh"
#include "JLang/JSTDObjectWriter.hh"
#include "JLang/JSTDObjectReader.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 of 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 object 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 orientation of anchor. More...
 
struct  JACOUSTICS::JSydney::JParameters_t
 Extended data structure for parameters of stage. More...
 
struct  JACOUSTICS::JSydney::string_type
 Auxiliary data structure for decomposed string. More...
 
struct  JACOUSTICS::JSydney::detector_type
 Auxiliary data structure for detector with decomposed strings. More...
 

Namespaces

 JACOUSTICS
 Auxiliary classes and methods for acoustic position calibration.
 

Typedefs

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

Functions

int main (int argc, char **argv)
 

Variables

static const char JACOUSTICS::skip_t = '#'
 Script commands. More...
 
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 1226 of file JSydney.cc.

1227 {
1228  using namespace std;
1229  using namespace JPP;
1230 
1231  typedef JContainer< std::set<JTransmission_t> > disable_container;
1232 
1233  JMultipleFileScanner<JEvent> inputFile;
1234  JLimit_t& numberOfEvents = inputFile.getLimit();
1235  JFilenames filenames; // file names
1236  JFitParameters parameters; // fit parameters
1237  string script; // script file
1238  JSoundVelocity V = getSoundVelocity; // default sound velocity
1239  disable_container disable; // disable tansmissions
1240  size_t threads; // number of threads
1241  int debug;
1242 
1243  try {
1244 
1245  JParser<> zap("Application to perform acoustic pre-calibration.");
1246 
1247  zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
1248  zap['n'] = make_field(numberOfEvents) = JLimit::max();
1249  zap['a'] = make_field(filenames.detector);
1250  zap['@'] = make_field(parameters) = JPARSER::initialised();
1251  zap['s'] = make_field(script, "steering script");
1252  zap['V'] = make_field(V, "sound velocity") = JPARSER::initialised();
1253  zap['T'] = make_field(filenames.tripod, "tripod file");
1254  zap['Y'] = make_field(filenames.transmitter, "transmitter file") = JPARSER::initialised();
1255  zap['H'] = make_field(filenames.hydrophone, "hydrophone file") = JPARSER::initialised();
1256  zap['M'] = make_field(getMechanics, "mechanics data") = JPARSER::initialised();
1257  zap['!'] = make_field(disable, "disable transmission") = JPARSER::initialised();
1258  zap['N'] = make_field(threads, "number of threads") = 1;
1259  zap['d'] = make_field(debug) = 1;
1260 
1261  zap(argc, argv);
1262  }
1263  catch(const exception &error) {
1264  FATAL(error.what() << endl);
1265  }
1266 
1267  if (threads == 0) {
1268  FATAL("Invalid number of threads " << threads << endl);
1269  }
1270 
1271  JSydney sydney(filenames, V, threads, debug);
1272 
1273  const JSydney::ids_t receivers = sydney.getReceivers();
1274  const JSydney::ids_t emitters = sydney.getEmitters();
1275 
1276  typedef vector<JEvent> buffer_type;
1277 
1278  buffer_type zbuf;
1279 
1280  while (inputFile.hasNext()) {
1281 
1282  const JEvent* evt = inputFile.next();
1283 
1284  if (emitters.count(evt->getID())) {
1285  zbuf.push_back(*evt);
1286  }
1287  }
1288 
1289  const JRange<double> unit(0.0, 1.0);
1290 
1291  sort(zbuf.begin(), zbuf.end()); // sort according first time-of-emission
1292 
1293  for (buffer_type::iterator p = zbuf.begin(), q; p != zbuf.end(); p = q) {
1294 
1295  for (q = p; ++q != zbuf.end() && q->begin()->getToE() <= p->rbegin()->getToE() + parameters.Tmax_s; ) {}
1296 
1297  JEvent::overlap(p, q, parameters.deadTime_s); // empty overlapping events
1298 
1299  JSydney::input_type buffer;
1300 
1301  for (buffer_type::iterator evt = p; evt != q; ++evt) {
1302 
1303  sort(evt->begin(), evt->end(), JKatoomba<>::compare);
1304 
1305  JEvent::iterator __end = unique(evt->begin(), evt->end(), make_comparator(&JTransmission::getID, JComparison::eq()));
1306 
1307  for (JEvent::iterator i = evt->begin(); i != __end; ) {
1308 
1309  if (disable.count(JTransmission_t(evt->getID(), i->getID())) == 0 &&
1310  disable.count(JTransmission_t(-1, i->getID())) == 0) {
1311 
1312  if (receivers.count(i->getID()) && i->getQ() >= parameters.Qmin * (unit(parameters.Qmin) ? i->getW() : 1.0)) {
1313  ++i; continue;
1314  }
1315  }
1316 
1317  iter_swap(i, --__end);
1318  }
1319 
1320  buffer.push_back(JEvent(evt->getOID(), buffer.size(), evt->getID(), evt->begin(), __end));
1321  }
1322 
1323  if (getNumberOfEmitters(buffer.begin(), buffer.end()) >= parameters.Nmin) {
1324  sydney.input.push_back(buffer);
1325  }
1326  }
1327 
1328  sydney.run(script);
1329 }
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 of file names.
Definition: JSydney.cc:96
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
std::vector< JHitW0 > buffer_type
hits
Definition: JPerth.cc:67
size_t getNumberOfEmitters(T __begin, T __end)
Get number of emitters.
List of object identifiers.
Definition: JSydney.cc:140
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:133
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.
Template definition of fit function of acoustic model.
Definition: JKatoomba_t.hh:146
int debug
debug level