117 Error(
"ctor",
"volume not specified");
172 static Int_t icall = 0;
175 if (unique_volumes) {
185 for (
Int_t i = 0; i < nd; i++)
205 Info(
"CheckOverlaps",
"[LEGACY] Checking overlaps by sampling %d points for %s and daughters", npoints,
207 Info(
"CheckOverlaps",
"=== NOTE: Many overlaps may be missed. Extrusions NOT checked with sampling option ! ===");
211 fVolume->CheckOverlapsBySampling(ovlp, npoints);
219 while ((node = next())) {
234 for (
auto i = 0; i < novlps; i++) {
240 Info(
"CheckOverlaps",
"Number of illegal overlaps/extrusions : %d found in %g [sec]", novlps, timer.
RealTime());
251 Info(
"CheckOverlaps",
"Option 's' deprecated. Use CheckOverlapsBySampling() instead.");
263 Info(
"CheckOverlaps",
"Checking overlaps for %s and daughters within %g",
fVolume->GetName(), ovlp);
268 std::vector<TGeoOverlapCandidate> candidates;
269 candidates.reserve(2048);
271 Int_t ncand = checker->EnumerateOverlapCandidates(
fVolume, ovlp, option, candidates);
274 while ((node = next())) {
277 ncand += checker->EnumerateOverlapCandidates(node->
GetVolume(), ovlp, option, candidates);
281 Info(
"CheckOverlaps",
"--- found %d candidates in %g [sec]", ncand, timer.
RealTime());
283 Info(
"CheckOverlaps",
"--- filling points to be checked...");
285 checker->BuildMeshPointsCache(candidates);
287 Info(
"CheckOverlaps",
"--- points filled in: %g [sec]", timer.
RealTime());
292 std::vector<TGeoOverlapResult> results;
293 results.reserve(256);
297 const size_t chunkSize = 1024;
298 auto makeChunks = [&](
size_t n) {
299 std::vector<std::pair<size_t, size_t>> chunks;
300 chunks.reserve((
n + chunkSize - 1) / chunkSize);
301 for (
size_t b = 0;
b <
n;
b += chunkSize)
302 chunks.emplace_back(
b, std::min(
n,
b + chunkSize));
306 auto chunks = makeChunks(candidates.size());
307 std::mutex resultsMutex;
314 Info(
"CheckOverlaps",
"--- checking candidates with %u threads (use ROOT::EnableImplicitMT(N) to change)...",
317 Info(
"CheckOverlaps",
"--- checking candidates with %u threads...", nthreads);
325 [&](
const std::pair<size_t, size_t> &range) {
327 static thread_local bool navInit =
false;
334 std::vector<TGeoOverlapResult> local;
337 for (
size_t i = range.first; i < range.second; ++i) {
339 if (checker->ComputeOverlap(candidates[i],
r))
340 local.emplace_back(std::move(
r));
343 if (!local.empty()) {
344 std::lock_guard<std::mutex> lock(resultsMutex);
345 results.insert(results.end(), std::make_move_iterator(local.begin()), std::make_move_iterator(local.end()));
351 Info(
"CheckOverlaps",
"--- checking candidates with on a single thread (IMT not configured)...");
353 for (
size_t i = 0; i < candidates.size(); ++i) {
355 if (checker->ComputeOverlap(candidates[i],
r))
356 results.emplace_back(std::move(
r));
361 for (
const auto &
r : results)
362 checker->MaterializeOverlap(
r);
370 for (
Int_t i = 0; i < novlps; i++)
373 Info(
"CheckOverlaps",
"Number of illegal overlaps/extrusions : %d found in %g [sec]", novlps, timer.
RealTime());
434 printf(
"== Inspecting node %s ",
GetName());
436 printf(
"mother volume %s. ",
fMother->GetName());
438 printf(
"(Node is MANY)\n");
442 printf(
" possibly overlapping with : ");
447 printf(
"Transformation matrix:\n");
463 for (
Int_t i = 0; i < nd; i++)
464 fVolume->GetNode(i)->CheckShapes();
494 printf(
"node %s is ONLY\n",
GetName());
498 printf(
"node %s no overlaps\n",
GetName());
504 for (i = 0; i < nd; i++) {
509 for (i = 0; i <
fNovlp; i++) {
526 Int_t istart = ifree;
528 for (
Int_t id = 0;
id < nd;
id++) {
530 array[istart +
id] = ifree;
531 array[ifree++] = ++nodeid;
546 while ((daughter = (
TGeoNode *)next())) {
547 if (daughter == node) {
548 gGeoManager->GetListOfNodes()->AddAt(daughter, level + 1);
554 while ((daughter = (
TGeoNode *)next())) {
555 new_level = daughter->
FindNode(node, level + 1);
556 if (new_level >= 0) {
557 gGeoManager->GetListOfNodes()->AddAt(daughter, level + 1);
576 out <<
" vol = gGeoManager->GetVolume(" << quote <<
fVolume->GetName() << quote <<
");" << std::endl;
578 if (!
fVolume->IsVisDaughters())
579 out <<
" vol->SetVisDaughters(kFALSE);" << std::endl;
590 out <<
" vol->SetVisibility(kFALSE);" << std::endl;
599 for (
Int_t i = 0; i < nd; i++) {
605 out <<
" vol = gGeoManager->GetVolume(" << quote <<
fVolume->GetName() << quote <<
");" << std::endl;
606 out <<
" node = vol->GetNode(" << i <<
");" << std::endl;
608 out <<
" node->VisibleDaughters(kFALSE);" << std::endl;
613 out <<
" node->SetVisibility(kFALSE);" << std::endl;
748 printf(
" Local : %g, %g, %g\n", point[0], point[1], point[2]);
749 if (!
fVolume->Contains(&point[0])) {
750 printf(
"current point not inside this\n");
756 printf(
"current node divided\n");
759 printf(
"point not inside division element\n");
762 printf(
"inside division element %s\n", node->
GetName());
767 printf(
"volume not voxelized\n");
777 printf(
"no candidates for current point\n");
781 for (
Int_t id = 0;
id < ncheck;
id++) {
782 node =
fVolume->GetNode(check_list[
id]);
787 printf(
"%i %s %s\n", check_list[
id], node->
GetName(), overlap.
Data());
798 printf(
"node %s no overlaps\n",
GetName());
801 printf(
"Overlaps for node %s :\n",
GetName());
805 printf(
" %s\n", node->
GetName());
816 return fVolume->GetShape()->Safety(local, in);
824 Int_t *ovlps =
nullptr;
825 if (src && (novlp > 0)) {
826 ovlps =
new Int_t[novlp];
827 memcpy(ovlps, src, novlp *
sizeof(
Int_t));
851 if (vis && !
fVolume->IsVisible())
900 Int_t count = 40 + 4;
1200 next =
fTop->GetNode(0);
1207 for (i = 2; i <
fLevel + 1; i++) {
1235 nd =
fTop->GetNdaughters();
1303 if (!level || level >
fLevel)
1306 for (
Int_t i = 2; i < level + 1; i++)
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char).
externTGeoManager * gGeoManager
externTGeoIdentity * gGeoIdentity
This class provides a simple interface to execute the same task multiple times in parallel threads,...
unsigned GetPoolSize() const
Returns the number of worker threads in the task arena.
void Foreach(F func, unsigned nTimes, unsigned nChunks=0)
Execute a function without arguments several times in parallel, dividing the execution in nChunks.
Using a TBrowser one can browse all ROOT objects.
Bool_t IsVisStreamed() const
Bool_t IsVisTouched() const
void SetVisStreamed(Bool_t vis=kTRUE)
Mark attributes as "streamed to file".
void SetVisDaughters(Bool_t vis=kTRUE)
Set visibility for the daughters.
virtual void SetVisibility(Bool_t vis=kTRUE)
Set visibility for this object.
void SetVisTouched(Bool_t vis=kTRUE)
Mark visualization attributes as "modified".
ABC for user objects attached to TGeoVolume or TGeoNode.
virtual TGeoExtension * Grab()=0
virtual void Release() const =0
Matrix class used for computing global transformations Should NOT be used for node definition.
void SetIterator(const TGeoIterator *iter)
TGeoIterator & operator=(const TGeoIterator &iter)
Assignment.
void Reset(TGeoVolume *top=nullptr)
Resets the iterator for volume TOP.
TGeoIteratorPlugin * fPlugin
virtual ~TGeoIterator()
Destructor.
const TGeoMatrix * GetCurrentMatrix() const
Returns global matrix for current node.
void SetTopName(const char *name)
Set the top name for path.
void GetPath(TString &path) const
Returns the path for the current node.
void IncreaseArray()
Increase by 30 the size of the array.
TGeoNode * GetNode(Int_t level) const
Returns current node at a given level.
TGeoNode * operator()()
Returns next node.
Int_t GetIndex(Int_t i) const
TGeoNode * Next()
Returns next node.
void SetUserPlugin(TGeoIteratorPlugin *plugin)
Set a plugin.
void Skip()
Stop iterating the current branch.
TGeoVolume * GetTopVolume() const
The manager class for any TGeo geometry.
TGeoNavigator * AddNavigator()
Add a navigator in the list of navigators.
TObjArray * GetListOfOverlaps()
TVirtualGeoChecker * GetGeomChecker()
Make a default checker if none present. Returns pointer to it.
void RebuildVoxels()
Rebuild the voxel structures that are flagged as needing rebuild.
void ClearOverlaps()
Clear the list of overlaps.
TGeoNavigator * GetCurrentNavigator() const
Returns current navigator for the calling thread.
void SetCheckingOverlaps(Bool_t flag=kTRUE)
void SetMaxThreads(Int_t nthreads)
Set maximum number of threads for navigation.
void SortOverlaps()
Sort overlaps by decreasing overlap distance. Extrusions comes first.
Geometrical transformation package.
virtual void LocalToMasterVect(const Double_t *local, Double_t *master) const
convert a vector by multiplying its column vector (x, y, z, 1) to matrix inverse
void Print(Option_t *option="") const override
print the matrix in 4x4 format
virtual void MasterToLocal(const Double_t *master, Double_t *local) const
convert a point by multiplying its column vector (x, y, z, 1) to matrix
virtual void MasterToLocalVect(const Double_t *master, Double_t *local) const
convert a point by multiplying its column vector (x, y, z, 1) to matrix
virtual void LocalToMaster(const Double_t *local, Double_t *master) const
convert a point by multiplying its column vector (x, y, z, 1) to matrix inverse
Class providing navigation API for TGeo geometries.
TGeoNodeCache * GetCache() const
TGeoStateInfo * GetInfo()
Get next state info pointer.
void ReleaseInfo()
Release last used state info pointer.
void SetMatrix(const TGeoMatrix *matrix)
Matrix setter.
TGeoNode * MakeCopyNode() const override
Make a copy of this node.
Int_t GetByteCount() const override
return the total size in bytes of this node
TGeoNodeMatrix()
Default constructor.
~TGeoNodeMatrix() override
Destructor.
Int_t GetOptimalVoxels() const override
Returns type of optimal voxelization for this node.
TGeoNodeMatrix(const TGeoNodeMatrix &gnm)=delete
void SetFinder(TGeoPatternFinder *finder)
TGeoPatternFinder * fFinder
TGeoPatternFinder * GetFinder() const override
~TGeoNodeOffset() override
Destructor.
TGeoNodeOffset()
Default constructor.
Int_t GetIndex() const override
Get the index of this offset.
TGeoNodeOffset(const TGeoNodeOffset &)=delete
TGeoNode * MakeCopyNode() const override
Make a copy of this node.
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Bool_t IsOverlapping() const
void SetFWExtension(TGeoExtension *ext)
Connect framework defined extension to the node.
Bool_t IsVisDaughters() const
Bool_t IsOnScreen() const
check if this node is drawn. Assumes that this node is current
TGeoVolume * GetVolume() const
void SaveAttributes(std::ostream &out)
save attributes for this node
void CheckOverlapsBySampling(Double_t ovlp=0.1, Int_t npoints=1000000)
Check overlaps bigger than OVLP hierarchically, starting with this node.
void CheckShapes()
check for wrong parameters in shapes
void PrintOverlaps() const
print possible overlapping nodes
TGeoExtension * fFWExtension
! Transient framework-defined extension to volumes
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
compute the closest distance of approach from point px,py to this node
TGeoNode()
Default constructor.
TGeoExtension * fUserExtension
! Transient user-defined extension to volumes
void SetOverlapping(Bool_t flag=kTRUE)
TGeoExtension * GrabFWExtension() const
Get a copy of the framework extension pointer.
void SetOverlaps(Int_t *ovlp, Int_t novlp)
set the list of overlaps for this node (ovlp must be created with operator new)
void PrintCandidates() const
print daughters candidates for containing current point
void ls(Option_t *option="") const override
Print the path (A/B/C/...) to this node on stdout.
Int_t GetNdaughters() const
TGeoNode * GetDaughter(Int_t ind) const
virtual TGeoMatrix * GetMatrix() const =0
void SetVisibility(Bool_t vis=kTRUE) override
Set visibility of the node (obsolete).
TGeoNode(const TGeoNode &)=delete
Bool_t MayOverlap(Int_t iother) const
Check the overlab between the bounding box of the node overlaps with the one the brother with index I...
void CopyOverlaps(Int_t *ovlp, Int_t novlp)
Copy content of lst of overlaps from source array.
void SetMotherVolume(TGeoVolume *mother)
void SetUserExtension(TGeoExtension *ext)
Connect user-defined extension to the node.
virtual void LocalToMasterVect(const Double_t *local, Double_t *master) const
Convert a vector from local reference system to mother reference.
void Browse(TBrowser *b) override
How-to-browse for a node.
void Paint(Option_t *option="") override
Paint this node and its content according to visualization settings.
void DrawOverlaps()
Method drawing the overlap candidates with this node.
virtual void LocalToMaster(const Double_t *local, Double_t *master) const
Convert the point coordinates from local reference system to mother reference.
Int_t CountDaughters(Bool_t unique_volumes=kFALSE)
Returns the number of daughters.
void DrawOnly(Option_t *option="")
draw only this node independently of its vis options
void Draw(Option_t *option="") override
draw current node according to option
void SetNumber(Int_t number)
virtual void MasterToLocal(const Double_t *master, Double_t *local) const
Convert the point coordinates from mother reference to local reference system.
TGeoExtension * GrabUserExtension() const
Get a copy of the user extension pointer.
Int_t FindNode(const TGeoNode *node, Int_t level)
Search for a node within the branch of this one.
void VisibleDaughters(Bool_t vis=kTRUE)
Set visibility of the daughters (obsolete).
void FillIdArray(Int_t &ifree, Int_t &nodeid, Int_t *array) const
Fill array with node id. Recursive on node branch.
virtual void MasterToLocalVect(const Double_t *master, Double_t *local) const
Convert a vector from mother reference to local reference system.
char * GetObjectInfo(Int_t px, Int_t py) const override
Get node info for the browser.
~TGeoNode() override
Destructor.
void SetCloned(Bool_t flag=kTRUE)
void CheckOverlaps(Double_t ovlp=0.1, Option_t *option="")
Check overlaps bigger than OVLP hierarchically, starting with this node.
void InspectNode() const
Inspect this node.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute mouse actions on this volume.
Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const
computes the closest distance from given point to this shape
base finder class for patterns. A pattern is specifying a division type
virtual TGeoNode * FindNode(Double_t *, const Double_t *=nullptr)
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
void SetVisibility(Bool_t vis=kTRUE) override
set visibility of this volume
void CheckOverlapsBySampling(Double_t ovlp=0.1, Int_t npoints=1000000)
Overlap by sampling legacy checking tool. Check for illegal overlaps within a limit OVLP.
Bool_t IsSelected() const
void SelectVolume(Bool_t clear=kFALSE)
Select this volume as matching an arbitrary criteria.
Finder class handling voxels.
virtual Int_t * GetCheckList(const Double_t *point, Int_t &nelem, TGeoStateInfo &td)
get the list of daughter indices for which point is inside their bbox
void PrintVoxelLimits(const Double_t *point) const
print the voxel containing point
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
Int_t GetEntriesFast() const
TObject * At(Int_t idx) const override
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Stop()
Stop the stopwatch.
void ToLower()
Change string to lower-case.
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual void OpProgress(const char *opname, Long64_t current, Long64_t size, TStopwatch *watch=nullptr, Bool_t last=kFALSE, Bool_t refresh=kFALSE, const char *msg="")=0
Abstract class for geometry painters.
virtual Int_t DistanceToPrimitiveVol(TGeoVolume *vol, Int_t px, Int_t py)=0
virtual const char * GetVolumeInfo(const TGeoVolume *volume, Int_t px, Int_t py) const =0
virtual void ExecuteVolumeEvent(TGeoVolume *volume, Int_t event, Int_t px, Int_t py)=0
virtual void PaintNode(TGeoNode *node, Option_t *option="", TGeoMatrix *global=nullptr)=0
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
UInt_t GetThreadPoolSize()
Returns the size of ROOT's thread pool.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Statefull info for the current geometry level.