source: trunk/source/geometry/solids/specific/test/testG4Tess_Quadr/src/TEx01DetectorConstruction.cc @ 1316

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

update geant4-09-04-beta-cand-01 interfaces-V09-03-09 vis-V09-03-08

File size: 8.7 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: TEx01DetectorConstruction.cc,v 1.3 2007/05/18 10:39:04 gcosmo Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-cand-01 $
29//
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33#include "TEx01DetectorConstruction.hh"
34
35#include "G4Material.hh"
36#include "G4Box.hh"
37#include "G4LogicalVolume.hh"
38#include "G4PVPlacement.hh"
39#include "G4PVParameterised.hh"
40#include "G4SDManager.hh"
41
42#include "G4UserLimits.hh"
43
44#include "G4VisAttributes.hh"
45#include "G4Colour.hh"
46
47#include "G4ios.hh"
48
49#include "G4QuadrangularFacet.hh"
50#include "G4VFacet.hh"
51
52//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
54TEx01DetectorConstruction::TEx01DetectorConstruction()
55:solidWorld(0),  logicWorld(0),  physiWorld(0),
56 solidTarget(0), logicTarget(0), physiTarget(0)
57{;}
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
61TEx01DetectorConstruction::~TEx01DetectorConstruction()
62{;}
63
64//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
66G4VPhysicalVolume* TEx01DetectorConstruction::Construct()
67{
68//--------- Material definition ---------
69
70  G4double a, z;
71  G4double density;
72  G4int nel;
73
74  //Air
75  G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole);
76  G4Element* O = new G4Element("Oxygen"  , "O", z=8., a= 16.00*g/mole);
77   
78  G4Material* Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2);
79  Air->AddElement(N, 70*perCent);
80  Air->AddElement(O, 30*perCent);
81
82  //Lead
83  G4Material* Pb = 
84  new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
85   
86  // Print all the materials defined.
87  //
88  G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
89  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
90
91//--------- Sizes of the principal geometrical components (solids)  ---------
92 
93  fTargetLength  = 10.0 * cm;                        // Full length of Target
94 
95  fWorldLength= 1.2 *(fTargetLength*2.0);
96   
97  G4double targetSize  = 0.5*fTargetLength;    // Half length of the Target 
98     
99//--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
100 
101  //------------------------------
102  // World
103  //------------------------------
104
105  G4double HalfWorldLength = 0.5*fWorldLength;
106 
107 solidWorld= new G4Box("world",HalfWorldLength,HalfWorldLength,HalfWorldLength);
108 logicWorld= new G4LogicalVolume( solidWorld, Air, "World", 0, 0, 0);
109 
110  //  Must place the World Physical volume unrotated at (0,0,0).
111  //
112  physiWorld = new G4PVPlacement(0,               // no rotation
113                                 G4ThreeVector(), // at (0,0,0)
114                                 logicWorld,      // its logical volume
115                                 "World",         // its name
116                                 0,               // its mother  volume
117                                 false,           // no boolean operations
118                                 0);              // no field specific to volume
119                                 
120  //------------------------------
121  // Target
122  //------------------------------
123 
124  G4ThreeVector positionTarget = G4ThreeVector(0.0,0.0,0.0);
125   
126  //solidTarget = new G4Box("target",targetSize,targetSize,targetSize);
127
128  solidTarget = new G4TessellatedSolid("target");
129  G4QuadrangularFacet *facet1 = new
130  G4QuadrangularFacet (G4ThreeVector(-targetSize,-targetSize,-targetSize),
131                     G4ThreeVector(-targetSize,+targetSize,-targetSize),
132                     G4ThreeVector(+targetSize,+targetSize,-targetSize),
133                     G4ThreeVector(+targetSize,-targetSize,-targetSize),
134                     ABSOLUTE);
135  G4QuadrangularFacet *facet2 = new
136  G4QuadrangularFacet (G4ThreeVector(-targetSize,-targetSize/2,+targetSize),
137                     G4ThreeVector(+targetSize,-targetSize/2,+targetSize),
138                     G4ThreeVector(+targetSize,+targetSize,+targetSize),
139                     G4ThreeVector(-targetSize,+targetSize,+targetSize),
140                     ABSOLUTE);
141  G4QuadrangularFacet *facet3 = new
142  G4QuadrangularFacet (G4ThreeVector(-targetSize,-targetSize,-targetSize),
143                     G4ThreeVector(+targetSize,-targetSize,-targetSize),
144                     G4ThreeVector(+targetSize,-targetSize/2,+targetSize),
145                     G4ThreeVector(-targetSize,-targetSize/2,+targetSize),
146                     ABSOLUTE);
147  G4QuadrangularFacet *facet4 = new
148  G4QuadrangularFacet (G4ThreeVector(-targetSize,+targetSize,-targetSize),
149                     G4ThreeVector(-targetSize,+targetSize,+targetSize),
150                     G4ThreeVector(+targetSize,+targetSize,+targetSize),
151                     G4ThreeVector(+targetSize,+targetSize,-targetSize),
152                     ABSOLUTE);
153  G4QuadrangularFacet *facet5 = new
154  G4QuadrangularFacet (G4ThreeVector(-targetSize,-targetSize,-targetSize),
155                     G4ThreeVector(-targetSize,-targetSize/2,+targetSize),
156                     G4ThreeVector(-targetSize,+targetSize,+targetSize),
157                     G4ThreeVector(-targetSize,+targetSize,-targetSize),
158                     ABSOLUTE);
159  G4QuadrangularFacet *facet6 = new
160  G4QuadrangularFacet (G4ThreeVector(+targetSize,-targetSize,-targetSize),
161                     G4ThreeVector(+targetSize,+targetSize,-targetSize),
162                     G4ThreeVector(+targetSize,+targetSize,+targetSize),
163                     G4ThreeVector(+targetSize,-targetSize/2,+targetSize),
164                     ABSOLUTE);
165
166  solidTarget->AddFacet((G4VFacet*) facet1);
167  solidTarget->AddFacet((G4VFacet*) facet2);
168  solidTarget->AddFacet((G4VFacet*) facet3);
169  solidTarget->AddFacet((G4VFacet*) facet4);
170  solidTarget->AddFacet((G4VFacet*) facet5);
171  solidTarget->AddFacet((G4VFacet*) facet6);
172 
173  solidTarget->SetSolidClosed(true);
174  logicTarget = new G4LogicalVolume(solidTarget,Pb,"Target",0,0,0);
175  physiTarget = new G4PVPlacement(0,               // no rotation
176                                  positionTarget,  // at (x,y,z)
177                                  logicTarget,     // its logical volume                                 
178                                  "Target",        // its name
179                                  logicWorld,      // its mother  volume
180                                  false,           // no boolean operations
181                                  0);              // no particular field
182 
183//--------- Visualization attributes -------------------------------
184
185  G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
186  BoxVisAtt->SetVisibility(false);
187  G4VisAttributes* FacetVisAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0));
188  FacetVisAtt->SetVisibility(true);
189 
190  logicWorld  ->SetVisAttributes(BoxVisAtt); 
191  logicTarget ->SetVisAttributes(FacetVisAtt);
192 
193//--------- example of User Limits -------------------------------
194
195  // below is an example of how to set tracking constraints in a given
196  // logical volume(see also in N02PhysicsList how to setup the process
197  // G4UserSpecialCuts). 
198  // Sets a max Step length in the tracker region
199  // G4double maxStep = 0.5*ChamberWidth, maxLength = 2*fTrackerLength;
200  // G4double maxTime = 0.1*ns, minEkin = 10*MeV;
201  // logicTracker->SetUserLimits(new G4UserLimits(maxStep,maxLength,maxTime,
202  //                                               minEkin));
203 
204  return physiWorld;
205}
206//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.