Jpp  18.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Private Types | Private Attributes | List of all members
JACOUSTICS::JSydney Struct Reference

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

Classes

struct  fits_t
 Auxiliary data structure for group of lists of identifiers of to-be-fitted objects. More...
 
struct  ids_t
 List of identifiers. More...
 
struct  JAnchorEditor
 Auxiliary class to edit rotation 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...
 

Public Types

typedef std::vector< JEventievt_type
 
typedef std::vector< ievt_typeidat_type
 

Public Member Functions

 JSydney (const JFilenames &filenames, const JSoundVelocity &V, const size_t jobs, const int debug)
 Constructor. More...
 
void stage_0 (const JParameters_t &parameters)
 Fit procedure to determine the positions of tripods using strings that are fixed. More...
 
void stage_a (const JParameters_t &parameters)
 Fit procedure to determine the positions of the strings and tripods. More...
 
void stage_b (const JParameters_t &parameters)
 Fit procedure to determine the stretching and z-positions of individual strings. More...
 
void stage_c (const JParameters_t &parameters)
 Fit procedure to determine the z-positions of the modules. More...
 
double operator() (const int option) const
 Get chi2. More...
 
void run (const std::string &script)
 Run. More...
 
void store (const std::string &dir=".")
 Store data in given directory. More...
 

Public Attributes

JFilenames filenames
 
JSoundVelocity V
 
size_t jobs
 
int debug
 
JSetup setup
 
fits_t fits
 
JTOOLS::JHashMap< int, JLocationreceivers
 
std::unique_ptr< JLocationRouterrouter
 
idat_type idat
 

Static Public Attributes

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

Private Types

typedef std::vector< JSuperEvtodat_type
 

Private Attributes

odat_type odat
 
JDetector detector
 PMTs. More...
 
JFitParameters parameters
 

Detailed Description

Main class for pre-calibration using acoustics data.

Definition at line 126 of file JSydney.cc.

Member Typedef Documentation

Definition at line 1017 of file JSydney.cc.

Definition at line 1018 of file JSydney.cc.

Definition at line 1023 of file JSydney.cc.

Constructor & Destructor Documentation

JACOUSTICS::JSydney::JSydney ( const JFilenames filenames,
const JSoundVelocity V,
const size_t  jobs,
const int  debug 
)
inline

Constructor.

Parameters
filenamesfile names
Vsound velocity
jobsjobs
debugdebug

Definition at line 561 of file JSydney.cc.

564  :
565  filenames(filenames),
566  V(V),
567  jobs(jobs),
568  debug(debug)
569  {
570  load(filenames.detector, setup.detector);
571 
572  setup.tripods.load(filenames.tripod.c_str());
573 
574  if (filenames.hydrophone != "") { setup.hydrophones .load(filenames.hydrophone .c_str()); }
575  if (filenames.transmitter != "") { setup.transmitters.load(filenames.transmitter.c_str()); }
576 
577  for (JDetector::const_iterator i = setup.detector.begin(); i != setup.detector.end(); ++i) {
578  receivers[i->getID()] = i->getLocation();
579  }
580 
581  // detach PMTs
582 
584 
585  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
586  module->clear();
587  }
588 
589  router.reset(new JLocationRouter(setup.detector));
590 
592 
593  this->V.set(setup.detector.getUTMZ()); // sound velocity at detector depth
594 
597 
599 
600  ROOT::EnableThreadSafety();
601  }
void initialise(const JSetup &setup)
Initialise.
Definition: JSydney.cc:238
JDetector detector
detector
Definition: JSydney.cc:101
std::string detector
detector
Definition: JSydney.cc:90
tripods_container tripods
tripods
Definition: JSydney.cc:102
transmitters_container transmitters
transmitters
Definition: JSydney.cc:119
double getUTMZ() const
Get UTM Z.
hydrophones
hydrophones
std::string hydrophone
hydrophone
Definition: JSydney.cc:92
Detector file.
Definition: JHead.hh:226
Router for direct addressing of location data in detector data structure.
JFilenames filenames
Definition: JSydney.cc:1007
JSoundVelocity V
Definition: JSydney.cc:1008
void load(const char *file_name)
Load from input file.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
JTOOLS::JHashMap< int, JLocation > receivers
Definition: JSydney.cc:1014
std::string tripod
tripod
Definition: JSydney.cc:91
std::string transmitter
transmitter
Definition: JSydney.cc:93
JSoundVelocity & set(const double z0)
Set depth.
std::unique_ptr< JLocationRouter > router
Definition: JSydney.cc:1015
Template definition of fit function of acoustic model.
Definition: JKatoomba_t.hh:75

