Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JACOUSTICS::JSydney Struct Reference

Main class for pre-calibration using acoustics data. More...

Classes

struct  detector_type
 Auxiliary data structure for detector with decomposed strings. More...
 
struct  fit_t
 Auxiliary data structure for fit options. More...
 
struct  fits_t
 Auxiliary data structure for group of lists of identifiers of to-be-fitted objects. More...
 
struct  ids_t
 Map object identifiers to fit options. More...
 
struct  JAnchorEditor
 Auxiliary class to edit orientation of anchor. More...
 
struct  JDyneemaEditor
 Auxiliary class to edit length of Dyneema ropes. More...
 
struct  JModuleEditor
 Auxiliary class to edit (z) position of module. More...
 
struct  JParameters_t
 Extended data structure for parameters of stage. More...
 
struct  JStringEditor
 Auxiliary class to edit (x,y,z) position of string. More...
 
struct  JTripodEditor
 Auxiliary class to edit (x,y,z) position of tripod. More...
 
struct  string_type
 Auxiliary data structure for decomposed string. More...
 

Public Types

typedef std::vector< JEventinput_type
 

Public Member Functions

 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 &parameters)
 Fit procedure to determine the positions of tripods and transmitters using strings that are fixed.
 
void stage_a (const JParameters_t &parameters)
 Fit procedure to determine the positions of the strings and tripods.
 
void stage_b (const JParameters_t &parameters)
 Fit procedure to determine the stretching and z-positions of individual strings.
 
void stage_c (const JParameters_t &parameters)
 Fit procedure to determine the z-positions of the modules.
 
void stage_d (const JParameters_t &parameters)
 Fit procedure to determine the z-positions of anchors.
 
void stage_x (const JParameters_t &parameters)
 Fit procedure to determine the (x,y,z) positions of the modules.
 
double operator() (const int option) const
 Get chi2.
 
void run (const std::string &script)
 Run.
 
void store (const std::string &dir=".")
 Store data in given directory.
 
ids_t getReceivers () const
 Get list of identifiers of receivers.
 
ids_t getEmitters () const
 Get list of identifiers of emitters.
 

Public Attributes

JFilenames filenames
 
JSoundVelocity V
 
size_t threads
 
int debug
 
JSetup setup
 
fits_t fits
 
JTOOLS::JHashMap< int, JLocationreceivers
 
std::unique_ptr< JLocationRouterrouter
 
std::vector< input_typeinput
 

Static Public Attributes

static constexpr double RADIUS_M = 1.0
 maximal horizontal distance between T-bar and emitter/hydrophone
 

Private Attributes

std::vector< JSuperEvtoutput
 
JDetector detector
 PMTs.
 
JFitParameters parameters
 

Detailed Description

Main class for pre-calibration using acoustics data.

Definition at line 157 of file JSydney.cc.

Member Typedef Documentation

◆ input_type

Constructor & Destructor Documentation

◆ JSydney()

JACOUSTICS::JSydney::JSydney ( const JFilenames & filenames,
const JDetectorMechanics_t & mechanics,
const JSoundVelocity & V,
const size_t threads,
const int debug )
inline

Constructor.

Parameters
filenamesfile names
mechanicsmechanical model parameters
Vsound velocity
threadsthreads
debugdebug

Definition at line 699 of file JSydney.cc.

