77 double position = 0.001;
83 string detectorFile_a;
84 string detectorFile_b;
97 JParser<> zap(
"Auxiliary program to find differences between two detector files.");
107 catch(
const exception &error) {
108 FATAL(error.what() << endl);
116 load(detectorFile_a, detector_a);
123 load(detectorFile_b, detector_b);
129 size_t numberOfPMTs = 0;
131 bool is_equal =
true;
136 setFormat<JPosition3D> (
JFormat_t(15, 9, std::ios::fixed | std::ios::showpos));
140 if (detector_a.getID() != detector_b.getID()) {
142 DEBUG(
"* Different detector identifiers "
143 << setw(5) << detector_a.getID() <<
" (A) and " << endl
144 << setw(5) << detector_b.getID() <<
" (B)." << endl
150 for (JDetector::iterator module = detector_a.begin(); module != detector_a.end(); ++module) {
151 if (module->size() > numberOfPMTs) {
152 numberOfPMTs = module->size();
158 for (JDetector::iterator module = detector_a.begin(); module != detector_a.end(); ++module) {
160 if (!module_router_b.hasModule(module->getID())) {
162 DEBUG(
"* Module " << setw(10) << module->getID() <<
" is in A " <<
getLabel(*module) <<
" but not in B" << endl);
168 for (JDetector::iterator module = detector_b.begin(); module != detector_b.end(); ++module) {
170 if (!module_router_a.hasModule(module->getID())) {
172 DEBUG(
"* Module " << setw(10) << module->getID() <<
" is in B " <<
getLabel(*module) <<
" but not in A" << endl);
182 DEBUG(
"Comparing module by module." << endl);
184 for (JDetector::iterator module_a = detector_a.begin(); module_a != detector_a.end(); ++module_a) {
186 if (!module_router_b.hasModule(module_a->getID())) {
193 const JModule* module_b = &module_router_b.getModule(module_a->getID());
195 DEBUG(
" Module " << setw(10) << module_a->getID());
199 if (module_a->getLocation() == module_b->
getLocation()) {
206 DEBUG(
" * different location: "
208 <<
getLabel(*module_b) <<
" (B)" << endl);
215 if (fabs(module_a->getT0() - module_b->
getT0()) > precision.time) {
217 DEBUG(
" * different T0: "
218 << module_a->getT0() <<
" (A), "
219 << module_b->
getT0() <<
" (B) "
220 <<
", B - A " << module_b->
getT0() - module_a->getT0() << endl);
229 DEBUG(
" * different quaternion calibration: "
230 << module_a->getQuaternion() <<
" (A), "
241 DEBUG(
" * different position: "
242 << module_a->getPosition() <<
" (A), "
251 if (module_a->size() != module_b->size()) {
253 DEBUG(
" * different number of PMTs: "
254 << module_a->size() <<
" (A), "
255 << module_b->size() <<
" (B)" << endl);
262 if (!module_a->empty() &&
263 !module_b->empty()) {
265 const JQuantile q = getQuantile(*module_a, *module_b);
267 if (fabs(q.
getMean()) > precision.time) {
269 DEBUG(
" * different average t0: "
279 if (fabs(module_a->getT0() - module_b->
getT0()) > precision.time) {
281 DEBUG(
" * different global t0: "
282 << module_a->getT0() <<
" (A), "
283 << module_b->
getT0() <<
" (B)"
284 <<
", B - A " << module_b->
getT0() - module_a->getT0()
292 if (module_a->getStatus() != module_b->
getStatus()) {
294 DEBUG(
" * different status module " << module_a->getID() <<
": "
295 << module_a->getStatus() <<
" (A), "
306 for (
unsigned int pmt = 0; pmt != module_a->size() && pmt != module_b->size(); ++pmt) {
308 const JPMT& pmt_a = module_a->getPMT(pmt);
313 DEBUG(
" * different identifier PMT " << pmt <<
": "
314 << setw(8) << pmt_a.
getID() <<
" (A" <<
FILL(2,
'0') << pmt <<
"), " <<
FILL()
315 << setw(8) << pmt_b.
getID() <<
" (B" <<
FILL(2,
'0') << pmt <<
")" <<
FILL()
316 <<
", B - A " << pmt_b.
getID() - pmt_a.
getID()
325 for (
unsigned int pmt = 0; pmt != module_a->size() && pmt != module_b->size(); ++pmt) {
327 const JPMT& pmt_a = module_a->getPMT(pmt);
330 if (fabs(pmt_a.
getT0() - pmt_b.
getT0()) > precision.time) {
332 DEBUG(
" * different T0 PMT " << pmt <<
": "
333 << pmt_a.
getT0() <<
" (A" <<
FILL(2,
'0') << pmt <<
"), " <<
FILL()
334 << pmt_b.
getT0() <<
" (B" <<
FILL(2,
'0') << pmt <<
")" <<
FILL()
335 <<
", B - A " << pmt_b.
getT0() - pmt_a.
getT0()
344 for (
unsigned int pmt = 0; pmt != module_a->size() && pmt != module_b->size(); ++pmt) {
346 const JPMT& pmt_a = module_a->getPMT(pmt);
353 DEBUG(
" * different PMT position: "
364 for (
unsigned int pmt = 0; pmt != module_a->size() && pmt != module_b->size(); ++pmt) {
366 const JPMT& pmt_a = module_a->getPMT(pmt);
373 if ((1.0 - dot) > precision.orientation) {
375 DEBUG(
" * different PMT direction: "
386 for (
unsigned int pmt = 0; pmt != module_a->size() && pmt != module_b->size(); ++pmt) {
388 const JPMT& pmt_a = module_a->getPMT(pmt);
393 DEBUG(
" * different status PMT " << pmt <<
": "
410 for (JDetector::iterator module = detector_a.begin(); module != detector_a.end(); ++module) {
411 string.insert(module->getString());
412 floor .insert(module->getFloor ());
415 for (JDetector::iterator module = detector_b.begin(); module != detector_b.end(); ++module) {
416 string.insert(module->getString());
417 floor .insert(module->getFloor ());
423 string.size(), -0.5,
string.size() - 0.5,
424 floor .size(), -0.5, floor .size() - 0.5);
434 TH2D* X2 = (TH2D*) M2.Clone(
"X2" );
435 TH2D* Y2 = (TH2D*) M2.Clone(
"Y2" );
436 TH2D* Z2 = (TH2D*) M2.Clone(
"Z2" );
437 TH2D* T2 = (TH2D*) M2.Clone(
"T2" );
438 TH2D* RMS = (TH2D*) M2.Clone(
"RMS");
439 TH2D* R2 = (TH2D*) M2.Clone(
"R2" );
440 TH2D* QA = (TH2D*) M2.Clone(
"QA" );
441 TH2D* QB = (TH2D*) M2.Clone(
"QB" );
442 TH2D* QC = (TH2D*) M2.Clone(
"QC" );
443 TH2D* QD = (TH2D*) M2.Clone(
"QD" );
444 TH2D* Q2 = (TH2D*) M2.Clone(
"Q2" );
446 for (JDetector::iterator module = detector_a.begin(); module != detector_a.end(); ++module) {
447 if (!module_router_b.hasModule(module->getID()) ) {
448 M2.Fill(module->getString(), module->getFloor(), -1.0);
452 for (JDetector::iterator module = detector_b.begin(); module != detector_b.end(); ++module) {
453 if (!module_router_a.hasModule(module->getID()) ) {
454 M2.Fill(module->getString(), module->getFloor(), +1.0);
459 for (JDetector::iterator module_a = detector_a.begin(); module_a != detector_a.end(); ++module_a) {
461 if (!module_router_b.hasModule(module_a->getID())) {
465 const JModule* module_b = &module_router_b.getModule(module_a->getID());
467 for (
size_t i = 0; i != numberOfPMTs; ++i) {
469 if (module_a->getFloor() != 0) {
470 H1[module_a->getID()]->SetBinContent(i + 1, module_a->getPMT(i).getT0() - module_b->
getPMT(i).
getT0());
474 X2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), module_a->getX() - module_b->
getX());
475 Y2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), module_a->getY() - module_b->
getY());
476 Z2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), module_a->getZ() - module_b->
getZ());
478 if (module_a->getFloor() != 0 &&
482 const JQuantile q = getQuantile(*module_a, *module_b);
486 const double phi = (
JVector3Z_t.
getDot(q1.twist) >= 0.0 ? +1.0 : -1.0) * q1.twist.getAngle();
488 R2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), phi);
489 QA ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), Q.
getA());
490 QB ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), Q.
getB());
491 QC ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), Q.
getC());
492 QD ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), Q.
getD());
493 Q2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), Q.
getAngle());
494 T2 ->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), q.
getMean());
495 RMS->Fill(getBin(
string, module_a->getString()), getBin(floor, module_a->getFloor()), q.
getSTDev());
502 for (TH2D* h2 : { &M2, X2, Y2, Z2, T2, RMS, R2, QA, QB, QC, QD, Q2 }) {
Utility class to parse command line options.
double getAngle(const JQuaternion3D &first, const JQuaternion3D &second)
Get space angle between quanternions.
Q(UTCMax_s-UTCMin_s)-livetime_s
double getB() const
Get b value.
int getFloor() const
Get floor number.
Data structure for a composite optical module.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
#define gmake_property(A)
macro to convert (template) parameter to JPropertiesElement object
std::string getLabel(const JLocation &location)
Get module label for monitoring and other applications.
const JDirection3D & getDirection() const
Get direction.
Router for direct addressing of module data in detector data structure.
Utility class to parse parameter values.
static JRotation getRotation
Function object to get rotation matrix to go from first to second module.
#define MAKE_CSTRING(A)
Make C-string.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
double getDistance(const JVector3D &pos) const
Get distance to point.
double getDot(const JAngle3D &angle) const
Get dot product.
double getDistance(const JFirst_t &first, const JSecond_t &second)
Get distance between objects.
const JQuaternion3D & getQuaternion() const
Get quaternion.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
#define ASSERT(A,...)
Assert macro.
const JLocation & getLocation() const
Get location.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
int getID() const
Get identifier.
Data structure for PMT geometry, calibration and status.
double getY() const
Get y position.
const JPosition3D & getPosition() const
Get position.
const JPMT & getPMT(const int index) const
Get PMT.
Auxiliary data structure for sequence of same character.
double getD() const
Get d value.
Data structure for unit quaternion in three dimensions.
double getAngle() const
Get rotation angle.
const JStatus & getStatus() const
Get status.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
static const JVector3D JVector3Z_t(0, 0, 1)
unit z-vector
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
double getC() const
Get c value.
double getX() const
Get x position.
double getA() const
Get a value.
double getDot(const JVector3D &vector) const
Get dot product.
Data structure for position in three dimensions.
Auxiliary data structure for decomposition of quaternion in twist and swing quaternions.
double getZ() const
Get z position.
double getT0() const
Get time offset.