Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
geom_cms.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_eve_7
3///
4/// \macro_code
5///
6/// \author Alja Mrak-Tadel
7
8#include <sstream>
9#include <iostream>
10
11#include "TGeoManager.h"
12#include "TGeoVolume.h"
13#include "TGeoMaterial.h"
14#include "TGeoMatrix.h"
15#include "TSystem.h"
16#include "TFile.h"
17#include <ROOT/REveGeoShape.hxx>
18#include <ROOT/REveTrans.hxx>
19#include <ROOT/REveScene.hxx>
20#include <ROOT/REveViewer.hxx>
21#include <ROOT/REveElement.hxx>
22#include <ROOT/REveManager.hxx>
23
24namespace REX = ROOT::Experimental;
25
27{
28 auto gss = n->GetVolume()->GetShape();
29 auto b1s = new REX::REveGeoShape(n->GetName());
30 b1s->InitMainTrans();
31 b1s->RefMainTrans().SetFrom(trans.Array());
32 b1s->SetShape(gss);
33 b1s->SetMainColor(kCyan);
34 holder->AddElement(b1s);
35}
36
38 int level)
39{
40 ++level;
41 if (level > maxlevel)
42 return;
43
44 for (int i = 0; i < pn->GetNdaughters(); ++i) {
45 TGeoNode *n = pn->GetDaughter(i);
46 TGeoMaterial *material = n->GetVolume()->GetMaterial();
48 ctrans.SetFrom(trans.Array());
49
50 {
51 TGeoMatrix *gm = n->GetMatrix();
52 const Double_t *rm = gm->GetRotationMatrix();
53 const Double_t *tv = gm->GetTranslation();
55 t(1, 1) = rm[0];
56 t(1, 2) = rm[1];
57 t(1, 3) = rm[2];
58 t(2, 1) = rm[3];
59 t(2, 2) = rm[4];
60 t(2, 3) = rm[5];
61 t(3, 1) = rm[6];
62 t(3, 2) = rm[7];
63 t(3, 3) = rm[8];
64 t(1, 4) = tv[0];
65 t(2, 4) = tv[1];
66 t(3, 4) = tv[2];
67 ctrans *= t;
68 }
69
70 std::string mn = material->GetName();
71 if (mn == mat) {
72 n->ls();
74 }
76 }
77}
78
79TGeoNode *getNodeFromPath(TGeoNode *top, std::string path)
80{
81 TGeoNode *node = top;
82 istringstream f(path);
83 string s;
84 while (getline(f, s, '/'))
85 node = node->GetVolume()->FindNode(s.c_str());
86
87 return node;
88}
89
90void geom_cms()
91{
92
93 auto eveMng = REX::REveManager::Create();
94
96
97 auto geoManager = eveMng->GetGeometry("http://root.cern/files/cms.root");
98 TGeoNode *top = geoManager->GetTopVolume()->FindNode("CMSE_1");
99
100 // tracker
101 {
102 auto holder = new REX::REveElement("Tracker");
103 eveMng->GetGlobalScene()->AddElement(holder);
104 TGeoNode *n = getNodeFromPath(top, "TRAK_1/SVTX_1/TGBX_1/GAW1_1");
105 REX::REveTrans trans;
106 std::string material = "TOB_Silicon";
107 filterChildNodes(n, trans, holder, material, 6, 0);
108 }
109
110 // muon
111 {
112 auto holder = new REX::REveElement("MUON");
113 eveMng->GetGlobalScene()->AddElement(holder);
114
115 auto n = getNodeFromPath(top, "MUON_1/MB_1");
116
117 std::string material = "M_B_Air";
118 REX::REveTrans trans;
119 filterChildNodes(n, trans, holder, material, 1, 0);
120
121 auto bv = n->GetVolume();
122 for (int i = 1; i < 5; ++i) {
123 auto n = bv->FindNode(Form("MBXC_%d", i));
124 auto gss = n->GetVolume()->GetShape();
125 auto b1s = new REX::REveGeoShape(Form("Arc %d", i));
126 b1s->InitMainTrans();
127 const double *move = n->GetMatrix()->GetTranslation();
128 b1s->RefMainTrans().SetFrom(*(n->GetMatrix()));
129 b1s->SetShape(gss);
130 b1s->SetMainColor(kBlue);
131 holder->AddElement(b1s);
132 }
133 }
134
135 eveMng->Show();
136}
#define f(i)
Definition RSha256.hxx:104
double Double_t
Double 8 bytes.
Definition RtypesCore.h:74
@ kCyan
Definition Rtypes.h:67
@ kBlue
Definition Rtypes.h:67
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2570
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
Base class describing materials.
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
TGeoNode * FindNode(const char *name) const
search a daughter inside the list of nodes
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const Int_t n
Definition legend1.C:16
Namespace for ROOT features in testing.
Definition TROOT.h:100