703 :
705 V(V),
707 debug(debug)
708 {
710
711 setup.mechanics = mechanics;
713
714 if (filenames.hydrophone != "") { setup.hydrophones .load(filenames.hydrophone .c_str()); }
716
717 for (JDetector::const_iterator i = setup.detector.begin(); i != setup.detector.end(); ++i) {
718 receivers[i->getID()] = i->getLocation();
719 }
720
721 // detach PMTs
722
724
725 for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
726 module->clear();
727 }
728
730
732
733 this->V.set(setup.detector.getUTMZ()); // sound velocity at detector depth
734
737
739
740 ROOT::EnableThreadSafety();
741 }
Router for direct addressing of location data in detector data structure.
double getUTMZ() const
Get UTM Z.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Detector file.
Definition JHead.hh:227
std::string transmitter
transmitter
Definition JSydney.cc:123
std::string detector
detector
Definition JSydney.cc:120
std::string hydrophone
hydrophone
Definition JSydney.cc:122
std::string tripod
tripod
Definition JSydney.cc:121
Template definition of fit function of acoustic model.
tripods_container tripods
tripods
Definition JSydney.cc:133
hydrophones
hydrophones
JDetectorMechanics_t mechanics
mechanical model
Definition JSydney.cc:132
transmitters_container transmitters
transmitters
Definition JSydney.cc:150
JDetector detector
detector
Definition JSydney.cc:131
JSoundVelocity & set(const double z0)
Set depth.
void initialise(const JSetup &setup)
Initialise.
Definition JSydney.cc:361
JFilenames filenames
Definition JSydney.cc:1384
std::unique_ptr< JLocationRouter > router
Definition JSydney.cc:1392
JTOOLS::JHashMap< int, JLocation > receivers
Definition JSydney.cc:1391
JSoundVelocity V
Definition JSydney.cc:1385
void load(const char *file_name)
Load from input file.

Member Function Documentation

◆ stage_0()

void JACOUSTICS::JSydney::stage_0 ( const JParameters_t & parameters)
inline

Fit procedure to determine the positions of tripods and transmitters using strings that are fixed.

Parameters
parametersparameters

Definition at line 790 of file JSydney.cc.

791 {
792 using namespace std;
793 using namespace JPP;
794
795 this->parameters = parameters;
796
797 JDetector A; // old strings
798 detector_type B; // new strings with transmitter -> fit only base module
799 JDetector C; // new strings w/o transmitter -> discard completely from fit
800
801 for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
802
803 if (fits.strings .count(module->getString()) == 0)
804 A.push_back(*module);
805 else if (fits.transmitters.count(module->getString()) != 0)
806 B.push_back(*module);
807 else
808 C.push_back(*module);
809 }
810
811 setup.detector.swap(A);
812
813 for (const auto& element : B) {
814 setup.detector.push_back(element.second.base);
815 }
816
818
819 JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
820
821 for (const auto& i : fits.tripods) {
822 if (i.second.x) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.x: " << RIGHT(4) << i.first), new JTripodEditor(setup, i.first, JVector3X_t), parameters.steps[0])); }
823 if (i.second.y) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.y: " << RIGHT(4) << i.first), new JTripodEditor(setup, i.first, JVector3Y_t), parameters.steps[0])); }
824 if (i.second.z) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.z: " << RIGHT(4) << i.first), new JTripodEditor(setup, i.first, JVector3Z_t), parameters.steps[0])); }
825 }
826
827 for (const auto& i : fits.transmitters) {
828 if (i.second.x) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "transmitter.x: " << RIGHT(4) << i.first), new JStringEditor(setup, i.first, JVector3X_t, true), parameters.steps[0])); }
829 if (i.second.y) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "transmitter.y: " << RIGHT(4) << i.first), new JStringEditor(setup, i.first, JVector3Y_t, true), parameters.steps[0])); }
830 if (i.second.z) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "transmitter.z: " << RIGHT(4) << i.first), new JStringEditor(setup, i.first, JVector3Z_t, true), parameters.steps[0])); }
831 }
832
833 const double chi2 = fit(*this);
834
835 for (auto& element : B) {
836
837 const JModule& base = setup.detector.getModule(router->getAddress(JLocation(element.second.base.getString(),0)));
838 const JVector3D pos = base.getPosition() - element.second.base.getPosition();
839
840 for (string_type::iterator module = element.second.begin(); module != element.second.end(); ++module) {
841
842 module->add(pos);
843
844 setup.detector.push_back(*module);
845 }
846 }
847
848 copy(C.begin(), C.end(), back_inserter(setup.detector));
849
850 sort(setup.detector.begin(), setup.detector.end(), make_comparator(&JModule::getLocation));
851
853
854 STATUS("detector: " << FIXED(9,4) << chi2 << endl);
855 }
#define STATUS(A)
Definition JMessage.hh:63
#define MAKE_STRING(A)
Make string.
Definition JPrint.hh:48
Detector data structure.
Definition JDetector.hh:96
const JModule & getModule(const JModuleAddress &address) const
Get module parameters.
Definition JDetector.hh:270
Logical location of module.
Definition JLocation.hh:40
Data structure for a composite optical module.
Definition JModule.hh:76
const JPosition3D & getPosition() const
Get position.
Data structure for vector in three dimensions.
Definition JVector3D.hh:36
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition JHead.cc:163
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.
@ LEFT
Definition JTwosome.hh:18
@ RIGHT
Definition JTwosome.hh:18
static const double C
Physics constants.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
ids_t transmitters
identifiers of strings with transmitter
Definition JSydney.cc:374
ids_t tripods
identifiers of tripods
Definition JSydney.cc:372
ids_t strings
identifiers of strings
Definition JSydney.cc:371
JFitParameters parameters
Definition JSydney.cc:1401
Conjugate gradient fit.
Definition JGradient.hh:76
Auxiliary data structure for editable parameter.
Definition JGradient.hh:50

