source: trunk/source/processes/scoring/test/test1/src/A01DetectorConstruction.cc @ 1249

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

nvx fichiers dans CVS

File size: 5.4 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// $Id: A01DetectorConstruction.cc,v 1.3 2006/12/13 15:49:00 gunter Exp $
27// --------------------------------------------------------------
28//
29
30#include "A01DetectorConstruction.hh"
31
32///////////////////////////////////#include "G4FieldManager.hh"
33///////////////////////////////////#include "G4TransportationManager.hh"
34///////////////////////////////////#include "A01Field.hh"
35
36#include "G4Material.hh"
37#include "G4Element.hh"
38#include "G4MaterialTable.hh"
39
40#include "G4VSolid.hh"
41#include "G4Box.hh"
42#include "G4LogicalVolume.hh"
43#include "G4VPhysicalVolume.hh"
44#include "G4PVPlacement.hh"
45#include "G4PVReplica.hh"
46
47#include "G4SDManager.hh"
48#include "G4MultiFunctionalDetector.hh"
49#include "G4PSNofStep.hh"
50#include "G4PSTrackLength.hh"
51#include "G4PSNofSecondary.hh"
52#include "G4PSEnergyDeposit.hh"
53
54#include "G4VisAttributes.hh"
55#include "G4Colour.hh"
56
57A01DetectorConstruction::A01DetectorConstruction()
58: air(0), water(0), worldVisAtt(0), phantomVisAtt(0) 
59{;}
60
61A01DetectorConstruction::~A01DetectorConstruction() 
62{
63    delete worldVisAtt;
64    delete phantomVisAtt;
65}
66
67G4VPhysicalVolume* A01DetectorConstruction::Construct() 
68{
69    ConstructMaterials();
70
71    G4Box * worldSolid = new G4Box("worldBox", 1.*m, 1.*m, 1.*m);
72    G4LogicalVolume * worldLogical
73        = new G4LogicalVolume(worldSolid, air, "worldLogical", 0, 0, 0);
74    G4VPhysicalVolume* worldPhysical
75        = new G4PVPlacement(0, G4ThreeVector(), worldLogical, "worldPhysical",
76                            0, 0, 0);
77    // water phantom
78    G4Box * phantomSolid = new G4Box("phantomBox", 60.*cm, 60.*cm, 60*cm);
79    G4LogicalVolume * phantomLogical
80        = new G4LogicalVolume(phantomSolid, water, "phantomLogical", 0, 0 ,0);
81    new G4PVPlacement(0, G4ThreeVector(), phantomLogical, "phantomPhysical",
82                      worldLogical, 0, 0);
83    G4Box * layerSolid = new G4Box("PhantomLayerBox", 60.*cm, 60.*cm, 3.*cm);
84    G4LogicalVolume * layerLogical
85        = new G4LogicalVolume(layerSolid, water, "PhantomLayerLogical", 0, 0, 0);
86    new G4PVReplica("PhantomLayerPhysical",layerLogical,phantomLogical,kZAxis,20,6.*cm);
87
88    G4SDManager* SDman = G4SDManager::GetSDMpointer();
89    G4String SDname;
90    G4MultiFunctionalDetector* aSD = new G4MultiFunctionalDetector(SDname="MassWorld");
91    SDman->AddNewDetector(aSD);
92    layerLogical->SetSensitiveDetector(aSD);
93
94    aSD->RegisterPrimitive(new G4PSNofStep("NofStep"));
95    aSD->RegisterPrimitive(new G4PSTrackLength("TrackLength"));
96    aSD->RegisterPrimitive(new G4PSNofSecondary("NofSecondary"));
97    aSD->RegisterPrimitive(new G4PSEnergyDeposit("EnergyDeposit"));
98
99    worldLogical->SetVisAttributes(G4VisAttributes::GetInvisible());
100
101    phantomVisAtt = new G4VisAttributes(G4Colour(0.6,0.8,1.0));
102    phantomLogical->SetVisAttributes(phantomVisAtt);
103    layerLogical->SetVisAttributes(phantomVisAtt);
104
105    return worldPhysical;
106}
107
108void A01DetectorConstruction::ConstructMaterials() {
109
110    G4double a;
111    G4double z;
112    G4double density;
113    G4double weightRatio;
114    G4String name;
115    G4String symbol;
116    G4int nElem;
117    G4int nAtoms;
118
119    // elements for mixtures and compounds
120    a = 1.01*g/mole;
121    G4Element* elH = new G4Element(name="Hydrogen", symbol="H", z=1., a);
122    a = 14.01*g/mole;
123    G4Element* elN = new G4Element(name="Nitrogen", symbol="N", z=7., a);
124    a = 16.00*g/mole;
125    G4Element* elO = new G4Element(name="Oxigen", symbol="O", z=8., a);
126
127    // Air
128    density = 1.29*mg/cm3;
129    air = new G4Material(name="Air", density, nElem=2);
130    air->AddElement(elN, weightRatio=.7);
131    air->AddElement(elO, weightRatio=.3);
132
133    // Water
134    density = 1.0*g/cm3;
135    water = new G4Material(name="H2O", density, nElem=2);
136    water->AddElement(elH, nAtoms=2);
137    water->AddElement(elO, nAtoms=1);
138
139    G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
140    G4cout << *(G4Material::GetMaterialTable()) << G4endl;
141}
142
143
Note: See TracBrowser for help on using the repository browser.