310 {
312
314 std::string the_arg{
argv[
arg]};
315 if (the_arg == "--refFile" && arg +1 < argc) {
318 } else if (the_arg == "--testFile" && arg + 1 < argc) {
321 }
322 }
324 std::cerr<<"Please parse the path of the reference file via --refFile "<<std::endl;
325 return EXIT_FAILURE;
326 }
328 std::cerr<<"Please parse the path of the test file via --testFile "<<std::endl;
329 return EXIT_FAILURE;
330 }
335 std::set<RpcChamber> refChambers =
readTreeDump(refFile);
336 if (refChambers.empty()) {
337 std::cerr<<
"The file "<<
refFile<<
" should contain at least one chamber "<<std::endl;
338 return EXIT_FAILURE;
339 }
340 std::set<RpcChamber> testChambers =
readTreeDump(testFile);
341 if (testChambers.empty()) {
342 std::cerr<<
"The file "<<
testFile<<
" should contain at least one chamber "<<std::endl;
343 return EXIT_FAILURE;
344 }
345 std::cout<<
"Read "<<refChambers.size()<<
" chambers from reference: "<<
refFile
346 <<
" & "<<testChambers.size()<<
" from "<<
testFile<<std::endl;
347 int return_code = EXIT_SUCCESS;
348 unsigned int goodChambers{0};
351 std::set<RpcChamber>::const_iterator test_itr = testChambers.find(
reference);
352
353 if (test_itr == testChambers.end()) {
354 std::cerr<<
"runRpcGeoComparison() "<<__LINE__<<
": The chamber "<<
reference<<
" is not part of the testing "<<std::endl;
355 return_code = EXIT_FAILURE;
356 continue;
357 }
358 bool chamberOkay = true;
360
364
365
368
371
374
377 if (!chamberOkay) continue;
378
380 test.geoModelTransform;
381
383 std::cerr<<
"runRpcGeoComparison() "<<__LINE__<<
": "<<
test<<
" is displaced by "
385 continue;
386 }
387
388
390 for (
const RpcLayer& refLayer :
reference.layers) {
391 break;
392 std::set<RpcLayer>::const_iterator lay_itr =
test.layers.find(refLayer);
393 if (lay_itr ==
test.layers.end()) {
394 std::cerr<<
"runRpcGeoComparison() "<<__LINE__<<
": "<<
test<<
" "
395 <<refLayer<<" is not found. "<<std::endl;
396 chamberOkay = false;
397 continue;
398 }
399
400 const RpcLayer& testLayer{*lay_itr};
402 refLayer.transform;
403 if (layAlignment.translation().mag() >
tolerance) {
404 std::cerr<<
"runRpcGeoComparison() "<<__LINE__<<
": "<<
test<<
" "
405 <<"the layer "<<testLayer<<" is misplaced w.r.t. reference by "
407 <<
Amg::toString(refLayer.transform.translation()) <<
" delta : "
409 <<", perp: "<<layAlignment.translation().perp()
410 <<", mag: "<<layAlignment.translation().mag()<<std::endl;
411 chamberOkay = false;
412 }
416 std::cerr<<
"runRpcGeoComparison() "<<__LINE__<<
": "<<
test<<
" "
417 <<"the layer "<<testLayer<<" is misaligned w.r.t. reference by "
418 <<GeoTrf::toString(layAlignment, true)<<std::endl;
419 chamberOkay = false;
420 }
421 }
423 if (!chamberOkay) continue;
424 unsigned int failedEta{0}, failedPhi{0};
425 for (
const RpcStrip& refStrip :
reference.strips) {
426 std::set<RpcStrip>::const_iterator strip_itr =
test.strips.find(refStrip);
427 if (strip_itr ==
test.strips.end()) {
428 std::cerr<<
"runRpcGeoComparison() "<<__LINE__<<
": "<<
test<<
" "
429 <<refStrip<<" is not found. "<<std::endl;
430 chamberOkay = false;
431 continue;
432 }
433 const RpcStrip& testStrip{*strip_itr};
434 const Amg::Vector3D diffStrip{testStrip.position - refStrip.position};
436 constexpr unsigned int maxFail = 3;
437 if ( (!refStrip.measPhi && ( (++failedEta) <= maxFail || refStrip.strip <= 3)) ||
438 (refStrip.measPhi && ( (++failedPhi) <= maxFail || refStrip.strip <= 3)) ) {
439 std::cerr<<
"runRpcGeoComparison() "<<__LINE__<<
": "<<
test<<
" "
440 <<testStrip<<
" should be located at "<<
Amg::toString(refStrip.position, 2)
442 <<diffStrip.perp()<<", mag: "<<diffStrip.mag()<<std::endl;
443 } else if (failedEta > maxFail && failedPhi > maxFail) {
444 break;
445 }
446 chamberOkay = false;
447 }
448 continue;
449 const Amg::Vector2D diffLocStrip{testStrip.locPos - refStrip.locPos};
451 std::cerr<<
"runRpcGeoComparison() "<<__LINE__<<
": "<<
test<<
" "
452 <<testStrip<<
" should be located at "<<
Amg::toString(refStrip.locPos, 2)
453 <<
" displacement: "<<
Amg::toString(diffLocStrip,2)<<
", mag: "<<diffLocStrip.mag()<<std::endl;
454 chamberOkay = false;
455 }
456 }
457 if (!chamberOkay) {
458 return_code = EXIT_FAILURE;
459 continue;
460 }
461
464 std::cerr<<"runRpcGeoComparison() "<<__LINE__<<": The alignable nodes are at differnt places for "
466 return_code = EXIT_FAILURE;
467 } else {
468 ++goodChambers;
469 }
470
471 }
473 if (refChambers.find(test) == refChambers.end()) {
474 std::cerr<<
"runRpcGeoComparison() "<<__LINE__<<
": The chamber "<<
test<<
" is not in the references."<<std::endl;
475 return_code = EXIT_FAILURE;
476 }
477 }
478 std::cout<<"runRpcGeoComparison() "<<__LINE__<<": "<<
479 goodChambers<<"/"<<refChambers.size()<<" chambers are in complete agreement. "<<std::endl;
480 return return_code;
481
482}
static std::string FindCalibFile(const std::string &logical_file_name)
Amg::Transform3D getRotateX3D(double angle)
get a rotation transformation around X-axis
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
bool doesNotDeform(const Amg::Transform3D &trans)
Checks whether the linear part of the transformation rotates or stetches any of the basis vectors.
Amg::Transform3D getRotateZ3D(double angle)
get a rotation transformation around Z-axis
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
#define TEST_BASICPROP(attribute, propName)
std::set< RpcChamber > readTreeDump(const std::string &inputFile)
Helper struct to assess that the layers are properly oriented.
Helper struct to represent a full Rpc chamber.