◆ stage_a()

void JACOUSTICS::JSydney::stage_a ( const JParameters_t & parameters)
inline

Fit procedure to determine the positions of the strings and tripods.

Parameters
parametersparameters

Definition at line 863 of file JSydney.cc.

864 {
865 using namespace std;
866 using namespace JPP;
867
868 this->parameters = parameters;
869
870 JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
871
872 for (const auto& i : fits.strings) {
873 if (i.second.x) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.x: " << RIGHT(4) << i.first), new JStringEditor(setup, i.first, JVector3X_t, true), parameters.steps[0])); }
874 if (i.second.y) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.y: " << RIGHT(4) << i.first), new JStringEditor(setup, i.first, JVector3Y_t, true), parameters.steps[0])); }
875 if (i.second.z) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.z: " << RIGHT(4) << i.first), new JStringEditor(setup, i.first, JVector3Z_t, false), parameters.steps[0])); }
876 }
877
878 for (const auto& i : fits.tripods) {
879 if (i.second.x) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.x: " << RIGHT(4) << i.first), new JTripodEditor(setup, i.first, JVector3X_t), parameters.steps[1])); }
880 if (i.second.y) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.y: " << RIGHT(4) << i.first), new JTripodEditor(setup, i.first, JVector3Y_t), parameters.steps[1])); }
881 if (i.second.z) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.z: " << RIGHT(4) << i.first), new JTripodEditor(setup, i.first, JVector3Z_t), parameters.steps[1])); }
882 }
883
884 for (const auto& i : ids_t(fits.hydrophones, fits.transmitters)) {
885 fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "anchor.R: " << RIGHT(4) << i.first), new JAnchorEditor(setup, i.first), parameters.steps[0] / RADIUS_M));
886 }
887
888 for (const auto& i : fits.transmitters) {
889
890 JModule& module = setup.detector.getModule(router->getAddress(JLocation(i.first,0)));
891
892 if (true) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "anchor.R: " << RIGHT(4) << i.first), new JAnchorEditor(setup, i.first), parameters.steps[0] / RADIUS_M)); }
893 if (i.second.z) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "anchor.z: " << RIGHT(4) << i.first), new JModuleEditor(module), parameters.steps[0])); }
894 }
895
896 const double chi2 = fit(*this);
897
898 STATUS("detector: " << FIXED(9,4) << chi2 << endl);
899 }
ids_t hydrophones
identifiers of strings with hydrophone
Definition JSydney.cc:373
static constexpr double RADIUS_M
maximal horizontal distance between T-bar and emitter/hydrophone
Definition JSydney.cc:159

◆ stage_b()

