Jpp 21.0.0
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< JEvent > input_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, JLocation > receivers
 
std::unique_ptr< JLocationRouter > router
 
std::vector< input_type > input
 

Static Public Attributes

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

Private Attributes

std::vector< JSuperEvt > output
 
JDetector detector
 PMTs.
 
JFitParameters parameters
 

Detailed Description

Main class for pre-calibration using acoustics data.

Definition at line 155 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 697 of file JSydney.cc.

701 :
703 V(V),
705 debug(debug)
706 {
707 load(filenames.detector, setup.detector);
708
709 setup.mechanics = mechanics;
710 setup.tripods.load(filenames.tripod.c_str());
711
712 if (filenames.hydrophone != "") { setup.hydrophones .load(filenames.hydrophone .c_str()); }
713 if (filenames.transmitter != "") { setup.transmitters.load(filenames.transmitter.c_str()); }
714
715 for (JDetector::const_iterator i = setup.detector.begin(); i != setup.detector.end(); ++i) {
716 receivers[i->getID()] = i->getLocation();
717 }
718
719 // detach PMTs
720
721 detector = setup.detector;
722
723 for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
724 module->clear();
725 }
726
727 router.reset(new JLocationRouter(setup.detector));
728
730
731 this->V.set(setup.detector.getUTMZ()); // sound velocity at detector depth
732
735
737
738 ROOT::EnableThreadSafety();
739 }
Router for direct addressing of location data in detector data structure.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Definition setup.py:1
Detector file.
Definition JHead.hh:227
std::string transmitter
transmitter
Definition JSydney.cc:121
std::string detector
detector
Definition JSydney.cc:118
std::string hydrophone
hydrophone
Definition JSydney.cc:120
std::string tripod
tripod
Definition JSydney.cc:119
Template definition of fit function of acoustic model.
JSoundVelocity & set(const double z0)
Set depth.
void initialise(const JSetup &setup)
Initialise.
Definition JSydney.cc:359
JFilenames filenames
Definition JSydney.cc:1385
std::unique_ptr< JLocationRouter > router
Definition JSydney.cc:1393
JTOOLS::JHashMap< int, JLocation > receivers
Definition JSydney.cc:1392
JSoundVelocity V
Definition JSydney.cc:1386

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

789 {
790 using namespace std;
791 using namespace JPP;
792
793 this->parameters = parameters;
794
795 JDetector A; // old strings
796 detector_type B; // new strings with transmitter -> fit only base module
797 JDetector C; // new strings w/o transmitter -> discard completely from fit
798
799 for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
800
801 if (fits.strings .count(module->getString()) == 0)
802 A.push_back(*module);
803 else if (fits.transmitters.count(module->getString()) != 0)
804 B.push_back(*module);
805 else
806 C.push_back(*module);
807 }
808
809 setup.detector.swap(A);
810
811 for (const auto& element : B) {
812 setup.detector.push_back(element.second.base);
813 }
814
815 router.reset(new JLocationRouter(setup.detector));
816
817 JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
818
819 for (const auto& i : fits.tripods) {
820 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])); }
821 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])); }
822 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])); }
823 }
824
825 for (const auto& i : fits.transmitters) {
826 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])); }
827 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])); }
828 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])); }
829 }
830
831 const double chi2 = fit(*this);
832
833 for (auto& element : B) {
834
835 const JModule& base = setup.detector.getModule(router->getAddress(JLocation(element.second.base.getString(),0)));
836 const JVector3D pos = base.getPosition() - element.second.base.getPosition();
837
838 for (string_type::iterator module = element.second.begin(); module != element.second.end(); ++module) {
839
840 module->add(pos);
841
842 setup.detector.push_back(*module);
843 }
844 }
845
846 copy(C.begin(), C.end(), back_inserter(setup.detector));
847
848 sort(setup.detector.begin(), setup.detector.end(), make_comparator(&JModule::getLocation));
849
850 router.reset(new JLocationRouter(setup.detector));
851
852 STATUS("detector: " << FIXED(9,4) << chi2 << endl);
853 }
#define STATUS(A)
Definition JMessage.hh:63
#define MAKE_STRING(A)
Make string.
Definition JPrint.hh:48
Detector data structure.
Definition JDetector.hh:96
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:157
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:372
ids_t tripods
identifiers of tripods
Definition JSydney.cc:370
ids_t strings
identifiers of strings
Definition JSydney.cc:369
JFitParameters parameters
Definition JSydney.cc:1402
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 861 of file JSydney.cc.

