BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
DetectorDescription/ROOTGeo/ROOTGeo-00-00-16/src/MucROOTGeo.cxx
Go to the documentation of this file.
1//$id$
2/*
3 * 2004/11/29 Zhengyun You Peking University
4 * Muc Geometry General for EventDisplay
5 *
6 * 2004/12/11 Zhengyun You Peking University
7 * named from MucGeo to MucROOTGeo
8 * inherit from class SubDetectorROOTGeo
9 */
10
11using namespace std;
12
13#include <string>
14#include <fstream>
15#include <iostream>
16#include <sstream>
17#include <vector>
18#include <iomanip>
19
20#include <TGeoManager.h>
21
22#include "ROOTGeo/MucROOTGeo.h"
23
24const int MucROOTGeo::m_kSeg[m_kPart] = {4, 8, 4};
25const int MucROOTGeo::m_kAbsorber[m_kPart] = {9, 9, 9};
26const int MucROOTGeo::m_kGap[m_kPart] = {8, 9, 8};
27const int MucROOTGeo::m_kPanel[m_kPart] = {4, 3, 4};
28
30{
31 // Default constructor.
32 for (int part = 0; part < m_kPart; part++) {
33 for (int seg = 0; seg < m_kSegMax; seg++) {
34 for (int gap = 0; gap < m_kGapMax; gap++) {
35 m_NodeGap[part][seg][gap] = 0;
36 m_PhysicalGap[part][seg][gap] = 0;
37 // m_NodeBox[part][seg][gap] = 0;
38 // m_PhysicalBox[part][seg][gap] = 0;
39 for (int strip = 0; strip < m_kStripMax; strip++) {
40 m_NodeStrip[part][seg][gap][strip] = 0;
41 m_PhysicalStrip[part][seg][gap][strip] = 0;
42 }
43 }
44 }
45 }
46
47 string GdmlManagementPath = getenv("GDMLMANAGEMENTROOT");
48 //cout << "MucGeoGeneral::InitFromXML(), GdmlManagementPath not found" << endl;
49 string GdmlFile = GdmlManagementPath + string("/dat/Muc.gdml");
50 //string GdmlFile = string("Muc.gdml");
51 cout << "GdmlFile " << GdmlFile << endl;
52 InitFromGdml( GdmlFile.c_str(), "Muc" );
53}
54
56{ }
57
58void
59MucROOTGeo::InitFromGdml( const char *gdmlFile, const char *setupName )
60{
61 ReadGdml(gdmlFile, setupName);
62 SetNode();
63 //SetDefaultVis();
64
65 m_ROOTGeoInit = 1;
66}
67
68void
70{
71 m_Muc = GetTopVolume();
72 if(!m_Muc) {
73 m_Muc = GetLogicalVolume("logicalMuc");
74 }
75 if(!m_Muc) std::cout << "m_Muc = 0" << std::endl;
76
77 int gapCount = 0;
78 for (int part = 0; part < m_kPart; part++) {
79 for (int seg = 0; seg < m_kSeg[part]; seg++) {
80 for (int gap = 0; gap < m_kGap[part]; gap++) {
81 m_StripNum[part][seg][gap] = GetVolumeStripPlane(part, seg, gap)->GetNdaughters();
82 //std::cout << part << " " << seg << " " << gap << " " << m_StripNum[part][seg][gap] <<" "<<GetVolumeStripPlane(part, seg, gap)->GetName()<< std::endl;
83
84 std::stringstream osnameGap;
85 osnameGap << "pv_" << "l" << "Muc" << "P" << part << "S" << seg << "G" << gap << "_" << gapCount;
86 m_NodeGap[part][seg][gap] = GetNode( osnameGap.str() );
87 gapCount++;
88
89 //cout<<"in MucROOTGeo "<<m_NodeGap[part][seg][gap]->GetName()<<" "<<m_NodeGap[part][seg][gap]->GetDaughter(0)->GetName()<<endl;
90
91 std::stringstream osnameBox;
92 osnameBox << "pv_" << "l" << "Muc" << "P" << part << "S" << seg << "G" << gap << "Al" << "_" << "0";
93 // m_NodeAluminumBox[part][seg][gap] = GetNode( osnameBox.str() );
94 TGeoNode *temp = GetNode( osnameBox.str() );
95
96 int segment = 0; if(part==1&&seg==2) segment = 2;
97 std::stringstream osnameStripPlane;
98 osnameStripPlane << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "SP" << "_" << "0";
99 m_NodeStripPlane[part][seg][gap] = GetNode( osnameStripPlane.str() );
100
101 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
102 std::stringstream osnameStrip;
103 if(strip < 10) {
104 osnameStrip << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << "00" << strip << "_" << strip;
105 }
106 else if(strip < 100) {
107 osnameStrip << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << "0" << strip << "_" << strip;
108 }
109 else {
110 osnameStrip << "pv_" << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "s" << strip << "_" << strip;
111 }
112
113 m_NodeStrip[part][seg][gap][strip] = GetNode( osnameStrip.str() );
114 }
115 }
116 }
117 }
118}
119
120void
122{
123 //std::cout << "begin of set defaultvis" << std::endl;
124 int mucColor = 2;
125 int absorberColor = 2;
126 int gapColor = 8;
127 int gasChamberColor = 8;
128 int bakeliteColor = 8;
129 int stripColor = 6;
130
131 m_Muc->SetLineColor(mucColor);
132 m_Muc->SetVisibility(0);
133
134 for (int part = 0; part < m_kPart; part++) {
135 for (int seg = 0; seg < m_kSeg[part]; seg++) {
136 for (int absorber = 0; absorber < m_kAbsorber[part]; absorber++) {
137 GetVolumeAbsorber(part, seg, absorber)->SetLineColor(absorberColor);
138 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(0);
139 if (part != 1) {
140 for (int panel = 0; panel < m_kPanel[part]; panel++) {
141 GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetLineColor(absorberColor);
142 GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetVisibility(0);
143 }
144 }
145 }
146
147 for (int gap = 0; gap < m_kGap[part]; gap++) {
148 GetVolumeGap(part, seg, gap)->SetLineColor(gapColor);
149 GetVolumeGap(part, seg, gap)->SetVisibility(0);
150 GetVolumeStripPlane(part, seg, gap)->SetLineColor(gapColor);
151 GetVolumeStripPlane(part, seg, gap)->SetVisibility(0);
152
153 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
154 GetVolumeStrip(part, seg, gap, strip)->SetLineColor(stripColor);
155 GetVolumeStrip(part, seg, gap, strip)->SetVisibility(1);
156 }
157
158 for (int panel = 0; panel < m_kPanel[part]; panel++) {
159 for(int bakelite = 0; bakelite < m_kBakelite; bakelite++) {
160 GetVolumeBakelite(part, seg, gap, panel, bakelite)->SetLineColor(bakeliteColor);
161 GetVolumeBakelite(part, seg, gap, panel, bakelite)->SetVisibility(0);
162 }
163 for (int gasChamber = 0; gasChamber < m_kGasChamber; gasChamber++) {
164 GetVolumeGasChamber(part, seg, gap, panel, gasChamber)->SetLineColor(gasChamberColor);
165 GetVolumeGasChamber(part, seg, gap, panel, gasChamber)->SetVisibility(0);
166 }
167 }
168 }
169 }
170 }
171
172 for (int part = 0; part < m_kPart; part++) {
173 for (int seg = 0; seg < m_kSeg[part]; seg++) {
174 for (int gap = 0; gap < m_kGap[part]; gap++) {
175 GetGap(part, seg, gap)->SetVisibility(0);
176 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
177 GetStrip(part, seg, gap, strip)->SetVisibility(0);
178 }
179 }
180 }
181 }
182
183 //std::cout << "end of set defaultvis" << std::endl;
184}
185
186void
188{
189 for (int part = 0; part < m_kPart; part++) {
190 for (int seg = 0; seg < m_kSeg[part]; seg++) {
191 for (int absorber = 0; absorber < m_kAbsorber[part]; absorber++) {
192 if(part == 1) {
193 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(1);
194 }
195 else {
196 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(0);
197 for (int panel = 0; panel < m_kPanel[part]; panel++) {
198 GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetVisibility(1);
199 }
200 }
201 }
202
203 for (int gap = 0; gap < m_kGap[part]; gap++) {
204 GetVolumeGap(part, seg, gap)->SetVisibility(0);
205 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
206 GetVolumeStrip(part, seg, gap, strip)->SetVisibility(0);
207 }
208
209 for (int panel = 0; panel < m_kPanel[part]; panel++) {
210 for(int bakelite = 0; bakelite < m_kBakelite; bakelite++) {
211 GetVolumeBakelite(part, seg, gap, panel, bakelite)->SetVisibility(1);
212 }
213 for (int gasChamber = 0; gasChamber < m_kGasChamber; gasChamber++) {
214 GetVolumeGasChamber(part, seg, gap, panel, gasChamber)->SetVisibility(1);
215 }
216 }
217 }
218 }
219 }
220
221 for (int part = 0; part < m_kPart; part++) {
222 for (int seg = 0; seg < m_kSeg[part]; seg++) {
223 for (int gap = 0; gap < m_kGap[part]; gap++) {
224 GetGap(part, seg, gap)->SetVisibility(1);
225 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
226 GetStrip(part, seg, gap, strip)->SetVisibility(0);
227 }
228 }
229 }
230 }
231}
232
233void
235{
236 for (int part = 0; part < m_kPart; part++) {
237 for (int seg = 0; seg < m_kSeg[part]; seg++) {
238 for (int absorber = 0; absorber < m_kAbsorber[part]; absorber++) {
239 if(part == 1) {
240 if(seg > 2) GetVolumeAbsorber(part, seg, absorber)->SetVisibility(1);
241 }
242 else {
243 GetVolumeAbsorber(part, seg, absorber)->SetVisibility(0);
244 for (int panel = 0; panel < m_kPanel[part]; panel++) {
245 if(seg > 0 && seg < 3) GetVolumeAbsorberPanel(part, seg, absorber, panel)->SetVisibility(1);
246 }
247 }
248 }
249
250 for (int gap = 0; gap < m_kGap[part]; gap++) {
251 if (part == 1 && seg > 2) {
252 GetVolumeGap(part, seg, gap)->SetVisibility(1);
253 GetGap(part, seg, gap)->SetVisibility(1);
254 }
255 else {
256 GetVolumeGap(part, seg, gap)->SetVisibility(0);
257 GetGap(part, seg, gap)->SetVisibility(0);
258 }
259 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
260 GetVolumeStrip(part, seg, gap, strip)->SetVisibility(0);
261 }
262
263 for (int panel = 0; panel < m_kPanel[part]; panel++) {
264 for (int bakelite = 0; bakelite < m_kBakelite; bakelite++) {
265 if ((part != 1 && seg > 0 && seg < 3) || (part == 1 && seg > 2)) GetVolumeBakelite(part, seg, gap, panel, bakelite)->SetVisibility(1);
266 }
267 for (int gasChamber = 0; gasChamber < m_kGasChamber; gasChamber++) {
268 if ((part != 1 && seg > 0 && seg < 3) || (part == 1 && seg > 2)) GetVolumeGasChamber(part, seg, gap, panel, gasChamber)->SetVisibility(1);
269 }
270 }
271 }
272 }
273 }
274
275}
276
277void
279{
280 int stripColor = 2;
281
282 if (gGeoManager == 0) std::cout << "Create gGeoManager first" << std::endl;
283 TGeoNode *bes = gGeoManager->GetTopNode();
284 TGeoNode *muc = bes->GetDaughter(m_childNo);
285
286 for (int part = 0; part < m_kPart; part++) {
287 for (int seg = 0; seg < m_kSeg[part]; seg++) {
288 for (int gap = 0; gap < m_kGap[part]; gap++) {
289 TGeoNode *nodeGap = GetGap(part, seg, gap);
290 m_PhysicalGap[part][seg][gap] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
291 TString("/") + muc->GetName() +
292 TString("/") + nodeGap->GetName() +
293 TString("/") + nodeGap->GetDaughter(0)->GetName());
294 m_PhysicalGap[part][seg][gap]->SetVisibility(0);
295 m_PhysicalGap[part][seg][gap]->SetIsVolAtt(kFALSE);
296
297 TGeoNode *nodeStripPlane = GetStripPlane(part, seg, gap);
298 //std::cout << nodeGap->GetName() << " " << nodeStripPlane->GetName() << endl;
299
300 //TGeoNode *nodeBox = GetAluminumBox(part, seg, gap);
301// m_PhysicalAluminumBox[part][seg][gap] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
302// TString("/") + muc->GetName() +
303// TString("/") + nodeGap->GetName() +
304// TString("/") + nodeGap->GetDaughter(0)->GetName() );
305
306
307 for (int strip = 0; strip < m_StripNum[part][seg][gap]; strip++) {
308 TGeoNode *nodeStrip = GetStrip(part, seg, gap, strip);
309 m_PhysicalStrip[part][seg][gap][strip] = gGeoManager->MakePhysicalNode( TString("/") + bes->GetName() +
310 TString("/") + muc->GetName() +
311 TString("/") + nodeGap->GetName() +
312 TString("/") + nodeGap->GetDaughter(0)->GetName() +
313 TString("/") + nodeStripPlane->GetName() +
314 TString("/") + nodeStrip->GetName() );
315 m_PhysicalStrip[part][seg][gap][strip]->SetVisibility(0);
316 m_PhysicalStrip[part][seg][gap][strip]->SetIsVolAtt(kFALSE);
317 m_PhysicalStrip[part][seg][gap][strip]->SetLineColor(stripColor);
318 }
319 }
320 }
321 }
322}
323
324int
326{
327 int part = m_kPart;
328 return part;
329}
330
331int
333{
334 int seg = m_kSeg[part];
335 return seg;
336}
337
338int
340{
341 int gap = m_kGap[part];
342 return gap;
343}
344
345int
346MucROOTGeo::GetStripNum(int part, int seg, int gap)
347{
348 int strip = m_StripNum[part][seg][gap];
349 return strip;
350}
351
352TGeoVolume*
353MucROOTGeo::GetVolumeAbsorber( int part, int seg, int absorber )
354{
355 std::stringstream osname;
356 osname << "l" << "Muc" << "P" << part << "S" << seg << "Ab" << absorber;
357
358 return GetLogicalVolume( osname.str() );
359}
360
361float
362MucROOTGeo::GetAbsorberThickness( int part, int seg, int absorber )
363{
364 float thickness = 0.0;
365 TGeoVolume *vol = GetVolumeAbsorber(part, seg, absorber);
366 if (vol) {
367 thickness = 2.0*((TGeoBBox*)vol->GetShape())->GetDZ();
368 }
369
370 return thickness;
371}
372
373TGeoVolume*
374MucROOTGeo::GetVolumeAbsorberPanel( int part, int seg, int absorber, int panel )
375{
376 std::stringstream osname;
377 osname << "l" << "Muc" << "P" << part << "S" << seg << "Ab" << absorber << "Pn" << panel;
378
379 return GetLogicalVolume( osname.str() );
380}
381
382TGeoVolume*
383MucROOTGeo::GetVolumeGap( int part, int seg, int gap )
384{
385 std::stringstream osname;
386 osname << "l" << "Muc" << "P" << part << "S" << seg << "G" << gap;
387
388 return GetLogicalVolume( osname.str() );
389}
390
391TGeoVolume*
392MucROOTGeo::GetVolumeAluminumBox( int part, int seg, int gap )
393{
394 std::stringstream osname;
395 osname <<"l" << "Muc" << "P" << part << "S" << seg << "G" << gap <<"Al";
396
397 return GetLogicalVolume( osname.str() );
398}
399
400TGeoVolume*
401MucROOTGeo::GetVolumeStripPlane( int part, int seg, int gap )
402{
403 int segment = 0; if(part==1&&seg==2) segment = 2;
404 std::stringstream osname;
405 osname << "l" << "Muc" << "P" << part << "S" << segment << "G" << gap << "SP";
406
407 return GetLogicalVolume( osname.str() );
408}
409
410TGeoVolume*
411MucROOTGeo::GetVolumeStrip( int part, int seg, int gap, int strip )
412{
413 std::stringstream osname;
414 if(strip < 10) {
415 osname << "l" << "Muc" << "P" << part << "S" << "0" << "G" << gap << "s" << "00" << strip;
416 }
417 else if(strip<100){
418 osname << "l" << "Muc" << "P" << part << "S" << "0" << "G" << gap << "s" << "0" << strip;
419 }
420 else {
421 osname << "l" << "Muc" << "P" << part << "S" << "0" << "G" << gap << "s" << strip;
422 }
423
424 return GetLogicalVolume( osname.str() );
425}
426
427TGeoVolume*
428MucROOTGeo::GetVolumeGasChamber( int part, int seg, int gap, int panel, int gasChamber )
429{
430 std::stringstream osname;
431 osname << "l" << "Muc" << "P" << part << "S" << "0" << "G" << gap << "R" << gasChamber << "Pn" << panel << "C";
432
433 return GetLogicalVolume( osname.str() );
434}
435
436TGeoVolume*
437MucROOTGeo::GetVolumeBakelite( int part, int seg, int gap, int panel, int bakelite )
438{
439 std::stringstream osname;
440 osname << "l" << "Muc" << "P" << part << "S" << "0" << "G" << gap << "R" << panel << "B" << bakelite;
441
442 return GetLogicalVolume( osname.str() );
443}
444
445TGeoNode*
446MucROOTGeo::GetGap( int part, int seg, int gap )
447{
448 if (m_NodeGap[part][seg][gap] != 0) {
449 return m_NodeGap[part][seg][gap];
450 }
451 else {
452 std::cout << "Node: " << "Part" << part << "Seg" << seg << "Gap" << gap << " not found" << std::endl;
453 return 0;
454 }
455}
456
457// TGeoNode*
458// MucROOTGeo::GetAluminumBox( int part, int seg, int gap )
459// {
460// if (m_NodeAluminumBox[part][seg][gap] != 0) {
461// return m_NodeAluminumBox[part][seg][gap];
462// }
463// else {
464// std::cout << "Node: " << "Part" << part << "Seg" << seg << "Gap" << gap << "AluminumBox" << " not found" << std::endl;
465// return 0;
466// }
467// }
468
469
470TGeoNode*
471MucROOTGeo::GetStripPlane( int part, int seg, int gap )
472{
473 if (m_NodeStripPlane[part][seg][gap] != 0) {
474 return m_NodeStripPlane[part][seg][gap];
475 }
476 else {
477 std::cout << "Node: " << "Part" << part << "Seg" << seg << "Gap" << gap << "StripPlane" << " not found" << std::endl;
478 return 0;
479 }
480}
481
482TGeoNode*
483MucROOTGeo::GetStrip( int part, int seg, int gap, int strip )
484{
485 if (m_NodeStrip[part][seg][gap][strip] != 0) {
486 return m_NodeStrip[part][seg][gap][strip];
487 }
488 else {
489 std::cout << "Node: " << "Part" << part << "Seg" << "0" << "Gap" << gap << "Strip" << strip << " not found" << std::endl;
490 return 0;
491 }
492}
493
494TGeoPhysicalNode*
495MucROOTGeo::GetPhysicalGap( int part, int seg, int gap )
496{
497 if (m_PhysicalGap[part][seg][gap] != 0) {
498 return m_PhysicalGap[part][seg][gap];
499 }
500 else {
501 std::cout << "PhysicalNode: " << "Part" << part << "Seg" << seg << "Gap" << gap << " not found" << std::endl;
502 return 0;
503 }
504}
505
506// TGeoPhysicalNode*
507// MucROOTGeo::GetPhysicalAluminumBox( int part, int seg, int gap )
508// {
509// if (m_PhysicalAluminumBox[part][seg][gap] != 0) {
510// return m_PhysicalAluminumBox[part][seg][gap];
511// }
512// else {
513// std::cout << "PhysicalNode: " << "Part" << part << "Seg" << seg << "Gap" << gap << "AluminumBox" << " not found" << std::endl;
514// return 0;
515// }
516// }
517
518TGeoPhysicalNode*
519MucROOTGeo::GetPhysicalStrip( int part, int seg, int gap, int strip )
520{
521 if (m_PhysicalStrip[part][seg][gap][strip] != 0) {
522 return m_PhysicalStrip[part][seg][gap][strip];
523 }
524 else {
525 std::cout << "PhysicalNode: " << "Part" << part << "Seg" << seg << "Gap" << gap << "Strip" << strip << " not found" << std::endl;
526 return 0;
527 }
528}
TGeoVolume * GetVolumeStripPlane(int part, int seg, int gap)
Get strip plane volume;.
void SetPhysicalNode()
Set the pointers to the physical nodes;.
float GetAbsorberThickness(int part, int seg, int absorber)
Get thickness of an absorber;.
TGeoVolume * GetVolumeAluminumBox(int part, int seg, int gap)
Get box volume;
TGeoVolume * GetVolumeGasChamber(int part, int seg, int gap, int panel, int gasChamber)
Get rpc gas chamber volume;
TGeoPhysicalNode * GetPhysicalStrip(int part, int seg, int gap, int strip)
Get strip physical node;.
TGeoVolume * GetVolumeBakelite(int part, int seg, int gap, int panel, int bakelite)
Get rpc bakelite volume;
void SetNode()
Set the pointers to theirs nodes;.
TGeoVolume * GetVolumeAbsorberPanel(int part, int seg, int absorber, int panel)
Get absorber panel volume;
TGeoVolume * GetVolumeGap(int part, int seg, int gap)
Get gap volume;
int GetSegNum(int part)
Get number of segment on part;.
TGeoNode * GetGap(int part, int seg, int gap)
Get absorber node;
TGeoNode * GetStripPlane(int part, int seg, int gap)
Get box node;.
void SetDefaultVis()
Set default visual attributes;.
TGeoVolume * GetVolumeStrip(int part, int seg, int gap, int strip)
Get strip volume;
TGeoVolume * GetVolumeAbsorber(int part, int seg, int absorber)
Get absorber volume;
TGeoPhysicalNode * GetPhysicalGap(int part, int seg, int gap)
Get rpc gas chamber node;
TGeoNode * GetStrip(int part, int seg, int gap, int strip)
Get strip node;
int GetStripNum(int part, int seg, int gap)
Get number of strip on gap;.
void InitFromGdml(const char *gdmlFile, const char *setupName)
Initialize the instance of ROOTGeo.
int GetGapNum(int part)
Get number of gap on part;.
TGeoNode * GetNode(const std::string &nn)
Get a node(physical volume) by name;.
TGeoVolume * GetLogicalVolume(const std::string &vn)
Get a logical volume by name;.
void ReadGdml(const char *gdmlFile, const char *setupName)
Initialize the instance of ROOTGeo.