void JACOUSTICS::JSydney::stage_b ( const JParameters_t & parameters)
inline

Fit procedure to determine the stretching and z-positions of individual strings.

Parameters
parametersparameters

Definition at line 907 of file JSydney.cc.

908 {
909 using namespace std;
910 using namespace JPP;
911
912 this->parameters = parameters;
913
914 map<int, JDetector> buffer;
915
916 double z0 = 0.0;
917
918 for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
919
920 buffer[module->getString()].push_back(*module);
921
922 if (module->getZ() > z0) {
923 z0 = module->getZ();
924 }
925 }
926
927 JDetector tx;
928
929 for (transmitters_container::iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
930 try {
931 tx.push_back(router->getModule(i->getLocation()));
932 }
933 catch(const exception&) {}
934 }
935
936 for (const auto& i : fits.strings) {
937
938 setup.detector.swap(buffer[i.first]);
939
940 copy(tx.begin(), tx.end(), back_inserter(setup.detector));
941
943
944 JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
945
946 if (i.second.z) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.M: " << RIGHT(4) << i.first), new JDyneemaEditor(setup, i.first, z0), parameters.steps[0])); }
947 if (i.second.z) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.z: " << RIGHT(4) << i.first), new JStringEditor (setup, i.first, JVector3Z_t, false), parameters.steps[1])); }
948
949 const double chi2 = fit(*this);
950
951 STATUS("string: " << setw(4) << i.first << ' ' << FIXED(9,4) << chi2 << endl);
952
953 buffer[i.first].clear();
954
955 copy_if(setup.detector.begin(), setup.detector.end(), back_inserter(buffer[i.first]), make_predicate(&JModule::getString, i.first));
956 }
957
958 setup.detector.clear();
959
960 for (const auto& element : buffer) {
961 copy(element.second.begin(), element.second.end(), back_inserter(setup.detector));
962 }
963
965 }

◆ stage_c()

void JACOUSTICS::JSydney::stage_c ( const JParameters_t & parameters)
inline

Fit procedure to determine the z-positions of the modules.

Parameters
parametersparameters

Definition at line 973 of file JSydney.cc.

974 {
975 using namespace std;
976 using namespace JPP;
977
978 this->parameters = parameters;
979
980 JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
981
982 for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
983 if (fits.strings.count(module->getString()) != 0 && module->getFloor() != 0) {
984 fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.z: " << right << module->getLocation()), new JModuleEditor(*module), parameters.steps[0]));
985 }
986 }
987
988 const double chi2 = fit(*this);
989
990 STATUS("detector: " << FIXED(9,4) << chi2 << endl);
991 }

◆ stage_d()

void JACOUSTICS::JSydney::stage_d ( const JParameters_t & parameters)
inline

Fit procedure to determine the z-positions of anchors.

Parameters
parametersparameters

Definition at line 999 of file JSydney.cc.

1000 {
1001 using namespace std;
1002 using namespace JPP;
1003
1004 this->parameters = parameters;
1005
1006 JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
1007
1008 for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
1009
1010 if (fits.strings.count(module->getString()) != 0 && module->getFloor() == 0) {
1011
1012 const fit_t fcc = fits.strings.at(module->getString());
1013
1014 if (fcc.z) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.z: " << right << module->getLocation()), new JModuleEditor(*module), parameters.steps[0])); }
1015 }
1016 }
1017
1018 const double chi2 = fit(*this);
1019
1020 STATUS("detector: " << FIXED(9,4) << chi2 << endl);
1021 }

◆ stage_x()

void JACOUSTICS::JSydney::stage_x ( const JParameters_t & parameters)
inline

Fit procedure to determine the (x,y,z) positions of the modules.

This procedure should be considered unorthodox - it can be used to modify the detector file in such a way to accommodate anomalies in the shapes of a string (e.g. entanglement of string in D0ORCA018).

Parameters
parametersparameters

Definition at line 1031 of file JSydney.cc.

