Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
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 "JLang/JRedirectStream.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

namespace  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.
 
static const std::string JACOUSTICS::initialise_t = "initialise"
 initialise
 
static const std::string JACOUSTICS::fix_t = "fix"
 fix objects
 
static const std::string JACOUSTICS::string_t = "string"
 string
 
static const std::string JACOUSTICS::tripod_t = "tripod"
 tripod
 
static const std::string JACOUSTICS::stage_t = "stage"
 fit stage
 

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 1273 of file JSydney.cc.

1274{
1275 using namespace std;
1276 using namespace JPP;
1277
1278 typedef JContainer< std::set<JTransmission_t> > disable_container;
1279
1281 JLimit_t& numberOfEvents = inputFile.getLimit();
1282 JFilenames filenames; // file names
1283 JFitParameters parameters; // fit parameters
1284 string script; // script file
1285 JSoundVelocity V = getSoundVelocity; // default sound velocity
1286 disable_container disable; // disable tansmissions
1287 size_t threads; // number of threads
1288 int debug;
1289
1290 try {
1291
1292 JParser<> zap("Application to perform acoustic pre-calibration.");
1293
1294 zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
1295 zap['n'] = make_field(numberOfEvents) = JLimit::max();
1296 zap['a'] = make_field(filenames.detector);
1297 zap['@'] = make_field(parameters) = JPARSER::initialised();
1298 zap['s'] = make_field(script, "steering script");
1299 zap['V'] = make_field(V, "sound velocity") = JPARSER::initialised();
1300 zap['T'] = make_field(filenames.tripod, "tripod file");
1301 zap['Y'] = make_field(filenames.transmitter, "transmitter file") = JPARSER::initialised();
1302 zap['H'] = make_field(filenames.hydrophone, "hydrophone file") = JPARSER::initialised();
1303 zap['M'] = make_field(getMechanics, "mechanics data") = JPARSER::initialised();
1304 zap['!'] = make_field(disable, "disable transmission") = JPARSER::initialised();
1305 zap['N'] = make_field(threads, "number of threads") = 1;
1306 zap['d'] = make_field(debug) = 1;
1307
1308 zap(argc, argv);
1309 }
1310 catch(const exception &error) {
1311 FATAL(error.what() << endl);
1312 }
1313
1314 if (threads == 0) {
1315 FATAL("Invalid number of threads " << threads << endl);
1316 }
1317
1318 JSydney sydney(filenames.strip(), V, threads, debug);
1319
1320 const JSydney::ids_t receivers = sydney.getReceivers();
1321 const JSydney::ids_t emitters = sydney.getEmitters();
1322
1324
1325 buffer_type zbuf;
1326
1327 while (inputFile.hasNext()) {
1328
1329 const JEvent* evt = inputFile.next();
1330
1331 if (emitters.count(evt->getID())) {
1332 zbuf.push_back(*evt);
1333 }
1334 }
1335
1336 sort(zbuf.begin(), zbuf.end()); // sort according first time-of-emission
1337
1338 for (buffer_type::iterator p = zbuf.begin(), q; p != zbuf.end(); p = q) {
1339
1340 for (q = p; ++q != zbuf.end() && q->begin()->getToE() <= p->rbegin()->getToE() + parameters.Tmax_s; ) {}
1341
1342 JEvent::overlap(p, q, parameters.deadTime_s); // empty overlapping events
1343
1344 JSydney::input_type buffer;
1345
1346 for (buffer_type::iterator evt = p; evt != q; ++evt) {
1347
1348 sort(evt->begin(), evt->end(), JKatoomba<>::compare);
1349
1350 JEvent::iterator __end = unique(evt->begin(), evt->end(), make_comparator(&JTransmission::getID, JComparison::eq()));
1351
1352 for (JEvent::iterator i = evt->begin(); i != __end; ) {
1353
1354 if (disable.count(JTransmission_t(evt->getID(), i->getID())) == 0 &&
1355 disable.count(JTransmission_t(-1, i->getID())) == 0) {
1356
1357 if (receivers.count(i->getID()) && i->getQ() >= parameters.Qmin * (parameters.Qmin <= 1.0 ? i->getW() : 1.0)) {
1358 ++i; continue;
1359 }
1360 }
1361
1362 iter_swap(i, --__end);
1363 }
1364
1365 buffer.push_back(JEvent(evt->getDetectorID(), buffer.size(), evt->getID(), evt->begin(), __end));
1366 }
1367
1368 if (getNumberOfEmitters(buffer.begin(), buffer.end()) >= parameters.Nmin) {
1369 sydney.input.push_back(buffer);
1370 }
1371 }
1372
1373 sydney.run(script);
1374}
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#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.
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:70
JFIT::JEvent JEvent
Definition JHistory.hh:404
int getID() const
Get emitter identifier.
const int getDetectorID() const
Get detector identifier.
Auxiliary data structure for handling of file names.
Definition JSydney.cc:98
std::string transmitter
transmitter
Definition JSydney.cc:117
JFilenames & strip()
Strip leading and trailing white spaces.
Definition JSydney.cc:104
std::string detector
detector
Definition JSydney.cc:114
std::string hydrophone
hydrophone
Definition JSydney.cc:116
std::string tripod
tripod
Definition JSydney.cc:115
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.
Implementation for depth dependend velocity of sound.
List of object identifiers.
Definition JSydney.cc:159
Main class for pre-calibration using acoustics data.
Definition JSydney.cc:150
Acoustic transmission identifier.
int getID() const
Get 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
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128