source: trunk/source/geometry/solids/specific/test/testG4Tess_Tria/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.9 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.5 2007/05/18 10:40:29 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 "G4TriangularFacet.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  G4TriangularFacet *facet1 = new
130  G4TriangularFacet (G4ThreeVector(-targetSize,-targetSize,        0.0),
131                     G4ThreeVector(+targetSize,-targetSize,        0.0),
132                     G4ThreeVector(        0.0,        0.0,+targetSize),
133                     ABSOLUTE);
134  G4TriangularFacet *facet2 = new
135  G4TriangularFacet (G4ThreeVector(+targetSize,-targetSize,        0.0),
136                     G4ThreeVector(+targetSize,+targetSize,        0.0),
137                     G4ThreeVector(        0.0,        0.0,+targetSize),
138                     ABSOLUTE);
139  G4TriangularFacet *facet3 = new
140  G4TriangularFacet (G4ThreeVector(+targetSize,+targetSize,        0.0),
141                     G4ThreeVector(-targetSize,+targetSize,        0.0),
142                     G4ThreeVector(        0.0,        0.0,+targetSize),
143                     ABSOLUTE);
144  G4TriangularFacet *facet4 = new
145  G4TriangularFacet (G4ThreeVector(-targetSize,+targetSize,        0.0),
146                     G4ThreeVector(-targetSize,-targetSize,        0.0),
147                     G4ThreeVector(        0.0,        0.0,+targetSize),
148                     ABSOLUTE);
149  G4TriangularFacet *facet5 = new
150  G4TriangularFacet (G4ThreeVector(-targetSize,-targetSize,        0.0),
151                     G4ThreeVector(        0.0,        0.0,-targetSize/2.),
152                     G4ThreeVector(+targetSize,-targetSize,        0.0),
153                     ABSOLUTE);
154  G4TriangularFacet *facet6 = new
155  G4TriangularFacet (G4ThreeVector(+targetSize,-targetSize,        0.0),
156                     G4ThreeVector(        0.0,        0.0,-targetSize/2.),
157                     G4ThreeVector(+targetSize,+targetSize,        0.0),
158                     ABSOLUTE);
159  G4TriangularFacet *facet7 = new
160  G4TriangularFacet (G4ThreeVector(+targetSize,+targetSize,        0.0),
161                     G4ThreeVector(        0.0,        0.0,-targetSize/2.),
162                     G4ThreeVector(-targetSize,+targetSize,        0.0),
163                     ABSOLUTE);
164  G4TriangularFacet *facet8 = new
165  G4TriangularFacet (G4ThreeVector(-targetSize,+targetSize,        0.0),
166                     G4ThreeVector(        0.0,        0.0,-targetSize/2.),
167                     G4ThreeVector(-targetSize,-targetSize,        0.0),
168                     ABSOLUTE);
169  solidTarget->AddFacet((G4VFacet*) facet1);
170  solidTarget->AddFacet((G4VFacet*) facet2);
171  solidTarget->AddFacet((G4VFacet*) facet3);
172  solidTarget->AddFacet((G4VFacet*) facet4);
173  solidTarget->AddFacet((G4VFacet*) facet5);
174  solidTarget->AddFacet((G4VFacet*) facet6);
175  solidTarget->AddFacet((G4VFacet*) facet7);
176  solidTarget->AddFacet((G4VFacet*) facet8);
177 
178  solidTarget->SetSolidClosed(true);
179  logicTarget = new G4LogicalVolume(solidTarget,Pb,"Target",0,0,0);
180  physiTarget = new G4PVPlacement(0,               // no rotation
181                                  positionTarget,  // at (x,y,z)
182                                  logicTarget,     // its logical volume                                 
183                                  "Target",        // its name
184                                  logicWorld,      // its mother  volume
185                                  false,           // no boolean operations
186                                  0);              // no particular field
187 
188//--------- Visualization attributes -------------------------------
189
190  G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
191  BoxVisAtt->SetVisibility(false);
192  G4VisAttributes* FacetVisAtt= new G4VisAttributes(G4Colour(1.0,0.0,0.0));
193  FacetVisAtt->SetVisibility(true);
194 
195  logicWorld  ->SetVisAttributes(BoxVisAtt); 
196  logicTarget ->SetVisAttributes(FacetVisAtt);
197 
198//--------- example of User Limits -------------------------------
199
200  // below is an example of how to set tracking constraints in a given
201  // logical volume(see also in N02PhysicsList how to setup the process
202  // G4UserSpecialCuts). 
203  // Sets a max Step length in the tracker region
204  // G4double maxStep = 0.5*ChamberWidth, maxLength = 2*fTrackerLength;
205  // G4double maxTime = 0.1*ns, minEkin = 10*MeV;
206  // logicTracker->SetUserLimits(new G4UserLimits(maxStep,maxLength,maxTime,
207  //                                               minEkin));
208 
209  return physiWorld;
210}
211//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.