1032 {
1033 using namespace std;
1034 using namespace JPP;
1035
1036 this->parameters = parameters;
1037
1038 JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
1039
1040 for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
1041
1042 if (fits.strings.count(module->getString()) != 0 && module->getFloor() != 0) {
1043
1044 const fit_t fcc = fits.strings.at(module->getString());
1045
1046 if (fcc.x) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.x: " << right << module->getLocation()), new JModuleEditor(*module, JVector3X_t), parameters.steps[0])); }
1047 if (fcc.y) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.y: " << right << module->getLocation()), new JModuleEditor(*module, JVector3Y_t), parameters.steps[0])); }
1048 if (fcc.z) { fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.z: " << right << module->getLocation()), new JModuleEditor(*module, JVector3Z_t), parameters.steps[0])); }
1049 }
1050 }
1051
1052 const double chi2 = fit(*this);
1053
1054 STATUS("detector: " << FIXED(9,4) << chi2 << endl);
1055 }

◆ operator()()

double JACOUSTICS::JSydney::operator() ( const int option) const
inline

Get chi2.

Parameters
optionoption
Returns
chi2/NDF

Definition at line 1064 of file JSydney.cc.

1065 {
1066 using namespace std;
1067 using namespace JPP;
1068
1070
1071 JHashMap<int, JEmitter> emitters;
1072
1073 for (tripods_container::const_iterator i = setup.tripods.begin(); i != setup.tripods.end(); ++i) {
1074 {
1075 emitters[i->getID()] = JEmitter(i->getID(), i->getUTMPosition() - setup.detector.getUTMPosition());
1076 }
1077 }
1078
1079 for (transmitters_container::const_iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
1080 try {
1081 emitters[i->getID()] = JEmitter(i->getID(), i->getPosition() + router->getModule(i->getLocation()).getPosition());
1082 }
1083 catch(const exception&) {} // if no module available, discard transmitter
1084 }
1085
1086 if (option == 0 || // step wise improvement of the chi2
1087 option == 1) { // evaluation of the chi2 before the determination of the gradient of the chi2
1088
1089 this->output.clear();
1090
1091 JSTDObjectWriter<JSuperEvt> out(this->output); // write data for subsequent use
1092
1093 JFremantle::output = (option == 1 ? &out : NULL);
1094
1095 {
1096 JFremantle fremantle(geometry, V, parameters, threads, 2 * threads);
1097
1098 for (const input_type& superevt : input) {
1099
1100 const JWeight getWeight(superevt.begin(), superevt.end());
1101
1103
1104 for (input_type::const_iterator evt = superevt.begin(); evt != superevt.end(); ++evt) {
1105
1106 if (emitters.has(evt->getID())) {
1107
1108 const JEmitter& emitter = emitters [evt->getID()];
1109 const double weight = getWeight(evt->getID());
1110
1111 for (JEvent::const_iterator i = evt->begin(); i != evt->end(); ++i) {
1112
1113 if (geometry.hasLocation(receivers[i->getID()])) {
1114
1115 data.push_back(JHit(emitter,
1116 distance(superevt.begin(), evt),
1117 receivers[i->getID()],
1118 i->getToA(),
1120 weight));
1121 }
1122 }
1123 }
1124 }
1125
1126 if (getMinimumNumberOfEmitters(data.begin(), data.end()) >= parameters.Nmin) {
1127 fremantle.enqueue(data);
1128 }
1129 }
1130 }
1131
1132 return JFremantle::Q.getMean(numeric_limits<float>::max());
1133
1134 } else if (option == 2) { // evaluation of the derivative of the chi2 to each fit parameter
1135
1136 {
1138
1139 JPlatypus platypus(geometry, emitters, V, parameters, in, threads);
1140 }
1141
1142 return JPlatypus::Q.getMean(numeric_limits<float>::max());
1143
1144 } else {
1145
1146 return numeric_limits<float>::max();
1147 }
1148 }
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Thread pool for global fits.
static output_type * output
optional output
static JMATH::JQuantile_t Q
chi2/NDF
Thread pool for global fits using super events.
static JMATH::JQuantile_t Q
chi2/NDF
Implementation of object output from STD container.
bool has(const T &value) const
Test whether given value is present.
const JUTMPosition & getUTMPosition() const
Get UTM position.
size_t getMinimumNumberOfEmitters(T __begin, T __end)
Get minimum number of emitters for any string in data.
JRECONSTRUCTION::JWeight getWeight
Acoustic emitter.
Definition JEmitter.hh:30
size_t Nmin
minimum number of emitters
double sigma_s
time-of-arrival resolution [s]
Acoustics hit.
std::vector< input_type > input
Definition JSydney.cc:1395
std::vector< JSuperEvt > output
Definition JSydney.cc:1398
Auxiliary data structure to unify weights of acoustics data according to the number of pings per emit...
double getMean() const
Get mean value.
General purpose class for hash map of unique keys.
Definition JHashMap.hh:75

