281{
285
287 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
291
293 JLimit_t& numberOfEvents = inputFile.getLimit();
294 string detectorFile;
295 JCalibration_t calibrationFile;
296 double Tmax_s;
297 string pdfFile;
299 bool overwriteDetector;
302 int number_of_iterations = 1000;
303 int number_of_extra_steps = 0;
305 double T_ns = 2.5;
306 size_t threads;
308
309 const int DEFAULT_ID = -1;
310
311 try {
312
314
319
320 JParser<> zap(
"Program to determine string or optical module time calibrations.");
321
329 zap[
'A'] =
make_field(overwriteDetector,
"overwrite detector file provided through '-a' with fitted time offsets.");
333 zap[
'N'] =
make_field(threads,
"number of threads") = 1;
335
336 zap(argc, argv);
337 }
338 catch(const exception& error) {
339 FATAL(error.what() << endl);
340 }
341
342
343 if (strings.empty() == modules.empty()) {
344 FATAL(
"Set either strings (option -S) or modules (option -M)." << endl);
345 }
346
348
349 try {
351 }
354 }
355
356 unique_ptr<JDynamics> dynamics;
357
358 try {
359
361
362 dynamics->load(calibrationFile);
363 }
364 catch(const exception& error) {
365 if (!calibrationFile.empty()) {
367 }
368 }
369
371
372 NOTICE(
"Reading PDFs... " << flush);
373
375
377
378 JRegressor_t::debug =
debug;
379 JRegressor_t::T_ns.setRange(parameters.
TMin_ns, parameters.
TMax_ns);
380 JRegressor_t::Vmax_npe = parameters.
VMax_npe;
381 JRegressor_t::MAXIMUM_ITERATIONS = parameters.
NMax;
382
383
384
385
387
389
392
394
396
397 for (JParallelFileScanner_t in(*i); (skip -= in.skip(skip)) == 0 && in.hasNext() && counter != numberOfEvents; ++counter) {
398
399 STATUS(
"event: " << setw(10) << counter <<
'\r');
DEBUG(endl);
400
401 multi_pointer_type ps = in.next();
402
405
406 summary.update(*tev);
407
408 if (dynamics) {
409 dynamics->update(*tev);
410 }
411
412 if (!evt->empty()) {
413
415
416 buildL0(*tev, router, true, back_inserter(dataL0));
417
419
423
427 }
428
430
431
432
434
435 for (vector<JHitL0>::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
436
437 JHitW0 hit(*i, summary.getRate(i->getPMTIdentifier()));
438
439 hit.rotate(R);
440
441 if (match(hit)) {
442 buffer.push_back(hit);
443 }
444 }
445
446
447
449
450 buffer_type::const_iterator __end = unique(buffer.begin(), buffer.end(), equal_to<JDAQPMTIdentifier>());
451
452
453
455
456 for (buffer_type::const_iterator hit = buffer.begin(); hit != __end; ++hit) {
457
458 const JModule& module = router.getModule(hit->getModuleID());
459
460 if (!strings.empty()) {
map[module.
getString()].push_back(*hit); }
461 if (!modules.empty()) {
map[module.
getID()] .push_back(*hit); }
462 }
463
465 }
466 }
467 }
469
470
471
472
473 JGradient fit(number_of_iterations, number_of_extra_steps, epsilon, 3);
474
477
480
482
483 const double chi2 = fit(perth);
484
485 STATUS(
"result: " <<
FIXED(12,6) << chi2 <<
' ' << setw(6) << fit.numberOfIterations << endl);
486
487 for (size_t i = 0; i != fit.size(); ++i) {
488 {
490
491 if (p != NULL) {
STATUS(fit[i].name <<
' ' <<
FIXED(9,3) << p->
t0 <<
" [ns]" << endl); }
492 }
493 }
494
495
496 if (overwriteDetector) {
497
499
501
502 for (size_t i = 0; i != fit.size(); ++i) {
503
505
506 if (p != NULL) {
508 }
509 }
510
512
513 for (JDetector::iterator module =
detector.begin(); module !=
detector.end(); ++module) {
514
515 if (!module->empty()) {
516
522 module->getPMT(pmt).addT0(p->second - t0);
523 }
524 }
525 }
526 }
527
528 NOTICE(
"Store calibration data on file " << detectorFile << endl);
529
531 }
532}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_STRING(A)
Make string.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
int getString() const
Get string number.
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Utility class to parse parameter values.
Data structure for set of track fit results.
Data structure for track fit results with history and optional associated values.
const std::vector< double > & getW() const
Get associated values.
double getT() const
Get time.
bool hasW(const int i) const
Check availability of value.
Data structure for fit of straight line paralel to z-axis.
int getID() const
Get identifier.
Utility class to parse command line options.
Auxiliary class for a hit with background rate value.
General purpose class for object reading from a list of file names.
General purpose class for parallel reading of objects from a single file or multiple files.
File router for fast addressing of summary data.
static const int JSTART_LENGTH_METRES
distance between projected positions on the track of optical modules for which the response does not ...
JDirection3D getDirection(const Vec &dir)
Get direction.
JPosition3D getPosition(const Vec &pos)
Get position.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
std::set< int > getStringIDs(const JDetector &detector)
Get list of strings identifiers.
std::set< int > getModuleIDs(const JDetector &detector, const bool option=false)
Get list of modules identifiers.
JTOOLS::JRange< double > JZRange
const array_type< JValue_t > & get_values(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &data)
Method to create array of values of map.
std::iterator_traits< T >::value_type getAverage(T __begin, T __end)
Get average.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Long64_t counter_type
Type definition for counter.
KM3NeT DAQ data structures and auxiliaries.
static const int NUMBER_OF_PMTS
Total number of PMTs in module.
Auxiliary data structure for sequence of same character.
Auxiliary data structure for floating point format specification.
Data structure for measured coincidence rates of all pairs of PMTs in optical module.
Dynamic detector calibration.
Auxiliary class to match data points with given model.
Auxiliary data structure for editable parameter.
Template data structure for storage of internal data.
Auxiliary class for recursive type list generation.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for editing time offset.
double t0
time offset [ns]
Data structure for fit parameters.
double TTS_ns
transition-time spread [ns]
double TMin_ns
minimal time w.r.t. Cherenkov hypothesis [ns]
double roadWidth_m
road width [m]
double TMax_ns
maximal time w.r.t. Cherenkov hypothesis [ns]
double VMax_npe
maximum number of of photo-electrons
double ZMax_m
maximal z-positon [m]
double ZMin_m
minimal z-positon [m]
int NMax
maximum number of iterations
double R_Hz
default rate [Hz]
Auxiliary data structure for chi2 function object.
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.
Auxiliary data structure for sorting of hits.