862 {
863 using namespace std;
864 using namespace JPP;
865
866 this->parameters = parameters;
867
868 JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
869
870 for (const auto& i : fits.strings) {
871 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])); }
872 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])); }
873 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])); }
874 }
875
876 for (const auto& i : fits.tripods) {
877 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])); }
878 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])); }
879 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])); }
880 }
881
882 for (const auto& i : ids_t(fits.hydrophones, fits.transmitters)) {
883 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));
884 }
885
886 for (const auto& i : fits.transmitters) {
887
888 JModule& module = setup.detector.getModule(router->getAddress(JLocation(i.first,0)));
889
890 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)); }
891 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])); }
892 }
893
894 const double chi2 = fit(*this);
895
896 STATUS("detector: " << FIXED(9,4) << chi2 << endl);
897 }
ids_t hydrophones
identifiers of strings with hydrophone
Definition JSydney.cc:371
static constexpr double RADIUS_M
maximal horizontal distance between T-bar and emitter/hydrophone
Definition JSydney.cc:157

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

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

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

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

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

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

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

1030 {
1031 using namespace std;
1032 using namespace JPP;
1033
1034 this->parameters = parameters;
1035
1036 JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
1037
1038 for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
1039
1040 if (fits.strings.count(module->getString()) != 0 && module->getFloor() != 0) {
1041
1042 const fit_t fcc = fits.strings.at(module->getString());
1043
1044 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])); }
1045 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])); }
1046 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])); }
1047 }
1048 }
1049
1050 const double chi2 = fit(*this);
1051
1052 STATUS("detector: " << FIXED(9,4) << chi2 << endl);
1053 }

◆ operator()()

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

Get chi2.

Parameters
optionoption
Returns
chi2/NDF

Definition at line 1062 of file JSydney.cc.

1063 {
1064 using namespace std;
1065 using namespace JPP;
1066
1067 const JGeometry geometry(setup.detector, setup.mechanics, setup.hydrophones);
1068
1069 JHashMap<int, JEmitter> emitters;
1070
1071 for (tripods_container::const_iterator i = setup.tripods.begin(); i != setup.tripods.end(); ++i) {
1072 {
1073 emitters[i->getID()] = JEmitter(i->getID(), i->getUTMPosition() - setup.detector.getUTMPosition());
1074 }
1075 }
1076
1077 for (transmitters_container::const_iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
1078 try {
1079 emitters[i->getID()] = JEmitter(i->getID(), i->getPosition() + router->getModule(i->getLocation()).getPosition());
1080 }
1081 catch(const exception&) {} // if no module available, discard transmitter
1082 }
1083
1084 if (option == 0 || // step wise improvement of the chi2
1085 option == 1) { // evaluation of the chi2 before the determination of the gradient of the chi2
1086
1087 this->output.clear();
1088
1089 JSTDObjectWriter<JSuperEvt> out(this->output); // write data for subsequent use
1090
1091 JFremantle::output = (option == 1 ? &out : NULL);
1092
1093 {
1094 JFremantle fremantle(geometry, V, parameters, threads, 2 * threads);
1095
1096 for (const input_type& superevt : input) {
1097
1098 const JWeight getWeight(superevt.begin(), superevt.end());
1099
1101
1102 for (input_type::const_iterator evt = superevt.begin(); evt != superevt.end(); ++evt) {
1103
1104 if (emitters.has(evt->getID())) {
1105
1106 const JEmitter& emitter = emitters [evt->getID()];
1107 const double weight = getWeight(evt->getID());
1108
1109 for (JEvent::const_iterator i = evt->begin(); i != evt->end(); ++i) {
1110
1111 if (geometry.hasLocation(receivers[i->getID()])) {
1112
1113 data.push_back(JHit(emitter,
1114 distance(superevt.begin(), evt),
1115 receivers[i->getID()],
1116 i->getToA(),
1118 weight));
1119 }
1120 }
1121 }
1122 }
1123
1124 if (getMinimumNumberOfEmitters(data.begin(), data.end()) >= parameters.Nmin) {
1125 fremantle.enqueue(data);
1126 }
1127 }
1128 }
1129
1130 return JFremantle::Q.getMean(numeric_limits<float>::max());
1131
1132 } else if (option == 2) { // evaluation of the derivative of the chi2 to each fit parameter
1133
1134 {
1136
1137 JPlatypus platypus(geometry, emitters, V, parameters, in, threads);
1138 }
1139
1140 return JPlatypus::Q.getMean(numeric_limits<float>::max());
1141
1142 } else {
1143
1144 return numeric_limits<float>::max();
1145 }
1146 }
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.
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:1396
std::vector< JSuperEvt > output
Definition JSydney.cc:1399
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 1154 of file JSydney.cc.