◆ run()

void JACOUSTICS::JSydney::run ( const std::string & script)
inline

Run.

Parameters
scriptsteering script

Definition at line 1156 of file JSydney.cc.

1157 {
1158 using namespace std;
1159 using namespace JPP;
1160
1161 ifstream in(script.c_str());
1162
1163 while (in) {
1164
1165 string buffer, key;
1166
1167 if (getline(in, buffer)) {
1168
1169 if (buffer.empty() || buffer[0] == skip_t) {
1170 continue;
1171 }
1172
1173 istringstream is(buffer);
1174
1175 is >> key;
1176
1177 if (key == initialise_t) { // set object identifiers
1178
1180
1181 } else if (key == fix_t) { // fix object identifiers
1182
1183 string type; // type of object
1184 ids_t id; // identifiers
1185
1186 if (is >> type >> id) {
1187 if (type == string_t) {
1188 fits.strings .erase(id);
1189 fits.hydrophones .erase(id);
1191 } else if (type == tripod_t) {
1192 fits.tripods .erase(id);
1193 } else {
1194 THROW(JValueOutOfRange, "Invalid type <" << type << ">");
1195 }
1196 }
1197
1198 } else if (key == set_t) { // set coordinates
1199
1200 string type; // type of object
1201 char c; // coordinate
1202 ids_t id; // identifiers
1203
1204 if (is >> type >> c >> id) {
1205
1206 if (c == X_t ||
1207 c == Y_t ||
1208 c == Z_t) {
1209
1210 id.set(c, false);
1211
1212 if (type == string_t) {
1213 fits.strings .set(id, logical_and());
1214 fits.hydrophones .set(id, logical_and());
1215 fits.transmitters.set(id, logical_and());
1216 } else if (type == tripod_t) {
1217 fits.tripods .set(id, logical_and());
1218 } else {
1219 THROW(JValueOutOfRange, "Invalid type <" << type << ">; possible values " << string_t << " or " << tripod_t);
1220 }
1221
1222 } else {
1223 THROW(JValueOutOfRange, "Invalid coordinate <" << c << ">; possible values " << X_t << ", " << Y_t << " or " << Z_t);
1224 }
1225 }
1226
1227 } else if (key == stage_t) { // stage
1228
1229 string stage;
1230 JParameters_t input;
1231
1232 if (is >> stage >> input) {
1233
1234 STATUS("stage " << setw(3) << stage << " {" << input << "}" << endl);
1235
1236 JTimer timer;
1237
1238 timer.start();
1239
1240 ofstream out(MAKE_CSTRING("stage-" << stage << ".log"));
1241
1242 {
1243 JRedirectStream redirect(cout, out);
1244
1245 switch (stage[stage.size() - 1]) {
1246
1247 case '0':
1248 stage_0(input);
1249 break;
1250
1251 case 'a':
1252 case 'A':
1253 stage_a(input);
1254 break;
1255
1256 case 'b':
1257 case 'B':
1258 stage_b(input);
1259 break;
1260
1261 case 'c':
1262 case 'C':
1263 stage_c(input);
1264 break;
1265
1266 case 'd':
1267 case 'D':
1268 stage_d(input);
1269 break;
1270
1271 case 'x':
1272 case 'X':
1273 stage_x(input);
1274 break;
1275
1276 default:
1277 THROW(JValueOutOfRange, "Invalid stage <" << stage << ">");
1278 break;
1279 }
1280 }
1281
1282 out.close();
1283
1284 store(stage);
1285 store();
1286
1287 timer.stop();
1288
1289 STATUS("Elapsed time " << FIXED(12,3) << timer.usec_wall * 1.0e-6 << " s." << endl);
1290 }
1291
1292 } else {
1293 THROW(JValueOutOfRange, "Invalid key <" << key << ">");
1294 }
1295 }
1296 }
1297
1298 in.close();
1299 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define MAKE_CSTRING(A)
Make C-string.
Definition JPrint.hh:57
Auxiliary class for CPU timing and usage.
Definition JTimer.hh:33
unsigned long long usec_wall
Definition JTimer.hh:238
void stop()
Stop timer.
Definition JTimer.hh:127
void start()
Start timer.
Definition JTimer.hh:106
This class can be used to temporarily redirect one output (input) stream to another output (input) st...
Exception for accessing a value in a collection that is outside of its range.
static const std::string string_t
string
Definition JSydney.cc:93
static const std::string tripod_t
tripod
Definition JSydney.cc:94
static const char Z_t
set z-coordinate
Definition JSydney.cc:99
static const std::string set_t
set coordinate of object
Definition JSydney.cc:96
static const std::string initialise_t
initialise
Definition JSydney.cc:91
static const char Y_t
set y-coordinate
Definition JSydney.cc:98
static const char skip_t
Script commands.
Definition JSydney.cc:90
static const char X_t
set x-coordinate
Definition JSydney.cc:97
static const std::string stage_t
fit stage
Definition JSydney.cc:95
static const std::string fix_t
fix objects
Definition JSydney.cc:92
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition JString.hh:478
void erase(const ids_t &B)
Erase elements that are in given list of identifiers.
Definition JSydney.cc:258
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...
Definition JSydney.cc:273
void stage_x(const JParameters_t &parameters)
Fit procedure to determine the (x,y,z) positions of the modules.
Definition JSydney.cc:1031
void store(const std::string &dir=".")
Store data in given directory.
Definition JSydney.cc:1307
void stage_c(const JParameters_t &parameters)
Fit procedure to determine the z-positions of the modules.
Definition JSydney.cc:973
void stage_0(const JParameters_t &parameters)
Fit procedure to determine the positions of tripods and transmitters using strings that are fixed.
Definition JSydney.cc:790
void stage_d(const JParameters_t &parameters)
Fit procedure to determine the z-positions of anchors.
Definition JSydney.cc:999
void stage_b(const JParameters_t &parameters)
Fit procedure to determine the stretching and z-positions of individual strings.
Definition JSydney.cc:907
void stage_a(const JParameters_t &parameters)
Fit procedure to determine the positions of the strings and tripods.
Definition JSydney.cc:863

◆ store()

void JACOUSTICS::JSydney::store ( const std::string & dir = ".")
inline

Store data in given directory.

Parameters
dirdirectory

Definition at line 1307 of file JSydney.cc.

1308 {
1309 using namespace JPP;
1310
1311 if (getFileStatus(dir.c_str()) || (mkdir(dir.c_str(), S_IRWXU | S_IRWXG) != -1)) {
1312
1313 // attach PMTs
1314
1315 for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
1316 module->set(router->getModule(module->getLocation()).getPosition());
1317 }
1318
1320
1322
1323 if (filenames.hydrophone != "") { setup.hydrophones .store(getFilename(dir, filenames.hydrophone) .c_str()); }
1325
1326 } else {
1327
1328 THROW(JValueOutOfRange, "Invalid directory <" << dir << ">");
1329 }
1330 }
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.
static JStat getFileStatus
Function object for file status.
Definition JStat.hh:173
void store(const char *file_name) const
Store to output file.

