Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix facetIsDegenerated utility function #1214

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DDCAD/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ elseif(DD4HEP_LOAD_ASSIMP)

ExternalProject_Add(
assimp_project
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/assimp
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/external/assimp
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
GIT_REPOSITORY https://github.com/assimp/assimp.git
GIT_TAG v5.0.1
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
Expand Down
15 changes: 8 additions & 7 deletions DDCAD/include/DDCAD/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define DDCAD_UTILITIES_H

#include <vector>
#include <cmath>

#include <TGeoTessellated.h>
#include <TGeoVector3.h>
Expand Down Expand Up @@ -63,13 +64,13 @@ namespace dd4hep {
//
// v1.z v2.z v3.z v1.z v2.z
double det = 0.0
+ v1.x() * v2.y() * v3.z()
+ v2.x() * v3.y() * v1.z()
+ v3.x() * v1.y() * v2.z()
- v1.z() * v2.y() * v3.x()
- v2.z() * v3.y() * v1.x()
- v3.z() * v1.y() * v2.x();
return det < epsilon;
+ v1.x() * v2.y() * v3.z()
+ v2.x() * v3.y() * v1.z()
+ v3.x() * v1.y() * v2.z()
- v1.z() * v2.y() * v3.x()
- v2.z() * v3.y() * v1.x()
- v3.z() * v1.y() * v2.x();
return std::fabs(det) < epsilon;
}
}
}
Expand Down
73 changes: 41 additions & 32 deletions DDCore/src/plugins/DetectorCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ namespace {
bool check_placements { false };
bool check_volmgr { false };
bool check_sensitive { false };
bool ignore_detector { false };

SensitiveDetector get_current_sensitive_detector();

Expand Down Expand Up @@ -449,7 +450,7 @@ void DetectorCheck::checkManagerSingleVolume(DetElement detector, PlacedVolume p
if ( pv.volume().isSensitive() ) {
PlacedVolume det_place = m_volMgr.lookupDetElementPlacement(vid);
++m_sens_counters.elements;
if ( pv.ptr() != det_place.ptr() ) {
if ( !ignore_detector && pv.ptr() != det_place.ptr() ) {
err << "VolumeMgrTest: Wrong placement "
<< " got " << det_place.name() << " (" << (void*)det_place.ptr() << ")"
<< " instead of " << pv.name() << " (" << (void*)pv.ptr() << ") "
Expand Down Expand Up @@ -551,33 +552,35 @@ void DetectorCheck::checkManagerSingleVolume(DetElement detector, PlacedVolume p
printout(ERROR, m_det.name(), "DETELEMENT_PERSISTENCY FAILED: World transformation have DIFFERET pointer!");
++m_place_counters.errors;
}

if ( pv.ptr() == det_elem.placement().ptr() ) {
// The computed transformation 'trafo' MUST be equal to:
// m_volMgr.worldTransformation(vid) AND det_elem.nominal().worldTransformation()
int res1 = detail::matrix::_matrixEqual(trafo, det_elem.nominal().worldTransformation());
int res2 = detail::matrix::_matrixEqual(trafo, m_volMgr.worldTransformation(m_mapping,vid));
if ( res1 != detail::matrix::MATRICES_EQUAL || res2 != detail::matrix::MATRICES_EQUAL ) {
printout(ERROR, m_det.name(), "DETELEMENT_PLACEMENT FAILED: World transformation DIFFER.");
++m_place_counters.errors;
}
else {
printout(INFO, m_det.name(), "DETELEMENT_PLACEMENT: PASSED. All matrices equal: %s",
volumeID(vid).c_str());
}
}
else {
// The computed transformation 'trafo' MUST be equal to:
// m_volMgr.worldTransformation(vid)
// The det_elem.nominal().worldTransformation() however is DIFFERENT!
int res2 = detail::matrix::_matrixEqual(trafo, m_volMgr.worldTransformation(m_mapping,vid));
if ( res2 != detail::matrix::MATRICES_EQUAL ) {
printout(ERROR, m_det.name(), "VOLUME_PLACEMENT FAILED: World transformation DIFFER.");
++m_place_counters.errors;

if ( !ignore_detector ) {
if ( pv.ptr() == det_elem.placement().ptr() ) {
// The computed transformation 'trafo' MUST be equal to:
// m_volMgr.worldTransformation(vid) AND det_elem.nominal().worldTransformation()
int res1 = detail::matrix::_matrixEqual(trafo, det_elem.nominal().worldTransformation());
int res2 = detail::matrix::_matrixEqual(trafo, m_volMgr.worldTransformation(m_mapping,vid));
if ( res1 != detail::matrix::MATRICES_EQUAL || res2 != detail::matrix::MATRICES_EQUAL ) {
printout(ERROR, m_det.name(), "DETELEMENT_PLACEMENT FAILED: World transformation DIFFER.");
++m_place_counters.errors;
}
else {
printout(INFO, m_det.name(), "DETELEMENT_PLACEMENT: PASSED. All matrices equal: %s",
volumeID(vid).c_str());
}
}
else {
printout(INFO, m_det.name(), "VOLUME_PLACEMENT: PASSED. All matrices equal: %s",
volumeID(vid).c_str());
// The computed transformation 'trafo' MUST be equal to:
// m_volMgr.worldTransformation(vid)
// The det_elem.nominal().worldTransformation() however is DIFFERENT!
int res2 = detail::matrix::_matrixEqual(trafo, m_volMgr.worldTransformation(m_mapping,vid));
if ( res2 != detail::matrix::MATRICES_EQUAL ) {
printout(ERROR, m_det.name(), "VOLUME_PLACEMENT FAILED: World transformation DIFFER.");
++m_place_counters.errors;
}
else {
printout(INFO, m_det.name(), "VOLUME_PLACEMENT: PASSED. All matrices equal: %s",
volumeID(vid).c_str());
}
}
}
}
Expand Down Expand Up @@ -643,6 +646,7 @@ void DetectorCheck::help(int argc,char** argv) {
" sensitive volume placements. \n\n"
" NOTE: Option requires proper PhysVolID setup \n"
" of the sensitive volume placements ! \n"
" -ignore_detector Ignore DetElement placement check for -volmgr \n"
<< std::endl;
std::cout << "Arguments: " << std::endl;
for(int iarg=0; iarg<argc;++iarg) {
Expand All @@ -659,6 +663,7 @@ long DetectorCheck::run(Detector& description,int argc,char** argv) {
bool structure = false;
bool sensitive = false;
bool placements = false;
bool ignore_de = false;
printout(ALWAYS, "DetectorCheck", "++ Processing plugin...");
for(int iarg=0; iarg<argc;++iarg) {
if ( argv[iarg] == 0 ) break;
Expand All @@ -674,6 +679,8 @@ long DetectorCheck::run(Detector& description,int argc,char** argv) {
geometry = true;
else if ( ::strncasecmp(argv[iarg], "-sensitive",4) == 0 )
sensitive = true;
else if ( ::strncasecmp(argv[iarg], "-ignore_detelement",4) == 0 )
ignore_de = true;
else if ( ::strncasecmp(argv[iarg], "-help",4) == 0 )
help(argc, argv);
else
Expand All @@ -685,12 +692,13 @@ long DetectorCheck::run(Detector& description,int argc,char** argv) {
if ( name == "all" || name == "All" || name == "ALL" ) {
for (const auto& det : description.detectors() ) {
printout(INFO, "DetectorCheck", "++ Processing subdetector: %s", det.second.name());
test.check_structure = structure;
test.check_placements = placements;
test.check_volmgr = volmgr;
test.check_geometry = geometry;
test.check_sensitive = sensitive;
test.execute(det.second, 9999);
test.check_structure = structure;
test.check_placements = placements;
test.check_volmgr = volmgr;
test.check_geometry = geometry;
test.check_sensitive = sensitive;
test.ignore_detector = ignore_de;
test.execute(det.second, 9999);
}
return 1;
}
Expand All @@ -702,6 +710,7 @@ long DetectorCheck::run(Detector& description,int argc,char** argv) {
test.check_volmgr = volmgr;
test.check_geometry = geometry;
test.check_sensitive = sensitive;
test.ignore_detector = ignore_de;
test.execute(det, 9999);
}
return 1;
Expand Down
Loading