1155 {
1156 using namespace std;
1157 using namespace JPP;
1158
1159 ifstream in(script.c_str());
1160
1161 while (in) {
1162
1163 string buffer, key;
1164
1165 if (getline(in, buffer)) {
1166
1167 if (buffer.empty() || buffer[0] == skip_t) {
1168 continue;
1169 }
1170
1171 istringstream is(buffer);
1172
1173 is >> key;
1174
1175 if (key == initialise_t) { // set object identifiers
1176
1178
1179 } else if (key == fix_t) { // fix object identifiers
1180
1181 string type; // type of object
1182 ids_t id; // identifiers
1183
1184 if (is >> type >> id) {
1185 if (type == string_t) {
1186 fits.strings .erase(id);
1187 fits.hydrophones .erase(id);
1189 } else if (type == tripod_t) {
1190 fits.tripods .erase(id);
1191 } else {
1192 THROW(JValueOutOfRange, "Invalid type <" << type << ">");
1193 }
1194 }
1195
1196 } else if (key == set_t) { // set coordinates
1197
1198 string type; // type of object
1199 char c; // coordinate
1200 ids_t id; // identifiers
1201
1202 if (is >> type >> c >> id) {
1203
1204 if (c == X_t ||
1205 c == Y_t ||
1206 c == Z_t) {
1207
1208 id.set(c, false);
1209
1210 if (type == string_t) {
1211 fits.strings .set(id, logical_and());
1212 fits.hydrophones .set(id, logical_and());
1213 fits.transmitters.set(id, logical_and());
1214 } else if (type == tripod_t) {
1215 fits.tripods .set(id, logical_and());
1216 } else {
1217 THROW(JValueOutOfRange, "Invalid type <" << type << ">; possible values " << string_t << " or " << tripod_t);
1218 }
1219
1220 } else {
1221 THROW(JValueOutOfRange, "Invalid coordinate <" << c << ">; possible values " << X_t << ", " << Y_t << " or " << Z_t);
1222 }
1223 }
1224
1225 } else if (key == stage_t) { // stage
1226
1227 string stage;
1228 JParameters_t input;
1229
1230 if (is >> stage >> input) {
1231
1232 STATUS("stage " << setw(3) << stage << " {" << input << "}" << endl);
1233
1234 JTimer timer;
1235
1236 timer.start();
1237
1238 ofstream out(MAKE_CSTRING("stage-" << stage << ".log"));
1239
1240 {
1241 JRedirectStream redirect(cout, out);
1242
1243 switch (stage[stage.size() - 1]) {
1244
1245 case '0':
1246 stage_0(input);
1247 break;
1248
1249 case 'a':
1250 case 'A':
1251 stage_a(input);
1252 break;
1253
1254 case 'b':
1255 case 'B':
1256 stage_b(input);
1257 break;
1258
1259 case 'c':
1260 case 'C':
1261 stage_c(input);
1262 break;
1263
1264 case 'd':
1265 case 'D':
1266 stage_d(input);
1267 break;
1268
1269 case 'x':
1270 case 'X':
1271 stage_x(input);
1272 break;
1273
1274 default:
1275 THROW(JValueOutOfRange, "Invalid stage <" << stage << ">");
1276 break;
1277 }
1278 }
1279
1280 out.close();
1281
1282 store(stage);
1283 store();
1284
1285 timer.stop();
1286
1287 STATUS("Elapsed time " << FIXED(12,3) << timer.usec_wall * 1.0e-6 << " s." << endl);
1288 }
1289
1290 } else {
1291 THROW(JValueOutOfRange, "Invalid key <" << key << ">");
1292 }
1293 }
1294 }
1295
1296 in.close();
1297 }
#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:91
static const std::string tripod_t
tripod
Definition JSydney.cc:92
static const char Z_t
set z-coordinate
Definition JSydney.cc:97
static const std::string set_t
set coordinate of object
Definition JSydney.cc:94
static const std::string initialise_t
initialise
Definition JSydney.cc:89
static const char Y_t
set y-coordinate
Definition JSydney.cc:96
static const char skip_t
Script commands.
Definition JSydney.cc:88
static const char X_t
set x-coordinate
Definition JSydney.cc:95
static const std::string stage_t
fit stage
Definition JSydney.cc:93
static const std::string fix_t
fix objects
Definition JSydney.cc:90
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:256
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:271
void stage_x(const JParameters_t &parameters)
Fit procedure to determine the (x,y,z) positions of the modules.
Definition JSydney.cc:1029
void store(const std::string &dir=".")
Store data in given directory.
Definition JSydney.cc:1305
void stage_c(const JParameters_t &parameters)
Fit procedure to determine the z-positions of the modules.
Definition JSydney.cc:971
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:788
void stage_d(const JParameters_t &parameters)
Fit procedure to determine the z-positions of anchors.
Definition JSydney.cc:997
void stage_b(const JParameters_t &parameters)
Fit procedure to determine the stretching and z-positions of individual strings.
Definition JSydney.cc:905
void stage_a(const JParameters_t &parameters)
Fit procedure to determine the positions of the strings and tripods.
Definition JSydney.cc:861

