source: trunk/source/digits_hits/utils/test/test3/src/Tst1DetectorConstruction.cc@ 1358

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

update to last version 4.9.4

File size: 4.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: Tst1DetectorConstruction.cc,v 1.2 2010/09/30 20:53:08 asaim Exp $
28// GEANT4 tag $Name: $
29//
30//
31
32#include "Tst1DetectorConstruction.hh"
33
34#include "G4Material.hh"
35#include "G4Box.hh"
36#include "G4LogicalVolume.hh"
37#include "G4PVPlacement.hh"
38#include "G4UniformMagField.hh"
39#include "G4FieldManager.hh"
40#include "G4TransportationManager.hh"
41#include "G4VisAttributes.hh"
42#include "G4Colour.hh"
43#include "G4ios.hh"
44
45Tst1DetectorConstruction::Tst1DetectorConstruction()
46:constructed(false)
47{;}
48
49Tst1DetectorConstruction::~Tst1DetectorConstruction()
50{;}
51
52G4VPhysicalVolume* Tst1DetectorConstruction::Construct()
53{
54 if(!constructed)
55 {
56 constructed = true;
57 DefineMaterials();
58 SetupGeometry();
59 }
60 return worldPhys;
61}
62
63void Tst1DetectorConstruction::DefineMaterials()
64{
65 G4String name, symbol; //a=mass of a mole;
66 G4double a, z, density; //z=mean number of protons;
67
68 G4int ncomponents, natoms;
69 G4double fractionmass;
70
71 //
72 // define Elements
73 //
74
75 a = 1.01*g/mole;
76 G4Element* H = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
77
78 a = 14.01*g/mole;
79 G4Element* N = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
80
81 a = 16.00*g/mole;
82 G4Element* O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
83
84 //
85 // define a material from elements. case 1: chemical molecule
86 //
87
88 density = 1.000*g/cm3;
89 water = new G4Material(name="Water", density, ncomponents=2);
90 water->AddElement(H, natoms=2);
91 water->AddElement(O, natoms=1);
92
93 //
94 // define a material from elements. case 2: mixture by fractional mass
95 //
96
97 density = 1.290*mg/cm3;
98 air = new G4Material(name="Air" , density, ncomponents=2);
99 air->AddElement(N, fractionmass=0.7);
100 air->AddElement(O, fractionmass=0.3);
101}
102
103void Tst1DetectorConstruction::SetupGeometry()
104{
105 //
106 // World
107 //
108 G4VSolid* worldSolid = new G4Box("World",2.*m,2.*m,2.*m);
109 G4LogicalVolume* worldLogical = new G4LogicalVolume(worldSolid,air,"World");
110 worldPhys = new G4PVPlacement(0,G4ThreeVector(),worldLogical,"World",
111 0,false,0);
112
113 //
114 // Phantom
115 //
116 G4VSolid* phantomSolid = new G4Box("Calor",1.*m,1.*m,1.*m);
117 G4LogicalVolume* phantomLogical = new G4LogicalVolume(phantomSolid,water,"Phantom");
118 phantomPhys = new G4PVPlacement(0,G4ThreeVector(),phantomLogical,"Phantom",
119 worldLogical,false,0);
120
121 //
122 // Magnetic field
123 //
124 G4UniformMagField* myField
125 = new G4UniformMagField(G4ThreeVector(0.,0.,10.0*tesla));
126// = new G4UniformMagField(G4ThreeVector(1.0*tesla,0.,0.));
127 G4FieldManager* fieldMgr
128 = G4TransportationManager::GetTransportationManager()->GetFieldManager();
129 fieldMgr->SetDetectorField(myField);
130 fieldMgr->CreateChordFinder(myField);
131
132 //
133 // Visualization attributes
134 //
135// worldLogical->SetVisAttributes(G4VisAttributes::Invisible);
136 G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
137 simpleBoxVisAtt->SetVisibility(true);
138 phantomLogical->SetVisAttributes(simpleBoxVisAtt);
139}
140
141
Note: See TracBrowser for help on using the repository browser.