◆ getReceivers()

ids_t JACOUSTICS::JSydney::getReceivers ( ) const
inline

Get list of identifiers of receivers.

Returns
list of identifiers

Definition at line 1338 of file JSydney.cc.

1339 {
1340 ids_t buffer;
1341
1342 for (JDetector::const_iterator i = setup.detector.begin(); i != setup.detector.end(); ++i) {
1343 if ((i->getFloor() != 0 && !i->has(PIEZO_DISABLE)) || (setup.hydrophones.hasString(i->getString()) && !i->has(HYDROPHONE_DISABLE))) {
1344 buffer.insert(i->getID());
1345 }
1346 }
1347
1348 return buffer;
1349 }
static const int HYDROPHONE_DISABLE
Enable (disable) use of hydrophone if this status bit is 0 (1);.
static const int PIEZO_DISABLE
Enable (disable) use of piezo if this status bit is 0 (1);.

◆ getEmitters()

ids_t JACOUSTICS::JSydney::getEmitters ( ) const
inline

Get list of identifiers of emitters.

Returns
list of identifiers

Definition at line 1357 of file JSydney.cc.

1358 {
1359 using namespace std;
1360
1361 ids_t buffer;
1362
1363 for (tripods_container::const_iterator i = setup.tripods.begin(); i != setup.tripods.end(); ++i) {
1364 buffer.insert(i->getID());
1365 }
1366
1367 for (transmitters_container::const_iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
1368
1369 try {
1370
1371 const JModule& module = router->getModule(i->getLocation());
1372
1373 if (!module.has(TRANSMITTER_DISABLE)) {
1374 buffer.insert(i->getID());
1375 }
1376 }
1377 catch(const exception&) {}
1378 }
1379
1380 return buffer;
1381 }
bool has(const int bit) const
Test PMT status.
Definition JStatus.hh:198
static const int TRANSMITTER_DISABLE
Enable (disable) use of transmitter if this status bit is 0 (1);.

