geom.C
Go to the documentation of this file.
1 class TGeoNode;
2 class TGeoVolume;
3 
5 {
6  TObjArray* va = gGeoManager->GetListOfVolumes();
7  int nv = va->GetEntries();
8  for (int i=0; i<nv; ++i) {
9  TGeoVolume* v = (TGeoVolume*)va->At(i);
10  std::string m(v->GetMaterial()->GetName());
11  int lc, vi, tr, vd;
12  if (m == "Air") { lc = kWhite; vi = 0; tr = 0; vd = 1; }
13  else if (m == "Granite") { lc = kYellow-8; vi = 1; tr = 0; vd = 1; }
14  else if (m == "Dirt") { lc = kGreen-8; vi = 1; tr = 0; vd = 1; }
15  else if (m == "ShotRock") { lc = kOrange-9; vi = 1; tr = 0; vd = 1; }
16  else if (m == "BariteRock") { lc = kOrange-4; vi = 1; tr = 0; vd = 1; }
17  else if (m == "Concrete") { lc = kGray; vi = 1; tr = 0; vd = 1; }
18  else if (m == "PVC") { lc = kWhite; vi = 1; tr = 0; vd = 1; }
19  else if (m == "Scintillator") { lc = kBlue-9; vi = 1; tr = 0; vd = 1; }
20  else if (m == "Glue") { lc = kViolet-9; vi = 1; tr = 0; vd = 1; }
21  else if (m == "Steel") { lc = kOrange+4; vi = 1; tr = 0; vd = 1; }
22  else if (m == "PivoterSteel") { lc = kOrange+2; vi = 1; tr = 0; vd = 1; }
23  else {
24  std::cout << "'" << m << "' has no defaults" << std::endl;
25  lc = kOrange; vi = 1; tr = 0; vd = 1;
26  }
27  v->SetLineColor(lc);
28  v->SetVisibility(vi);
29  v->VisibleDaughters(vd);
30  v->SetTransparency(tr);
31  }
32 }
33 
34 //......................................................................
35 
37 {
38  gGeoManager->GetVolume("vPlaneV")->VisibleDaughters(0);
39  gGeoManager->GetVolume("vPlaneV")->SetVisibility(1);
40  gGeoManager->GetVolume("vPlaneV")->SetLineColor(kWhite);
41 
42  gGeoManager->GetVolume("vPlaneH")->VisibleDaughters(0);
43  gGeoManager->GetVolume("vPlaneH")->SetVisibility(1);
44  gGeoManager->GetVolume("vPlaneH")->SetLineColor(kGray);
45 }
46 
47 //......................................................................
48 
50 {
51  gGeoManager->GetVolume("vPlaneVIPND")->VisibleDaughters(1);
52  gGeoManager->GetVolume("vPlaneVIPND")->SetVisibility(1);
53  gGeoManager->GetVolume("vPlaneVIPND")->SetLineColor(kBlue);
54 
55  gGeoManager->GetVolume("vPlaneHIPND")->VisibleDaughters(1);
56  gGeoManager->GetVolume("vPlaneHIPND")->SetVisibility(1);
57  gGeoManager->GetVolume("vPlaneHIPND")->SetLineColor(kGray);
58 
59  gGeoManager->GetVolume("vDetEnclosure")->SetVisibility(1);
60 
61  /*
62  gGeoManager->GetVolume("vShedEWWall")->SetVisibility(1);
63  gGeoManager->GetVolume("vShedEWWall")->SetLineColor(kBlue);
64 
65  gGeoManager->GetVolume("vShedNWall")->SetVisibility(1);
66  gGeoManager->GetVolume("vShedNWall")->SetLineColor(kBlue);
67 
68  gGeoManager->GetVolume("vShedSWall")->SetVisibility(1);
69  gGeoManager->GetVolume("vShedSWall")->SetLineColor(kBlue);
70 
71  gGeoManager->GetVolume("vShedRoof")->SetVisibility(1);
72  gGeoManager->GetVolume("vShedRoof")->SetLineColor(kBlue);
73  */
74 
75  gGeoManager->GetVolume("vSuperBlockIPND")->VisibleDaughters(1);
76  gGeoManager->GetVolume("vSuperBlockIPND")->SetVisibility(1);
77  gGeoManager->GetVolume("vSuperBlockIPND")->SetLineColor(kBlue-5);
78 
79  gGeoManager->GetVolume("vPlaneV")->VisibleDaughters(0);
80  gGeoManager->GetVolume("vPlaneV")->SetVisibility(1);
81  gGeoManager->GetVolume("vPlaneV")->SetLineColor(kWhite);
82 
83  gGeoManager->GetVolume("vPlaneH")->VisibleDaughters(0);
84  gGeoManager->GetVolume("vPlaneH")->SetVisibility(1);
85  gGeoManager->GetVolume("vPlaneH")->SetLineColor(kGray);
86 
87  gGeoManager->GetVolume("vDetEnclosure")->VisibleDaughters(1);
88 
89 }
90 
91 //......................................................................
92 
94 {
95 // gGeoManager->GetVolume("vPlaneVIPND")->VisibleDaughters(0);
96 // gGeoManager->GetVolume("vPlaneVIPND")->SetVisibility(1);
97 // gGeoManager->GetVolume("vPlaneVIPND")->SetLineColor(kWhite);
98 
99 // gGeoManager->GetVolume("vPlaneHIPND")->VisibleDaughters(0);
100 // gGeoManager->GetVolume("vPlaneHIPND")->SetVisibility(1);
101 // gGeoManager->GetVolume("vPlaneHIPND")->SetLineColor(kGray);
102 
103  gGeoManager->GetVolume("vPlaneV")->VisibleDaughters(0);
104  gGeoManager->GetVolume("vPlaneV")->SetVisibility(1);
105  gGeoManager->GetVolume("vPlaneV")->SetLineColor(kWhite);
106 
107  gGeoManager->GetVolume("vPlaneH")->VisibleDaughters(0);
108  gGeoManager->GetVolume("vPlaneH")->SetVisibility(1);
109  gGeoManager->GetVolume("vPlaneH")->SetLineColor(kGray);
110 
111  gGeoManager->GetVolume("vDetEnclosure")->VisibleDaughters(1);
112  gGeoManager->GetVolume("vDetEnclosure")->SetLineColor(kGreen);
113 
114  gGeoManager->GetVolume("vWestRockFill")->SetLineColor(kOrange);
115  gGeoManager->GetVolume("vMINOSTunnelWestRock")->SetLineColor(kGreen);
116  gGeoManager->GetVolume("vRockTop")->SetLineColor(kRed);
117  gGeoManager->GetVolume("vRockBase")->SetLineColor(kRed);
118  gGeoManager->GetVolume("vRockTop")->SetVisibility(1);
119  gGeoManager->GetVolume("vMINOSNorthWall")->SetLineColor(kBlue);
120 }
121 
122 //......................................................................
123 
124 int ncells = 0;
125 void FindCells(TGeoNode* planenode, TGeoNode* n, TGeoVolume* v)
126 {
127  const char* nm = v->GetName();
128  if (strncmp(nm,"vCell",5)==0) {
129  ++ncells;
130  std::cout << "Found cell "
131  << planenode->GetName() << "\t"
132  << n->GetName() << "\t"
133  << ncells
134  << std::endl;
135  return;
136  }
137  int nd = v->GetNdaughters();
138  for (int i=0; i<nd; ++i) {
139  FindCells(planenode, v->GetNode(i), v->GetNode(i)->GetVolume());
140  }
141 }
142 
143 //......................................................................
144 
145 int nplanes = 0;
146 void FindPlanes(TGeoNode* n, TGeoVolume* v)
147 {
148  const char* nm = v->GetName();
149  if (strncmp(nm,"vPlane",6)==0) {
150  ++nplanes;
151  FindCells(n, n, v);
152  return;
153  }
154 
155  int nd = v->GetNdaughters();
156  for (int i=0; i<nd; ++i) {
157  FindPlanes(v->GetNode(i), v->GetNode(i)->GetVolume());
158  }
159 }
160 
161 //......................................................................
162 
163 void geom(int which=0)
164 {
165  gSystem->Load("libGeom");
166  gSystem->Load("libGdml");
167 
168  TString det = "fardet-12x12-28block-xtru-vacuum-stagger-pivoter";
169 
170  if (which==1) det = "ndos-2x3-6block-xtru-vacuum";
171  else if (which==2) det = "neardet-3x3-8block-xtru-vacuum-stagger";
172  else if (which==3) det = "fardet-12x12-28block-xtru-vacuum-stagger-pivoter";
173  else if (which==4) det = "neardet_scibar-box-air";
174  else if (which==5) det = "ndos-2x3-6block-xtru-air";
175  else if (which==6) det = "ndos-2x3-6block-box-air";
176  else if (which==7) det = "ndos-2x3-6block-box-vacuum";
177  else if (which==8) det = "ndos-2x3-6block-trap-air";
178  else if (which==9) det = "ndos-2x3-6block-trap-vacuum";
179  else if (which==10) det = "ndos-2x3-4block_nomc-xtru-vacuum";
180  else if (which==11) det = "ndos-2x3-6block_nomc-xtru-vacuum";
181  else if (which==12) det = "ndos-2x3-6block-xtru_nocutout-air";
182  else if (which==13) det = "neardet-2x3-6block-xtru-vacuum";
183  else if (which==14) det = "neardet-3x2-6block-box-vacuum";
184  else if (which==15) det = "neardet-3x3-6block-box-vacuum";
185  else if (which==16) det = "fardet-12x12-29block-xtru-vacuum";
186  else if (which==17) det = "testbeam-1x1-2block-xtru-vacuum";
187  else if (which==18) det = "testbeam-1x1-3block-xtru-vacuum";
188  else if (which==19) det = "testbeam-2x2-2block-xtru-vacuum";
189  else if (which==20) det = "testbeam-2x2-3block-xtru-vacuum";
190  else if(which != 0){
191  fprintf(stderr, "Specify a geometry by number (look at the source)\n");
192  exit(1);
193  }
194 
195  TGeoManager::Import(det+".gdml");
196  gGeoManager->DefaultColors();
197  SetDrawOptions();
198 // if (which==0) SetFarDetOptions();
199 // if (which==1) SetNearDetOptions();
200 // if (which==2) SetIPNDOptions();
201 // if (which==3) SetIPNDOptions();
202 // if (which==4) SetNearDetOptions();
203 
204  // SetDrawOptions(gGeoManager->GetVolume("vWorld"));
205 
206  // TList* mat = gGeoManager->GetListOfMaterials();
207  // TIter next(mat);
208  // TObject *obj;
209  // while (obj = next()) obj->Print();
210 
211  // FindPlanes(0, gGeoManager->GetVolume("vWorld"));
212  gGeoManager->CheckOverlaps(0.00001);
213  gGeoManager->PrintOverlaps();
214 
215  gGeoManager->SetMaxVisNodes(70000);
216  gGeoManager->GetVolume("vWorld")->Draw("ogl");
217  gGeoManager->SetVisOption(0);
218 
219  TFile *tf = new TFile(det+".root", "RECREATE");
220  gGeoManager->Write();
221  tf->Close();
222 }
enum BeamMode kOrange
enum BeamMode kRed
void SetNearDetOptions()
Definition: geom.C:93
static constexpr Double_t nm
Definition: Munits.h:133
Timing fit.
void FindPlanes(TGeoNode *n, TGeoVolume *v)
Definition: geom.C:146
void SetDrawOptions()
Definition: geom.C:4
void SetFarDetOptions()
Definition: geom.C:36
void SetIPNDOptions()
Definition: geom.C:49
void FindCells(TGeoNode *planenode, TGeoNode *n, TGeoVolume *v)
Definition: geom.C:125
OStream cout
Definition: OStream.cxx:6
int nplanes
Definition: geom.C:145
enum BeamMode kViolet
def lc(target="")
Definition: g4zmq.py:63
void geom(int which=0)
Definition: geom.C:163
exit(0)
int ncells
Definition: geom.C:124
enum BeamMode kGreen
enum BeamMode kBlue
enum BeamMode string