Member Function Documentation

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

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

Parameters
parametersparameters

Definition at line 609 of file JSydney.cc.

610  {
611  using namespace std;
612  using namespace JPP;
613 
614  this->parameters = parameters;
615 
616  JDetector buffer[2];
617 
618  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
619 
620  if (fits.strings.count(module->getString()) != 0)
621  buffer[0].push_back(*module); // new strings
622  else
623  buffer[1].push_back(*module); // old strings
624  }
625 
626  setup.detector.swap(buffer[1]);
627 
628  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
629 
630  for (const int i : fits.tripods) {
631  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "tripod.x: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3X_t), parameters.steps[0]));
632  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "tripod.y: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Y_t), parameters.steps[0]));
633  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "tripod.z: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Z_t), parameters.steps[0]));
634  }
635 
636  const double chi2 = fit(*this);
637 
638  copy(buffer[0].begin(), buffer[0].end(), back_inserter(setup.detector));
639 
640  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
641  }
JDetector detector
detector
Definition: JSydney.cc:101
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
static const JVector3D JVector3X_t(1, 0, 0)
unit x-vector
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:127
Auxiliary data structure for editable parameter.
Definition: JGradient.hh:47
JFitParameters parameters
Definition: JSydney.cc:1027
static const JVector3D JVector3Z_t(0, 0, 1)
unit z-vector
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
Definition: JMatrixNZ.sh:106
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
static const JVector3D JVector3Y_t(0, 1, 0)
unit y-vector
Conjugate gradient fit.
Definition: JGradient.hh:73
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 649 of file JSydney.cc.

650  {
651  using namespace std;
652  using namespace JPP;
653 
654  this->parameters = parameters;
655 
656  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
657 
658  for (const int i : fits.strings) {
659  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "string.x: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3X_t, true), parameters.steps[0]));
660  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "string.y: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3Y_t, true), parameters.steps[0]));
661  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "string.z: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3Z_t, false), parameters.steps[0]));
662  }
663 
664  for (const int i : fits.tripods) {
665  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "tripod.x: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3X_t), parameters.steps[1]));
666  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "tripod.y: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Y_t), parameters.steps[1]));
667  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "tripod.z: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Z_t), parameters.steps[1]));
668  }
669 
670  for (const int i : ids_t(fits.hydrophones, fits.transmitters)) {
671  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "anchor.R: " << RIGHT(4) << i), new JAnchorEditor(setup, i), parameters.steps[0] / RADIUS_M));
672  }
673 
674  for (const int i : fits.transmitters) {
675 
676  JModule& module = setup.detector.getModule(router->getAddress(JLocation(i,0)));
677 
678  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "anchor.R: " << RIGHT(4) << i), new JAnchorEditor(setup, i), parameters.steps[0] / RADIUS_M));
679  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "anchor.z: " << RIGHT(4) << i), new JModuleEditor(module), parameters.steps[0]));
680  }
681 
682  const double chi2 = fit(*this);
683 
684  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
685  }
JDetector detector
detector
Definition: JSydney.cc:101
Data structure for a composite optical module.
Definition: JModule.hh:68
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
static const JVector3D JVector3X_t(1, 0, 0)
unit x-vector
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:127
Logical location of module.
Definition: JLocation.hh:37
ids_t transmitters
transmitters
Definition: JSydney.cc:251
const JModule & getModule(const JModuleAddress &address) const
Get module parameters.
Definition: JDetector.hh:270
Auxiliary data structure for editable parameter.
Definition: JGradient.hh:47
JFitParameters parameters
Definition: JSydney.cc:1027
ids_t hydrophones
hydrophones
Definition: JSydney.cc:250
static const JVector3D JVector3Z_t(0, 0, 1)
unit z-vector
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
Definition: JMatrixNZ.sh:106
static const JVector3D JVector3Y_t(0, 1, 0)
unit y-vector
Conjugate gradient fit.
Definition: JGradient.hh:73
static constexpr double RADIUS_M
maximal horizontal distance between T-bar and emitter/hydrophone
Definition: JSydney.cc:128
std::unique_ptr< JLocationRouter > router
Definition: JSydney.cc:1015
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 693 of file JSydney.cc.

