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