BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
DetectorDescription/ROOTGeo/src/TofROOTGeo.cxx
Go to the documentation of this file.
1//$id$
2/*
3 * 2004/11/29 Zhengyun You Peking University
4 * Tof Geometry General for EventDisplay
5 *
6 * 2004/12/9 Zhengyun You Peking University
7 * named from TofGeo to TofROOTGeo
8 * inherit from class SubDetectorROOTGeo
9 */
10
11using namespace std;
12
13#include <fstream>
14#include <iomanip>
15#include <iostream>
16#include <sstream>
17#include <string>
18#include <vector>
19
20#include <TGeoManager.h>
21
22#include "ROOTGeo/TofROOTGeo.h"
23
25 // Default constructor.
26 for ( int part = 0; part < m_kPart; part++ )
27 {
28 for ( int scin = 0; scin < m_kAssemblyBr; scin++ )
29 {
30 m_NodeScin[part][scin] = 0;
31 m_PhysicalScin[part][scin] = 0;
32 }
33 }
34}
35
37
38void TofROOTGeo::InitFromGdml( const char* gdmlFile, const char* setupName ) {
39 ReadGdml( gdmlFile, setupName );
40 SetNode();
42
43 m_ROOTGeoInit = 1;
44}
45
47 m_Tof = GetTopVolume();
48 if ( !m_Tof ) std::cout << "m_Tof = 0" << std::endl;
49
50 for ( int part = 0; part < m_kPart; part++ )
51 {
52 int nScin = 0;
53 if ( part == 1 ) nScin = m_kAssemblyBr;
54 else nScin = m_kAssemblyEc;
55 for ( int scin = 0; scin < nScin; scin++ )
56 {
57 std::stringstream osname;
58 if ( part == 0 )
59 {
60 osname << "pv_"
61 << "logical"
62 << "Tof"
63 << "ScinEc"
64 << "_" << m_kAssemblyBr + m_kAssemblyEc + scin << "_0";
65 }
66 else if ( part == 1 )
67 {
68 osname << "pv_"
69 << "logical"
70 << "Tof"
71 << "ScinBr"
72 << "_" << scin << "_0";
73 }
74 else if ( part == 2 )
75 {
76 osname << "pv_"
77 << "logical"
78 << "Tof"
79 << "ScinEc"
80 << "_" << m_kAssemblyBr + scin << "_0";
81 }
82
83 m_NodeScin[part][scin] = GetNode( osname.str() );
84 }
85 }
86}
87
89 // std::cout << "begin of set defaultvis" << std::endl;
90 int tofColor = 2;
91 int scinColor = 6;
92 int bucketColor = 4;
93
94 m_Tof->SetLineColor( tofColor );
95 m_Tof->SetVisibility( 0 );
96
97 for ( int part = 0; part < m_kPart; part++ )
98 {
99 GetVolumeScin( part )->SetLineColor( scinColor );
100 GetVolumeScin( part )->SetVisibility( 1 );
101 GetVolumeBucket( part )->SetLineColor( bucketColor );
102 GetVolumeBucket( part )->SetVisibility( 0 );
103
104 int nScin = 0;
105 if ( part == 1 ) nScin = m_kAssemblyBr;
106 else nScin = m_kAssemblyEc;
107 for ( int scin = 0; scin < nScin; scin++ )
108 {
109 GetScin( part, scin )->SetVisibility( 0 );
110
111 int nBucket = 0;
112 if ( part == 1 ) nBucket = m_kBucketBr;
113 else nBucket = m_kBucketEc;
114 for ( int bucket = 0; bucket < nBucket; bucket++ )
115 { GetBucket( part, scin, bucket )->SetVisibility( 0 ); }
116 }
117 }
118 // std::cout << "end of set defaultvis" << std::endl;
119}
120
122 for ( int part = 0; part < m_kPart; part++ )
123 {
124 GetVolumeScin( part )->SetVisibility( 1 );
125 GetVolumeBucket( part )->SetVisibility( 1 );
126
127 int nScin = 0;
128 if ( part == 1 ) nScin = m_kAssemblyBr;
129 else nScin = m_kAssemblyEc;
130 for ( int scin = 0; scin < nScin; scin++ )
131 {
132 GetScin( part, scin )->SetVisibility( 1 );
133
134 int nBucket = 0;
135 if ( part == 1 ) nBucket = m_kBucketBr;
136 else nBucket = m_kBucketEc;
137 for ( int bucket = 0; bucket < nBucket; bucket++ )
138 { GetBucket( part, scin, bucket )->SetVisibility( 1 ); }
139 }
140 }
141}
142
144 for ( int part = 0; part < m_kPart; part++ )
145 {
146 GetVolumeScin( part )->SetVisibility( 1 );
147 GetVolumeBucket( part )->SetVisibility( 1 );
148
149 int nScin = 0;
150 if ( part == 1 ) nScin = m_kAssemblyBr;
151 else nScin = m_kAssemblyEc;
152 for ( int scin = 0; scin < nScin; scin++ )
153 {
154 if ( scin < nScin / 4 ) GetScin( part, scin )->SetVisibility( 0 );
155 else GetScin( part, scin )->SetVisibility( 1 );
156
157 int nBucket = 0;
158 if ( part == 1 ) nBucket = m_kBucketBr;
159 else nBucket = m_kBucketEc;
160 for ( int bucket = 0; bucket < nBucket; bucket++ )
161 {
162 if ( scin < nScin / 4 ) GetBucket( part, scin, bucket )->SetVisibility( 0 );
163 else GetBucket( part, scin, bucket )->SetVisibility( 1 );
164 }
165 }
166 }
167}
168
170 int scinColor = 6;
171
172 if ( gGeoManager == 0 ) std::cout << "Create gGeoManager first" << std::endl;
173 TGeoNode* bes = gGeoManager->GetTopNode();
174 // std::cout << "m_childNo " << m_childNo << std::endl;
175 TGeoNode* tof = bes->GetDaughter( m_childNo );
176
177 for ( int part = 0; part < m_kPart; part++ )
178 {
179 int nScin = 0;
180 if ( part == 1 ) nScin = m_kAssemblyBr;
181 else nScin = m_kAssemblyEc;
182 for ( int scin = 0; scin < nScin; scin++ )
183 {
184 TGeoNode* nodeScin = GetScin( part, scin );
185 m_PhysicalScin[part][scin] = gGeoManager->MakePhysicalNode(
186 TString( "/" ) + bes->GetName() + TString( "/" ) + tof->GetName() + TString( "/" ) +
187 nodeScin->GetName() );
188 m_PhysicalScin[part][scin]->SetVisibility( 0 );
189 m_PhysicalScin[part][scin]->SetIsVolAtt( kFALSE );
190 m_PhysicalScin[part][scin]->SetLineColor( scinColor );
191 }
192 }
193}
194
196 int nPart = m_kPart;
197 return nPart;
198}
199
200int TofROOTGeo::GetScinNb( int part ) {
201 int nScin = m_kAssemblyBr;
202 if ( part != 1 ) nScin = m_kAssemblyEc;
203 return nScin;
204}
205
206TGeoVolumeAssembly* TofROOTGeo::GetVolumeAssembly( int part ) {
207 std::stringstream osname;
208 if ( part == 0 || part == 2 )
209 {
210 osname << "logical"
211 << "Tof"
212 << "AssemblyEc";
213 }
214 else
215 {
216 if ( part == 1 )
217 {
218 osname << "logical"
219 << "Tof"
220 << "AssemblyBr";
221 }
222 }
223
224 return GetAssemblyVolume( osname.str() );
225}
226
227TGeoVolume* TofROOTGeo::GetVolumeScin( int part ) {
228 std::stringstream osname;
229 if ( part == 0 || part == 2 )
230 {
231 osname << "logical"
232 << "Tof"
233 << "ScinEc";
234 }
235 else
236 {
237 if ( part == 1 )
238 {
239 osname << "logical"
240 << "Tof"
241 << "ScinBr";
242 }
243 }
244
245 return GetLogicalVolume( osname.str() );
246}
247
248TGeoVolume* TofROOTGeo::GetVolumeBucket( int part ) {
249 std::stringstream osname;
250 if ( part == 0 || part == 2 )
251 {
252 osname << "logical"
253 << "Tof"
254 << "BucketEc";
255 }
256 else
257 {
258 if ( part == 1 )
259 {
260 osname << "logical"
261 << "Tof"
262 << "BucketBr";
263 }
264 }
265
266 return GetLogicalVolume( osname.str() );
267}
268
269TGeoNode* TofROOTGeo::GetScin( int part, int scin ) {
270 if ( m_NodeScin[part][scin] != 0 ) { return m_NodeScin[part][scin]; }
271 else
272 {
273 std::cout << "Node: "
274 << "Part" << part << "Scin" << scin << " not found" << std::endl;
275 return 0;
276 }
277
278 return m_NodeScin[part][scin];
279}
280
281TGeoNode* TofROOTGeo::GetBucket( int part, int scin, int bucket ) {
282 std::stringstream osname;
283 if ( part == 0 )
284 {
285 osname << "pv_"
286 << "logical"
287 << "Tof"
288 << "BucketEc"
289 << "_" << m_kAssemblyBr + m_kAssemblyEc + scin << "_1";
290 }
291 else if ( part == 1 )
292 {
293 osname << "pv_"
294 << "logical"
295 << "Tof"
296 << "BucketBr"
297 << "_" << scin << "_" << bucket + 1;
298 }
299 else if ( part == 2 )
300 {
301 osname << "pv_"
302 << "logical"
303 << "Tof"
304 << "BucketEc"
305 << "_" << m_kAssemblyBr + scin << "_1";
306 }
307
308 return GetNode( osname.str() );
309}
310
311TGeoPhysicalNode* TofROOTGeo::GetPhysicalScin( int part, int scin ) {
312 if ( m_PhysicalScin[part][scin] != 0 ) { return m_PhysicalScin[part][scin]; }
313 else
314 {
315 std::cout << "PhysicalNode: "
316 << "Part" << part << "Scin" << scin << " not found" << std::endl;
317 return 0;
318 }
319}
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.
TGeoVolumeAssembly * GetAssemblyVolume(const std::string &an)
Get an assembly by name;.
void SetQuarterVisible()
Set quater visible;.
TGeoVolume * GetVolumeScin(int part)
Get scintillator volume;.
void InitFromGdml(const char *gdmlFile, const char *setupName)
Initialize the instance of ROOTGeo.
TGeoVolume * GetVolumeBucket(int part)
Get bucket volume;.
void SetDefaultVis()
Set default visual attributes;.
TGeoVolumeAssembly * GetVolumeAssembly(int part)
Get assembly volume; part=0,2 for AssemblyEc, 1 for AssemblyBr;.
TGeoNode * GetScin(int part, int scin)
Get scintillator node;.
TGeoNode * GetBucket(int part, int scin, int bucket)
Get bucket node, 0 for west bucket, 1 for the east one;.
int GetScinNb(int part)
Get number of scintillators on each part;.
void SetPhysicalNode()
Set the pointers to the physical nodes;.
TGeoPhysicalNode * GetPhysicalScin(int part, int scin)
Get scintillator physical node;.
void SetNode()
Set the pointers to theirs nodes;.