694  {
695  using namespace std;
696  using namespace JPP;
697 
698  this->parameters = parameters;
699 
700  map<int, JDetector> buffer;
701 
702  double z0 = 0.0;
703 
704  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
705 
706  buffer[module->getString()].push_back(*module);
707 
708  if (module->getZ() > z0) {
709  z0 = module->getZ();
710  }
711  }
712 
713  setup.detector.clear();
714 
715  for (const int i : fits.strings) {
716 
717  setup.detector.swap(buffer[i]);
718 
719  router.reset(new JLocationRouter(setup.detector));
720 
721  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
722 
723  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "string.M: " << RIGHT(4) << i), new JDyneemaEditor(setup, i, z0), parameters.steps[0]));
724  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "string.z: " << RIGHT(4) << i), new JStringEditor (setup, i, JVector3Z_t, false), parameters.steps[1]));
725 
726  const double chi2 = fit(*this);
727 
728  STATUS("string: " << setw(4) << i << ' ' << FIXED(9,4) << chi2 << endl);
729 
730  setup.detector.swap(buffer[i]);
731  }
732 
733  setup.detector.clear();
734 
735  for (const auto& detector : buffer) {
736  copy(detector.second.begin(), detector.second.end(), back_inserter(setup.detector));
737  }
738 
739  router.reset(new JLocationRouter(setup.detector));
740  }
JDetector detector
detector
Definition: JSydney.cc:101
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:127
Detector file.
Definition: JHead.hh:226
Router for direct addressing of location data in detector data structure.
Auxiliary data structure for editable parameter.
Definition: JGradient.hh:47
JFitParameters parameters
Definition: JSydney.cc:1027
static const JVector3D JVector3Z_t(0, 0, 1)
unit z-vector
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
Definition: JMatrixNZ.sh:106
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
Conjugate gradient fit.
Definition: JGradient.hh:73
std::unique_ptr< JLocationRouter > router
Definition: JSydney.cc:1015
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 748 of file JSydney.cc.

749  {
750  using namespace std;
751  using namespace JPP;
752 
753  this->parameters = parameters;
754 
755  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
756 
757  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
758  if (fits.strings.count(module->getString()) != 0 && module->getFloor() != 0) {
759  fit.push_back(JModifier_t(MAKE_STRING(LEFT(12) << "module.z: " << right << module->getLocation()), new JModuleEditor(*module), parameters.steps[0]));
760  }
761  }
762 
763  const double chi2 = fit(*this);
764 
765  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
766  }
JDetector detector
detector
Definition: JSydney.cc:101
#define STATUS(A)
Definition: JMessage.hh:63
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:127
Auxiliary data structure for editable parameter.
Definition: JGradient.hh:47
JFitParameters parameters
Definition: JSydney.cc:1027
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
Definition: JMatrixNZ.sh:106
Conjugate gradient fit.
Definition: JGradient.hh:73
double JACOUSTICS::JSydney::operator() ( const int  option) const
inline

Get chi2.

Parameters
optionoption
Returns
chi2/NDF

Definition at line 775 of file JSydney.cc.

