source: trunk/source/geometry/solids/test/SurfaceVisTest/src/DetectorConstruction.cc

Last change on this file was 1347, checked in by garnier, 14 years ago

geant4 tag 9.4

File size: 23.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//
28//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
29//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 
31#include "DetectorConstruction.hh"
32#include "DetectorMessenger.hh"
33
34#include "G4Material.hh"
35
36#include "G4Box.hh"
37#include "G4Orb.hh"
38#include "G4Tubs.hh"
39#include "G4Sphere.hh"
40#include "G4Cons.hh"
41#include "G4Hype.hh"
42#include "G4Para.hh"
43#include "G4Paraboloid.hh"
44#include "G4Torus.hh"
45#include "G4Trd.hh"
46#include "G4Ellipsoid.hh"
47#include "G4EllipticalTube.hh"
48#include "G4EllipticalCone.hh"
49
50#include "G4Trap.hh"
51#include "G4Trd.hh"
52#include "G4Tet.hh"
53#include "G4GenericTrap.hh"
54#include "G4TessellatedSolid.hh"
55#include "G4ExtrudedSolid.hh"
56
57#include "G4Polycone.hh"
58#include "G4Polyhedra.hh"
59
60#include "G4TwistedTubs.hh"
61#include "G4TwistedBox.hh"
62#include "G4TwistedTrd.hh"
63#include "G4TwistedTrap.hh"
64
65#include "G4BooleanSolid.hh"
66#include "G4DisplacedSolid.hh"
67#include "G4UnionSolid.hh"
68#include "G4IntersectionSolid.hh"
69#include "G4SubtractionSolid.hh"
70#include "G4ReflectedSolid.hh"
71
72#include "G4BREPSolidBox.hh"
73#include "G4TwoVector.hh"
74#include "G4TriangularFacet.hh"
75#include "G4QuadrangularFacet.hh"
76
77#include "G4LogicalVolume.hh"
78#include "G4PVPlacement.hh"
79#include "G4PVParameterised.hh"
80#include "G4SDManager.hh"
81
82#include "G4UserLimits.hh"
83
84#include "G4VisAttributes.hh"
85#include "G4Colour.hh"
86
87#include "G4ios.hh"
88
89#include "G4UnitsTable.hh"
90
91#include "G4RunManager.hh"
92#include "G4GeometryManager.hh"
93#include "G4PhysicalVolumeStore.hh"
94#include "G4LogicalVolumeStore.hh"
95#include "G4SolidStore.hh"
96
97//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
98 
99DetectorConstruction::DetectorConstruction()
100:solidWorld(0),  logicWorld(0),  physiWorld(0),
101 logicTracker(0),physiTracker(0), 
102 fWorldLength(0.)
103{
104    detectorMessenger = new DetectorMessenger(this);
105}
106
107//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108 
109DetectorConstruction::~DetectorConstruction()
110{
111    delete detectorMessenger;             
112}
113
114////////////////////////////////////////////////////////////////
115
116void DetectorConstruction::SwitchDetector()
117{
118   G4RunManager::GetRunManager()->DefineWorldVolume(physiWorld);
119 
120}
121
122
123G4VPhysicalVolume*
124DetectorConstruction::SelectDetector( const G4String& val )
125{
126
127   G4GeometryManager::GetInstance()->OpenGeometry();
128   G4PhysicalVolumeStore::GetInstance()->Clean();
129   G4LogicalVolumeStore::GetInstance()->Clean();
130   G4SolidStore::GetInstance()->Clean();
131   ///////
132  G4double a, z;
133
134  G4double density;
135  G4int nel;
136
137  //Air
138  G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole);
139  G4Element* O = new G4Element("Oxygen"  , "O", z=8., a= 16.00*g/mole);
140   
141  G4Material* Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2);
142  Air->AddElement(N, 70*perCent);
143  Air->AddElement(O, 30*perCent);
144
145  // Print all the materials defined.
146  //
147  //  G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
148  //G4cout << *(G4Material::GetMaterialTable()) << G4endl;
149
150  G4Box* b1 = new G4Box ( "b1", 100*cm, 50*cm, 50*cm );
151  G4Box* b2 = new G4Box ( "b2", 50*cm, 100*cm, 50*cm );
152
153  fval = val ;
154  G4double fTrackerR1,fTrackerR2,fPhi,fPhiSegment,fTheta,fThetaSegment ; 
155  G4double fSemiAxisX,fSemiAxisY,fSemiAxisZ  ;
156  G4double fTrackerR,fTrackerpDx1,fTrackerpDy1,fTrackerpDz;
157  if (val == "Sphere")
158  {
159    // only solid sphere is supportet for now
160      fTrackerR1 = 0*cm ;
161      fTrackerR2 = 12*cm ;
162      fPhi = 0*deg ;
163      fPhiSegment = 360*deg ;
164      fTheta = 0*deg ;
165      fThetaSegment = 180*deg ;
166      aVolume = new G4Sphere ("aSphere",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
167  }
168
169  else if (val == "HalfSphere")
170  {
171    // only solid sphere is supportet for now
172      fTrackerR1 = 0*cm ;
173      fTrackerR2 = 12*cm ;
174      fPhi = 0*deg ;
175      fPhiSegment = 180*deg ;
176      fTheta = 0*deg ;
177      fThetaSegment = 180*deg ;
178      aVolume = new G4Sphere ("aHalfSphere",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
179
180  }
181  else if (val == "HollowSphere")
182  {
183    // only solid sphere is supportet for now
184      fTrackerR1 = 12*cm ;
185      fTrackerR2 = 14*cm ;
186      fPhi = 0*deg ;
187      fPhiSegment = 360*deg ;
188      fTheta = 0*deg ;
189      fThetaSegment = 180*deg ;
190      aVolume = new G4Sphere ("aHollowSphere",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
191
192  }
193  else if (val == "HalfHollowSphere")
194  {
195    // only solid sphere is supportet for now
196      fTrackerR1 = 12*cm ;
197      fTrackerR2 = 14*cm ;
198      fPhi = 0*deg ;
199      fPhiSegment = 180*deg ;
200      fTheta = 0*deg ;
201      fThetaSegment = 180*deg ;
202      aVolume = new G4Sphere ("aHalfHollowSphere",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
203
204  }
205  else if (val == "Q1Shell")
206  {
207    // only solid sphere is supportet for now
208      fTrackerR1 = 10*cm ;
209      fTrackerR2 = 12*cm ;
210      fPhi = 0*deg ;
211      fPhiSegment = 90*deg ;
212      fTheta = 0*deg ;
213      fThetaSegment = 90*deg ;
214      aVolume = new G4Sphere ("aQ1Shell",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
215
216  }
217  else if (val == "Q2Shell")
218  {
219    // only solid sphere is supportet for now
220      fTrackerR1 = 10*cm ;
221      fTrackerR2 = 12*cm ;
222      fPhi = 90*deg ;
223      fPhiSegment = 90*deg ;
224      fTheta = 0*deg ;
225      fThetaSegment = 90*deg ;
226      aVolume = new G4Sphere ("aQ2Shell",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
227
228  } 
229  else if (val == "Q3Shell")
230  {
231    // only solid sphere is supportet for now
232      fTrackerR1 = 10*cm ;
233      fTrackerR2 = 12*cm ;
234      fPhi = 180*deg ;
235      fPhiSegment = 90*deg ;
236      fTheta = 0*deg ;
237      fThetaSegment = 90*deg ;
238      aVolume = new G4Sphere ("aQ3Shell",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
239
240  }
241  else if (val == "Q4Shell")
242  {
243    // only solid sphere is supportet for now
244      fTrackerR1 = 10*cm ;
245      fTrackerR2 = 12*cm ;
246      fPhi = 270*deg ;
247      fPhiSegment = 90*deg ;
248      fTheta = 0*deg ;
249      fThetaSegment = 90*deg ;
250      aVolume = new G4Sphere ("aQ4Shell",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
251
252  }
253  else if (val == "Q5Shell")
254  {
255    // only solid sphere is supportet for now
256      fTrackerR1 = 10*cm ;
257      fTrackerR2 = 12*cm ;
258      fPhi = 0*deg ;
259      fPhiSegment = 90*deg ;
260      fTheta = 90*deg ;
261      fThetaSegment = 90*deg ;
262      aVolume = new G4Sphere ("aQ5Shell",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
263
264  }
265else if (val == "Q6Shell")
266  {
267    // only solid sphere is supportet for now
268      fTrackerR1 = 10*cm ;
269      fTrackerR2 = 12*cm ;
270      fPhi = 90*deg ;
271      fPhiSegment = 90*deg ;
272      fTheta = 90*deg ;
273      fThetaSegment = 90*deg ;
274      aVolume = new G4Sphere ("aQ5Shell",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
275
276  } 
277  else if (val == "Q7Shell")
278  {
279    // only solid sphere is supportet for now
280      fTrackerR1 = 10*cm ;
281      fTrackerR2 = 12*cm ;
282      fPhi = 180*deg ;
283      fPhiSegment = 90*deg ;
284      fTheta = 90*deg ;
285      fThetaSegment = 90*deg ;
286      aVolume = new G4Sphere ("aQ7Shell",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
287
288  }
289  else if (val == "Q8Shell")
290  {
291    // only solid sphere is supportet for now
292      fTrackerR1 = 10*cm ;
293      fTrackerR2 = 12*cm ;
294      fPhi = 270*deg ;
295      fPhiSegment = 90*deg ;
296      fTheta = 90*deg ;
297      fThetaSegment = 90*deg ;
298      aVolume = new G4Sphere ("aQ8Shell",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
299
300  }
301
302
303  else if (val == "Shell")
304  {
305    // only solid sphere is supportet for now
306      fTrackerR1 = 10*cm ;
307      fTrackerR2 = 12*cm ;
308      fPhi = 30*deg ;
309      fPhiSegment = 120*deg ;
310      fTheta = 10*deg ;
311      fThetaSegment = 100*deg ;
312      aVolume = new G4Sphere ("aShell",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
313
314  }
315  else if (val == "Ring")
316  {
317    // only solid sphere is supportet for now
318      fTrackerR1 = 10*cm ;
319      fTrackerR2 = 12*cm ;
320      fPhi = 30*deg ;
321      fPhiSegment = 120*deg ;
322      fTheta = 10*deg ;
323      fThetaSegment = 40*deg ;
324      aVolume = new G4Sphere ("aRing",  fTrackerR1, fTrackerR2 ,fPhi, fPhiSegment, fTheta, fThetaSegment);
325
326  }
327  else if ( val == "Ellipsoid" ) {
328
329    fSemiAxisX = 1*cm ;
330    fSemiAxisY = 10*cm ;
331    fSemiAxisZ = 100*cm ;
332
333    aVolume = new  G4Ellipsoid("aEllipsoid",
334                               fSemiAxisX,
335                               fSemiAxisY,
336                               fSemiAxisZ,
337                               -fSemiAxisZ,fSemiAxisZ);
338
339
340  }
341  else if (val == "Orb")
342  {
343
344    fTrackerR = 11*cm ;
345    aVolume = new G4Orb ( "aOrb", fTrackerR );
346
347  }
348  else if (val == "Box") 
349  {         
350
351    fTrackerpDx1 = 10*cm ;
352    fTrackerpDy1 = 10*cm ;
353    fTrackerpDz  = 10*cm ;
354
355    aVolume = new G4Box ( "aBox", fTrackerpDx1, fTrackerpDy1, fTrackerpDz );
356  }
357  else if (val == "Cons")
358  {       
359
360    fTrackerpDz = 80*cm ;
361    fTrackerR1 = 11*cm ;
362    fTrackerR2 = 16*cm ;
363
364    aVolume = new G4Cons ( "aCons", 0.8*fTrackerR1 , fTrackerR1, 0.8*fTrackerR2, fTrackerR2, fTrackerpDz, 10*deg, 120.*deg  ); 
365
366  }
367  else if (val == "manyCons")
368  {       
369    aVolume = new G4Cons ( "aCone", 2*cm, 6*cm, 8*cm, 14*cm,
370                           10*cm, 10*deg, 300*deg ); 
371  //  10*cm, 10*deg, 300*deg );
372                           //  0., pi);
373
374 
375  }
376  else if (val == "Tubs")
377  {
378
379    // only solid Tube is supported.
380    fTrackerpDz = 80*cm ;
381    fTrackerR = 11*cm ;
382
383    aVolume = new G4Tubs ( "aTube",0.8*fTrackerR,fTrackerR,fTrackerpDz,40.,100*deg) ;
384
385  }
386  else if (val == "Hype")
387  {
388    aVolume = new G4Hype ("aHype", 7*cm, 10*cm, 40*deg, 40*deg, 40*cm );
389  }
390  else if (val == "Torus")
391  {
392
393    fPhi = 40*deg ;
394    fPhiSegment = 100*deg ;
395
396    fTrackerR1 = 5*cm ;
397    fTrackerR2 = 6*cm ;
398    fTrackerR  = 20*cm ;
399
400    aVolume = new G4Torus("aTorus", fTrackerR1, fTrackerR2 ,fTrackerR, fPhi, fPhiSegment) ;
401
402  }
403  else if (val == "Para")
404  {
405    aVolume = new G4Para ("aPara", 8*cm, 10*cm, 12*cm, 30*deg, 45*deg, 60*deg);
406  }
407  else if (val == "Paraboloid")
408  {
409    aVolume = new G4Paraboloid ("aParaboloid", 8*cm, 1*cm, 12*cm);
410  }
411  else if (val == "PolyconeGen")
412  {
413    G4double rr[]={100,120,140,120};
414    G4double zz[]={-100,-100,100,100};
415    aVolume = new G4Polycone ("aPolycone",0*deg,90*deg, 4, rr,zz);
416 }
417 else if (val == "PolyconeGenComplex")
418  {
419    G4double        zPlanes[]       =       {-11640.*mm,    -11640.*mm,     -11570.722*mm,  -9766.005*mm, 
420                                                -4487.828*mm,   4487.828*mm,    9766.005*mm,    11570.722*mm, 
421                                                11640.*mm,      11640.*mm,      11580.*mm,      9750.*mm,
422                                            4500.*mm,       -4500.*mm,      -9750.*mm,      -11580.*mm,
423                                             -11640.*mm};
424 
425        G4double        radius[]        =       {250.*mm,       305.*mm,        305.*mm,        2770.461*mm,
426                                                4932.*mm,       4932.*mm,       2770.461*mm,    305.*mm,
427                                                305.*mm,        250.*mm,        250.*mm,        2750.*mm,
428                                                 4900.*mm,       4900.*mm,       2750.*mm,       250.*mm,
429                                                   250.*mm};
430    aVolume = new G4Polycone ("aPolycone",0*deg,360*deg, 16, radius,zPlanes);
431 }
432  else if (val == "Polycone")
433  {
434    G4double rIn[]={100,120,0,0,120,120};
435    G4double rOut[]={120,140,140,120,140,160};
436    G4double zPlane[]={-200,-100,0,100,200,300};
437    aVolume = new G4Polycone ("aPolycone",0*deg,90*deg, 6,zPlane, rIn,rOut);
438  }
439 else if (val == "PolyhedraGen")
440  {
441    G4double rr[]={100,120,140,120};
442    G4double zz[]={-100,-100,100,100};
443    aVolume = new G4Polyhedra ("aPolycone",0*deg,90*deg,8, 4, rr,zz);
444  }
445 else if (val == "PolyhedraGenComplex")
446  {
447    G4double rr[]={ 100, 120,   0,  0,140,120,150,150,150,140, 130};
448    G4double zz[]={-150,-100,-100,-50,  0,200,200,100,0,  -50,-100};
449    aVolume = new G4Polyhedra ("aPolycone",0*deg,360*deg,8, 11, rr,zz);
450  }
451 else if (val == "Polyhedra")
452  {
453    G4double rOut[5]={2100,600,1500,1500,3800.};
454    G4double rIn[5]={0,500,0,700,100};
455    G4double zPlane[5]={-100,1000,1500,2500,3000.};
456    aVolume = new G4Polyhedra ("aPolycone",0*deg,60*deg,6, 5,zPlane, rIn,rOut);
457  }
458 
459  else if (val == "Trd")
460  {
461    aVolume = new G4Trd ("aTrd", 80*cm, 100*cm, 70*cm, 90*cm, 100*cm);
462  }
463  else if (val == "b1Ub2") 
464  {         
465    aVolume = new G4UnionSolid("b1Ub2",b1,b2);
466    /*
467    G4Box * box1 = new G4Box("Box1",1092.500000,240.103374,92.000000);
468    G4Box * box2 = new G4Box("Box2",540.103374,792.500000,92.000000);
469
470    G4double L1 = 1104;
471
472    aVolume =
473    new G4UnionSolid("ECShapeBoxes",
474                     box1,
475                     box2,
476                     0,
477                     G4ThreeVector(-L1/2.,
478                                   L1/2.,
479                                   0.));
480    */
481  }
482  else if (val == "b1Ib2") 
483  {         
484    aVolume = new G4IntersectionSolid("b1Ib2",b1,b2);
485  }
486  else if (val == "b1Sb2") 
487  {         
488    aVolume = new G4SubtractionSolid("b1Sb2",b1,b2);
489  }
490  else if (val == "b1Ib1") 
491  {         
492    aVolume = new G4IntersectionSolid("b1Ib1",b1,b1);
493  }
494  else if (val == "b1Ub1") 
495  {         
496    aVolume = new G4UnionSolid("b1Ub1",b1,b1);
497  }
498  else if (val == "b1Sb1") 
499  {         
500    aVolume = new G4SubtractionSolid("b1Sb1",b1,b1);
501  }
502
503  else if ( val == "Tet" ) 
504  {
505    //   G4ThreeVector anchor = G4ThreeVector(0, 0, 0);
506    //G4ThreeVector     p2 = G4ThreeVector(10*cm, 5*cm , 0);
507    //G4ThreeVector     p3 = G4ThreeVector(5*cm,10*cm,0);
508    //G4ThreeVector     p4 = G4ThreeVector(5*cm,5*cm  ,10*cm);
509   
510    //aVolume = new G4Tet("aTet",anchor,p2,p3,p4);
511      G4ThreeVector pzero(0,0,0);
512      G4ThreeVector pnt1(10.*cm,0.*cm,0.*cm),pnt2(5.0*cm,10.*cm,0.*cm), pnt3(5.*cm,5.*cm,10.*cm);
513      G4bool  goodTet;
514      aVolume= new G4Tet( "aTet", pzero, pnt1, pnt2, pnt3, &goodTet);
515  }
516  else if ( val == "Trap") 
517  {
518      fTrackerpDz = 80*cm;
519    fTheta = 10*deg ;
520    fPhi  =  40*deg ;
521    fTrackerpDy1 = 16*cm ;
522    fTrackerpDx1 = 24*cm ;
523    G4double fTrackerpDx2 = 14*cm ;
524    G4double fTrackerpDy2 = 8*cm ;
525    G4double fTrackerpDx3 = 16*cm ;
526    G4double fTrackerpDx4 = 11*cm ;
527    G4double fAlph = 50*deg    ;
528
529    aVolume = new G4Trap("aTrap",
530                                fTrackerpDz,         // half z length
531                                fTheta,              // direction between end planes
532                                fPhi,                // defined by polar and azimutal angles.
533                                fTrackerpDy1,        // half y length at -pDz
534                                fTrackerpDx1,        // half x length at -pDz,-pDy
535                                fTrackerpDx2,        // half x length at -pDz,+pDy
536                                fAlph,                // tilt angle at +pDz
537                                fTrackerpDy2,        // half y length at +pDz
538                                fTrackerpDx3,        // half x length at +pDz,-pDy
539                                fTrackerpDx4,        // half x length at +pDz,+pDy
540                                fAlph                // tilt angle at +pDz
541                                ) ;
542   
543 
544  }
545  else if ( val == "EllipticalCone" ) 
546  {
547    aVolume = new G4EllipticalCone("aEllipticalCone",
548                        0.5*mm,       // xSemiAxis
549                        1*mm,       // ySemiAxis
550                        40*mm,      // zheight
551                        25*mm) ;    // zTopCut
552
553  }
554  else if ( val == "EllipticalTube" ) 
555  {
556    aVolume = new G4EllipticalTube("aEllipticalTube" ,
557                                   2*cm,   // xSemiAxis
558                                   5*cm,   // ySemiAxis
559                                   35*cm) ;  // zheight
560
561  }
562  else if (val == "GenericTrap" ){
563   std::vector<G4TwoVector> vertices;
564   vertices.push_back(G4TwoVector( -4.5*cm, -4.5*cm));
565   vertices.push_back(G4TwoVector( -4.5*cm,  4.5*cm));
566   vertices.push_back(G4TwoVector(  4.5*cm,  4.5*cm));
567   vertices.push_back(G4TwoVector(  4.5*cm, -4.5*cm));
568   vertices.push_back(G4TwoVector( -3.5*cm, -3.5*cm));
569   vertices.push_back(G4TwoVector( -3.5*cm,  3.5*cm));
570   vertices.push_back(G4TwoVector(  3.5*cm,  3.5*cm));
571   vertices.push_back(G4TwoVector(  3.5*cm, -2.5*cm));     
572   aVolume = new G4GenericTrap("aGenTrd",14.*cm,vertices);
573  }
574
575 else if(val == "TessellatedSolid")
576  { 
577    G4double targetSize = 10.*cm;
578    G4TessellatedSolid* aVolume1 = new G4TessellatedSolid("aTessellatedSolid");
579    G4TriangularFacet *facet1 = new
580    G4TriangularFacet (G4ThreeVector(-targetSize,-targetSize,        0.0),
581                     G4ThreeVector(+targetSize,-targetSize,        0.0),
582                     G4ThreeVector(        0.0,        0.0,+targetSize),
583                     ABSOLUTE);
584    G4TriangularFacet *facet2 = new
585    G4TriangularFacet (G4ThreeVector(+targetSize,-targetSize,        0.0),
586                     G4ThreeVector(+targetSize,+targetSize,        0.0),
587                     G4ThreeVector(        0.0,        0.0,+targetSize),
588                     ABSOLUTE);
589    G4TriangularFacet *facet3 = new
590    G4TriangularFacet (G4ThreeVector(+targetSize,+targetSize,        0.0),
591                     G4ThreeVector(-targetSize,+targetSize,        0.0),
592                     G4ThreeVector(        0.0,        0.0,+targetSize),
593                     ABSOLUTE);
594    G4TriangularFacet *facet4 = new
595    G4TriangularFacet (G4ThreeVector(-targetSize,+targetSize,        0.0),
596                     G4ThreeVector(-targetSize,-targetSize,        0.0),
597                     G4ThreeVector(        0.0,        0.0,+targetSize),
598                     ABSOLUTE);
599    G4QuadrangularFacet *facet5 = new
600    G4QuadrangularFacet (G4ThreeVector(-targetSize,-targetSize,        0.0),
601                     G4ThreeVector(-targetSize,+targetSize,        0.0),
602                     G4ThreeVector(+targetSize,+targetSize,        0.0),
603                     G4ThreeVector(+targetSize,-targetSize,        0.0),
604                     ABSOLUTE);
605
606    aVolume1->AddFacet((G4VFacet*) facet1);
607    aVolume1->AddFacet((G4VFacet*) facet2);
608    aVolume1->AddFacet((G4VFacet*) facet3);
609    aVolume1->AddFacet((G4VFacet*) facet4);
610    aVolume1->AddFacet((G4VFacet*) facet5);
611 
612    aVolume1->SetSolidClosed(true);
613
614    aVolume = aVolume1;
615
616  }
617  else if (val == "ExtrudedSolid")
618  {
619   std::vector<G4TwoVector> polygon;
620   polygon.push_back(G4TwoVector(-3.*cm, -3.0*cm));
621   polygon.push_back(G4TwoVector(-3.*cm,  3.0*cm));
622   polygon.push_back(G4TwoVector( 3.*cm,  3.0*cm));
623   polygon.push_back(G4TwoVector( 3.*cm, -3.0*cm));
624   polygon.push_back(G4TwoVector( 1.5*cm, -3.0*cm));
625   polygon.push_back(G4TwoVector( 1.5*cm,  1.5*cm));
626   polygon.push_back(G4TwoVector(-1.5*cm,  1.5*cm));
627   polygon.push_back(G4TwoVector(-1.5*cm, -3.0*cm));
628 
629   std::vector<G4ExtrudedSolid::ZSection> zsections;
630   zsections.push_back(G4ExtrudedSolid::ZSection(-4.0*cm, G4TwoVector(-2.0*cm, 1.0*cm), 1.5));
631   zsections.push_back(G4ExtrudedSolid::ZSection( 1.0*cm, G4TwoVector(  0*cm,  0*cm), 0.5));
632   zsections.push_back(G4ExtrudedSolid::ZSection( 1.5*cm, G4TwoVector(  0*cm,  0*cm), 0.7));
633   zsections.push_back(G4ExtrudedSolid::ZSection( 4.0*cm, G4TwoVector( 2.0*cm, 2.0*cm), 0.9));
634
635   aVolume = new G4ExtrudedSolid("aExtrudedSolid", polygon, zsections);
636  }
637   else if (val == "TwistedBox")
638  {
639    aVolume = new G4TwistedBox("aTwistedBox",40*deg,5*cm,10*cm,15*cm);
640  }
641  else if (val == "TwistedTrd")
642  { 
643    aVolume = new G4TwistedTrd("aTwistedTrd",5*cm,10*cm,8*cm,15*cm,18*cm,20*deg);
644  }
645  else if (val == "TwistedTrap")
646  {
647    aVolume = new G4TwistedTrap("aTwistedTrap",40*deg,5*cm,10*cm,8*cm,15*cm);
648  }
649  else if ( val == "TwistedTrap2") 
650  {
651    aVolume = new G4TwistedTrap("aTwistedTrap2",
652                                   20*deg,    // twist angle
653                                   80*cm,         // half z length
654                                   10*deg,      // direction between end planes
655                                   40*deg,        // defined by polar and azimutal angles.
656                                   8*cm,        // half y length at -pDz
657                                   11*cm,        // half x length at -pDz,-pDy
658                                   16*cm,        // half x length at -pDz,+pDy
659                                   8*cm,        // half y length at +pDz
660                                   11*cm,         // half x length at +pDz,-pDy
661                                   16*cm,        // half x length at +pDz,+pDy
662                                   -50*deg        // tilt angle at +pDz
663                                   ) ;
664  }
665  else if ( val == "TwistedTubs")
666  {
667    aVolume = new G4TwistedTubs("aTwistedTubs",10.*deg,1*cm,2*cm,4*cm,171.*deg);
668
669  }
670  else
671    { G4cout <<"DetectorConstruction tried to select "<<val<<G4endl;
672    G4Exception("DetectorConstruction::SelectDetector() - Invalid shape!");
673  }
674
675  fWorldLength= 10*m ;
676   
677//--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
678 
679  //------------------------------
680  // World
681  //------------------------------
682
683  G4double HalfWorldLength = 0.5*fWorldLength;
684  solidWorld= new G4Box("world",HalfWorldLength,HalfWorldLength,HalfWorldLength);
685  logicWorld= new G4LogicalVolume( solidWorld, Air, "World", 0, 0, 0);
686 
687  //  Must place the World Physical volume unrotated at (0,0,0).
688  //
689  physiWorld = new G4PVPlacement(0,               // no rotation
690                                 G4ThreeVector(), // at (0,0,0)
691                                 logicWorld,      // its logical volume
692                                 "World",         // its name
693                                 0,               // its mother  volume
694                                 false,           // no boolean operations
695                                 0);              // no field specific to volume
696                                 
697
698
699  G4LogicalVolume* aVolume_log = new G4LogicalVolume(aVolume, Air, "aVolume_L", 0,0,0);
700
701  // G4VPhysicalVolume * aVolume_phys1 =
702      new G4PVPlacement(0,
703                        G4ThreeVector(0*cm, 0*cm, 0*cm),
704                        aVolume_log, 
705                        val, 
706                        logicWorld, 
707                        false,
708                        0);
709
710
711
712//--------- Visualization attributes -------------------------------
713
714
715// the world is transparent
716  G4VisAttributes* WorldAtt = new G4VisAttributes(G4Colour(1.,1.,1.,0.));
717  WorldAtt->SetVisibility(true);
718  logicWorld->SetVisAttributes(WorldAtt); 
719
720  G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(0.0,1.0,0.0));
721  BoxVisAtt->SetVisibility(true);
722  BoxVisAtt->SetForceSolid(true);
723  aVolume_log->SetVisAttributes(BoxVisAtt);
724 
725//--------- example of User Limits -------------------------------
726
727 
728  return physiWorld;
729
730}
731
732//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
733 
734G4VPhysicalVolume* DetectorConstruction::Construct()
735{
736
737
738  //-------------------Hall ----------------------------------
739 
740  return SelectDetector ("Polyhedra");  // default is Polyhedra
741
742}
743
Note: See TracBrowser for help on using the repository browser.