Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
write_geo_extract.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve_7
3/// Helper script to create REveGeoShapeExtract fro TGeo geometry
4/// One can rely on GeoTable to access paths
5/// \macro_code
6///
7/// \author Alja Mrak Tadel
8
11#include <ROOT/REveManager.hxx>
12#include "TFile.h"
13
14#include <set>
15#include <vector>
16#include <iostream>
17
18using namespace ROOT::Experimental;
19
20REveGeoShape *makeShape(const std::string &targetPath, const char* name)
21{
22 // for the moment top node is tracker at the startup
23
25 TGeoNode *currentNode;
26
27 while ((currentNode = next())) {
29 next.GetPath(currentPath); // Retrieves the full hierarchy path
30 // std::cout << "compare" << currentPath << "\n";
31 if (currentPath == targetPath) {
32 // Found the node via path matching
33 printf("Node found: %s\n", currentNode->GetName());
34 break;
35 }
36 }
37
38 const TGeoMatrix *mat = next.GetCurrentMatrix();
39 const Double_t *t = mat->GetTranslation(); // size 3
40 const Double_t *r = mat->GetRotationMatrix(); // size 9 (3x3)
41
42 Double_t m[16];
43 if (mat->IsScale()) {
44 const Double_t *s = mat->GetScale();
45 m[0] = r[0] * s[0];
46 m[1] = r[3] * s[0];
47 m[2] = r[6] * s[0];
48 m[3] = 0;
49 m[4] = r[1] * s[1];
50 m[5] = r[4] * s[1];
51 m[6] = r[7] * s[1];
52 m[7] = 0;
53 m[8] = r[2] * s[2];
54 m[9] = r[5] * s[2];
55 m[10] = r[8] * s[2];
56 m[11] = 0;
57 m[12] = t[0];
58 m[13] = t[1];
59 m[14] = t[2];
60 m[15] = 1;
61 } else {
62 m[0] = r[0];
63 m[1] = r[3];
64 m[2] = r[6];
65 m[3] = 0;
66 m[4] = r[1];
67 m[5] = r[4];
68 m[6] = r[7];
69 m[7] = 0;
70 m[8] = r[2];
71 m[9] = r[5];
72 m[10] = r[8];
73 m[11] = 0;
74 m[12] = t[0];
75 m[13] = t[1];
76 m[14] = t[2];
77 m[15] = 1;
78 }
79
80 TGeoShape *shape = currentNode->GetVolume()->GetShape();
81 shape->SetName(name);
83 rgs->SetShape(shape);
84
85 rgs->InitMainTrans();
86 rgs->RefMainTrans().SetFrom(m);
87 return rgs;
88}
89
91{
93
94 auto eveMng = REveManager::Create();
95 // eveMng->AllowMultipleRemoteConnections(false, false);
96 auto s_geoManager = TGeoManager::Import("http://xrd-cache-1.t2.ucsd.edu/alja/mail/geo/cmsSimGeo2026.root");
97
98 // tracker wrapper
99 REveGeoShape *tracker = makeShape("cms:OCMS/tracker:Tracker_1/otst:supportR1190Z1450_1", "tracker");
100 tracker->SetMainColor(kRed);
101 tracker->SetMainTransparency(50);
102
103 // tracker barrel
105 makeShape("cms:OCMS/tracker:Tracker_1/pixbar:Phase2OTBarrel_1/tracker:supportR212Z604_1", "barrel");
106 tracker->AddElement(barrel);
107
108 // front and back endcaps
109 REveGeoShape *e1 = makeShape("cms:OCMS/tracker:Tracker_1/pixfwd:Phase2OTForward_1", "endcap_1");
110 tracker->AddElement(e1);
111 REveGeoShape *e2 = makeShape("cms:OCMS/tracker:Tracker_1/pixfwd:Phase2OTForward_2", "endcap_2");
112 tracker->AddElement(e2);
113
114 // save extract on top element
115 tracker->SaveExtract("testShapeExtract.root", "VSDGeo");
116
117 eveMng->GetEventScene()->AddElement(tracker);
118 eveMng->Show();
119}
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
@ kRed
Definition Rtypes.h:67
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
char name[80]
Definition TGX11.cxx:145
R__EXTERN TGeoManager * gGeoManager
Wrapper for TGeoShape with absolute positioning and color attributes allowing display of extracted TG...
static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected=kTRUE, Bool_t forceCacheread=kFALSE)
Sets the directory where to locally stage/cache remote files.
Definition TFile.cxx:4338
A geometry iterator.
Definition TGeoNode.h:249
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
TGeoVolume * GetTopVolume() const
Geometrical transformation package.
Definition TGeoMatrix.h:39
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
TGeoVolume * GetVolume() const
Definition TGeoNode.h:100
Base abstract class for all shapes.
Definition TGeoShape.h:25
TGeoShape * GetShape() const
Definition TGeoVolume.h:191
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
Basic string class.
Definition TString.h:138
Namespace for ROOT features in testing.
Definition TROOT.h:100
TMarker m
Definition textangle.C:8