776  {
777  using namespace std;
778  using namespace JPP;
779 
780  const JGeometry geometry(setup.detector, setup.hydrophones);
781 
782  JHashMap<int, JEmitter> emitters;
783 
784  for (tripods_container::const_iterator i = setup.tripods.begin(); i != setup.tripods.end(); ++i) {
785  {
786  emitters[i->getID()] = JEmitter(i->getID(), i->getUTMPosition() - setup.detector.getUTMPosition());
787  }
788  }
789 
790  for (transmitters_container::const_iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
791  try {
792  emitters[i->getID()] = JEmitter(i->getID(), i->getPosition() + router->getModule(i->getLocation()).getPosition());
793  }
794  catch(const exception&) {} // if no module available, discard transmitter
795  }
796 
797  if (option == 0 || // step wise improvement of the chi2
798  option == 1) { // evaluation of the chi2 before the determination of the gradient of the chi2
799 
800  JSTDObjectWriter<JSuperEvt> out(this->odat); // storage of data for subsequent use
801 
802  this->odat.clear();
803 
804  JFremantle::output = (option == 1 ? &out : NULL);
805 
806  {
807  JFremantle fremantle(geometry, V, parameters, jobs);
808 
809  for (idat_type::const_iterator superevt = idat.begin(); superevt != idat.end(); ++superevt) {
810 
811  const JWeight getWeight(superevt->begin(), superevt->end());
812 
813  set<int> counter;
815 
816  for (ievt_type::const_iterator evt = superevt->begin(); evt != superevt->end(); ++evt) {
817 
818  const JEmitter& emitter = emitters [evt->getID()];
819  const double weight = getWeight(evt->getID());
820 
821  for (JEvent::const_iterator i = evt->begin(); i != evt->end(); ++i) {
822 
823  if (geometry.hasLocation(receivers[i->getID()])) {
824 
825  data.push_back(JHit(emitter,
826  distance(superevt->begin(), evt),
827  receivers[i->getID()],
828  i->getToA(),
830  weight));
831 
832  counter.insert(evt->getID());
833  }
834  }
835  }
836 
837  if (counter.size() >= parameters.Nmin) {
838  fremantle.enqueue(data);
839  }
840  }
841  }
842 
843  return JFremantle::Q.getMean(numeric_limits<float>::max());
844 
845  } else if (option == 2) { // evaluation of the derivative of the chi2 to each fit parameter
846 
847  {
848  JPlatypus platypus(geometry, emitters, V, parameters, jobs);
849 
850  for (odat_type::const_iterator superevt = odat.begin(); superevt != odat.end(); ++superevt) {
851  platypus.enqueue(*superevt);
852  }
853  }
854 
855  return JPlatypus::Q.getMean(numeric_limits<float>::max());
856 
857  } else {
858 
859  return numeric_limits<float>::max();
860  }
861  }
JDetector detector
detector
Definition: JSydney.cc:101
double getWeight(T __begin, T __end)
Get total weight of data points.
Definition: JKatoomba_t.hh:59
const JUTMPosition & getUTMPosition() const
Get UTM position.
Definition: JUTMPosition.hh:84
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
JVector3D getPosition(T __begin, T __end, const JPredicate< JTypename_t, JComparator_t > &predicate)
Get position from element in data which corresponds to given predicate.
General purpose class for hash map of unique keys.
Definition: JHashMap.hh:72
Auxiliary data structure to unify weights of acoustics data according to the number of pings per emit...
tripods_container tripods
tripods
Definition: JSydney.cc:102
transmitters_container transmitters
transmitters
Definition: JSydney.cc:119
double getMean() const
Get mean value.
Definition: JQuantile.hh:252
Acoustics hit.
size_t Nmin
minimum number of emitters
hydrophones
hydrophones
Implementation of object output from STD container.
Acoustic emitter.
Definition: JEmitter.hh:27
JSoundVelocity V
Definition: JSydney.cc:1008
static JTOOLS::JQuantile Q
chi2/NDF
Definition: JPlatypus_t.hh:171
Thread pool for global fits.
Definition: JPlatypus_t.hh:34
static output_type * output
optional output
JFitParameters parameters
Definition: JSydney.cc:1027
JTOOLS::JHashMap< int, JLocation > receivers
Definition: JSydney.cc:1014
Thread pool for global fits.
Definition: JFremantle_t.hh:34
double sigma_s
time-of-arrival resolution [s]
static JTOOLS::JQuantile Q
chi2/NDF
std::unique_ptr< JLocationRouter > router
Definition: JSydney.cc:1015
void JACOUSTICS::JSydney::run ( const std::string script)
inline

