Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
REveGeoOverlaps.hxx
Go to the documentation of this file.
1
2#ifndef ROOT7_REveGeoOverlaps
3#define ROOT7_REveGeoOverlaps
4
6
7#include "TGeoMatrix.h"
8
9#include <set>
10#include <string>
11#include <vector>
12
13class TGeoManager;
14class TGeoVolume;
15
16namespace ROOT {
17namespace Experimental {
18
19////////////////////////////////////////////////////////////////////////////////
20/// \class REveGeoOverlapTable
21/// \brief The overlaps and extrusions of a geometry, as a flat list plus a 3D view.
22///
23/// Server side of the overlap browser. ScanOverlaps() runs TGeoVolume::CheckOverlaps()
24/// once over the whole geometry and turns the resulting TGeoOverlap objects into
25/// something a client can display; the list is streamed with the element and the
26/// client picks one row, which comes back as a SelectOverlap() MIR.
27///
28/// Three things TGeoOverlap does not hand over and that this class works out:
29///
30/// - **which placement an overlap belongs to.** TGeoOverlap names two volumes and
31/// gives their matrices but never a TGeoNode. The matrices are in the frame of
32/// the mother volume whose daughters were checked, so (volume, matrix) pins the
33/// daughter down exactly.
34/// - **where that is in the detector.** An overlap is a property of a *logical*
35/// volume, so it exists at every physical placement of that volume -- possibly
36/// several. Each entry therefore carries the global matrix of every placement,
37/// and the 3D view draws the pair at all of them.
38/// - **which points are usable.** The TPolyMarker3D that TGeoOverlap fills is in
39/// the mother's own local frame -- the same one the matrices above use, not
40/// global coordinates, despite how it looks at first glance -- and some points
41/// come out non-finite, or finite but nowhere near either daughter. Left in,
42/// the bad ones give the point set an unbounded bbox (the camera has nothing
43/// to frame) or just draw markers in the wrong place; both are handled here.
44
46public:
47 /// One kind of flaw, with every placement of it that the geometry contains.
48 /// The CMS geometry reports the EBAR/ESPM extrusion 36 times, once per
49 /// supermodule; grouping turns 71 rows into 36 distinct problems.
50 struct Group {
51 std::string fVol1, fVol2;
52 bool fExtrusion{true};
53 double fValue{0.}; ///< largest value among the members
54 std::vector<int> fMembers; ///< indices into the entry list
55 };
56
57 struct Entry {
58 std::string fName; ///< TGeoOverlap name, e.g. ov00035
59 std::string fTitle; ///< human-readable description
60 std::string fVol1, fVol2; ///< names of the two volumes
61 bool fExtrusion{true}; ///< extrusion, as opposed to a real overlap
62 double fValue{0.}; ///< overlap/extrusion size, in cm
63
64 TGeoVolume *fV1{nullptr}; ///<! first volume; the mother, for an extrusion
65 TGeoVolume *fV2{nullptr}; ///<! second volume
66 TGeoVolume *fMother{nullptr}; ///<! volume both matrices are expressed in
67 TGeoHMatrix fM1, fM2; ///<! placements, in the mother's local frame
68
69 std::vector<TGeoHMatrix> fGlobals; ///<! global matrix of every placement of the mother
70 std::vector<float> fLocalMarkers; ///<! marker points, in the mother's frame, finite only
71 int fNumRawMarkers{0}; ///< points the overlap carried, before filtering
72 };
73
74private:
77
78 std::vector<Entry> fEntries;
79 std::vector<Group> fGroups;
80 REveElement *fHolder{nullptr}; ///<! where the selected overlap is drawn; put this in a 3D scene
81 TGeoManager *fMgr{nullptr}; ///<! kept from ScanOverlaps() so SetPrecision() can re-run it
82 int fSelected{-1};
84 double fPrecision{0.001};
85 int fScanGen{0}; ///< bumped by ScanOverlaps(); lets the client tell a rescan from an ordinary selection stamp
86 float fMarkerSize{8.f};
87 float fCrossSize{15.f}; ///< cap, in cm, on the half-length of each marker's 3D-cross arm; AddPlacement()
88 ///< scales the actual arm to the smaller daughter's size and never exceeds this
89
91 void LocalizeMarkers(Entry &ent, const std::vector<float> &localPts);
92 void AddPlacement(const Entry &ent, const TGeoHMatrix &global, int placement, std::set<std::string> *seen = nullptr,
93 int inst = -1, int ninst = 0);
94 std::string MakeTip(const Entry &ent, int which, int placement, int inst, int ninst) const;
95 void BuildGroups();
96 void Redraw();
97
98public:
99 REveGeoOverlapTable(const Text_t *n = "Overlaps", const Text_t *t = "");
101
102 void ScanOverlaps(TGeoManager *mgr, double precision = 0.001);
103
104 /** Element carrying the shapes of the selected overlap. Add it to a 3D scene. */
106
107 int GetNumOverlaps() const { return (int)fEntries.size(); }
108 int GetNumGroups() const { return (int)fGroups.size(); }
109 int GetSelected() const { return fSelected; }
110 double GetPrecision() const { return fPrecision; }
111 float GetMarkerSize() const { return fMarkerSize; }
112 float GetCrossSize() const { return fCrossSize; }
113
114 // reachable from the client as MIRs
115 void SelectOverlap(int idx);
116 void SelectUniqueOverlap(int gidx);
117 void SetMarkerSize(float size);
118 void SetCrossSize(float size);
119 void SetPrecision(double precision);
120 void PrintOverlap(int idx);
121 void PrintUniqueOverlap(int gidx);
122
123 Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
124};
125
126} // namespace Experimental
127} // namespace ROOT
128
129#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
char Text_t
General string (char)
Definition RtypesCore.h:77
The overlaps and extrusions of a geometry, as a flat list plus a 3D view.
void ScanOverlaps(TGeoManager *mgr, double precision=0.001)
Find every overlap and extrusion in the geometry and work out where each one is.
void SelectOverlap(int idx)
Show one overlap and nothing else.
std::string MakeTip(const Entry &ent, int which, int placement, int inst, int ninst) const
Text shown when the mouse is over one of the drawn pieces.
REveGeoOverlapTable & operator=(const REveGeoOverlapTable &)=delete
float fCrossSize
cap, in cm, on the half-length of each marker's 3D-cross arm; AddPlacement() scales the actual arm to...
void AddPlacement(const Entry &ent, const TGeoHMatrix &global, int placement, std::set< std::string > *seen=nullptr, int inst=-1, int ninst=0)
Draw one placement of the selected overlap: the two shapes and the points.
void SetMarkerSize(float size)
Marker size for the overlap points.
REveElement * fHolder
! where the selected overlap is drawn; put this in a 3D scene
TGeoManager * fMgr
! kept from ScanOverlaps() so SetPrecision() can re-run it
void SetPrecision(double precision)
Re-run the overlap check at a new precision and rebuild the table from scratch.
REveGeoOverlapTable(const REveGeoOverlapTable &)=delete
void PrintOverlap(int idx)
Print one overlap's details to the server console: name, volumes, mother, TGeoOverlap's own title (us...
void Redraw()
Re-run whichever selection is current, so a change of appearance takes effect without the client havi...
void SelectUniqueOverlap(int gidx)
Show every instance of one kind of flaw at once.
void LocalizeMarkers(Entry &ent, const std::vector< float > &localPts)
Filter the marker points down to the ones that plausibly belong to this flaw.
int fScanGen
bumped by ScanOverlaps(); lets the client tell a rescan from an ordinary selection stamp
void PrintUniqueOverlap(int gidx)
Print a whole group – every entry sharing this (vol1, vol2, extrusion) – to the server console,...
void SetCrossSize(float size)
Cap, in cm, on the half-length of each marker's 3D-cross arm.
void CollectPlacements(TGeoManager *mgr)
Global matrix of every physical placement of each mother volume.
Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override
Write core json.
void BuildGroups()
Collapse entries that are the same flaw repeated.
REveElement * GetVizHolder()
Element carrying the shapes of the selected overlap.
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition TGeoMatrix.h:459
The manager class for any TGeo geometry.
Definition TGeoManager.h:46
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:45
const Int_t n
Definition legend1.C:16
TGeoVolume * fV1
! first volume; the mother, for an extrusion
TGeoHMatrix fM2
! placements, in the mother's local frame
std::string fName
TGeoOverlap name, e.g. ov00035.
std::string fTitle
human-readable description
std::string fVol2
names of the two volumes
std::vector< TGeoHMatrix > fGlobals
! global matrix of every placement of the mother
bool fExtrusion
extrusion, as opposed to a real overlap
int fNumRawMarkers
points the overlap carried, before filtering
TGeoVolume * fMother
! volume both matrices are expressed in
double fValue
overlap/extrusion size, in cm
std::vector< float > fLocalMarkers
! marker points, in the mother's frame, finite only
One kind of flaw, with every placement of it that the geometry contains.
std::vector< int > fMembers
indices into the entry list
double fValue
largest value among the members