Geant4  10.01.p01
ExExChDetectorConstruction.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 //
26 //
27 
29 #include "G4RunManager.hh"
30 
31 #include "G4Material.hh"
32 #include "G4NistManager.hh"
33 
34 #include "G4Box.hh"
35 #include "G4Tubs.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4PVPlacement.hh"
38 #include "G4UniformMagField.hh"
39 #include "G4SystemOfUnits.hh"
40 #include "G4PhysicalConstants.hh"
41 
42 #include "G4GeometryManager.hh"
43 #include "G4PhysicalVolumeStore.hh"
44 #include "G4LogicalVolumeStore.hh"
45 #include "G4SolidStore.hh"
46 
47 #include "G4VisAttributes.hh"
48 #include "G4Colour.hh"
49 
50 #include "G4SDManager.hh"
52 
53 #include "XLatticeManager3.hh"
54 
55 #include "XLogicalAtomicLattice.hh"
57 #include "XLogicalBase.hh"
58 #include "XUnitCell.hh"
59 
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76 fWorldLogic(0),fXtalLogic(0){
77 
78  bXtal = true;
79  fXtalAngle = G4ThreeVector(0.,0.,0.);
81  70. * CLHEP::millimeter,
82  1.94 * CLHEP::millimeter);
84  0. * CLHEP::meter,
85  0. * CLHEP::meter);
86 
88  5.431 * CLHEP::angstrom,
89  5.431 * CLHEP::angstrom);
90 
92  90.*CLHEP::deg,
93  90.*CLHEP::deg);
94 
95  fXtalTVA = 0.075 * CLHEP::angstrom;
96  fXtalMiller = G4ThreeVector(2,2,0);
97 
98  SetXtalMaterial("G4_Si");
99 
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
104 
106 }
107 
108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
109 
111 }
112 
113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114 
116  //** World **//
118  fWorldSizeZ = 2.2 * CLHEP::meter;
120  Instance()->FindOrBuildMaterial("G4_Galactic");
121 
122  fWorldSolid = new G4Box("World",
123  fWorldSizeXY/2.,
124  fWorldSizeXY/2.,
125  fWorldSizeZ/2.);
126 
129  "World");
130 
132  G4ThreeVector(),
133  fWorldLogic,
134  "World",
135  0,
136  false,
137  0);
138 
139  //** SSD **//
141 
143  1.92 * CLHEP::centimeter,
144  0.06 * CLHEP::centimeter); //
146  fSSD1XtalDistance = - 0.01 * CLHEP::meter;
148 
149  fSSDSolid = new G4Box("SiSD",
150  fSSDSize.x()/2.,
151  fSSDSize.y()/2.,
152  fSSDSize.z()/2.);
153 
154  fSSDLogic = new G4LogicalVolume(fSSDSolid,Si,"SiSD");
155 
156  new G4PVPlacement(0,
158  fSSDLogic,"SiSD",
159  fWorldLogic,
160  false,
161  0);
162 
163  new G4PVPlacement(0,
165  fSSDLogic,
166  "SiSD",
167  fWorldLogic,
168  false,
169  1);
170 
171  new G4PVPlacement(0,
173  fSSDLogic,
174  "SiSD",
175  fWorldLogic,
176  false,2
177  );
178 
179 #ifndef G4MULTITHREADED
180  G4String SDname;
181  G4VSensitiveDetector* telescope =
182  new ExExChSensitiveDetector(SDname="/telescope");
184  fSSDLogic->SetSensitiveDetector(telescope);
185 #endif
186 
188 
189  return fWorldPhysical;
190 }
191 
192 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
193 
194 #ifdef G4MULTITHREADED
196  G4String SDname;
197  G4VSensitiveDetector* telescope =
198  new ExExChSensitiveDetector(SDname="/telescope");
200  fSSDLogic->SetSensitiveDetector(telescope);
201 }
202 #else
204 }
205 #endif
206 
207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
208 
210  if(fXtalCurvatureRadius.x() != 0.){
211  double fXtalAngleOut =
213  fXtalSolid = new G4Tubs("Target",
214  fXtalCurvatureRadius.x() - fXtalSize.x()/2,
215  fXtalCurvatureRadius.x() + fXtalSize.x()/2,
216  fXtalSize.y()/2.,
217  fXtalAngle.y(),
218  fXtalAngleOut);
219  }
220  else{
221  fXtalSolid = new G4Box("Target",
222  fXtalSize.x()/2.,
223  fXtalSize.y()/2.,
224  fXtalSize.z()/2.);
225  }
226 
228 
229  G4RotationMatrix* vRotationMatrix =
230  new G4RotationMatrix; // Rotates X and Z axes only
231 
232  if(fXtalCurvatureRadius.x() != 0.){
233  vRotationMatrix->rotateX(fXtalAngle.x()-CLHEP::pi*0.5);
234  vRotationMatrix->rotateY(fXtalAngle.y());
235  vRotationMatrix->rotateZ(fXtalAngle.z());
236  fXtalPhysical =
237  new G4PVPlacement(vRotationMatrix,
239  fXtalLogic,"Target",
240  fWorldLogic,
241  false,
242  0);
243  }
244  else{
245  vRotationMatrix->rotateX(fXtalAngle.x());
246  vRotationMatrix->rotateY(fXtalAngle.y());
247  vRotationMatrix->rotateZ(fXtalAngle.z());
248  fXtalPhysical =
249  new G4PVPlacement(vRotationMatrix,
250  G4ThreeVector(0.,0.,0.),
251  fXtalLogic,"Target",
252  fWorldLogic,
253  false,
254  0);
255  }
256 
257  //----------------------------------------
258  // Create XLogicalLattice
259  //----------------------------------------
260  XLogicalLattice* logicalLattice = new XLogicalLattice();
261  double vScatteringConstant =
263  logicalLattice->SetScatteringConstant(vScatteringConstant);
264 
265  //----------------------------------------
266  // Create XLogicalBase
267  //----------------------------------------
268  XLogicalAtomicLatticeDiamond *diamond_lattice =
270  G4Element* element = G4NistManager::
272  XLogicalBase *base = new XLogicalBase(element,diamond_lattice);
273 
274  //----------------------------------------
275  // Create XUnitCell
276  //----------------------------------------
277  XUnitCell* myCell = new XUnitCell();
278  myCell->SetSize(fXtalCellSize);
279  myCell->AddBase(base);
280 
281  //----------------------------------------
282  // Create XPhysicalLattice
283  //----------------------------------------
284  XPhysicalLattice* physicalLattice =
285  new XPhysicalLattice(fXtalPhysical, logicalLattice);
286  physicalLattice->SetUnitCell(myCell);
287  physicalLattice->SetMillerOrientation(G4int(fXtalMiller.x()),
288  G4int(fXtalMiller.y()),
289  G4int(fXtalMiller.z()));
290  physicalLattice->SetLatticeOrientation(fXtalAngle.x(),
291  fXtalAngle.y(),
292  fXtalAngle.z());
293  physicalLattice->SetThermalVibrationAmplitude(fXtalTVA);
294  physicalLattice->SetCurvatureRadius(fXtalCurvatureRadius);
295 
296  //----------------------------------------
297  // Register XPhysicalLattice
298  //----------------------------------------
299  if(XLatticeManager3::
300  GetXLatticeManager()->GetXPhysicalLattice(fXtalPhysical)
301  != physicalLattice){
303  GetXLatticeManager()->RegisterLattice(physicalLattice);
304  }
305 
306 }
307 
308 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.
309 
311  G4Material* vMaterial = G4Material::GetMaterial(name, false);
312 
313  if(!vMaterial){
314  vMaterial = G4NistManager::Instance()->FindOrBuildMaterial(name);
315  }
316 
317  if (vMaterial && vMaterial != fXtalMaterial) {
318  G4cout << "DetectorConstructor::SetXtalMaterial() - New Xtal Material: "
319  << vMaterial->GetName() << G4endl;
320  fXtalMaterial = vMaterial;
321  if(fXtalLogic){
322  fXtalLogic->SetMaterial(vMaterial);
324  }
325  }
326 }
327 
328 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
329 
331  if(fXtalMaterial) {
332  return fXtalMaterial->GetName();
333  }
334  return "";
335 }
336 
337 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
338 
340  if(fXtalCurvatureRadius != cr) {
343  }
344 }
345 
346 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
347 
349  if(fXtalSize != size) {
351  fXtalSize = size;
352  }
353 }
354 
355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
356 
358  if(fXtalAngle != angle) {
360  fXtalAngle = angle;
361  }
362 }
363 
364 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
365 
367  if(fXtalCellSize != cellsize) {
369  fXtalCellSize = cellsize;
370  }
371 }
372 
373 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
374 
376  if(fXtalMiller != miller) {
378  fXtalMiller = miller;
379  }
380 }
381 
382 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
383 
385  G4ThreeVector cellangle) {
386  if(fXtalCellAngle != cellangle) {
388  fXtalCellAngle = cellangle;
389  }
390 }
391 
392 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
393 
395  G4double thermvibr) {
396  if(fXtalTVA != thermvibr) {
398  fXtalTVA = thermvibr;
399  }
400 }
401 
402 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..
void GeometryHasBeenModified(G4bool prop=true)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
void SetThermalVibrationAmplitude(G4double)
static XLatticeManager3 * GetXLatticeManager()
G4double GetZ() const
Definition: G4Material.cc:632
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
void SetSize(G4ThreeVector)
Definition: XUnitCell.cc:73
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:603
Definition: G4Box.hh:64
G4String name
Definition: TRTMaterials.hh:40
const G4String & GetName() const
Definition: G4Material.hh:178
const G4double pi
Definition: G4Tubs.hh:85
void SetScatteringConstant(G4double)
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
void SetUnitCell(XUnitCell *)
G4GLOB_DLL std::ostream G4cout
static const double meter
Definition: G4SIunits.hh:72
void PhysicsHasBeenModified()
static const double deg
Definition: G4SIunits.hh:133
G4Material * Si
Definition: TRTMaterials.hh:78
static const double second
Definition: G4SIunits.hh:138
void AddBase(XLogicalBase *)
Definition: XUnitCell.cc:97
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:67
bool RegisterLattice(XPhysicalLattice *)
static const double centimeter
Definition: G4SIunits.hh:80
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
void SetMillerOrientation(int, int, int)
void SetCurvatureRadius(G4ThreeVector)
void SetLatticeOrientation(G4double, G4double)
ExExChDetectorConstructionMessenger * fMessenger
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
void SetXtalMaterial(const G4String &name)
static const double millimeter
Definition: G4SIunits.hh:76
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
void SetMaterial(G4Material *pMaterial)
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
static const double angstrom
Definition: G4SIunits.hh:92