Run.

Parameters
scriptsteering script

Definition at line 869 of file JSydney.cc.

870  {
871  using namespace std;
872  using namespace JPP;
873 
874  ifstream in(script.c_str());
875 
876  while (in) {
877 
878  string key, value;
879 
880  if (in >> key) {
881 
882  if (key == initialise_t) { // set object identifiers
883 
885 
886  } else if (key == fix_t) { // fix object identifiers
887 
888  getline(in, value);
889 
890  istringstream is(value);
891 
892  string type; // type of object
893  ids_t id; // identifiers
894 
895  if (is >> type >> id) {
896  if (type == string_t) {
897  fits.strings .fix(id);
898  fits.hydrophones .fix(id);
899  fits.transmitters.fix(id);
900  } else if (type == tripod_t) {
901  fits.tripods .fix(id);
902  } else {
903  THROW(JValueOutOfRange, "Invalid type <" << type << ">");
904  }
905  }
906 
907  } else if (key == stage_t) { // stage
908 
909  getline(in, value);
910 
911  istringstream is(value);
912 
913  string stage;
914  JParameters_t input;
915 
916  if (is >> stage >> input) {
917 
918  STATUS("stage " << setw(3) << stage << " {" << input << "}" << endl);
919 
920  JTimer timer;
921 
922  timer.start();
923 
924  ofstream out(MAKE_CSTRING("stage-" << stage << ".log"));
925 
926  {
927  JRedirectStream redirect(cout, out);
928 
929  switch (stage[stage.size() - 1]) {
930 
931  case '0':
932  stage_0(input);
933  break;
934 
935  case 'a':
936  case 'A':
937  stage_a(input);
938  break;
939 
940  case 'b':
941  case 'B':
942  stage_b(input);
943  break;
944 
945  case 'c':
946  case 'C':
947  stage_c(input);
948  break;
949 
950  default:
951  THROW(JValueOutOfRange, "Invalid stage <" << stage << ">");
952  break;
953  }
954  }
955 
956  out.close();
957 
958  store(stage);
959  store();
960 
961  timer.stop();
962 
963  STATUS("Elapsed time " << FIXED(12,3) << timer.usec_wall * 1.0e-6 << " s." << endl);
964  }
965 
966  } else {
967  THROW(JValueOutOfRange, "Invalid key <" << key << ">");
968  }
969  }
970  }
971 
972  in.close();
973  }
void initialise(const JSetup &setup)
Initialise.
Definition: JSydney.cc:238
void stage_b(const JParameters_t &parameters)
Fit procedure to determine the stretching and z-positions of individual strings.
Definition: JSydney.cc:693
void stage_a(const JParameters_t &parameters)
Fit procedure to determine the positions of the strings and tripods.
Definition: JSydney.cc:649
$WORKDIR stage
static const std::string fix_t
fix objects
Definition: JSydney.cc:80
#define STATUS(A)
Definition: JMessage.hh:63
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
is
Definition: JDAQCHSM.chsm:167
void stop()
Stop timer.
Definition: JTimer.hh:113
static const std::string stage_t
fit stage
Definition: JSydney.cc:83
static const std::string tripod_t
tripod
Definition: JSydney.cc:82
void store(const std::string &dir=".")
Store data in given directory.
Definition: JSydney.cc:981
This class can be used to temporarily redirect one output (input) stream to another output (input) st...
void fix(const ids_t &B)
Fix.
Definition: JSydney.cc:173
ids_t transmitters
transmitters
Definition: JSydney.cc:251
Auxiliary class for CPU timing and usage.
Definition: JTimer.hh:32
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
void stage_c(const JParameters_t &parameters)
Fit procedure to determine the z-positions of the modules.
Definition: JSydney.cc:748
ids_t hydrophones
hydrophones
Definition: JSydney.cc:250
static const std::string initialise_t
initialise
Definition: JSydney.cc:79
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:178
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
script
Definition: JAcoustics.sh:2
void stage_0(const JParameters_t &parameters)
Fit procedure to determine the positions of tripods using strings that are fixed. ...
Definition: JSydney.cc:609
unsigned long long usec_wall
Definition: JTimer.hh:224
void start()
Start timer.
Definition: JTimer.hh:89
static const std::string string_t
string
Definition: JSydney.cc:81
void JACOUSTICS::JSydney::store ( const std::string dir = ".")
inline

