BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesMucConstruction.cc
Go to the documentation of this file.
1//---------------------------------------------------------------------------//
2// BOOST --- BESIII Object_Oreiented Simulation Tool //
3//---------------------------------------------------------------------------//
4// Description: RPC detector
5// Author: Youzy Peking University mail: youzy@hep.pku.cn
6// Created: Nov, 2003
7// Comment:
8//---------------------------------------------------------------------------//
9//
10
11#include "MucSim/BesMucConstruction.hh"
12#include "MucSim/BesMucSD.hh"
13
14#include "G4Geo/MucG4Geo.h"
15#include "SimUtil/ReadBoostRoot.hh"
16
17#include "G4Color.hh"
18#include "G4LogicalVolume.hh"
19#include "G4Material.hh"
20#include "G4PVPlacement.hh"
21#include "G4SDManager.hh"
22#include "G4ThreeVector.hh"
23#include "G4Tubs.hh"
24#include "G4VPhysicalVolume.hh"
25#include "G4VisAttributes.hh"
26#include "G4ios.hh"
27#include "globals.hh"
28#include <cstdlib>
29
30#include "strstream"
31// #include <strstream>
32// #include "MucGeomSvc/MucGeomSvc.h"
33
35
37
38void BesMucConstruction::Construct( G4LogicalVolume* logicBes ) {
39 // construct Muc
40
41 // Dengzy for boostroot environment
42 // ReadBoostRoot* boostroot=new ReadBoostRoot();
43 // G4String GeometryPath = boostroot->GetBoostRoot();
44 // delete boostroot;
45
46 // if(!GeometryPath){
47 // G4Exception("BOOST environment not set!");
48 // }
49 // GeometryPath += "/dat/Muc.gdml";
50
51 // m_config.SetURI(GeometryPath);
52 // m_config.SetSetupName( "Muc" );
53 // m_config.SetSetupVersion( "1.0" );
54 // m_config.SetType( "G4" );
55 // m_sxp.Configure(&m_config);
56 // m_sxp.Initialize();
57 // m_sxp.Run();
58
59 // G4cout << "Construct Muc from" << GeometryPath << G4endl;
60 // G4LogicalVolume* logicalMuc = FindLogicalVolume("logicalMuc");
61
62 // init geo from MucGeoSvc 2006.11.23
63
64 MucG4Geo* aMucG4Geo = new MucG4Geo();
65 G4LogicalVolume* logicalMuc = aMucG4Geo->GetTopVolume();
66 // G4LogicalVolume* logicalMuc = MucG4Geo::Instance()->GetTopVolume();
67
68 if ( !logicalMuc )
69 { G4cout << "BesMucConstruction::Construct() 1, logicalMuc not found!" << G4endl; }
70 else
71 {
72 // G4cout << "Muc" exist" << G4endl;
73 physicalMuc = new G4PVPlacement( 0, G4ThreeVector( 0, 0, 0 ), logicalMuc, "PhysicalMuc",
74 logicBes, false, 0 );
75 logicalMuc->SetVisAttributes( G4VisAttributes::Invisible );
76 }
77
78 // sensitive detectors
79 G4SDManager* aSDman = G4SDManager::GetSDMpointer();
80 BesMucSD* aMucSD = new BesMucSD( "BesMucSD", this );
81 aSDman->AddNewDetector( aMucSD );
82
83 G4LogicalVolume* lv = 0;
84
85 G4int partMax = 3;
86 // G4int segMax = 8, absorberMax = 9, gapMax = 9, panelMax = 4;
87 G4int stripMax = 96, bakeliteMax = 4, gasChamberMax = 2;
88 G4int segOnPart[3] = { 4, 8, 4 };
89 G4int absorberOnPart[3] = { 9, 9, 9 };
90 G4int gapOnPart[3] = { 8, 9, 8 };
91 G4int panelOnPart[3] = { 3, 4, 3 };
92 G4int part, seg, absorber, panel, gap, bakelite, gasChamber, strip;
93
94 for ( part = 0; part < partMax; part++ )
95 {
96 // for(seg = 0; seg < 1; seg++) {
97 for ( seg = 0; seg < segOnPart[part]; seg++ )
98 {
99 if ( seg == 0 || part == 1 && seg == 2 )
100 {
101 for ( gap = 0; gap < gapOnPart[part]; gap++ )
102 {
103 for ( gasChamber = 0; gasChamber < gasChamberMax; gasChamber++ )
104 {
105 int seg_shift = 0;
106 if ( part == 1 && seg == 2 ) seg_shift = 1;
107 for ( panel = 0; panel < panelOnPart[part] + seg_shift; panel++ )
108 {
109 std::ostrstream sf;
110 sf << "l"
111 << "Muc"
112 << "P" << part << "S" << seg << "G" << gap << "R" << gasChamber << "Pn"
113 << panel << "C" << std::ends;
114
115 // sf << "logical" << "Muc"
116 // << "Part" << part
117 // << "Seg" << seg
118 // << "Gap" << gap
119 // << "RpcUpDown" << gasChamber
120 // << "Panel" << panel
121 // << "GasChamber"
122 // << std::ends;
123
124 lv = FindLogicalVolume( sf.str() );
125 if ( !lv )
126 {
127 G4cout << "BesMucConstruction::Construct(), " << sf.str() << " not found!"
128 << G4endl;
129 }
130 else { lv->SetSensitiveDetector( aMucSD ); }
131 }
132 }
133 }
134 }
135 }
136 }
137
138 // visulizatioin attibutes
139 G4VisAttributes* mucVisAtt = new G4VisAttributes( G4Colour( 1.0, 0.0, 1.0, 0.05 ) );
140 G4VisAttributes* absorberVisAtt = new G4VisAttributes( G4Colour( 1.0, 0.3, 0.0, 1.0 ) );
141 G4VisAttributes* gapVisAtt = new G4VisAttributes( G4Colour( 0.5, 0.5, 0.5, 1.0 ) );
142 G4VisAttributes* stripVisAtt = new G4VisAttributes( G4Colour( 1.0, 0.0, 1.0, 1.0 ) );
143 G4VisAttributes* bakeliteVisAtt = new G4VisAttributes( G4Colour( 1.0, 1.0, 0.0, 1.0 ) );
144 G4VisAttributes* gasChamberVisAtt = new G4VisAttributes( G4Colour( 0.6, 0.8, 1.0, 1.0 ) );
145
146 lv = FindLogicalVolume( "logicalMuc" );
147 if ( !lv ) { G4cout << "BesMucConstruction::Construct() 2, logicMuc not found!" << G4endl; }
148 else
149 {
150 lv->SetVisAttributes( mucVisAtt );
151 lv->SetVisAttributes( G4VisAttributes::Invisible );
152 }
153
154 for ( part = 0; part < partMax; part++ )
155 {
156 for ( seg = 0; seg < segOnPart[part]; seg++ )
157 {
158 for ( absorber = 0; absorber < absorberOnPart[part]; absorber++ )
159 {
160 std::ostrstream sf;
161 sf << "logical"
162 << "Muc"
163 << "Part" << part << "Seg" << seg << "Absorber" << absorber << std::ends;
164
165 lv = FindLogicalVolume( sf.str() );
166 if ( lv )
167 {
168 lv->SetVisAttributes( absorberVisAtt );
169 // if(part == 1 || seg == 0 || seg == 1 || seg == 2) {
170 if ( part != 1 ) { lv->SetVisAttributes( G4VisAttributes::Invisible ); }
171 }
172 }
173 }
174 }
175
176 // for(part = 0; part < partMax; part++) {
177 // for(seg = 0; seg < segOnPart[part]; seg++) {
178 // for(absorber = 0; absorber < absorberOnPart[part]; absorber++) {
179 // for(panel = 0; panel < panelOnPart[part]; panel++) {
180 // std::ostrstream sf;
181 // sf << "logical"
182 // << "MucPart" << part
183 // << "Seg" << seg
184 // << "Absorber" << absorber
185 // << "Panel" << panel
186 // << std::ends;
187
188 // lv = FindLogicalVolume(sf.str());
189 // if(lv) {
190 // lv->SetVisAttributes(absorberVisAtt);
191 // if(part != 1) {
192 // lv->SetVisAttributes (G4VisAttributes::Invisible);
193 // }
194 // //lv->SetVisAttributes (G4VisAttributes::Invisible);
195 // }
196 // }
197 // }
198 // }
199 // }
200
201 for ( part = 0; part < partMax; part++ )
202 {
203 for ( seg = 0; seg < segOnPart[part]; seg++ )
204 {
205 for ( gap = 0; gap < gapOnPart[part]; gap++ )
206 {
207 std::ostrstream sf;
208 sf << "logical"
209 << "Muc"
210 << "Part" << part << "Seg" << seg << "Gap" << gap << std::ends;
211
212 lv = FindLogicalVolume( sf.str() );
213 if ( lv )
214 {
215 lv->SetVisAttributes( gapVisAtt );
216 lv->SetVisAttributes( G4VisAttributes::Invisible );
217 }
218 }
219 }
220 }
221
222 for ( part = 0; part < partMax; part++ )
223 {
224 for ( seg = 0; seg < 1; seg++ )
225 {
226 // for(seg = 0; seg < segOnPart[part]; seg++) {
227 for ( gap = 0; gap < gapOnPart[part]; gap++ )
228 {
229 std::ostrstream sf;
230 sf << "logical"
231 << "Muc"
232 << "Part" << part << "Seg" << seg << "Gap" << gap << "StripPlane" << std::ends;
233
234 lv = FindLogicalVolume( sf.str() );
235 if ( lv )
236 {
237 lv->SetVisAttributes( gapVisAtt );
238 lv->SetVisAttributes( G4VisAttributes::Invisible );
239 }
240 }
241 }
242 }
243
244 for ( part = 0; part < partMax; part++ )
245 {
246 for ( seg = 0; seg < 1; seg++ )
247 {
248 // for(seg = 0; seg < segOnPart[part]; seg++) {
249 for ( gap = 0; gap < gapOnPart[part]; gap++ )
250 {
251 for ( strip = 0; strip < stripMax; strip++ )
252 {
253 std::ostrstream sf;
254 if ( strip >= 0 && strip < 10 )
255 {
256 sf << "logical"
257 << "Muc"
258 << "Part" << part << "Seg" << seg << "Gap" << gap << "Strip0" << strip
259 << std::ends;
260 }
261 else if ( strip >= 10 && strip < 100 )
262 {
263 sf << "logical"
264 << "Muc"
265 << "Part" << part << "Seg" << seg << "Gap" << gap << "Strip" << strip
266 << std::ends;
267 }
268 else
269 {
270 G4cout << "BesMucConstruction::Construct(), strip=" << strip << " error!"
271 << G4endl;
272 }
273
274 lv = FindLogicalVolume( sf.str() );
275 if ( lv )
276 {
277 lv->SetVisAttributes( stripVisAtt );
278 lv->SetVisAttributes( G4VisAttributes::Invisible );
279 }
280 }
281 }
282 }
283 }
284
285 for ( part = 0; part < partMax; part++ )
286 {
287 for ( seg = 0; seg < 1; seg++ )
288 {
289 // for(seg = 0; seg < segOnPart[part]; seg++) {
290 for ( gap = 0; gap < gapOnPart[part]; gap++ )
291 {
292 for ( panel = 0; panel < panelOnPart[part]; panel++ )
293 {
294 for ( bakelite = 0; bakelite < bakeliteMax; bakelite++ )
295 {
296 std::ostrstream sf;
297 sf << "logical"
298 << "Muc"
299 << "Part" << part << "Seg" << seg << "Gap" << gap << "Panel" << panel
300 << "Bakelite" << bakelite << std::ends;
301
302 lv = FindLogicalVolume( sf.str() );
303 if ( lv )
304 {
305 lv->SetVisAttributes( bakeliteVisAtt );
306 lv->SetVisAttributes( G4VisAttributes::Invisible );
307 }
308 }
309 }
310 }
311 }
312 }
313
314 for ( part = 0; part < partMax; part++ )
315 {
316 for ( seg = 0; seg < 1; seg++ )
317 {
318 // for(seg = 0; seg < segOnPart[part]; seg++) {
319 for ( gap = 0; gap < gapOnPart[part]; gap++ )
320 {
321 for ( panel = 0; panel < panelOnPart[part]; panel++ )
322 {
323 for ( gasChamber = 0; gasChamber < gasChamberMax; gasChamber++ )
324 {
325 std::ostrstream sf;
326 sf << "logical"
327 << "Muc"
328 << "Part" << part << "Seg" << seg << "Gap" << gap << "Panel" << panel
329 << "GasChamber" << gasChamber << std::ends;
330
331 lv = FindLogicalVolume( sf.str() );
332 if ( lv )
333 {
334 lv->SetVisAttributes( gasChamberVisAtt );
335 // if( (part == 1 && (seg == 0 || seg == 1 || seg == 3 || seg == 4) )
336 // || (part == 0 && (seg == 0 || seg == 1 || seg ==2) ) ) {
337 // lv->SetVisAttributes (G4VisAttributes::Invisible);
338 // }
339 if ( part != 1 ) { lv->SetVisAttributes( G4VisAttributes::Invisible ); }
340 }
341 }
342 }
343 }
344 }
345 }
346 // m_sxp.Finalize();
347 delete aMucG4Geo;
348}
void Construct(G4LogicalVolume *logicBes)
G4LogicalVolume * GetTopVolume()
Get the top(world) volume;.