84 int scal = 0xFFFFFFFF;
87 string detectorFile_a;
88 string detectorFile_b;
96 properties[
TCAL] = precision.tcal;
97 properties[
PCAL] = precision.pcal;
98 properties[
RCAL] = precision.rcal;
99 properties[
ACAL] = precision.acal;
100 properties[
CCAL] = precision.ccal;
101 properties[
SCAL] = precision.scal;
103 JParser<> zap(
"Auxiliary program to find differences between two detector files.");
113 catch(
const exception &error) {
114 FATAL(error.what() << endl);
122 load(detectorFile_a, detector_a);
129 load(detectorFile_b, detector_b);
135 size_t numberOfPMTs = 0;
137 bool is_equal =
true;
142 setFormat<JPosition3D> (
JFormat_t(15, 9, std::ios::fixed | std::ios::showpos));
146 if (detector_a.
getID() != detector_b.
getID()) {
148 DEBUG(
"* Different detector identifiers "
149 << setw(5) << detector_a.
getID() <<
" (A) and " << endl
150 << setw(5) << detector_b.
getID() <<
" (B)." << endl
160 DEBUG(
" * different UTM position: "
169 for (JDetector::iterator module = detector_a.begin(); module != detector_a.end(); ++module) {
170 if (module->size() > numberOfPMTs) {
171 numberOfPMTs = module->size();
177 for (JDetector::iterator module = detector_a.begin(); module != detector_a.end(); ++module) {
179 if (!module_router_b.hasModule(module->getID())) {
181 DEBUG(
"* Module " << setw(10) << module->getID() <<
" is in A " <<
getLabel(*module) <<
" but not in B" << endl);
187 for (JDetector::iterator module = detector_b.begin(); module != detector_b.end(); ++module) {
189 if (!module_router_a.hasModule(module->getID())) {
191 DEBUG(
"* Module " << setw(10) << module->getID() <<
" is in B " <<
getLabel(*module) <<
" but not in A" << endl);
201 DEBUG(
"Comparing module by module." << endl);
203 for (JDetector::iterator module_a = detector_a.begin(); module_a != detector_a.end(); ++module_a) {
205 if (!module_router_b.hasModule(module_a->getID())) {
212 const JModule* module_b = &module_router_b.getModule(module_a->getID());
214 DEBUG(
" Module " << setw(10) << module_a->getID());
218 if (module_a->getLocation() == module_b->
getLocation()) {
225 DEBUG(
" * different location: "
227 <<
getLabel(*module_b) <<
" (B)" << endl);
234 if (fabs(module_a->getT0() - module_b->
getT0()) > precision.acal) {
236 DEBUG(
" * different T0: "
237 <<
FIXED(12,3) << module_a->getT0() <<
" (A), "
238 <<
FIXED(12,3) << module_b->
getT0() <<
" (B) "
239 <<
", B - A " << module_b->
getT0() - module_a->getT0() << endl);
246 if (module_a->getQuaternion() !=
JQuaternion3D(0.0, 0.0, 0.0, 0.0) &&
250 DEBUG(
" * different quaternion calibration: "
251 << module_a->getQuaternion() <<
" (A), "
262 DEBUG(
" * different position: "
263 << module_a->getPosition() <<
" (A), "
272 if (module_a->size() != module_b->size()) {
274 DEBUG(
" * different number of PMTs: "
275 << module_a->size() <<
" (A), "
276 << module_b->size() <<
" (B)" << endl);
283 if (!module_a->empty() &&
284 !module_b->empty()) {
286 const JQuantile q = getQuantile(*module_a, *module_b);
288 if (fabs(q.
getMean()) > precision.tcal) {
290 DEBUG(
" * different average t0: "
300 if (module_a->getStatus(precision.scal) != module_b->
getStatus(precision.scal)) {
302 DEBUG(
" * different status module " << module_a->getID() <<
": "
303 << module_a->getStatus() <<
" (A), "
314 for (
unsigned int pmt = 0; pmt != module_a->size() && pmt != module_b->size(); ++pmt) {
316 const JPMT& pmt_a = module_a->getPMT(pmt);
321 DEBUG(
" * different identifier PMT " << setw(2) << pmt <<
": "
322 << setw(8) << pmt_a.
getID() <<
" (A" <<
FILL(2,
'0') << pmt <<
"), " <<
FILL()
323 << setw(8) << pmt_b.
getID() <<
" (B" <<
FILL(2,
'0') << pmt <<
")" <<
FILL()
324 <<
", B - A " << pmt_b.
getID() - pmt_a.
getID()
333 for (
unsigned int pmt = 0; pmt != module_a->size() && pmt != module_b->size(); ++pmt) {
335 const JPMT& pmt_a = module_a->getPMT(pmt);
338 if (fabs(pmt_a.
getT0() - pmt_b.
getT0()) > precision.tcal) {
340 DEBUG(
" * different T0 PMT " << setw(2) << pmt <<
": "
343 <<
", B - A " << pmt_b.
getT0() - pmt_a.
getT0()
352 for (
unsigned int pmt = 0; pmt != module_a->size() && pmt != module_b->size(); ++pmt) {
354 const JPMT& pmt_a = module_a->getPMT(pmt);
361 DEBUG(
" * different PMT position: "
372 for (
unsigned int pmt = 0; pmt != module_a->size() && pmt != module_b->size(); ++pmt) {
374 const JPMT& pmt_a = module_a->getPMT(pmt);
381 if ((1.0 - dot) > precision.rcal) {
383 DEBUG(
" * different PMT direction: "
394 for (
unsigned int pmt = 0; pmt != module_a->size() && pmt != module_b->size(); ++pmt) {
396 const JPMT& pmt_a = module_a->getPMT(pmt);
401 DEBUG(
" * different status PMT " << setw(2) << pmt <<
": "
418 for (JDetector::iterator module = detector_a.begin(); module != detector_a.end(); ++module) {
419 string.insert(module->getString());
420 floor .insert(module->getFloor ());
423 for (JDetector::iterator module = detector_b.begin(); module != detector_b.end(); ++module) {
424 string.insert(module->getString());
425 floor .insert(module->getFloor ());
431 string.size(), -0.5,
string.size() - 0.5,
432 floor .size(), -0.5, floor .size() - 0.5);
442 TH2D* X2 = (TH2D*) M2.Clone(
"X2" );
443 TH2D* Y2 = (TH2D*) M2.Clone(
"Y2" );
444 TH2D* Z2 = (TH2D*) M2.Clone(
"Z2" );
445 TH2D* T2 = (TH2D*) M2.Clone(
"T2" );
446 TH2D* RMS = (TH2D*) M2.Clone(
"RMS");
447 TH2D* R2 = (TH2D*) M2.Clone(
"R2" );
448 TH2D* QA = (TH2D*) M2.Clone(
"QA" );
449 TH2D* QB = (TH2D*) M2.Clone(
"QB" );
450 TH2D* QC = (TH2D*) M2.Clone(
"QC" );
451 TH2D* QD = (TH2D*) M2.Clone(
"QD" );
452 TH2D* Q2 = (TH2D*) M2.Clone(
"Q2" );
454 for (JDetector::iterator module = detector_a.begin(); module != detector_a.end(); ++module) {
455 if (!module_router_b.hasModule(module->getID()) ) {
456 M2.Fill(module->getString(), module->getFloor(), -1.0);
460 for (JDetector::iterator module = detector_b.begin(); module != detector_b.end(); ++module) {
461 if (!module_router_a.hasModule(module->getID()) ) {
462 M2.Fill(module->getString(), module->getFloor(), +1.0);
467 for (JDetector::iterator module_a = detector_a.begin(); module_a != detector_a.end(); ++module_a) {
469 if (!module_router_b.hasModule(module_a->getID())) {
473 const JModule* module_b = &module_router_b.getModule(module_a->getID());
475 for (
size_t i = 0; i != numberOfPMTs; ++i) {
477 if (module_a->getFloor() != 0) {
478 H1[module_a->getID()]->SetBinContent(i + 1, module_a->getPMT(i).getT0() - module_b->
getPMT(i).
getT0());
482 X2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), module_a->getX() - module_b->
getX() + numeric_limits<double>::min());
483 Y2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), module_a->getY() - module_b->
getY() + numeric_limits<double>::min());
484 Z2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), module_a->getZ() - module_b->
getZ() + numeric_limits<double>::min());
486 if (module_a->getFloor() != 0 &&
490 const JQuantile q = getQuantile(*module_a, *module_b);
494 const double phi = (
JVector3Z_t.
getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
496 R2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), phi);
497 QA ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), Q.
getA());
498 QB ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), Q.
getB());
499 QC ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), Q.
getC());
500 QD ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), Q.
getD());
501 Q2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), Q.
getAngle());
502 T2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), q.
getMean());
503 RMS->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), q.
getSTDev());
510 for (TH2D* h2 : { &M2, X2, Y2, Z2, T2, RMS, R2, QA, QB, QC, QD, Q2 }) {
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_CSTRING(A)
Make C-string.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
double getT0() const
Get time offset.
int getFloor() const
Get floor number.
const JLocation & getLocation() const
Get location.
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
const JPMT & getPMT(const int index) const
Get PMT.
Data structure for PMT geometry, calibration and status.
Utility class to parse parameter values.
const JDirection3D & getDirection() const
Get direction.
double getDot(const JAngle3D &angle) const
Get dot product.
Data structure for position in three dimensions.
const JPosition3D & getPosition() const
Get position.
Data structure for unit quaternion in three dimensions.
const JQuaternion3D & getQuaternion() const
Get quaternion.
double getAngle() const
Get rotation angle.
double getB() const
Get b value.
double getD() const
Get d value.
double getC() const
Get c value.
double getA() const
Get a value.
double getY() const
Get y position.
double getDistance(const JVector3D &pos) const
Get distance to point.
double getZ() const
Get z position.
double getDot(const JVector3D &vector) const
Get dot product.
double getX() const
Get x position.
int getID() const
Get identifier.
Utility class to parse command line options.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
JPosition3D getPosition() const
Get position.
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
static JRotation getRotation
Function object to get rotation matrix to go from first to second module.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
double getAngle(const JQuaternion3D &first, const JQuaternion3D &second)
Get space angle between quanternions.
static const JVector3D JVector3Z_t(0, 0, 1)
unit z-vector
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).
static const std::string TCAL
PMT time offsets.
static const std::string PCAL
(optical|base) module positions
static const std::string SCAL
(module|PMT) status
static const std::string RCAL
optical module orientations
static const std::string ACAL
acoustic time offsets (piezo sensor or hydrophone)
static const std::string CCAL
compass alignment (a.k.a. quaternion calibration)
Auxiliary data structure for sequence of same character.
Auxiliary data structure for floating point format specification.
int getStatus() const
Get status.
Auxiliary data structure for decomposition of quaternion in twist and swing quaternions.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...