Geant4  10.00.p01
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: ExP01DetectorConstruction.cc 71791 2013-06-24 14:08:28Z gcosmo $
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 
60  fSolidWorld(0), fLogicWorld(0), fPhysiWorld(0),
61  fSolidTarget(0), fLogicTarget(0), fPhysiTarget(0),
62  fSolidTracker(0), fLogicTracker(0), fPhysiTracker(0),
63  fSolidChamber(0), fLogicChamber(0), fPhysiChamber(0),
64  fTargetMater(0), fChamberMater(0), fPMagField(0), fDetectorMessenger(0),
65  fWorldLength(0.), fTargetLength(0.), fTrackerLength(0.),
66  fNbOfChambers(0), fChamberWidth(0.), fChamberSpacing(0.)
67 {
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75 {
76  delete fPMagField;
77  delete fDetectorMessenger;
78 }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 
83 {
84 //--------- Material definition ---------
85 
86  G4double a, z;
87  G4double density, temperature, pressure;
88  G4int nel;
89 
90  //Air
91  G4Element* N = new G4Element("Nitrogen", "N", z=7., a= 14.01*g/mole);
92  G4Element* O = new G4Element("Oxygen" , "O", z=8., a= 16.00*g/mole);
93 
94  G4Material* Air = new G4Material("Air", density= 1.29*mg/cm3, nel=2);
95  Air->AddElement(N, 70*perCent);
96  Air->AddElement(O, 30*perCent);
97 
98  //Lead
99  G4Material* Pb =
100  new G4Material("Lead", z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
101 
102  //Xenon gas
103  G4Material* Xenon =
104  new G4Material("XenonGas", z=54., a=131.29*g/mole, density= 5.458*mg/cm3,
105  kStateGas, temperature= 293.15*kelvin, pressure= 1*atmosphere);
106 
107  // Print all the materials defined.
108  //
109  G4cout << G4endl << "The materials defined are : " << G4endl << G4endl;
110  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
111 
112 //--------- Sizes of the principal geometrical components (solids) ---------
113 
114  fNbOfChambers = 5;
115  fChamberWidth = 20*cm;
116  fChamberSpacing = 80*cm;
117 
118  fTrackerLength = (fNbOfChambers+1)*fChamberSpacing; // Full length of Tracker
119  fTargetLength = 5.0 * cm; // Full length of Target
120 
121  fTargetMater = Pb;
122  fChamberMater = Xenon;
123 
125 
126  G4double targetSize = 0.5*fTargetLength; // Half length of the Target
127  G4double trackerSize = 0.5*fTrackerLength; // Half length of the Tracker
128 
129 //--------- Definitions of Solids, Logical Volumes, Physical Volumes ---------
130 
131  //------------------------------
132  // World
133  //------------------------------
134 
135  G4double HalfWorldLength = 0.5*fWorldLength;
136 
137  fSolidWorld= new G4Box("world",HalfWorldLength,HalfWorldLength,HalfWorldLength);
138  fLogicWorld= new G4LogicalVolume( fSolidWorld, Air, "World", 0, 0, 0);
139 
140  // Must place the World Physical volume unrotated at (0,0,0).
141  //
142  fPhysiWorld = new G4PVPlacement(0, // no rotation
143  G4ThreeVector(), // at (0,0,0)
144  fLogicWorld, // its logical volume
145  "World", // its name
146  0, // its mother volume
147  false, // no boolean operations
148  0); // copy number
149 
150  //------------------------------
151  // Target
152  //------------------------------
153 
154  G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetSize+trackerSize));
155 
156  fSolidTarget = new G4Box("target",targetSize,targetSize,targetSize);
158  fPhysiTarget = new G4PVPlacement(0, // no rotation
159  positionTarget, // at (x,y,z)
160  fLogicTarget, // its logical volume
161  "Target", // its name
162  fLogicWorld, // its mother volume
163  false, // no boolean operations
164  0); // copy number
165 
166  G4cout << "Target is " << fTargetLength/cm << " cm of "
167  << fTargetMater->GetName() << G4endl;
168 
169  //------------------------------
170  // Tracker
171  //------------------------------
172 
173  G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
174 
175  fSolidTracker = new G4Box("tracker",trackerSize,trackerSize,trackerSize);
176  fLogicTracker = new G4LogicalVolume(fSolidTracker , Air, "Tracker",0,0,0);
177  fPhysiTracker = new G4PVPlacement(0, // no rotation
178  positionTracker, // at (x,y,z)
179  fLogicTracker, // its logical volume
180  "Tracker", // its name
181  fLogicWorld, // its mother volume
182  false, // no boolean operations
183  0); // copy number
184 
185  //------------------------------
186  // Tracker segments
187  //------------------------------
188  //
189  // An example of Parameterised volumes
190  // dummy values for G4Box -- modified by parameterised volume
191 
192  fSolidChamber = new G4Box("chamber", 100*cm, 100*cm, 10*cm);
194 
195  G4double firstPosition = -trackerSize + 0.5*fChamberWidth;
196  G4double firstLength = fTrackerLength/10;
197  G4double lastLength = fTrackerLength;
198 
200  fNbOfChambers, // NoChambers
201  firstPosition, // Z of center of first
202  fChamberSpacing, // Z spacing of centers
203  fChamberWidth, // Width Chamber
204  firstLength, // lengthInitial
205  lastLength); // lengthFinal
206 
207  // dummy value : kZAxis -- modified by parameterised volume
208  //
210  "Chamber", // their name
211  fLogicChamber, // their logical volume
212  fLogicTracker, // Mother logical volume
213  kZAxis, // Are placed along this axis
214  fNbOfChambers, // Number of chambers
215  chamberParam); // The parametrisation
216 
217  G4cout << "There are " << fNbOfChambers << " chambers in the tracker region. "
218  << "The chambers are " << fChamberWidth/mm << " mm of "
219  << fChamberMater->GetName() << "\n The distance between chamber is "
220  << fChamberSpacing/cm << " cm" << G4endl;
221 
222  //------------------------------------------------
223  // Sensitive detectors
224  //------------------------------------------------
225 
227 
228  G4String trackerChamberSDname = "ExP01/TrackerChamberSD";
229  ExP01TrackerSD* aTrackerSD = new ExP01TrackerSD( trackerChamberSDname );
230  SDman->AddNewDetector( aTrackerSD );
231  fLogicChamber->SetSensitiveDetector( aTrackerSD );
232 
233 //--------- Visualization attributes -------------------------------
234 
235  G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
236  fLogicWorld ->SetVisAttributes(BoxVisAtt);
237  fLogicTarget ->SetVisAttributes(BoxVisAtt);
238  fLogicTracker->SetVisAttributes(BoxVisAtt);
239 
240  G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
241  fLogicChamber->SetVisAttributes(ChamberVisAtt);
242 
243 //--------- example of User Limits -------------------------------
244 
245  // below is an example of how to set tracking constraints in a given
246  // logical volume(see also in N02PhysicsList how to setup the processes
247  // G4StepLimiter or G4UserSpecialCuts).
248 
249  // Sets a max Step length in the tracker region, with G4StepLimiter
250  //
251  G4double maxStep = 0.5*fChamberWidth;
253 
254  // Set additional contraints on the track, with G4UserSpecialCuts
255  //
256  // G4double maxLength = 2*fTrackerLength, maxTime = 0.1*ns, minEkin = 10*MeV;
257  // logicTracker->SetUserLimits(new G4UserLimits(maxStep,maxLength,maxTime,
258  // minEkin));
259 
260  return fPhysiWorld;
261 }
262 
263 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
264 
266 {
267  // search the material by its name
268  G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
269  if (pttoMaterial)
270  {fTargetMater = pttoMaterial;
271  fLogicTarget->SetMaterial(pttoMaterial);
272  G4cout << "\n----> The target is " << fTargetLength/cm << " cm of "
273  << materialName << G4endl;
274  }
275 }
276 
277 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
278 
280 {
281  // search the material by its name
282  G4Material* pttoMaterial = G4Material::GetMaterial(materialName);
283  if (pttoMaterial)
284  {fChamberMater = pttoMaterial;
285  fLogicChamber->SetMaterial(pttoMaterial);
286  G4cout << "\n----> The chambers are " << fChamberWidth/cm << " cm of "
287  << materialName << G4endl;
288  }
289 }
290 
291 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
292 
294 {
295  fPMagField->SetFieldValue(fieldValue);
296 }
297 
298 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static const double cm
Definition: G4SIunits.hh:106
Definition of the ExP01DetectorMessenger class.
void SetFieldValue(G4double fieldValue)
G4Material * Air
Definition: TRTMaterials.hh:57
CLHEP::Hep3Vector G4ThreeVector
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:578
G4double z
Definition: TRTMaterials.hh:39
Definition: G4Box.hh:63
const G4String & GetName() const
Definition: G4Material.hh:176
Detector messenger for the persistency example.
void SetUserLimits(G4UserLimits *pULimits)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:564
Definition of the ExP01DetectorConstruction class.
G4double a
Definition: TRTMaterials.hh:39
static const double mg
Definition: G4SIunits.hh:163
Chamber parameterisation for the persistency example.
int G4int
Definition: G4Types.hh:78
G4double density
Definition: TRTMaterials.hh:39
Definition of the ExP01TrackerSD class.
G4GLOB_DLL std::ostream G4cout
static const double cm3
Definition: G4SIunits.hh:108
static const double perCent
Definition: G4SIunits.hh:296
Magnetic field for the persistency example.
static const double kelvin
Definition: G4SIunits.hh:260
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:67
ExP01DetectorMessenger * fDetectorMessenger
Definition of the ExP01ChamberParameterisation class.
static const double g
Definition: G4SIunits.hh:162
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
static const double atmosphere
Definition: G4SIunits.hh:216
static const double mole
Definition: G4SIunits.hh:265
#define G4endl
Definition: G4ios.hh:61
Sensitive detector implementation for the ROOT hits persistency example.
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:345
Definition of the ExP01MagneticField class.
double G4double
Definition: G4Types.hh:76
void SetMaterial(G4Material *pMaterial)
static const double mm
Definition: G4SIunits.hh:102
void SetVisAttributes(const G4VisAttributes *pVA)
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
G4int nel
Definition: TRTMaterials.hh:41
virtual G4VPhysicalVolume * Construct()