101 JParser<> zap(
"Example application to test fit of model to acoustic data.");
106 zap[
'N'] =
make_field(numberOfCycles,
"number of cycles per emitter") = 10;
108 zap[
'T'] =
make_field(tripods,
"tripod data");
116 catch(
const exception &error) {
117 FATAL(error.what() << endl);
123 gRandom->SetSeed(seed);
125 const double sigma_s = 1.0e-5;
126 const double P_bg = 1.0e-4;
129 if (numberOfEvents <= 0) {
FATAL(
"Invalid number of events " << numberOfEvents << endl); }
130 if (numberOfCycles <= 0) {
FATAL(
"Invalid number of cycles " << numberOfCycles << endl); }
144 emitters.push_back(
JEmitter(i->getID(), i->getUTMPosition() -
detector.getUTMPosition()));
147 if (
detector.empty()) {
FATAL(
"No modules in detector." << endl); }
148 if (emitters.empty()) {
FATAL(
"No emitters in system." << endl); }
156 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
157 buffer[module->getString()].push_back(module_type(module->getLocation(), module->getPosition()));
166 if (p != bases.end()) {
168 p0 = p->getPosition();
170 }
else if (i->second.size() >= 2) {
172 sort(i->second.begin(), i->second.end());
175 const module_type&
p1 = i->second[0];
183 slope /= (double) (i->second.size() - 1);
187 p0 = p1 + (z0 - p1.getZ()) * slope;
191 FATAL(
"Invalid data for string " << i->first << endl);
197 << setw(4) << i->first <<
' '
201 << (p != bases.end() ?
"user":
"calculated") << endl);
221 TH1D h0(
"cpu", NULL, 100, 1.0, 7.0);
222 TH1D
h1(
"chi2/NDF", NULL, 100, 0.0, 5.0);
225 JManager<int, TH2D> H2(
new TH2D(
"string[%]", NULL, 100, -2.0e-4, +2.0e-4, 100, -2.0e-4, +2.0e-4));
230 for (
int number_of_events = 0,
count = 0; number_of_events != numberOfEvents; ++number_of_events) {
232 STATUS(
"event: " << setw(10) << number_of_events <<
'\r');
DEBUG(endl);
236 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
241 gRandom->Uniform(-1.0e-2, +1.0e-2));
248 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
249 module->set(estimator.detector[module->getString()].getPosition(model.
string[module->getString()], module->getFloor()));
259 for (
int number_of_cycles = 0; number_of_cycles != numberOfCycles; ++number_of_cycles) {
263 const double toe_s = number_of_cycles * 10.0 + gRandom->Uniform(-1.0, +1.0);
267 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
269 const double toa_s = toe_s + V.getTime(module->getDistance(emitter->getPosition()), emitter->getZ(), module->getZ());
273 if (gRandom->Rndm() >= P_bg)
274 t1_s = gRandom->Gaus(toa_s, sigma_s);
276 t1_s = gRandom->Uniform(toa_s + T_s.getLowerLimit(),
277 toa_s + T_s.getUpperLimit());
279 data.push_back(hit_type(*emitter,
281 module->getLocation(),
287 DEBUG(
"Model" << endl << model << endl);
290 DEBUG(
"hit: " << *hit << endl);
298 double chi2 = evaluator(result, data.begin(), data.end());
303 DEBUG(
"Final values" << endl
304 <<
FIXED(9,3) << chi2 <<
'/'
305 << data.size() - model.
getN() << endl
309 h0.Fill(log10((
double) timer.usec_wall));
310 h1.Fill(2.0 * chi2 / (
double) (data.size() - model.
getN()));
313 H2[i->first]->Fill(i->second.tx - result.
string [i->first].tx,
314 i->second.ty - result.
string [i->first].ty);
318 H1[i->first.getID()]->Fill(i->second.t1 - result.
emitter[i->first].t1);
Utility class to parse command line options.
size_t getN() const
Get number of fit parameters.
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
std::vector< T >::const_iterator const_iterator
Template specialisation of fit function of acoustic model based on linear approximation.
JPosition3D hydrophone
Hydrophone.
then for HISTOGRAM in h0 h1
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary data structure for floating point format specification.
double getDistance(const JVector3D &pos) const
Get distance to point.
JACOUSTICS::JModel::emitter_map emitter
Auxiliary class to manage set of compatible ROOT objects (e.g.
Model for fit to acoustics data.
JACOUSTICS::JModel::string_map string
static const JSoundVelocity getSoundVelocity(1541.0,-17.0e-3,-2000.0)
Function object for velocity of sound.
Data structure for vector in three dimensions.
Auxiliary container for detector elements.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Auxiliary class for CPU timing and usage.
double getY() const
Get y position.
void load(const JString &file_name, JDetector &detector)
Load detector from input file.
Implementation for velocity of sound.
Template specialisation of fit function of acoustic model based on JAbstractMinimiser minimiser...
double getX() const
Get x position.
Custom probability density function of time-of-arrival.
Data structure for position in three dimensions.
JMEstimator * getMEstimator(const int type)
Get M-Estimator.
static const double TBARZ_M
T-bar position relative to seabed [m].
double getZ() const
Get z position.
#define DEBUG(A)
Message macros.