source: trunk/source/visualization/test/src/MyDetectorConstruction.cc @ 952

Last change on this file since 952 was 952, checked in by garnier, 15 years ago

en test

File size: 29.3 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: MyDetectorConstruction.cc,v 1.39 2006/11/14 16:03:55 allison Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-03 $
29//
30//
31#include "MyDetectorConstruction.hh"
32
33#include "MyDetectorMessenger.hh"
34//#include "MyCalorimeterSD.hh"
35//#include "MyTrackerSD.hh"
36//#include "MyCalorimeterHit.hh"
37//#include "MyTrackerHit.hh"
38
39#include "G4Material.hh"
40#include "G4MaterialTable.hh"
41#include "G4Element.hh"
42#include "G4ElementTable.hh"
43#include "G4Box.hh"
44#include "G4Tubs.hh"
45#include "G4Cons.hh"
46#include "G4Sphere.hh"
47#include "G4Orb.hh"
48#include "G4Trap.hh"
49#include "G4EllipticalTube.hh"
50#include "G4EllipticalCone.hh"
51#include "G4Polyhedra.hh"
52#include "G4Polycone.hh"
53#include "G4Tet.hh"
54#include "G4TwistedTubs.hh"
55#include "G4TwistedBox.hh"
56#include "G4TwistedTrd.hh"
57#include "G4TwistedTrap.hh"
58#include "G4IntersectionSolid.hh"
59#include "G4SubtractionSolid.hh"
60#include "G4UnionSolid.hh"
61#include "G4DisplacedSolid.hh"
62#include "G4LogicalVolume.hh"
63#include "G4RotationMatrix.hh"
64#include "G4ThreeVector.hh"
65#include "G4Transform3D.hh"
66#include "G4PVPlacement.hh"
67#include "G4PVReplica.hh"
68#include "G4SDManager.hh"
69#include "G4VisAttributes.hh"
70#include "G4Colour.hh"
71#include "G4VisExtent.hh"
72
73#include "G4Polyhedron.hh"
74
75MyDetectorConstruction::MyDetectorConstruction()
76{
77  new MyDetectorMessenger(this);
78
79  expHall_x = 10. * m;
80  expHall_y = 10. * m;
81  expHall_z = 10. * m;
82
83  calBox_x = 100.*cm;
84  calBox_y = 50.*cm;
85  calBox_z = 50.*cm;
86  rotAngle = 30.*deg;
87  calPos = 200.*cm;
88  calMaterialName = "Pb";
89
90  trackerRadius = 50.*cm;
91  trackerHight = 100.*cm;
92  trackerPos = -200.*cm;
93}
94
95MyDetectorConstruction::~MyDetectorConstruction()
96{
97  for (size_t i = 0; i < materialPointerStore.size(); i++) {
98    delete materialPointerStore[i];
99  }
100}
101
102G4VPhysicalVolume* MyDetectorConstruction::Construct()
103{
104
105  //------------------------------------------------------ materials
106
107  G4double a, iz, z, density;
108  G4String name, symbol;
109  G4int nel;
110
111  a = 14.01*g/mole;
112  G4Element* elN = new G4Element(name="Nitrogen", symbol="N", iz=7., a);
113  a = 16.00*g/mole;
114  G4Element* elO = new G4Element(name="Oxygen", symbol="O", iz=8., a);
115
116  density = 1.29e-03*g/cm3;
117  G4Material* Air = new G4Material(name="Air", density, nel=2);
118  materialPointerStore.push_back(Air);
119  Air->AddElement(elN, .7);
120  Air->AddElement(elO, .3);
121
122  a = 207.19*g/mole;
123  density = 11.35*g/cm3;
124  G4Material* Pb = new G4Material(name="Lead", z=82., a, density);
125  materialPointerStore.push_back(Pb);
126
127  a = 39.95*g/mole;
128  density = 1.782e-03*g/cm3;
129  G4Material* Ar = new G4Material(name="ArgonGas", z=18., a, density);
130  materialPointerStore.push_back(Ar);
131
132  a = 26.98*g/mole;
133  density = 2.7*g/cm3;
134  G4Material* Al = new G4Material(name="Aluminum", z=13., a, density);
135  materialPointerStore.push_back(Al);
136
137  a = 55.85*g/mole;
138  density = 7.87*g/cm3;
139  G4Material* Fe = new G4Material(name="Iron", z=26., a, density);
140  materialPointerStore.push_back(Fe);
141
142  //------------------------------------------------------ volumes
143
144  //------------------------------ experimental hall
145  G4Box * experimentalHall_box
146    = new G4Box("expHall_b",expHall_x,expHall_y,expHall_z);
147  G4LogicalVolume * experimentalHall_log
148    = new G4LogicalVolume(experimentalHall_box,Air,"expHall_L",0,0,0);
149  //  G4VisAttributes * experimentalHallVisAtt
150  //      = new G4VisAttributes(G4Colour(1.0,1.0,1.0));
151  //  experimentalHallVisAtt->SetForceWireframe(true);
152  //  experimentalHall_log->SetVisAttributes(experimentalHallVisAtt);
153  experimentalHall_log -> SetVisAttributes (&G4VisAttributes::GetInvisible());
154  G4VPhysicalVolume * experimentalHall_phys
155    = new G4PVPlacement(0,G4ThreeVector(),"expHall_P",
156                        experimentalHall_log,0,false,0);
157
158  //------------------------------ calorimeter boxes
159  G4Box * calorimeter_box
160    = new G4Box("calorimeter_b",calBox_x,calBox_y,calBox_z);
161  G4Material* calMat;
162  if(calMaterialName=="Pb")
163  { calMat = Pb; }
164  else if(calMaterialName=="Al")
165  { calMat = Al; }
166  else if(calMaterialName=="Fe")
167  { calMat = Fe; }
168  else
169  { calMat = Air; }
170  G4LogicalVolume * calorimeter_log
171    = new G4LogicalVolume(calorimeter_box,calMat,"calo_L",0,0,0);
172  G4VisAttributes * calorimeterVisAtt
173      = new G4VisAttributes(G4Colour(0.,0.,1.));
174  //  calorimeterVisAtt->SetForceWireframe(true);
175  calorimeter_log->SetVisAttributes(calorimeterVisAtt);
176  G4VPhysicalVolume* calo_phys;
177  for(G4int i=0;i<3;i++)
178  {
179    G4RotationMatrix rm;
180    rm.rotateZ(i*rotAngle);
181    rm.print(G4cout);
182    calo_phys =
183    new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(0.*cm,i*calPos,0.*cm)),
184                      "calo_phys",calorimeter_log,experimentalHall_phys,
185                      false,i);
186    calo_phys->GetObjectRotationValue().print(G4cout);
187  }
188
189  //------------------------------ tracker tube
190  G4Tubs * tracker_tube
191    = new G4Tubs("tracker_tube",0.*cm,trackerRadius,trackerHight,
192                 0.*deg,360.*deg);
193  /*
194  G4cout << "Tracker tube polyhedron:\n"
195         << (HepPolyhedron)(*(tracker_tube->GetPolyhedron())) << G4endl;
196  */
197  G4LogicalVolume * tracker_log
198    = new G4LogicalVolume(tracker_tube,Ar,"tracker_L",0,0,0);
199  G4VisAttributes * trackerVisAtt
200    = new G4VisAttributes(G4Colour(0.,0.,1.));
201  //  trackerVisAtt->SetForceWireframe(true);
202  tracker_log->SetVisAttributes(trackerVisAtt);
203  //////////////............
204  G4RotationMatrix* tracker_rm = new G4RotationMatrix;
205  tracker_rm->rotateY(-30.*deg);
206  tracker_rm->print(G4cout);
207  G4VPhysicalVolume* tracker_phys =
208  //new G4PVPlacement(tracker_rm,G4ThreeVector(0.*cm,trackerPos,200.*cm),
209  new G4PVPlacement(G4Transform3D(*tracker_rm,G4ThreeVector(0.*cm,trackerPos,200.*cm)),
210  //////////////............
211  //new G4PVPlacement(0,G4ThreeVector(0.*cm,trackerPos,0.*cm),
212                    "tracker_phys",tracker_log,experimentalHall_phys,
213                    false,0);
214  tracker_phys->GetObjectRotationValue().print(G4cout);
215
216  //------------------------------ displaced box
217  G4Box * undisplaced_box = new G4Box("undisplaced_box",30.*cm,50.*cm,70.*cm);
218  G4RotationMatrix rm_db;
219  rm_db.rotateZ(20.*deg);
220  G4DisplacedSolid* displaced_box = new G4DisplacedSolid
221    ("displaced_box",undisplaced_box,
222     G4Transform3D(rm_db,G4ThreeVector(200.*cm,0.,0.)));
223  G4cout << "Displaced box extent:\n" << displaced_box->GetExtent() << G4endl;
224  G4LogicalVolume * displaced_box_log
225    = new G4LogicalVolume(displaced_box,Ar,"displaced_box_L",0,0,0);
226  new G4PVPlacement(0,G4ThreeVector(0.*cm,-200.*cm,0.*cm),
227                    "displaced_box_phys",displaced_box_log,
228                    experimentalHall_phys,
229                    false,0);
230
231  //-------------------------------------------- Boolean solids
232
233  G4Tubs* cylinder1 = new G4Tubs("Cylinder #1",20*cm,50*cm,30*cm,0,2*pi);
234  G4Box* box1 = new G4Box("Box #1",20*cm,30*cm,40*cm);
235  G4Box* box2 = new G4Box("Box #2",10*cm,20*cm,35*cm);
236  G4RotationMatrix* rm1 = new G4RotationMatrix;
237  rm1->rotateZ(20*deg);
238  G4RotationMatrix* rm2 = new G4RotationMatrix;
239  rm2->rotateZ(60*deg);
240
241  G4IntersectionSolid* cyl1Ibox1 =
242    new G4IntersectionSolid("cylinder1-intersection-box1", cylinder1, box1,
243                     rm1,G4ThreeVector(30.01*cm,30.01*cm,0.01*cm));
244  G4cout << "cylinder1-intersection-box1 extent:\n"
245         << cyl1Ibox1->GetExtent() << G4endl;
246  G4IntersectionSolid* cyl1Ibox1Ibox2 =
247    new G4IntersectionSolid("cylinder1-intersection-box1-intersection-box2", cyl1Ibox1, box2,
248                     rm2,G4ThreeVector(0.01,40.01*cm,0.01*cm));
249  G4cout << "cylinder1-intersection-box1-intersection-box2 extent:\n"
250         << cyl1Ibox1Ibox2->GetExtent() << G4endl;
251  G4LogicalVolume * intersection_log
252    = new G4LogicalVolume(cyl1Ibox1Ibox2,Ar,"intersection_L",0,0,0);
253  const G4VisAttributes* bool_red =
254    new G4VisAttributes(G4Colour(1.,0.,0.));
255  intersection_log->SetVisAttributes(bool_red);
256  new G4PVPlacement(0,G4ThreeVector(100.*cm,-50*cm,0.*cm),
257                    "intersection_phys",intersection_log,experimentalHall_phys,
258                    true,0);
259
260  G4SubtractionSolid* cyl1Sbox1 =
261    new G4SubtractionSolid("cylinder1-subtraction-box1", cylinder1, box1,
262                     rm1,G4ThreeVector(30.*cm,30.*cm,1.*cm));
263  G4SubtractionSolid* cyl1Sbox1Sbox2 =
264    new G4SubtractionSolid("cylinder1-subtraction-box1-subtraction-box2", cyl1Sbox1, box2,
265                     rm2,G4ThreeVector(0.,40*cm,2.*cm));
266  G4LogicalVolume * subtraction_log
267    = new G4LogicalVolume(cyl1Sbox1Sbox2,Ar,"subtraction_L",0,0,0);
268  const G4VisAttributes* bool_green =
269    new G4VisAttributes(G4Colour(0.,1.,0.));
270  subtraction_log->SetVisAttributes(bool_green);
271  new G4PVPlacement(0,G4ThreeVector(200.*cm,-50*cm,0.*cm),
272                    "subtraction_phys",subtraction_log,experimentalHall_phys,
273                    true,0);
274
275  G4UnionSolid* cyl1Ubox1 =
276    new G4UnionSolid("cylinder1-union-box1", cylinder1, box1,
277                     rm1,G4ThreeVector(30.*cm,30.*cm,1.*cm));
278  G4UnionSolid* cyl1Ubox1Ubox2 =
279    new G4UnionSolid("cylinder1-union-box1-union-box2", cyl1Ubox1, box2,
280                     rm2,G4ThreeVector(0.,40*cm,2.*cm));
281  G4LogicalVolume * union_log
282    = new G4LogicalVolume(cyl1Ubox1Ubox2,Ar,"union_L",0,0,0);
283  const G4VisAttributes* bool_blue =
284    new G4VisAttributes(G4Colour(0.,0.,1.));
285  union_log->SetVisAttributes(bool_blue);
286  new G4PVPlacement(0,G4ThreeVector(350.*cm,-50*cm,0.*cm),
287                    "union_phys",union_log,experimentalHall_phys,
288                    true,0);
289
290  //----------- Tubes, replicas(!?) and daughter boxes
291
292  const G4double eps = 10 * mm;
293  const G4double alp = 10 * mrad;
294
295  G4VisAttributes * grey
296    = new G4VisAttributes(G4Colour(0.5,0.5,0.5,0.1));
297
298
299  G4double tube_dPhi = twopi;
300  G4Tubs* tube = new G4Tubs("tube",20*cm,50*cm,30*cm,0.,tube_dPhi);
301  G4LogicalVolume * tube_log
302    = new G4LogicalVolume(tube,Ar,"tube_L",0,0,0);
303  G4VisAttributes * tube_VisAtt
304    = new G4VisAttributes(G4Colour(0.,1.,0.,0.1));
305  //  tube_log->SetVisAttributes(tube_VisAtt);
306  tube_log->SetVisAttributes(G4VisAttributes::GetInvisible());
307  new G4PVPlacement(0,G4ThreeVector(-200.*cm,0.,0.*cm),
308                    "tube_phys",tube_log,experimentalHall_phys,
309                    false,0);
310
311  G4double divided_tube_dPhi = tube_dPhi / 6.;
312  G4Tubs* divided_tube = new G4Tubs
313    ("divided_tube",
314     20*cm,50*cm,30*cm,-divided_tube_dPhi/2.,divided_tube_dPhi);
315  G4LogicalVolume * divided_tube_log
316    = new G4LogicalVolume(divided_tube,Ar,"divided_tube_L",0,0,0);
317  divided_tube_log->SetVisAttributes(grey);
318  new G4PVReplica("divided_tube_phys",divided_tube_log,tube_log,
319                  kPhi,6,divided_tube_dPhi);
320  /************
321  G4int iCopy;
322  for (iCopy = 0; iCopy < 6; iCopy++) {
323    new G4PVPlacement
324      (G4Transform3D
325       (G4RotationMatrix().rotateZ(divided_tube_dPhi/2.+iCopy*pi/3.),
326        G4ThreeVector()),
327       divided_tube_log,"divided_tube_phys",tube_log,
328       false,iCopy);
329  }
330  *********/
331
332  G4double divided_tube_inset_dPhi = divided_tube_dPhi - 2. * alp;
333  G4Tubs* divided_tube_inset = new G4Tubs
334    ("divided_tube_inset",
335     20*cm+eps,50*cm-eps,30*cm-eps,
336     -divided_tube_inset_dPhi/2.,
337     divided_tube_inset_dPhi);
338  G4LogicalVolume * divided_tube_inset_log
339    = new G4LogicalVolume(divided_tube_inset,Ar,"divided_tube_inset_L",0,0,0);
340  G4VisAttributes * divided_tube_inset_VisAtt
341    = new G4VisAttributes(G4Colour(1.,0.,0.,0.2));
342  //  divided_tube_inset_log->SetVisAttributes(divided_tube_inset_VisAtt);
343  divided_tube_inset_log->SetVisAttributes(G4VisAttributes::Invisible);
344  new G4PVPlacement(0,G4ThreeVector(),
345                    divided_tube_inset_log,"divided_tube_inset_phys",
346                    divided_tube_log,false,0);
347
348  G4double sub_divided_tube_dPhi = divided_tube_inset_dPhi / 4.;
349  G4Tubs* sub_divided_tube = new G4Tubs
350    ("sub_divided_tube",
351     20*cm+eps,50*cm-eps,30*cm-eps,
352     -sub_divided_tube_dPhi/2.,sub_divided_tube_dPhi);
353  G4LogicalVolume * sub_divided_tube_log
354    = new G4LogicalVolume(sub_divided_tube,Ar,"sub_divided_tube_L",0,0,0);
355  sub_divided_tube_log->SetVisAttributes(grey);
356  new G4PVReplica("sub_divided_tube_phys",
357                  sub_divided_tube_log,divided_tube_inset_log,
358                  kPhi,4,sub_divided_tube_dPhi,-divided_tube_inset_dPhi/2.);
359  /************
360  for (iCopy = 0; iCopy < 4; iCopy++) {
361    new G4PVPlacement
362      (G4Transform3D
363       (G4RotationMatrix().rotateZ
364        (-divided_tube_inset_dPhi/2.
365         +(iCopy+0.5)*sub_divided_tube_dPhi),
366        G4ThreeVector()),
367       sub_divided_tube_log,"sub_divided_tube_phys",divided_tube_inset_log,
368       false,iCopy);
369  }
370  ************/
371 
372  G4Box* daughter_box = new G4Box("daughter_box",4.*cm,3.*cm,25.*cm);
373  G4LogicalVolume * daughter_box_log
374    = new G4LogicalVolume(daughter_box,Ar,"daughter_box_L",0,0,0);
375  G4VisAttributes * daughter_box_VisAtt
376    = new G4VisAttributes(G4Colour(0.,0.,1.,0.3));
377  daughter_box_log->SetVisAttributes(daughter_box_VisAtt);
378  G4Box* grand_daughter_box = new G4Box("grand_daughter_box",1*cm,2*cm,5*cm);
379  G4LogicalVolume * grand_daughter_box_log
380    = new G4LogicalVolume(grand_daughter_box,Ar,"grand_daughter_box_L",0,0,0);
381  G4VisAttributes * grand_daughter_box_VisAtt
382    = new G4VisAttributes(G4Colour(1.,1.,0.));
383  grand_daughter_box_log->SetVisAttributes(grand_daughter_box_VisAtt);
384  G4Box* grand_daughter_box2 = new G4Box("grand_daughter_box2",1*cm,2*cm,5*cm);
385  G4LogicalVolume * grand_daughter_box2_log
386    = new G4LogicalVolume
387    (grand_daughter_box2,Ar,"grand_daughter_box2_L",0,0,0);
388  G4VisAttributes * grand_daughter_box2_VisAtt
389    = new G4VisAttributes(G4Colour(1.,0.,1.));
390  grand_daughter_box2_log->SetVisAttributes(grand_daughter_box2_VisAtt);
391  new G4PVPlacement(0,G4ThreeVector(-2*cm,0.,0.),
392                    grand_daughter_box_log,"grand_daughter_box_phys",
393                    daughter_box_log,false,0);
394  new G4PVPlacement(0,G4ThreeVector(2*cm,0.,0.),
395                    grand_daughter_box2_log,"grand_daughter_box2_phys",
396                    daughter_box_log,false,0);
397  new G4PVPlacement(0,G4ThreeVector(40*cm,0.,0.),
398                    daughter_box_log,"daughter_box_phys",
399                    sub_divided_tube_log,false,0);
400
401  //------------------------------------------------ Extra placements
402  // For good measure, as a test of drawn volume path, place in one of
403  // the earlier volumes...
404  new G4PVPlacement(0,G4ThreeVector(),
405                    "divided_tube_inset_phys",divided_tube_inset_log,
406                    calo_phys,false,0);  // Place in PV.
407  new G4PVPlacement(0,G4ThreeVector(),
408                    grand_daughter_box2_log,"grand_daughter_box2_phys",
409                    calorimeter_log,false,0);  // Place in LV.  Same effect.
410
411  //------------------------------------------------ sensitive detectors
412  /****************
413  G4SDManager* SDman = G4SDManager::GetSDMpointer();
414
415  G4String calorimeterSDname = "example2/calorimeter";
416  MyCalorimeterSD * myCalorimeterSD = new MyCalorimeterSD( calorimeterSDname );
417  SDman->AddNewDetector( myCalorimeterSD );
418  calorimeter_log->SetSensitiveDetector( myCalorimeterSD );
419
420  G4String trackerSDname = "example2/tracker";
421  MyTrackerSD * myTrackerSD = new MyTrackerSD( trackerSDname );
422  SDman->AddNewDetector( myTrackerSD );
423  tracker_log->SetSensitiveDetector( myTrackerSD );
424  ******************/
425
426  //-------------------------------------------- Sphere
427
428  G4Sphere* PD_vol_crystal
429      = new G4Sphere("Test_Sphere",
430                     100.*cm,           // inner radius
431                     200.*cm,           // outer radius
432                     0.,                // start phi
433                     90.*degree,         // delta phi
434                     0.,                // start theta
435                     90.*degree          // delta theta
436                     );
437
438
439  G4LogicalVolume* PD_log_crystal
440    = new G4LogicalVolume(PD_vol_crystal,Ar,"Test_Sphere");
441
442  G4VisAttributes * PD_att_crystal
443    = new G4VisAttributes(G4Colour(1.,0.,1.));
444  PD_att_crystal->SetForceAuxEdgeVisible(true);
445  PD_att_crystal->SetForceLineSegmentsPerCircle(100);
446  PD_log_crystal->SetVisAttributes(PD_att_crystal);
447
448  G4RotationMatrix rm;
449
450  new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(200.*cm,300.*cm,0)),
451                    "PD_physical", PD_log_crystal,
452                    experimentalHall_phys,false,0);
453
454//-------------------------------------------- Polyhedra and Polycone
455
456  const G4int numRZ = 10;
457  G4double polyhedra_r[] = {0,5,3,4,9,9,3,3,2,0};
458  G4double polyhedra_z[] = {0,1,2,3,0,5,4,3,2,1};
459  for (int i = 0; i < numRZ; ++i) {
460    polyhedra_r[i] *= 10*cm;
461    polyhedra_z[i] *= 10.*cm;
462  }
463
464  G4Polyhedra* polyhedra_solid
465      = new G4Polyhedra("Polyhedra_Test",
466                        0.,270.*deg,6,numRZ,polyhedra_r,polyhedra_z);
467                        //0.,twopi,6,numRZ,polyhedra_r,polyhedra_z);
468  G4cout << polyhedra_solid->StreamInfo(G4cout) << G4endl;
469
470  G4LogicalVolume* polyhedra_log
471    = new G4LogicalVolume(polyhedra_solid,Ar,"Polyhedra_Test");
472
473  G4VisAttributes * polyhedra_atts
474    = new G4VisAttributes(G4Colour(0.,1.,1.));
475  polyhedra_log->SetVisAttributes(polyhedra_atts);
476
477  new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(200.*cm,100.*cm,0)),
478                    "Polyhedra_Test", polyhedra_log,
479                    experimentalHall_phys,false,0);
480
481  const G4int numRZ1 = 10;
482  G4double polycone_r[] = {1,5,3,4,9,9,3,3,2,1};
483  G4double polycone_z[] = {0,1,2,3,0,5,4,3,2,1};
484  for (int i = 0; i < numRZ1; ++i) {
485    polycone_r[i] *= 10*cm;
486    polycone_z[i] *= 10.*cm;
487  }
488
489  G4Polycone* polycone_solid
490      = new G4Polycone("Polycone_Test",
491                       0.*deg,270.*deg,numRZ1,polycone_r,polycone_z);
492                       //0.,twopi,numRZ,polycone_r,polycone_z);
493  G4cout << polycone_solid->StreamInfo(G4cout) << G4endl;
494
495  G4LogicalVolume* polycone_log
496    = new G4LogicalVolume(polycone_solid,Ar,"Polycone_Test");
497
498  G4VisAttributes * polycone_atts
499    = new G4VisAttributes(G4Colour(1.,0.5,0.5));
500  polycone_log->SetVisAttributes(polycone_atts);
501
502  new G4PVPlacement(G4Transform3D(rm,G4ThreeVector(400.*cm,120.*cm,0)),
503                    "Polycone_Test", polycone_log,
504                    experimentalHall_phys,false,0);
505
506  //-------------------------------------------- Orb
507
508  G4Orb* orb
509    = new G4Orb("Test orb", 100.*cm);
510
511  G4LogicalVolume* orb_log
512    = new G4LogicalVolume(orb, Ar,"Test_orb");
513
514  G4VisAttributes * orb_att
515    = new G4VisAttributes(G4Colour(1.,0.,1.));
516  orb_att->SetForceAuxEdgeVisible(true);
517  orb_log->SetVisAttributes(orb_att);
518
519  new G4PVPlacement(G4Translate3D(-300.*cm,200.*cm,0),
520                    "Test orb", orb_log, 
521                    experimentalHall_phys,false,0);
522
523  //-------------------------------------------- Trapezoid
524
525  G4Trap* trap1_solid = new G4Trap
526    ("trap1_solid",
527     50.*cm,  //      pDz     Half-length along the z-axis
528     0.,      //      pTheta  Polar angle of the line joining the centres of the faces
529              //              at -/+pDz
530     0.,      //      pPhi    Azimuthal angle of the line joing the centre of the face at
531              //              -pDz to the centre of the face at +pDz
532     40.*cm,  //      pDy1     Half-length along y of the face at -pDz
533     30.*cm,  //      pDx1    Half-length along x of the side at y=-pDy1 of the face at -pDz
534     30.*cm,  //      pDx2    Half-length along x of the side at y=+pDy1 of the face at -pDz
535     20.*deg, //      pAlp1   Angle with respect to the y axis from the centre of the side
536              //              at y=-pDy1 to the centre at y=+pDy1 of the face at -pDz
537     40.*cm,  //      pDy2     Half-length along y of the face at +pDz
538     30.*cm,  //      pDx3    Half-length along x of the side at y=-pDy2 of the face at +pDz
539     30.*cm,  //      pDx4    Half-length along x of the side at y=+pDy2 of the face at +pDz
540     20.*deg  //      pAlp2   Angle with respect to the y axis from the centre of the side
541              //              at y=-pDy2 to the centre at y=+pDy2 of the face at +pDz
542     );
543  G4LogicalVolume* trap1_log = new G4LogicalVolume (trap1_solid,Ar,"trap1_log");
544  new G4PVPlacement
545    (G4Transform3D(rm,G4ThreeVector(-200.*cm,200.*cm,-200.*cm)),
546     "trap1_phys", trap1_log,
547     experimentalHall_phys,false,0);
548
549  G4Trap* trap2_solid = new G4Trap
550    ("trap2_solid",
551     50.*cm,  //      pDz     Half-length along the z-axis
552     20.*deg, //      pTheta  Polar angle of the line joining the centres of the faces
553              //              at -/+pDz
554     90.*deg, //      pPhi    Azimuthal angle of the line joing the centre of the face at
555              //              -pDz to the centre of the face at +pDz
556     40.*cm,  //      pDy1     Half-length along y of the face at -pDz
557     30.*cm,  //      pDx1    Half-length along x of the side at y=-pDy1 of the face at -pDz
558     30.*cm,  //      pDx2    Half-length along x of the side at y=+pDy1 of the face at -pDz
559     0.,      //      pAlp1   Angle with respect to the y axis from the centre of the side
560              //              at y=-pDy1 to the centre at y=+pDy1 of the face at -pDz
561     40.*cm,  //      pDy2     Half-length along y of the face at +pDz
562     30.*cm,  //      pDx3    Half-length along x of the side at y=-pDy2 of the face at +pDz
563     30.*cm,  //      pDx4    Half-length along x of the side at y=+pDy2 of the face at +pDz
564     0.       //      pAlp2   Angle with respect to the y axis from the centre of the side
565              //              at y=-pDy2 to the centre at y=+pDy2 of the face at +pDz
566     );
567  G4LogicalVolume* trap2_log = new G4LogicalVolume (trap2_solid,Ar,"trap2_log");
568  new G4PVPlacement
569    (G4Transform3D(rm,G4ThreeVector(-200.*cm,400.*cm,-200.*cm)),
570     "trap2_phys", trap2_log,
571     experimentalHall_phys,false,0);
572
573  //-------------------------------------------- Elliptical Tube
574  G4VSolid* eTube = new G4EllipticalTube("e-tube",100.*cm,50.*cm,100.*cm);
575  G4LogicalVolume* eTubeLog = new G4LogicalVolume(eTube,Ar,"e-tube-log");
576  new G4PVPlacement(G4Translate3D(G4ThreeVector(-400.*cm,0.,0)),
577                    "e-tube-phys", eTubeLog,
578                    experimentalHall_phys,false,0);
579
580  //-------------------------------------------- Elliptical Cone
581  G4VSolid* eCone = new G4EllipticalCone("e-cone",50.*cm,100.*cm,100.*cm,50.*cm);
582  //G4VSolid* eCone = new G4EllipticalCone("e-cone",1.*mm,0.5*mm,40.*mm,20.*mm);
583  G4LogicalVolume* eConeLog = new G4LogicalVolume(eCone,Ar,"e-cone-log");
584  new G4PVPlacement(G4Translate3D(G4ThreeVector(-500.*cm,400.*cm,0)),
585                    "e-cone-phys", eConeLog,
586                    experimentalHall_phys,false,0);
587
588  //-------------------------------------------- G4Cons
589  G4VSolid* eCons = new G4Cons("e-cons",50.*cm,70.*cm,100.*cm,140.*cm,200.*cm,0,twopi);
590  G4LogicalVolume* eConsLog = new G4LogicalVolume(eCons,Ar,"e-cons-log");
591  new G4PVPlacement(G4Translate3D(G4ThreeVector(-300.*cm,-200.*cm,60*cm)),
592                    "e-cons-phys", eConsLog,
593                    experimentalHall_phys,false,0);
594
595  /*
596  //--------------------------- Simple shared logical volume tree
597
598  G4VSolid* boxTwo = new G4Box("Box2", 100.*cm, 100.*cm, 100.*cm);
599  G4LogicalVolume* log2 = new G4LogicalVolume(boxTwo,Ar,"Log2");
600  new G4PVPlacement(G4Translate3D(G4ThreeVector(600.*cm,0.,0.)),
601                    "B",log2,
602                    experimentalHall_phys,false,0);
603  new G4PVPlacement(G4Translate3D(G4ThreeVector(900.*cm,0.,0.)),
604                    "C",log2,
605                    experimentalHall_phys,false,0);
606  G4VSolid* boxThree = new G4Box("Box3", 50.*cm, 50.*cm, 50.*cm);
607  G4LogicalVolume* log3 = new G4LogicalVolume(boxThree,Ar,"Log3");
608  new G4PVPlacement(G4Translate3D(),
609                    log3,"D",
610                    log2,false,0);
611  G4VSolid* boxFour = new G4Box("Box3", 30.*cm, 30.*cm, 30.*cm);
612  G4LogicalVolume* log4 = new G4LogicalVolume(boxFour,Ar,"Log4");
613  new G4PVPlacement(G4Translate3D(),
614                    log4,"E",
615                    log3,false,0);
616  */
617
618  /*
619  //--------------------------- Boolean for logical volume test
620
621  G4double alSLayer_x = 30.*cm;
622  G4double alSLayer_y = 50.*cm;
623  G4double alSLayer_z = 2.5*cm;
624
625  G4Box* box1B = new
626    G4Box("alSLayer_box",alSLayer_x/2.,alSLayer_y/2.,alSLayer_z/2.);
627
628  G4Tubs* Cylinder1 = new G4Tubs("Cylinder#1",0.*mm,alSLayer_x/2.,alSLayer_x/2.,0.,2.*M_PI);
629
630  G4UnionSolid* b1UnionC1 = new G4UnionSolid("Box+Cylinder", box1B,
631                         Cylinder1);
632
633  G4LogicalVolume* alSpaceCraft_log = new
634    G4LogicalVolume(b1UnionC1,Al,"alLayer_log",0,0,0); 
635
636  new G4PVPlacement(0,G4ThreeVector(900.*cm, 200.*cm, 0.),alSpaceCraft_log,"alLayer_phys",experimentalHall_log,false,0);
637  // new G4PVPlacement(G4Translate3D(G4ThreeVector(900.*cm, 200.*cm, 0.)),"alLayer_phys",alSpaceCraft_log,experimentalHall_log,false,0);
638  */
639
640  //----------- Radially replicated tube sector
641
642  G4double rMin = 50.*cm;
643  G4double DeltaR = 50.*cm;
644  G4VSolid* rrTubs = new G4Tubs
645    ("rrTubs",rMin,rMin + DeltaR,200*cm,180*deg,90*deg);
646  G4LogicalVolume* rrTubsLog = new G4LogicalVolume
647    (rrTubs,Ar,"rrTubs-log");
648  rrTubsLog->SetVisAttributes(G4VisAttributes::Invisible);
649  new G4PVPlacement(G4Translate3D(G4ThreeVector(400.*cm,-200.*cm,0)),
650                    "rrTubs-phys", rrTubsLog,
651                    experimentalHall_phys,false,0);
652  G4double deltaR = DeltaR / 6.;
653  G4Tubs* drrTubs = new G4Tubs
654    ("drrTubs",rMin,rMin + deltaR,200*cm,180*deg,90*deg);
655  G4LogicalVolume * drrTubsLog = new G4LogicalVolume
656    (drrTubs,Ar,"drrTubs-log");
657  drrTubsLog->SetVisAttributes(G4Colour::Red());
658  new G4PVReplica("drrTubs-phys",drrTubsLog,rrTubsLog,
659                  kRho,6,deltaR,rMin);
660
661
662  //----------- tetrahedron
663
664  G4VSolid* tet = new G4Tet
665    ("tet",
666     G4ThreeVector(),
667     G4ThreeVector(0.,100.*cm,0.),
668     G4ThreeVector(0.,0.,100.*cm),
669     G4ThreeVector(100*cm,0.,0.));
670  G4LogicalVolume* tet_log = new G4LogicalVolume
671    (tet,Ar,"tet-log");
672  tet_log->SetVisAttributes(G4VisAttributes(G4Colour(0.,1.,0.)));
673  new G4PVPlacement
674    (G4Translate3D(G4ThreeVector(300.*cm,-400.*cm,0.)),
675     "tet-phys", tet_log,
676     experimentalHall_phys,false,0);
677
678  //----------- Twisted solids
679
680  G4VSolid* aVolume;
681  G4LogicalVolume* aLog;
682  G4double fTrackerR1 ;   // r1
683  G4double fTrackerR2 ;   // r2
684  G4double fTrackerpDz  ;  // Full length of Tracker (pDz)
685  G4double fTrackerpDx1 ;  // twisted Trapezoid
686  G4double fTrackerpDx2 ;
687  G4double fTrackerpDy1 ;
688  G4double fTrackerpDy2 ;
689  G4double fTwistAngle ;
690  G4double fPhi ;
691
692  G4double myScale = 5.;
693
694  fTwistAngle = 90*deg ;
695  fTrackerpDz = myScale*20*cm ;
696  fTrackerR1  = myScale*7*cm ;
697  fTrackerR2  = myScale*10*cm ;
698  fPhi        = 180*deg ;
699
700  aVolume = new G4TwistedTubs
701    ("aTwistedTubs", fTwistAngle, fTrackerR1, fTrackerR2, fTrackerpDz, fPhi ) ;
702  //G4cout << "aTwistedTubs: volume: " << aVolume->GetCubicVolume() << G4endl;
703  aLog = new G4LogicalVolume
704    (aVolume,Ar,"aTwistedTubs-log");
705  aLog->SetVisAttributes(G4VisAttributes(G4Colour(1.,1.,0.)));
706  //  Comment out this G4PVPlacement to get voxelisation crash...
707  new G4PVPlacement
708    (G4Translate3D(G4ThreeVector(200.*cm,-400.*cm,0.)),
709     "aTwistedTubs-phys", aLog, experimentalHall_phys,false,0);
710
711  fTwistAngle = 50*deg ;
712  fTrackerpDx1 = myScale*4*cm ;
713  fTrackerpDy1 = myScale*6*cm ;
714  fTrackerpDz  = myScale*15*cm ;
715
716  aVolume = new G4TwistedBox
717    ("aTwistedBox",fTwistAngle,fTrackerpDx1,fTrackerpDy1,fTrackerpDz) ;
718  aLog = new G4LogicalVolume
719    (aVolume,Ar,"aTwistedBox-log");
720  aLog->SetVisAttributes(G4VisAttributes(G4Colour(1.,1.,0.)));
721  //  Comment out this G4PVPlacement to get voxelisation crash...
722  new G4PVPlacement
723    (G4Translate3D(G4ThreeVector(100.*cm,-400.*cm,0.)),
724     "aTwistedBox-phys", aLog, experimentalHall_phys,false,0);
725
726  fTrackerpDx1 = myScale*4*cm ;
727  fTrackerpDx2 = myScale*7*cm ;
728  fTrackerpDy1 = myScale*2*cm ;
729  fTrackerpDy2 = myScale*4*cm ;
730  fTrackerpDz  = myScale*15*cm ;
731  fTwistAngle = 50*deg ;
732
733  aVolume = new G4TwistedTrd
734    ("aTwistedTrd",fTrackerpDx1,fTrackerpDx2,fTrackerpDy1,fTrackerpDy2,
735     fTrackerpDz,fTwistAngle);
736  aLog = new G4LogicalVolume
737    (aVolume,Ar,"aTwistedTrd-log");
738  aLog->SetVisAttributes(G4VisAttributes(G4Colour(1.,1.,0.)));
739  new G4PVPlacement
740    (G4Translate3D(G4ThreeVector(000.*cm,-400.*cm,0.)),
741     "aTwistedTrd-phys", aLog, experimentalHall_phys,false,0);
742
743  fTrackerpDx1 = myScale*4*cm ;
744  fTrackerpDx2 = myScale*7*cm ;
745  fTrackerpDy1 = myScale*2*cm ;
746  fTrackerpDy2 = myScale*4*cm ;
747  fTrackerpDz  = myScale*15*cm ;
748  fTwistAngle = 50*deg ;
749
750  aVolume = new G4TwistedTrd
751    ("anotherTwistedTrd",fTrackerpDx1,fTrackerpDx2,fTrackerpDy1,fTrackerpDy2,
752     fTrackerpDz,fTwistAngle);
753  aLog = new G4LogicalVolume
754    (aVolume,Ar,"anotherTwistedTrd-log");
755  aLog->SetVisAttributes(G4VisAttributes(G4Colour(1.,1.,0.)));
756  new G4PVPlacement
757    (G4Translate3D(G4ThreeVector(-100.*cm,-400.*cm,0.)),
758     "anotherTwistedTrd-phys", aLog, experimentalHall_phys,false,0);
759
760  //-------------------------------------------- return
761  return experimentalHall_phys;
762}
Note: See TracBrowser for help on using the repository browser.