61{
64
70
71 string detectorFile;
73 int numberOfEvents;
82 bool unify;
83 disable_container disable;
84 waveform_container waveforms;
85 double background;
86 ULong_t seed;
88
89 numberOfPings[
WILDCARD] = NUMBER_OF_PINGS;
90 waveforms [
WILDCARD] = EMITTER_WAVEFORM;
91
92 try {
93
94 JParser<> zap(
"Example application to test fit of model to simulated acoustic data.");
95
102 zap[
'T'] =
make_field(tripods,
"tripod data");
105 zap[
'u'] =
make_field(unify,
"unify weighing of pings");
109 zap[
'B'] =
make_field(background,
"background probability") = 0.0;
112
113 zap(argc, argv);
114 }
115 catch(const exception &error) {
116 FATAL(error.what() << endl);
117 }
118
119
120 gRandom->SetSeed(seed);
121
122 if (numberOfEvents <= 0) {
FATAL(
"Invalid number of events " << numberOfEvents << endl); }
123
125
126 try {
128 }
131 }
132
134
135 for (tripods_container::const_iterator i = tripods.begin(); i != tripods.end(); ++i) {
136 emitters.push_back(
JEmitter(i->getID(),
137 i->getUTMPosition() -
detector.getUTMPosition()));
138 }
139
140 for (transmitters_container::const_iterator i = transmitters.begin(); i != transmitters.end(); ++i) {
141 try {
142 emitters.push_back(
JEmitter(i->getID(),
143 i->getPosition() +
detector.getModule(i->getLocation()).getPosition()));
144 }
145 catch(const exception&) {
146 continue;
147 }
148 }
149
150 if (
detector.empty()) {
FATAL(
"No modules in detector." << endl); }
151 if (emitters.empty()) {
FATAL(
"No emitters in system." << endl); }
152
153
155
156 const double D_m = -
detector.getUTMZ();
157
160
163
165
167
168
169 TH1D h0("cpu", NULL, 100, 0.0, 1.0e3);
170 TH1D h1("chi2/NDF", NULL, 100, 0.0, 5.0);
171
174
175
176 for (int number_of_events = 0, count = 0; number_of_events != numberOfEvents; ++number_of_events) {
177
178 STATUS(
"event: " << setw(10) << number_of_events <<
'\r');
DEBUG(endl);
179
181
182 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
183
185
186 model.string[
module->getString()] = JMODEL::JString(gRandom->Uniform(-2.0e-2, +2.0e-2),
187 gRandom->Uniform(-2.0e-2, +2.0e-2));
188 }
189 }
190
192
193
194
195 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
196 if (module->getFloor() != 0 && geometry.hasLocation(module->getLocation())) {
197 module->set(geometry[module->getString()].getPosition(model.string[module->getString()], module->getFloor()));
198 }
199 }
200
201
202
203
204 int minimum_number_of_pings = numeric_limits<int>::max();
205
206 for (vector<JEmitter>::const_iterator emitter = emitters.begin(); emitter != emitters.end(); ++emitter) {
207 minimum_number_of_pings = min(minimum_number_of_pings,
getValue(numberOfPings, emitter->getID(), numberOfPings[
WILDCARD]));
208 }
209
211
212 for (vector<JEmitter>::const_iterator emitter = emitters.begin(); emitter != emitters.end(); ++emitter) {
213
214 const int number_of_pings =
getValue(numberOfPings, emitter->getID(), numberOfPings[
WILDCARD]);
215
216 const double weight = (unify ? (double) minimum_number_of_pings / (double) number_of_pings : 1.0);
217
218 for (int ping_counter = 0; ping_counter != number_of_pings; ++ping_counter) {
219
220 ++count;
221
222 const double toe_s = emitter->getID() * 1000.0 + ping_counter * 10.0 + gRandom->Uniform(-1.0, +1.0);
223
224 model.emission[emitter->getID()][count] = toe_s;
225
226 for (JDetector::const_iterator module =
detector.begin(); module !=
detector.end(); ++module) {
227
228 if (disable.count(
JTransmission_t(emitter->getID(), module->getID())) == 0) {
229
230 if (geometry.hasLocation(module->getLocation())) {
231
233
234 const double d_m =
getDistance(module->getPosition(), emitter->getPosition());
235 const double toa_s = toe_s + V.
getTime(d_m, emitter->getZ(), module->getZ());
236 const double Q = waveform.
getQ(D_m, d_m);
237
238 if (Q >= parameters.
Qmin) {
239
240 double t1_s = toa_s;
241
242 if (gRandom->Rndm() >= background)
243 t1_s = gRandom->Gaus(toa_s, parameters.
sigma_s);
244 else
245 t1_s = gRandom->Uniform(toa_s + T_s.getLowerLimit(),
246 toa_s + T_s.getUpperLimit());
247
248 const JHit hit(*emitter,
249 count,
250 module->getLocation(),
251 t1_s,
253 weight);
254
255 DEBUG(
"hit: " << hit <<
' ' <<
FIXED(7,1) << Q << endl);
256
258 }
259 }
260 }
261 }
262 }
263 }
264
265 const chrono::steady_clock::time_point t0 = chrono::steady_clock::now();
266
268
269 const chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
270
272
273 cout << "result:" << ' '
276
277 for (data_type::const_iterator hit =
result.begin; hit !=
result.end; ++hit) {
278 cout <<
"hit: " << *hit <<
' ' <<
FIXED(9,3) << katoomba.evaluator(
result.value, *hit) << endl;
279 }
280 }
281
282 h0.Fill(chrono::duration_cast<chrono::milliseconds>(t1 - t0).count());
284
286
287 const double tx = (i->second.tx -
result.value.string [i->first].tx) * 1.0e3;
288 const double ty = (i->second.ty -
result.value.string [i->first].ty) * 1.0e3;
289
290 H2 ->Fill(tx, ty);
291 H2[i->first]->Fill(tx, ty);
292 }
293
295
296 const double t1 = i->second.t1 -
result.value.emission[i->first].t1;
297
298 H1 ->Fill(t1);
299 H1[i->first.getID()]->Fill(t1);
300 }
301 }
303
304
306
307 out << h0
308 << h1
309 << H1 << *H1
310 << H2 << *H2;
311
312 out.Write();
313 out.Close();
314}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
JContainer< std::vector< JTripod > > tripods_container
JContainer< std::vector< JTransmitter > > transmitters_container
JContainer< std::vector< JHydrophone > > hydrophones_container
static const JSoundVelocity getSoundVelocity(1541.0, -17.0e-3, -2000.0)
Function object for velocity of sound.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
void model(JModel_t &value)
Auxiliary function to constrain model during fit.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::vector< event_type > data_type
static const char WILDCARD
Auxiliary data structure for floating point format specification.
Auxiliary data structure for mechanical model parameters with commented data.
double Qmin
minimal quality transmission
double sigma_s
time-of-arrival resolution [s]
Global fit of prameterised detector geometry to acoustics data.
Template definition of fit function of acoustic model.
Model for fit to acoustics data.
Implementation for depth dependend velocity of sound.
virtual double getTime(const double D_m, const double z1, const double z2) const override
Get propagation time of sound.
JSoundVelocity & set(const double z0)
Set depth.
Acoustic transmission identifier.
Data structure for measured coincidence rates of all pairs of PMTs in optical module.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Empty structure for specification of parser element that is initialised (i.e. does not require input)...