Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
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 "JMath/JQuantile_t.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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 1257 of file JSydney.cc.

1258 {
1259  using namespace std;
1260  using namespace JPP;
1261 
1262  typedef JContainer< std::set<JTransmission_t> > disable_container;
1263 
1264  JMultipleFileScanner<JEvent> inputFile;
1265  JLimit_t& numberOfEvents = inputFile.getLimit();
1266  JFilenames filenames; // file names
1267  JFitParameters parameters; // fit parameters
1268  string script; // script file
1269  JSoundVelocity V = getSoundVelocity; // default sound velocity
1270  disable_container disable; // disable tansmissions
1271  size_t threads; // number of threads
1272  int debug;
1273 
1274  try {
1275 
1276  JParser<> zap("Application to perform acoustic pre-calibration.");
1277 
1278  zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
1279  zap['n'] = make_field(numberOfEvents) = JLimit::max();
1280  zap['a'] = make_field(filenames.detector);
1281  zap['@'] = make_field(parameters) = JPARSER::initialised();
1282  zap['s'] = make_field(script, "steering script");
1283  zap['V'] = make_field(V, "sound velocity") = JPARSER::initialised();
1284  zap['T'] = make_field(filenames.tripod, "tripod file");
1285  zap['Y'] = make_field(filenames.transmitter, "transmitter file") = JPARSER::initialised();
1286  zap['H'] = make_field(filenames.hydrophone, "hydrophone file") = JPARSER::initialised();
1287  zap['M'] = make_field(getMechanics, "mechanics data") = JPARSER::initialised();
1288  zap['!'] = make_field(disable, "disable transmission") = JPARSER::initialised();
1289  zap['N'] = make_field(threads, "number of threads") = 1;
1290  zap['d'] = make_field(debug) = 1;
1291 
1292  zap(argc, argv);
1293  }
1294  catch(const exception &error) {
1295  FATAL(error.what() << endl);
1296  }
1297 
1298  if (threads == 0) {
1299  FATAL("Invalid number of threads " << threads << endl);
1300  }
1301 
1302  JSydney sydney(filenames, V, threads, debug);
1303 
1304  const JSydney::ids_t receivers = sydney.getReceivers();
1305  const JSydney::ids_t emitters = sydney.getEmitters();
1306 
1307  typedef vector<JEvent> buffer_type;
1308 
1309  buffer_type zbuf;
1310 
1311  while (inputFile.hasNext()) {
1312 
1313  const JEvent* evt = inputFile.next();
1314 
1315  if (emitters.count(evt->getID())) {
1316  zbuf.push_back(*evt);
1317  }
1318  }
1319 
1320  sort(zbuf.begin(), zbuf.end()); // sort according first time-of-emission
1321 
1322  for (buffer_type::iterator p = zbuf.begin(), q; p != zbuf.end(); p = q) {
1323 
1324  for (q = p; ++q != zbuf.end() && q->begin()->getToE() <= p->rbegin()->getToE() + parameters.Tmax_s; ) {}
1325 
1326  JEvent::overlap(p, q, parameters.deadTime_s); // empty overlapping events
1327 
1328  JSydney::input_type buffer;
1329 
1330  for (buffer_type::iterator evt = p; evt != q; ++evt) {
1331 
1332  sort(evt->begin(), evt->end(), JKatoomba<>::compare);
1333 
1334  JEvent::iterator __end = unique(evt->begin(), evt->end(), make_comparator(&JTransmission::getID, JComparison::eq()));
1335 
1336  for (JEvent::iterator i = evt->begin(); i != __end; ) {
1337 
1338  if (disable.count(JTransmission_t(evt->getID(), i->getID())) == 0 &&
1339  disable.count(JTransmission_t(-1, i->getID())) == 0) {
1340 
1341  if (receivers.count(i->getID()) && i->getQ() >= parameters.Qmin * (parameters.Qmin <= 1.0 ? i->getW() : 1.0)) {
1342  ++i; continue;
1343  }
1344  }
1345 
1346  iter_swap(i, --__end);
1347  }
1348 
1349  buffer.push_back(JEvent(evt->getDetectorID(), buffer.size(), evt->getID(), evt->begin(), __end));
1350  }
1351 
1352  if (getNumberOfEmitters(buffer.begin(), buffer.end()) >= parameters.Nmin) {
1353  sydney.input.push_back(buffer);
1354  }
1355  }
1356 
1357  sydney.run(script);
1358 }
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Utility class to parse command line options.
Definition: JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
size_t getNumberOfEmitters(T __begin, T __end)
Get number of emitters.
static const JSoundVelocity getSoundVelocity(1541.0, -17.0e-3, -2000.0)
Function object for velocity of sound.
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:242
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::vector< JHitW0 > buffer_type
hits
Definition: JPerth.cc:71
JFIT::JEvent JEvent
Definition: JHistory.hh:353
bool overlap(const JRange< T, JComparator_t > &first, const JRange< T, JComparator_t > &second)
Test overlap between ranges.
Definition: JRange.hh:641
Definition: JSTDTypes.hh:14
int getID() const
Get emitter identifier.
const int getDetectorID() const
Get detector identifier.
Auxiliary data structure for handling of file names.
Definition: JSydney.cc:97
std::string transmitter
transmitter
Definition: JSydney.cc:101
std::string detector
detector
Definition: JSydney.cc:98
std::string hydrophone
hydrophone
Definition: JSydney.cc:100
std::string tripod
tripod
Definition: JSydney.cc:99
double Qmin
minimal quality transmission
double deadTime_s
dead time between events [s]
size_t Nmin
minimum number of emitters
double Tmax_s
time window to combine events [s]
Template definition of fit function of acoustic model.
Definition: JKatoomba_t.hh:77
Implementation for depth dependend velocity of sound.
List of object identifiers.
Definition: JSydney.cc:143
Main class for pre-calibration using acoustics data.
Definition: JSydney.cc:134
Acoustic transmission identifier.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition: JContainer.hh:42
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:68
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:45