ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExP01DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ExP01DetectorConstruction.cc
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 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
37 #include "ExP01MagneticField.hh"
38 #include "ExP01TrackerSD.hh"
39 
40 #include "G4Material.hh"
41 #include "G4Box.hh"
42 #include "G4LogicalVolume.hh"
43 #include "G4PVPlacement.hh"
44 #include "G4PVParameterised.hh"
45 #include "G4SDManager.hh"
46 
47 #include "G4UserLimits.hh"
48 
49 #include "G4VisAttributes.hh"
50 #include "G4Colour.hh"
51 
52 #include "G4SystemOfUnits.hh"
53 #include "G4ios.hh"
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
59  fSolidWorld(0), fLogicWorld(0), fPhysiWorld(0),
60  fSolidTarget(0), fLogicTarget(0), fPhysiTarget(0),
61  fSolidTracker(0), fLogicTracker(0), fPhysiTracker(0),
62  fSolidChamber(0), fLogicChamber(0), fPhysiChamber(0),
63  fTargetMater(0), fChamberMater(0), fPMagField(0), fDetectorMessenger(0),
64  fWorldLength(0.), fTargetLength(0.), fTrackerLength(0.),
65  fNbOfChambers(0), fChamberWidth(0.), fChamberSpacing(0.)
66 {
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74 {
75  delete fPMagField;
76  delete fDetectorMessenger;
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  fNbOfChambers = 5;
114  fChamberWidth = 20*cm;
115  fChamberSpacing = 80*cm;
116 
117  fTrackerLength = (fNbOfChambers+1)*fChamberSpacing; // Full length of Tracker
118  fTargetLength = 5.0 * cm; // Full length of Target
119 
120  fTargetMater = Pb;
121  fChamberMater = Xenon;
122 
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  fSolidWorld= new G4Box("world",HalfWorldLength,HalfWorldLength,HalfWorldLength);
137  fLogicWorld= new G4LogicalVolume( fSolidWorld, Air, "World", 0, 0, 0);
138 
139  // Must place the World Physical volume unrotated at (0,0,0).
140  //
141  fPhysiWorld = new G4PVPlacement(0, // no rotation
142  G4ThreeVector(), // at (0,0,0)
143  fLogicWorld, // 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  fSolidTarget = new G4Box("target",targetSize,targetSize,targetSize);
157  fPhysiTarget = new G4PVPlacement(0, // no rotation
158  positionTarget, // at (x,y,z)
159  fLogicTarget, // its logical volume
160  "Target", // its name
161  fLogicWorld, // its mother volume
162  false, // no boolean operations
163  0); // copy number
164 
165  G4cout << "Target is " << fTargetLength/cm << " cm of "
166  << fTargetMater->GetName() << G4endl;
167 
168  //------------------------------
169  // Tracker
170  //------------------------------
171 
172  G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
173 
174  fSolidTracker = new G4Box("tracker",trackerSize,trackerSize,trackerSize);
175  fLogicTracker = new G4LogicalVolume(fSolidTracker , Air, "Tracker",0,0,0);
176  fPhysiTracker = new G4PVPlacement(0, // no rotation
177  positionTracker, // at (x,y,z)
178  fLogicTracker, // its logical volume
179  "Tracker", // its name
180  fLogicWorld, // 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  fSolidChamber = new G4Box("chamber", 100*cm, 100*cm, 10*cm);
193 
194  G4double firstPosition = -trackerSize + 0.5*fChamberWidth;
195  G4double firstLength = fTrackerLength/10;
196  G4double lastLength = fTrackerLength;
197 
199  fNbOfChambers, // NoChambers
200  firstPosition, // Z of center of first
201  fChamberSpacing, // Z spacing of centers
202  fChamberWidth, // Width Chamber
203  firstLength, // lengthInitial
204  lastLength); // lengthFinal
205 
206  // dummy value : kZAxis -- modified by parameterised volume
207  //
209  "Chamber", // their name
210  fLogicChamber, // their logical volume
211  fLogicTracker, // Mother logical volume
212  kZAxis, // Are placed along this axis
213  fNbOfChambers, // Number of chambers
214  chamberParam); // The parametrisation
215 
216  G4cout << "There are " << fNbOfChambers << " chambers in the tracker region. "
217  << "The chambers are " << fChamberWidth/mm << " mm of "
218  << fChamberMater->GetName() << "\n The distance between chamber is "
219  << fChamberSpacing/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  fLogicChamber->SetSensitiveDetector( aTrackerSD );
231 
232 //--------- Visualization attributes -------------------------------
233 
234  G4VisAttributes* BoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
235  fLogicWorld ->SetVisAttributes(BoxVisAtt);
236  fLogicTarget ->SetVisAttributes(BoxVisAtt);
237  fLogicTracker->SetVisAttributes(BoxVisAtt);
238 
239  G4VisAttributes* ChamberVisAtt = new G4VisAttributes(G4Colour(1.0,1.0,0.0));
240  fLogicChamber->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*fChamberWidth;
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 fPhysiWorld;
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  {fTargetMater = pttoMaterial;
270  fLogicTarget->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  {fChamberMater = pttoMaterial;
284  fLogicChamber->SetMaterial(pttoMaterial);
285  G4cout << "\n----> The chambers are " << fChamberWidth/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......