Store data in given directory.

Parameters
dirdirectory

Definition at line 981 of file JSydney.cc.

982  {
983  using namespace JPP;
984 
985  if (getFileStatus(dir.c_str()) || (mkdir(dir.c_str(), S_IRWXU | S_IRWXG) != -1)) {
986 
987  // attach PMTs
988 
989  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
990  module->set(router->getModule(module->getLocation()).getPosition());
991  }
992 
994 
996 
997  if (filenames.hydrophone != "") { setup.hydrophones .store(getFilename(dir, filenames.hydrophone) .c_str()); }
999 
1000  } else {
1001 
1002  THROW(JValueOutOfRange, "Invalid directory <" << dir << ">");
1003  }
1004  }
std::string detector
detector
Definition: JSydney.cc:90
JVector3D getPosition(T __begin, T __end, const JPredicate< JTypename_t, JComparator_t > &predicate)
Get position from element in data which corresponds to given predicate.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
tripods_container tripods
tripods
Definition: JSydney.cc:102
transmitters_container transmitters
transmitters
Definition: JSydney.cc:119
hydrophones
hydrophones
std::string hydrophone
hydrophone
Definition: JSydney.cc:92
Detector file.
Definition: JHead.hh:226
JFilenames filenames
Definition: JSydney.cc:1007
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
void store(const char *file_name) const
Store to output file.
std::string tripod
tripod
Definition: JSydney.cc:91
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:128
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:178
std::string transmitter
transmitter
Definition: JSydney.cc:93
std::unique_ptr< JLocationRouter > router
Definition: JSydney.cc:1015

Member Data Documentation

constexpr double JACOUSTICS::JSydney::RADIUS_M = 1.0
static

maximal horizontal distance between T-bar and emitter/hydrophone

Definition at line 128 of file JSydney.cc.

JFilenames JACOUSTICS::JSydney::filenames

Definition at line 1007 of file JSydney.cc.

JSoundVelocity JACOUSTICS::JSydney::V

Definition at line 1008 of file JSydney.cc.

size_t JACOUSTICS::JSydney::jobs

Definition at line 1009 of file JSydney.cc.

int JACOUSTICS::JSydney::debug

Definition at line 1010 of file JSydney.cc.

JSetup JACOUSTICS::JSydney::setup

Definition at line 1011 of file JSydney.cc.

fits_t JACOUSTICS::JSydney::fits

Definition at line 1012 of file JSydney.cc.

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

Definition at line 1014 of file JSydney.cc.

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

Definition at line 1015 of file JSydney.cc.

idat_type JACOUSTICS::JSydney::idat

Definition at line 1020 of file JSydney.cc.

odat_type JACOUSTICS::JSydney::odat
mutableprivate

Definition at line 1024 of file JSydney.cc.

JDetector JACOUSTICS::JSydney::detector
private

PMTs.

Definition at line 1026 of file JSydney.cc.

JFitParameters JACOUSTICS::JSydney::parameters
private

Definition at line 1027 of file JSydney.cc.


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