Member Data Documentation

◆ RADIUS_M

double JACOUSTICS::JSydney::RADIUS_M = 1.0
staticconstexpr

maximal horizontal distance between T-bar and emitter/hydrophone

Definition at line 159 of file JSydney.cc.

◆ filenames

JFilenames JACOUSTICS::JSydney::filenames

Definition at line 1384 of file JSydney.cc.

◆ V

JSoundVelocity JACOUSTICS::JSydney::V

Definition at line 1385 of file JSydney.cc.

◆ threads

size_t JACOUSTICS::JSydney::threads

Definition at line 1386 of file JSydney.cc.

◆ debug

int JACOUSTICS::JSydney::debug

Definition at line 1387 of file JSydney.cc.

◆ setup

JSetup JACOUSTICS::JSydney::setup

Definition at line 1388 of file JSydney.cc.

◆ fits

fits_t JACOUSTICS::JSydney::fits

Definition at line 1389 of file JSydney.cc.

◆ receivers

JTOOLS::JHashMap<int, JLocation> JACOUSTICS::JSydney::receivers

Definition at line 1391 of file JSydney.cc.

◆ router

std::unique_ptr<JLocationRouter> JACOUSTICS::JSydney::router

Definition at line 1392 of file JSydney.cc.

◆ input

std::vector<input_type> JACOUSTICS::JSydney::input

Definition at line 1395 of file JSydney.cc.

◆ output

std::vector<JSuperEvt> JACOUSTICS::JSydney::output
mutableprivate

Definition at line 1398 of file JSydney.cc.

◆ detector

JDetector JACOUSTICS::JSydney::detector
private

PMTs.

Definition at line 1400 of file JSydney.cc.

◆ parameters

JFitParameters JACOUSTICS::JSydney::parameters
private

Definition at line 1401 of file JSydney.cc.


The documentation for this struct was generated from the following file: