source: trunk/examples/extended/parallel/ParN02/src/ExN02DetectorConstruction.cc@ 893

Last change on this file since 893 was 807, checked in by garnier, 17 years ago

update

File size: 11.2 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: ExN02DetectorConstruction.cc,v 1.3 2006/06/29 17:34:35 gunter Exp $
28// GEANT4 tag $Name: $
29//
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32
33#include "ExN02DetectorConstruction.hh"
34#include "ExN02DetectorMessenger.hh"
35#include "ExN02ChamberParameterisation.hh"
36#include "ExN02MagneticField.hh"
37#include "ExN02TrackerSD.hh"
38
39#include "G4Material.hh"
40#include "G4Box.hh"
41#include "G4LogicalVolume.hh"
42#include "G4PVPlacement.hh"
43#include "G4PVParameterised.hh"
44#include "G4SDManager.hh"
45
46#include "G4UserLimits.hh"
47
48#include "G4VisAttributes.hh"
49#include "G4Colour.hh"
50
51#include "G4ios.hh"
52
53//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54
55ExN02DetectorConstruction::ExN02DetectorConstruction()
56:solidWorld(0), logicWorld(0), physiWorld(0),
57 solidTarget(0), logicTarget(0), physiTarget(0),
58 solidTracker(0),logicTracker(0),physiTracker(0),
59 solidChamber(0),logicChamber(0),physiChamber(0),
60 TargetMater(0), ChamberMater(0),fpMagField(0),
61 fWorldLength(0.), fTargetLength(0.), fTrackerLength(0.),
62 NbOfChambers(0) , ChamberWidth(0.), ChamberSpacing(0.)
63{
64 fpMagField = new ExN02MagneticField();
65 detectorMessenger = new ExN02DetectorMessenger(this);
66}
67
68//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69
70ExN02DetectorConstruction::~ExN02DetectorConstruction()
71{
72 delete fpMagField;
73 delete detectorMessenger;
74}
75
76//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77
78G4VPhysicalVolume* ExN02DetectorConstruction::Construct()
79{
80//--------- Material definition ---------
81
82 G4double a, z;
83 G4double density, temperature, pressure;
84 G4int nel;
85
86 //Air
87 G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole);
88 G4Element* O = new G4Element("Oxygen" , "O", z=8., a= 16.00*g/mole);
89
90 G4Material* Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2);
91 Air->AddElement(N, 70*perCent);
92 Air->AddElement(O, 30*perCent);
93
94 //Lead
95 G4Material* Pb =
96 new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
97
98 //Xenon gas
99 G4Material* Xenon =
100 new G4Material("XenonGas", z=54., a=131.29*g/mole, density= 5.458*mg/cm3,
101 kStateGas, temperature= 1*atmosphere, pressure= 293.15*kelvin);
102
103 // Print all the materials defined.
104 //
105 G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
106 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
107
108//--------- Sizes of the principal geometrical components (solids) ---------
109
110 NbOfChambers = 5;
111 ChamberWidth = 20*cm;
112 ChamberSpacing = 80*cm;
113
114 fTrackerLength = (NbOfChambers+1)*ChamberSpacing; // Full length of Tracker
115 fTargetLength = 5.0 * cm; // Full length of Target
116
117 TargetMater = Pb;
118 ChamberMater = Xenon;
119
120 fWorldLength= 1.2 *(fTargetLength+fTrackerLength);
121
122 G4double targetSize = 0.5*fTargetLength; // Half length of the Target
123 G4double trackerSize = 0.5*fTrackerLength; // Half length of the Tracker
124
125//--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
126
127 //------------------------------
128 // World
129 //------------------------------
130
131 G4double HalfWorldLength = 0.5*fWorldLength;
132
133 solidWorld= new G4Box("world",HalfWorldLength,HalfWorldLength,HalfWorldLength);
134 logicWorld= new G4LogicalVolume( solidWorld, Air, "World", 0, 0, 0);
135
136 // Must place the World Physical volume unrotated at (0,0,0).
137 //
138 physiWorld = new G4PVPlacement(0, // no rotation
139 G4ThreeVector(), // at (0,0,0)
140 logicWorld, // its logical volume
141 "World", // its name
142 0, // its mother volume
143 false, // no boolean operations
144 0); // no field specific to volume
145
146 //------------------------------
147 // Target
148 //------------------------------
149
150 G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetSize+trackerSize));
151
152 solidTarget = new G4Box("target",targetSize,targetSize,targetSize);
153 logicTarget = new G4LogicalVolume(solidTarget,TargetMater,"Target",0,0,0);
154 physiTarget = new G4PVPlacement(0, // no rotation
155 positionTarget, // at (x,y,z)
156 logicTarget, // its logical volume
157 "Target", // its name
158 logicWorld, // its mother volume
159 false, // no boolean operations
160 0); // no particular field
161
162 G4cout << "Target is " << fTargetLength/cm << " cm of "
163 << TargetMater->GetName() << G4endl;
164
165 //------------------------------
166 // Tracker
167 //------------------------------
168
169 G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
170
171 solidTracker = new G4Box("tracker",trackerSize,trackerSize,trackerSize);
172 logicTracker = new G4LogicalVolume(solidTracker , Air, "Tracker",0,0,0);
173 physiTracker = new G4PVPlacement(0, // no rotation
174 positionTracker, // at (x,y,z)
175 logicTracker, // its logical volume
176 "Tracker", // its name
177 logicWorld, // its mother volume
178 false, // no boolean operations
179 0); // no particular field
180
181 //------------------------------
182 // Tracker segments
183 //------------------------------
184 //
185 // An example of Parameterised volumes
186 // dummy values for G4Box -- modified by parameterised volume
187
188 solidChamber = new G4Box("chamber", 100*cm, 100*cm, 10*cm);
189 logicChamber = new G4LogicalVolume(solidChamber,ChamberMater,"Chamber",0,0,0);
190
191 G4double firstPosition = -trackerSize + 0.5*ChamberWidth;
192 G4double firstLength = fTrackerLength/10;
193 G4double lastLength = fTrackerLength;
194
195 G4VPVParameterisation* chamberParam = new ExN02ChamberParameterisation(
196 NbOfChambers, // NoChambers
197 firstPosition, // Z of center of first
198 ChamberSpacing, // Z spacing of centers
199 ChamberWidth, // Width Chamber
200 firstLength, // lengthInitial
201 lastLength); // lengthFinal
202
203 // dummy value : kZAxis -- modified by parameterised volume
204 //
205 physiChamber = new G4PVParameterised(
206 "Chamber", // their name
207 logicChamber, // their logical volume
208 logicTracker, // Mother logical volume
209 kZAxis, // Are placed along this axis
210 NbOfChambers, // Number of chambers
211 chamberParam); // The parametrisation
212
213 G4cout << "There are " << NbOfChambers << " chambers in the tracker region. "
214 << "The chambers are " << ChamberWidth/mm << " mm of "
215 << ChamberMater->GetName() << "\n The distance between chamber is "
216 << ChamberSpacing/cm << " cm" << G4endl;
217
218 //------------------------------------------------
219 // Sensitive detectors
220 //------------------------------------------------
221
222 G4SDManager* SDman = G4SDManager::GetSDMpointer();
223
224 G4String trackerChamberSDname = "ExN02/TrackerChamberSD";
225 ExN02TrackerSD* aTrackerSD = new ExN02TrackerSD( trackerChamberSDname );
226 SDman->AddNewDetector( aTrackerSD );
227 logicChamber->SetSensitiveDetector( aTrackerSD );
228
229//--------- Visualization attributes -------------------------------
230
231 G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
232 logicWorld ->SetVisAttributes(BoxVisAtt);
233 logicTarget ->SetVisAttributes(BoxVisAtt);
234 logicTracker->SetVisAttributes(BoxVisAtt);
235
236 G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
237 logicChamber->SetVisAttributes(ChamberVisAtt);
238
239//--------- example of User Limits -------------------------------
240
241 // below is an example of how to set tracking constraints in a given
242 // logical volume(see also in N02PhysicsList how to setup the process
243 // G4UserSpecialCuts).
244 // Sets a max Step length in the tracker region
245 // G4double maxStep = 0.5*ChamberWidth, maxLength = 2*fTrackerLength;
246 // G4double maxTime = 0.1*ns, minEkin = 10*MeV;
247 // logicTracker->SetUserLimits(new G4UserLimits(maxStep,maxLength,maxTime,
248 // minEkin));
249
250 return physiWorld;
251}
252
253//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
254
255void ExN02DetectorConstruction::setTargetMaterial(G4String materialName)
256{
257 // search the material by its name
258 G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
259 if (pttoMaterial)
260 {TargetMater = pttoMaterial;
261 logicTarget->SetMaterial(pttoMaterial);
262 G4cout << "\n----> The target is " << fTargetLength/cm << " cm of "
263 << materialName << G4endl;
264 }
265}
266
267//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
268
269void ExN02DetectorConstruction::setChamberMaterial(G4String materialName)
270{
271 // search the material by its name
272 G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
273 if (pttoMaterial)
274 {ChamberMater = pttoMaterial;
275 logicChamber->SetMaterial(pttoMaterial);
276 G4cout << "\n----> The chambers are " << ChamberWidth/cm << " cm of "
277 << materialName << G4endl;
278 }
279}
280
281//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
282
283void ExN02DetectorConstruction::SetMagField(G4double fieldValue)
284{
285 fpMagField->SetFieldValue(fieldValue);
286}
287
288//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.