◆ store()

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

Store data in given directory.

Parameters
dirdirectory

Definition at line 1305 of file JSydney.cc.

1306 {
1307 using namespace std;
1308 using namespace JPP;
1309
1310 error_code error;
1311
1312 if (filesystem::is_directory(dir, error) || filesystem::create_directory(dir)) {
1313
1314 // attach PMTs
1315
1316 for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
1317 module->set(router->getModule(module->getLocation()).getPosition());
1318 }
1319
1321
1322 setup.tripods.store(getFilename(dir, filenames.tripod).c_str());
1323
1324 if (filenames.hydrophone != "") { setup.hydrophones .store(getFilename(dir, filenames.hydrophone) .c_str()); }
1325 if (filenames.transmitter != "") { setup.transmitters.store(getFilename(dir, filenames.transmitter).c_str()); }
1326
1327 } else {
1328
1329 THROW(JValueOutOfRange, "Invalid directory <" << dir << ">");
1330 }
1331 }
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.

◆ getReceivers()

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

Get list of identifiers of receivers.

Returns
list of identifiers

Definition at line 1339 of file JSydney.cc.

1340 {
1341 ids_t buffer;
1342
1343 for (JDetector::const_iterator i = setup.detector.begin(); i != setup.detector.end(); ++i) {
1344 if ((i->getFloor() != 0 && !i->has(PIEZO_DISABLE)) || (setup.hydrophones.hasString(i->getString()) && !i->has(HYDROPHONE_DISABLE))) {
1345 buffer.insert(i->getID());
1346 }
1347 }
1348
1349 return buffer;
1350 }
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 1358 of file JSydney.cc.

1359 {
1360 using namespace std;
1361
1362 ids_t buffer;
1363
1364 for (tripods_container::const_iterator i = setup.tripods.begin(); i != setup.tripods.end(); ++i) {
1365 buffer.insert(i->getID());
1366 }
1367
1368 for (transmitters_container::const_iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
1369
1370 try {
1371
1372 const JModule& module = router->getModule(i->getLocation());
1373
1374 if (!module.has(TRANSMITTER_DISABLE)) {
1375 buffer.insert(i->getID());
1376 }
1377 }
1378 catch(const exception&) {}
1379 }
1380
1381 return buffer;
1382 }
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 157 of file JSydney.cc.

◆ filenames

JFilenames JACOUSTICS::JSydney::filenames

Definition at line 1385 of file JSydney.cc.

◆ V

JSoundVelocity JACOUSTICS::JSydney::V

Definition at line 1386 of file JSydney.cc.

◆ threads

size_t JACOUSTICS::JSydney::threads

Definition at line 1387 of file JSydney.cc.

◆ debug

int JACOUSTICS::JSydney::debug

Definition at line 1388 of file JSydney.cc.

◆ setup

JSetup JACOUSTICS::JSydney::setup

Definition at line 1389 of file JSydney.cc.

◆ fits

fits_t JACOUSTICS::JSydney::fits

Definition at line 1390 of file JSydney.cc.

◆ receivers

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

Definition at line 1392 of file JSydney.cc.

◆ router

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

Definition at line 1393 of file JSydney.cc.

◆ input

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

Definition at line 1396 of file JSydney.cc.

◆ output

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

Definition at line 1399 of file JSydney.cc.

◆ detector

JDetector JACOUSTICS::JSydney::detector
private

PMTs.

Definition at line 1401 of file JSydney.cc.

◆ parameters

JFitParameters JACOUSTICS::JSydney::parameters
private

Definition at line 1402 of file JSydney.cc.


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