Jpp  18.2.1
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 1179 of file JSydney.cc.

1180 {
1181  using namespace std;
1182  using namespace JPP;
1183 
1184  typedef JContainer< std::set<JTransmission_t> > disable_container;
1185 
1186  JMultipleFileScanner<JEvent> inputFile;
1187  JLimit_t& numberOfEvents = inputFile.getLimit();
1188  JFilenames filenames; // file names
1189  JFitParameters parameters; // fit parameters
1190  string script; // script file
1191  JSoundVelocity V = getSoundVelocity; // default sound velocity
1192  disable_container disable; // disable tansmissions
1193  size_t threads; // number of threads
1194  int debug;
1195 
1196  try {
1197 
1198  JParser<> zap("Application to perform acoustic pre-calibration.");
1199 
1200  zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
1201  zap['n'] = make_field(numberOfEvents) = JLimit::max();
1202  zap['a'] = make_field(filenames.detector);
1203  zap['@'] = make_field(parameters) = JPARSER::initialised();
1204  zap['s'] = make_field(script, "steering script");
1205  zap['V'] = make_field(V, "sound velocity") = JPARSER::initialised();
1206  zap['T'] = make_field(filenames.tripod, "tripod file");
1207  zap['Y'] = make_field(filenames.transmitter, "transmitter file") = JPARSER::initialised();
1208  zap['H'] = make_field(filenames.hydrophone, "hydrophone file") = JPARSER::initialised();
1209  zap['M'] = make_field(getMechanics, "mechanics data") = JPARSER::initialised();
1210  zap['!'] = make_field(disable, "disable transmission") = JPARSER::initialised();
1211  zap['N'] = make_field(threads, "number of threads") = 1;
1212  zap['d'] = make_field(debug) = 1;
1213 
1214  zap(argc, argv);
1215  }
1216  catch(const exception &error) {
1217  FATAL(error.what() << endl);
1218  }
1219 
1220  if (threads == 0) {
1221  FATAL("Invalid number of threads " << threads << endl);
1222  }
1223 
1224  JSydney sydney(filenames, V, threads, debug);
1225 
1226  const JSydney::ids_t receivers = sydney.getReceivers();
1227  const JSydney::ids_t emitters = sydney.getEmitters();
1228 
1229  typedef vector<JEvent> buffer_type;
1230 
1231  buffer_type zbuf;
1232 
1233  while (inputFile.hasNext()) {
1234 
1235  const JEvent* evt = inputFile.next();
1236 
1237  if (emitters.count(evt->getID())) {
1238  zbuf.push_back(*evt);
1239  }
1240  }
1241 
1242  const JRange<double> unit(0.0, 1.0);
1243 
1244  sort(zbuf.begin(), zbuf.end()); // sort according first time-of-emission
1245 
1246  for (buffer_type::iterator p = zbuf.begin(), q; p != zbuf.end(); p = q) {
1247 
1248  for (q = p; ++q != zbuf.end() && q->begin()->getToE() <= p->rbegin()->getToE() + parameters.Tmax_s; ) {}
1249 
1250  JEvent::overlap(p, q, parameters.deadTime_s); // empty overlapping events
1251 
1252  JSydney::input_type buffer;
1253 
1254  for (buffer_type::iterator evt = p; evt != q; ++evt) {
1255 
1256  sort(evt->begin(), evt->end(), JKatoomba<>::compare);
1257 
1258  JEvent::iterator __end = unique(evt->begin(), evt->end(), make_comparator(&JTransmission::getID, JComparison::eq()));
1259 
1260  for (JEvent::iterator i = evt->begin(); i != __end; ) {
1261 
1262  if (disable.count(JTransmission_t(evt->getID(), i->getID())) == 0 &&
1263  disable.count(JTransmission_t(-1, i->getID())) == 0) {
1264 
1265  if (receivers.count(i->getID()) && i->getQ() >= parameters.Qmin * (unit(parameters.Qmin) ? i->getW() : 1.0)) {
1266  ++i; continue;
1267  }
1268  }
1269 
1270  iter_swap(i, --__end);
1271  }
1272 
1273  buffer.push_back(JEvent(evt->getOID(), buffer.size(), evt->getID(), evt->begin(), __end));
1274  }
1275 
1276  if (getNumberOfEmitters(buffer.begin(), buffer.end()) >= parameters.Nmin) {
1277  sydney.input.push_back(buffer);
1278  }
1279  }
1280 
1281  sydney.run(script);
1282 }
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.
script
Definition: JAcoustics.sh:2
Template definition of fit function of acoustic model.
Definition: JKatoomba_t.hh:146
int debug
debug level