92 static const std::string
fix_t =
"fix";
95 static const std::string
stage_t =
"stage";
96 static const std::string
set_t =
"set";
97 static const char X_t =
'x';
98 static const char Y_t =
'y';
99 static const char Z_t =
'z';
143 bool hasString(
const int id)
const
171 void set(
const char c,
const bool value)
203 using map_type::insert;
204 using map_type::erase;
221 for (
const int i : buffer) {
260 for (
const auto& i : B) {
261 this->
erase(i.first);
275 for (
const auto i : B) {
279 if (p != this->end()) {
280 p->second.x = OP(p->second.x, i.second.x);
281 p->second.y = OP(p->second.y, i.second.y);
282 p->second.z = OP(p->second.z, i.second.z);
294 void set(
const char c,
const bool value)
296 for (
iterator i = this->begin(); i != this->end(); ++i) {
297 i->second.set(c, value);
311 for (
int id; in >> id; ) {
332 for (
const auto& i :
object) {
333 out <<
' ' << i.first
335 << (i.second.x ?
X_t :
' ')
336 << (i.second.y ?
Y_t :
' ')
337 << (i.second.z ?
Z_t :
' ');
412 virtual void apply(
const double step)
override
416 module.add(direction * step);
445 for (
size_t i = 0; i !=
detector.size(); ++i) {
458 virtual void apply(
const double step)
override
460 for (
const auto i :
index) {
489 for (
size_t i = 0; i !=
detector.size(); ++i) {
502 virtual void apply(
const double step)
override
504 for (
const auto i :
index) {
509 module.set(JVector3D(module.getX(), module.getY(), z0 + (module.getZ() - z0) * (1.0 + step)));
511 module.set(JVector3D(module.getX(), module.getY(), z0 + (module.getZ() - z0) / (1.0 - step)));
551 virtual void apply(
const double step)
override
592 virtual void apply(
const double step)
override
619 Nmax (
std::numeric_limits<size_t>::max()),
645 for (
double value; in >> value; ) {
646 object.steps.push_back(value);
669 out << setw(2) <<
object.option <<
' '
670 << setw(2) <<
object.mestimator <<
' '
673 << setw(3) <<
object.Nextra;
675 for (
const double value :
object.
steps) {
676 out <<
' ' <<
FIXED(9,5) << value;
718 receivers[i->getID()] = i->getLocation();
740 ROOT::EnableThreadSafety();
780 (*this)[module.
getString()].push_back(module);
804 A.push_back(*module);
806 B.push_back(*module);
808 C.push_back(*module);
813 for (
const auto& element : B) {
833 const double chi2 = fit(*
this);
835 for (
auto& element : B) {
840 for (string_type::iterator module = element.second.begin(); module != element.second.end(); ++module) {
854 STATUS(
"detector: " <<
FIXED(9,4) << chi2 << endl);
896 const double chi2 = fit(*
this);
898 STATUS(
"detector: " <<
FIXED(9,4) << chi2 << endl);
920 buffer[module->getString()].push_back(*module);
922 if (module->getZ() > z0) {
931 tx.push_back(
router->getModule(i->getLocation()));
933 catch(
const exception&) {}
949 const double chi2 = fit(*
this);
951 STATUS(
"string: " << setw(4) << i.first <<
' ' <<
FIXED(9,4) << chi2 << endl);
953 buffer[i.first].clear();
955 copy_if(
setup.
detector.begin(),
setup.
detector.end(), back_inserter(buffer[i.first]), make_predicate(&JModule::getString, i.first));
960 for (
const auto& element : buffer) {
961 copy(element.second.begin(), element.second.end(), back_inserter(
setup.
detector));
983 if (
fits.
strings.count(module->getString()) != 0 && module->getFloor() != 0) {
988 const double chi2 = fit(*
this);
990 STATUS(
"detector: " <<
FIXED(9,4) << chi2 << endl);
1001 using namespace std;
1002 using namespace JPP;
1010 if (
fits.
strings.count(module->getString()) != 0 && module->getFloor() == 0) {
1018 const double chi2 = fit(*
this);
1020 STATUS(
"detector: " <<
FIXED(9,4) << chi2 << endl);
1033 using namespace std;
1034 using namespace JPP;
1042 if (
fits.
strings.count(module->getString()) != 0 && module->getFloor() != 0) {
1052 const double chi2 = fit(*
this);
1054 STATUS(
"detector: " <<
FIXED(9,4) << chi2 << endl);
1066 using namespace std;
1067 using namespace JPP;
1081 emitters[i->getID()] =
JEmitter(i->getID(), i->getPosition() +
router->getModule(i->getLocation()).getPosition());
1083 catch(
const exception&) {}
1104 for (input_type::const_iterator evt = superevt.begin(); evt != superevt.end(); ++evt) {
1106 if (emitters.
has(evt->getID())) {
1108 const JEmitter& emitter = emitters [evt->getID()];
1109 const double weight =
getWeight(evt->getID());
1111 for (JEvent::const_iterator i = evt->begin(); i != evt->end(); ++i) {
1115 data.push_back(
JHit(emitter,
1134 }
else if (option == 2) {
1146 return numeric_limits<float>::max();
1156 void run(
const std::string& script)
1158 using namespace std;
1159 using namespace JPP;
1161 ifstream in(script.c_str());
1169 if (buffer.empty() || buffer[0] ==
skip_t) {
1173 istringstream is(buffer);
1181 }
else if (key ==
fix_t) {
1186 if (is >> type >>
id) {
1198 }
else if (key ==
set_t) {
1204 if (is >> type >> c >>
id) {
1232 if (is >> stage >>
input) {
1234 STATUS(
"stage " << setw(3) << stage <<
" {" <<
input <<
"}" << endl);
1240 ofstream out(
MAKE_CSTRING(
"stage-" << stage <<
".log"));
1245 switch (stage[stage.size() - 1]) {
1307 void store(
const std::string& dir =
".")
1309 using namespace JPP;
1311 if (
getFileStatus(dir.c_str()) || (mkdir(dir.c_str(), S_IRWXU | S_IRWXG) != -1)) {
1315 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
1316 module->set(router->getModule(module->getLocation()).getPosition());
1344 buffer.
insert(i->getID());
1359 using namespace std;
1364 buffer.
insert(i->getID());
1371 const JModule& module =
router->getModule(i->getLocation());
1374 buffer.
insert(i->getID());
1377 catch(
const exception&) {}
1414 using namespace std;
1415 using namespace JPP;
1420 JLimit_t& numberOfEvents = inputFile.getLimit();
1426 disable_container disable;
1432 JParser<> zap(
"Application to perform acoustic pre-calibration.");
1434 zap[
'f'] =
make_field(inputFile,
"output of JAcousticEventBuilder[.sh]");
1438 zap[
's'] =
make_field(script,
"steering script");
1445 zap[
'N'] =
make_field(threads,
"number of threads") = 1;
1450 catch(
const exception &error) {
1451 FATAL(error.what() << endl);
1455 FATAL(
"Invalid number of threads " << threads << endl);
1471 if (emitters.count(evt->
getID())) {
1472 zbuf.push_back(*evt);
1476 sort(zbuf.begin(), zbuf.end());
1478 for (buffer_type::iterator p = zbuf.begin(), q; p != zbuf.end(); p = q) {
1480 for (q = p; ++q != zbuf.end() && q->begin()->getToE() <= p->rbegin()->getToE() + parameters.
Tmax_s; ) {}
1482 JEvent::overlap(p, q, parameters.
deadTime_s);
1486 for (buffer_type::iterator evt = p; evt != q; ++evt) {
1492 for (JEvent::iterator i = evt->begin(); i != __end; ) {
1497 if (receivers.count(i->getID()) && i->getQ() >= parameters.
Qmin * (parameters.
Qmin <= 1.0 ? i->getW() : 1.0)) {
1502 iter_swap(i, --__end);
1505 buffer.push_back(
JEvent(evt->getDetectorID(), buffer.size(), evt->getID(), evt->begin(), __end));
1509 sydney.
input.push_back(buffer);
ROOT TTree parameter settings.
Data structure for detector geometry and calibration.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
General purpose class for hash map of unique elements.
Data structure for hydrophone.
Fit functions of acoustic model.
Direct access to location in detector data structure.
General purpose messaging.
Data structure for optical module.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_CSTRING(A)
Make C-string.
#define MAKE_STRING(A)
Make string.
Auxiliary class to define a range between two values.
Acoustic transmission identifier.
Data structure for transmitter.
Data structure for tripod.
Auxiliary methods to convert data members or return values of member methods of a set of objects to a...
Thread pool for global fits.
static output_type * output
optional output
void enqueue(input_type &data)
Queue data.
static JMATH::JQuantile_t Q
chi2/NDF
Thread pool for global fits using super events.
static JMATH::JQuantile_t Q
chi2/NDF
const JModule & getModule(const JModuleAddress &address) const
Get module parameters.
Router for direct addressing of location data in detector data structure.
Logical location of module.
int getFloor() const
Get floor number.
int getString() const
Get string number.
Data structure for a composite optical module.
bool has(const int bit) const
Test PMT status.
Auxiliary class for CPU timing and usage.
unsigned long long usec_wall
const JPosition3D & getPosition() const
Get position.
Data structure for vector in three dimensions.
This class can be used to temporarily redirect one output (input) stream to another output (input) st...
Implementation of object output from STD container.
Exception for accessing a value in a collection that is outside of its range.
Utility class to parse command line options.
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.
double getUTMZ() const
Get UTM Z.
const JUTMPosition & getUTMPosition() const
Get UTM position.
static const int HYDROPHONE_DISABLE
Enable (disable) use of hydrophone if this status bit is 0 (1);.
static const int TRANSMITTER_DISABLE
Enable (disable) use of transmitter if this status bit is 0 (1);.
static const int PIEZO_DISABLE
Enable (disable) use of piezo if this status bit is 0 (1);.
void copy(const Head &from, JHead &to)
Copy header from from to to.
Auxiliary classes and methods for acoustic position calibration.
static const std::string string_t
string
size_t getMinimumNumberOfEmitters(T __begin, T __end)
Get minimum number of emitters for any string in data.
static const std::string tripod_t
tripod
static const char Z_t
set z-coordinate
JContainer< std::vector< JTripod > > tripods_container
static const std::string set_t
set coordinate of object
JContainer< std::vector< JTransmitter > > transmitters_container
static const std::string initialise_t
initialise
JContainer< std::vector< JHydrophone > > hydrophones_container
static const char Y_t
set y-coordinate
static const char skip_t
Script commands.
static const char X_t
set x-coordinate
static const std::string stage_t
fit stage
JMODEL::JString getString(const JFit &fit)
Get model parameters of string.
static const std::string fix_t
fix objects
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.
file Auxiliary data structures and methods for detector calibration.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
std::string strip(const std::string &file_name)
Strip leading and trailing white spaces from file name.
Auxiliary classes and methods for 3D geometrical objects and operations.
static const JVector3D JVector3X_t(1, 0, 0)
unit x-vector
static const JVector3D JVector3Y_t(0, 1, 0)
unit y-vector
static const JVector3D JVector3Z_t(0, 0, 1)
unit z-vector
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
array_type< JValue_t > make_array(const JValue_t(&array)[N])
Method to create array of values.
static const double C
Physics constants.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::vector< JHitW0 > buffer_type
hits
JRECONSTRUCTION::JWeight getWeight
static JStat getFileStatus
Function object for file status.
Auxiliary data structure for floating point format specification.
Auxiliary data structure for mechanical model parameters of strings in a given detector.
Auxiliary data structure for mechanical model parameters with commented data.
int getID() const
Get emitter identifier.
Auxiliary data structure for handling of file names.
std::string transmitter
transmitter
JFilenames & strip()
Strip leading and trailing white spaces.
std::string detector
detector
std::string hydrophone
hydrophone
double Qmin
minimal quality transmission
double deadTime_s
dead time between events [s]
size_t Nmin
minimum number of emitters
double sigma_s
time-of-arrival resolution [s]
double Tmax_s
time window to combine events [s]
bool hasLocation(const JLocation &location) const
Check if this detector has given location.
Template definition of fit function of acoustic model.
Auxiliary data structure for setup of complete system.
tripods_container tripods
tripods
JDetectorMechanics_t mechanics
mechanical model
transmitters_container transmitters
transmitters
JDetector detector
detector
Implementation for depth dependend velocity of sound.
JSoundVelocity & set(const double z0)
Set depth.
Auxiliary class to edit orientation of anchor.
virtual void apply(const double step) override
Apply step.
JAnchorEditor(JSetup &setup, const int id)
Constructor.
std::vector< JTransmitter > & transmitters
std::vector< JHydrophone > & hydrophones
Auxiliary class to edit length of Dyneema ropes.
JDyneemaEditor(JSetup &setup, const int id, const double z0=0.0)
Constructor.
std::vector< size_t > index
virtual void apply(const double step) override
Apply step.
Auxiliary class to edit (z) position of module.
virtual void apply(const double step) override
Apply step.
JModuleEditor(JModule &module, const JVector3D &direction)
Constructor.
JModuleEditor(JModule &module)
Constructor.
Extended data structure for parameters of stage.
JParameters_t()
Default constuctor.
friend std::ostream & operator<<(std::ostream &out, const JParameters_t &object)
Write parameters to output stream.
std::vector< double > steps
friend std::istream & operator>>(std::istream &in, JParameters_t &object)
Read parameters from input stream.
Auxiliary class to edit (x,y,z) position of string.
std::vector< size_t > index
JStringEditor(JSetup &setup, const int id, const JVector3D &direction, const bool option)
Constructor.
virtual void apply(const double step) override
Apply step.
Auxiliary class to edit (x,y,z) position of tripod.
JTripodEditor(JSetup &setup, const int id, const JVector3D &direction)
Constructor.
virtual void apply(const double step) override
Apply step.
std::vector< JTripod > & tripods
Auxiliary data structure for detector with decomposed strings.
void push_back(const JModule &module)
Add module.
Auxiliary data structure for fit options.
void set(const char c, const bool value)
Set value of given coordinate.
Auxiliary data structure for group of lists of identifiers of to-be-fitted objects.
ids_t transmitters
identifiers of strings with transmitter
ids_t tripods
identifiers of tripods
void initialise(const JSetup &setup)
Initialise.
ids_t hydrophones
identifiers of strings with hydrophone
fits_t()
Default constructor.
ids_t strings
identifiers of strings
Map object identifiers to fit options.
ids_t(const ids_t &A, const ids_t &B)
Difference constructor.
friend std::istream & operator>>(std::istream &in, ids_t &object)
Read identifiers from input stream.
friend std::ostream & operator<<(std::ostream &out, const ids_t &object)
Write identifiers and fit options to output stream.
void erase(const ids_t &B)
Erase elements that are in given list of identifiers.
void insert(const int id)
Insert identifier.
ids_t(const array_type< int > &buffer)
Copy constructor.
void set(const ids_t &B, const T &OP)
Set fit options of elements to result of given logical operator combined with fit options in given li...
std::map< int, fit_t > map_type
ids_t()
Default constructor.
void set(const char c, const bool value)
Set fit option of all elements for given coordinate.
Auxiliary data structure for decomposed string.
void push_back(const JModule &module)
Add module.
Main class for pre-calibration using acoustics data.
double operator()(const int option) const
Get chi2.
void stage_x(const JParameters_t ¶meters)
Fit procedure to determine the (x,y,z) positions of the modules.
ids_t getReceivers() const
Get list of identifiers of receivers.
std::unique_ptr< JLocationRouter > router
JTOOLS::JHashMap< int, JLocation > receivers
void run(const std::string &script)
Run.
static constexpr double RADIUS_M
maximal horizontal distance between T-bar and emitter/hydrophone
void store(const std::string &dir=".")
Store data in given directory.
ids_t getEmitters() const
Get list of identifiers of emitters.
std::vector< input_type > input
void stage_c(const JParameters_t ¶meters)
Fit procedure to determine the z-positions of the modules.
std::vector< JSuperEvt > output
JFitParameters parameters
JSydney(const JFilenames &filenames, const JDetectorMechanics_t &mechanics, const JSoundVelocity &V, const size_t threads, const int debug)
Constructor.
void stage_0(const JParameters_t ¶meters)
Fit procedure to determine the positions of tripods and transmitters using strings that are fixed.
std::vector< JEvent > input_type
void stage_d(const JParameters_t ¶meters)
Fit procedure to determine the z-positions of anchors.
void stage_b(const JParameters_t ¶meters)
Fit procedure to determine the stretching and z-positions of individual strings.
void stage_a(const JParameters_t ¶meters)
Fit procedure to determine the positions of the strings and tripods.
Acoustic transmission identifier.
int getID() const
Get identifier.
Auxiliary data structure to unify weights of acoustics data according to the number of pings per emit...
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Auxiliary data structure for editable parameter.
Auxiliary data structure for fit parameter.
void store(const char *file_name) const
Store to output file.
void load(const char *file_name)
Load from input file.
Implementation of object iteration from STD container.
Auxiliary data structure for return type of make methods.
double getMean() const
Get mean value.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.
Auxiliary data structure for floating point format specification.