Project
Loading...
Searching...
No Matches
O2OverlapCheck.h
Go to the documentation of this file.
1// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
13
14#ifndef ALICEO2_CADSUPPORT_O2OVERLAPCHECK_
15#define ALICEO2_CADSUPPORT_O2OVERLAPCHECK_
16
17#include <array>
18#include <string>
19#include <vector>
20
21class TGeoShape;
22class TGeoMatrix;
23class TGeoVolume;
24
25namespace o2
26{
27namespace cad
28{
29
37
38const char* OverlapVerdictName(OverlapVerdict verdict);
39
43 int pointsPerSolid = 20000;
45 double depthTolerance = 1.e-6;
48 double residualTolerance = 1.e-6;
50 double padCm = 0.1;
55 bool checkExtrusion = true;
56};
57
60 std::string nameA;
61 std::string nameB;
63
66 double depthCm = 0.;
67 std::array<double, 3> deepestPoint{{0., 0., 0.}};
68 std::string deepestPointFrom;
69
74 int sampledA = 0;
75 int sampledB = 0;
76
78 double separationCm = -1.;
79
80 double sharedVolumeCm3 = -1.;
81 double sharedVolumeErrCm3 = 0.;
83};
84
87 std::string name;
88 std::string shapeClass;
89 int requested = 0;
90 int accepted = 0;
91 int rejected = 0;
92 double worstResidualCm = 0.;
94};
95
97 std::vector<OverlapSolidReport> solids;
98 std::vector<OverlapPair> pairs;
99 std::vector<OverlapPair> extrusions;
100
101 int nSolids = 0;
102 int nPairsTotal = 0;
103 int nPairsTested = 0;
104 int nDisjoint = 0;
105 int nTouching = 0;
107 int nContained = 0;
108 int nExtruding = 0;
110 double worstResidualCm = 0.;
111 double elapsedSeconds = 0.;
112
115};
116
119int SampleBoundaryPoints(const TGeoShape* shape, int npoints, double residualTolerance,
120 std::vector<double>& points, int& rejected, double& worstResidual,
121 bool* usedPointsOnSegments = nullptr);
122
124OverlapPair CheckPairOverlap(const TGeoShape* shapeA, const TGeoMatrix* matA, const std::string& nameA,
125 const TGeoShape* shapeB, const TGeoMatrix* matB, const std::string& nameB,
126 const OverlapOptions& options = OverlapOptions());
127
129OverlapCensus CheckWorldOverlaps(const TGeoVolume* volume, const OverlapOptions& options = OverlapOptions());
130
131} // namespace cad
132} // namespace o2
133
134#endif
OverlapCensus CheckWorldOverlaps(const TGeoVolume *volume, const OverlapOptions &options=OverlapOptions())
Census every pair of volume's immediate daughters, and optionally each daughter against volume.
const char * OverlapVerdictName(OverlapVerdict verdict)
OverlapVerdict
Whether two placed solids may legally coexist: disjoint and touching are legal, interpenetrating and ...
@ Contained
every sampled boundary point of the smaller solid is inside the other
@ Disjoint
no sampled boundary point of either solid lies inside the other
@ Interpenetrating
a boundary point of one solid lies strictly inside the other: illegal
@ Touching
boundary points coincide, but none is deeper than the depth tolerance
OverlapPair CheckPairOverlap(const TGeoShape *shapeA, const TGeoMatrix *matA, const std::string &nameA, const TGeoShape *shapeB, const TGeoMatrix *matB, const std::string &nameB, const OverlapOptions &options=OverlapOptions())
Test one placed pair. matA / matB take each shape's local frame to the common frame.
int SampleBoundaryPoints(const TGeoShape *shape, int npoints, double residualTolerance, std::vector< double > &points, int &rejected, double &worstResidual, bool *usedPointsOnSegments=nullptr)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::vector< OverlapSolidReport > solids
int nPairsTotal
N (N - 1) / 2.
std::vector< OverlapPair > extrusions
int illegalCount() const
The one-line answer: nInterpenetrating + nContained + nExtruding.
int nPairsTested
after the bounding-box rejection
std::vector< OverlapPair > pairs
only the pairs that survived the bounding-box rejection
double depthTolerance
A containment shallower than this is a shared boundary, not an overlap. In cm.
double padCm
Bounding-box inflation before the pairwise rejection, in cm; it decides which disjoint pairs get a se...
int volumeSamples
Monte-Carlo samples for the shared volume of an illegal pair; 0, the default, disables the estimate.
One pair of placed solids, and everything measured about it.
OverlapVerdict verdict
double sharedVolumeCm3
Monte-Carlo estimate; < 0 when not measured.
int deepPointsAInsideB
... of which deeper than depthTolerance
int sampledA
accepted (on-boundary) sample counts actually used
int pointsAInsideB
sampled points of A found inside B at any depth
std::string deepestPointFrom
which solid's boundary the deepest point came from
double sharedVolumeErrCm3
its 1-sigma statistical error
std::array< double, 3 > deepestPoint
in the master frame
double separationCm
Smallest sampled distance from a boundary point of one solid to the other, in cm; meaningful only whe...
One solid's sampling report; a shape with a poor display mesh shows here as reduced coverage.
double worstResidualCm
the largest own-boundary distance among the accepted points