Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XrayFluoMercuryDetectorConstruction.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 // $Id: XrayFluoMercuryDetectorConstruction.cc
28 // GEANT4 tag $Name: XrayFluo-V05-02-06
29 //
30 // Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
31 //
32 // History:
33 // -----------
34 // 08 Sep 2003 Alfonso Mantero Created
35 // -------------------------------------------------------------------
36 
39 #include "XrayFluoSD.hh"
40 #include "XrayFluoNistMaterials.hh"
41 #include "G4PhysicalConstants.hh"
42 #include "G4SystemOfUnits.hh"
43 #include "G4Material.hh"
44 #include "G4ThreeVector.hh"
45 #include "G4Box.hh"
46 #include "G4Sphere.hh"
47 #include "G4Tubs.hh"
48 #include "G4LogicalVolume.hh"
49 #include "G4PVPlacement.hh"
51 #include "G4SDManager.hh"
52 #include "G4RunManager.hh"
53 #include "G4VisAttributes.hh"
54 #include "G4Colour.hh"
55 #include "G4ios.hh"
56 #include "G4PVReplica.hh"
57 #include "G4UserLimits.hh"
58 #include "G4GeometryManager.hh"
59 #include "G4PhysicalVolumeStore.hh"
60 #include "G4LogicalVolumeStore.hh"
61 #include "G4SolidStore.hh"
62 #include "G4SDManager.hh"
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
64 
65 
66 XrayFluoMercuryDetectorConstruction::XrayFluoMercuryDetectorConstruction()
67  : detectorType(0),mercuryGranularity(false), DeviceSizeX(0),
68  DeviceSizeY(0),DeviceThickness(0),
69  solidWorld(0),logicWorld(0),physiWorld(0),
70  solidHPGe(0),logicHPGe(0),physiHPGe(0),
71  solidScreen(0),logicScreen(0),physiScreen(0),
72  solidMercury (0),logicMercury(0),physiMercury (0),
73  solidOhmicPos(0),logicOhmicPos(0), physiOhmicPos(0),
74  solidOhmicNeg(0),logicOhmicNeg(0), physiOhmicNeg(0),
75  solidPixel(0),logicPixel(0), physiPixel(0),
76  screenMaterial(0),OhmicPosMaterial(0), OhmicNegMaterial(0),
77  pixelMaterial(0),mercuryMaterial(0),
78  defaultMaterial(0),HPGeSD(0)
79 
80 {
82 
83  DefineDefaultMaterials();
84 
85  NbOfPixelRows = 1; // should be 1
86  NbOfPixelColumns = 1; // should be 1
87  NbOfPixels = NbOfPixelRows*NbOfPixelColumns;
88  PixelSizeXY = std::sqrt(40.) * mm *0.5e6; // should be std::sqrt(40) * mm
89  PixelThickness = 3.5 * mm * 1e6; //should be 3.5 mm
90 
91  G4cout << "PixelThickness(mm): "<< PixelThickness/mm << G4endl;
92  G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/cm << G4endl;
93 
94  ContactSizeXY = std::sqrt(40.) * mm * 0.5e6; //should be the same as PixelSize or lower
95 
96  mercuryDia = 2 * 4880 * km ;
97  sunDia = 1390000 * km ;
98  mercurySunDistance = 57910000 * km ;
99 
100 
101  OhmicNegThickness = 0.005*mm *0.5e6 ;
102  OhmicPosThickness = 0.005*mm *0.5e6 ;
103 
104  screenThickness = 5 * mm *0.5e6;
105 
106  ThetaHPGe = 135. * deg ;
107  PhiHPGe = 225. * deg ;
108 
109 
110  distDe = (mercuryDia/2 + 400 * km);
111 
112  distScreen = distDe + (screenThickness+PixelThickness)/2+OhmicPosThickness ;
113 
114  distOptic = distDe - 1.*m * 1e5;
115 
116  opticThickness = 1.* cm *0.5e6;
117  opticDia = 21. * cm *0.5e6;
118  opticAperture = 1. * deg;
119 
120  PixelCopyNb=0;
121  grainCopyNb=0;
122  G4String defaultDetectorType = "sili";
123  ComputeApparateParameters();
124  SetDetectorType(defaultDetectorType);
125 
126  // create commands for interactive definition of the apparate
127 
128  detectorMessenger = new XrayFluoMercuryDetectorMessenger(this);
129  G4cout << "XrayFluoMercuryDetectorConstruction created" << G4endl;
130 }
131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
132 
133 
134 XrayFluoMercuryDetectorConstruction* XrayFluoMercuryDetectorConstruction::instance = 0;
135 
137 {
138  if (instance == 0)
139  {
141 
142  }
143  return instance;
144 }
145 
147 {
148 
149  if (type=="sili")
150  {
151  detectorType = XrayFluoSiLiDetectorType::GetInstance();
152  }
153  else if (type=="hpge")
154  {
155  detectorType = XrayFluoHPGeDetectorType::GetInstance();
156  }
157  else
158  {
160  execp << type + "detector type unknown";
161  G4Exception("XrayFluoMercuryDetectorConstruction::SetDetectorType()","example-xray_fluorescence05",
162  FatalException, execp);
163  }
164 }
165 
166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
167 
169 {
170  return detectorType;
171 }
172 
173 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
174 
176 
177 {
178  delete detectorMessenger;
179  delete detectorType;
180  G4cout << "XrayFluoMercuryDetectorConstruction deleted" << G4endl;
181 }
182 
183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
184 
186 {
187  return ConstructApparate();
188 }
189 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
190 
191 void XrayFluoMercuryDetectorConstruction::DefineDefaultMaterials()
192 {
193 
194 
195  //define materials of the apparate
196 
197  mercuryMaterial = materials->GetMaterial("Anorthosite");
198  screenMaterial = materials->GetMaterial("G4_Pb");
199  pixelMaterial = materials->GetMaterial("G4_Si");
200  OhmicPosMaterial = materials->GetMaterial("G4_Cu");
201  OhmicNegMaterial = materials->GetMaterial("G4_Pb");
202  defaultMaterial = materials->GetMaterial("G4_Galactic");
203 
204 
205 }
206 
207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
208 
209 G4VPhysicalVolume* XrayFluoMercuryDetectorConstruction::ConstructApparate()
210 {
211  // complete the apparate parameters definition
212 
213  ComputeApparateParameters();
214 
215  //world
216 
217  solidWorld = new G4Box("World", //its name
218  WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/2); //its size
219 
220  logicWorld = new G4LogicalVolume(solidWorld, //its solid
221  defaultMaterial, //its material
222  "World"); //its name
223  physiWorld = new G4PVPlacement(0, //no rotation
224  G4ThreeVector(), //at (0,0,0)
225  "World", //its name
226  logicWorld, //its logical volume
227  0, //its mother volume
228  false, //no boolean operation
229  0); //copy number
230 
231  //detector
232 
233  solidHPGe = 0; physiHPGe = 0; logicHPGe=0;
234  solidPixel=0; logicPixel=0; physiPixel=0;
235 
236  if (DeviceThickness > 0.)
237  {
238  solidHPGe = new G4Box("HPGeDetector", //its name
239  DeviceSizeX/2,DeviceSizeY/2,DeviceThickness/2);//size
240 
241 
242  logicHPGe = new G4LogicalVolume(solidHPGe, //its solid
243  defaultMaterial, //its material
244  "HPGeDetector"); //its name
245 
246  zRotPhiHPGe.rotateX(PhiHPGe);
247  G4double x,y,z;
248 
249  z = distDe * std::cos(ThetaHPGe);
250  y = distScreen * std::sin(ThetaHPGe);
251  x = 0.*cm;
252 
253  physiHPGe = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)),
254  "HPGeDetector", //its name
255  logicHPGe, //its logical volume
256  physiWorld, //its mother volume
257  false, //no boolean operation
258  0); //copy number
259  }
260  // Pixel
261 
262 
263 
264 
265  for ( G4int j=0; j < NbOfPixelColumns ; j++ )
266  { for ( G4int i=0; i < NbOfPixelRows ; i++ )
267  {
268  solidPixel=0; logicPixel=0; physiPixel=0;
269  if (PixelThickness > 0.)
270  solidPixel = new G4Box("Pixel",
271  PixelSizeXY/2,PixelSizeXY/2, PixelThickness/2);
272 
273  logicPixel = new G4LogicalVolume(solidPixel,
274  pixelMaterial, //its material
275  "Pixel"); //its name
276 
277  /*
278  zRotPhiHPGe.rotateX(PhiHPGe);
279  G4double x,y,z;
280  z = distDe * std::cos(ThetaHPGe);
281  y =distDe * std::sin(ThetaHPGe);
282  x = 0.*cm;*/
283  physiPixel = new G4PVPlacement(0,
284  G4ThreeVector(0,
285  i*PixelSizeXY,
286  j*PixelSizeXY ),
287  "Pixel",
288  logicPixel, //its logical volume
289  physiHPGe, //its mother volume
290  false, //no boolean operation
291  PixelCopyNb);//copy number
292 
293 
294 
295 
296 
297 
298  // OhmicNeg
299 
300  solidOhmicNeg=0; logicOhmicNeg=0; physiOhmicNeg=0;
301 
302  if (OhmicNegThickness > 0.)
303  { solidOhmicNeg = new G4Box("OhmicNeg", //its name
304  PixelSizeXY/2,PixelSizeXY/2,OhmicNegThickness/2);
305 
306  logicOhmicNeg = new G4LogicalVolume(solidOhmicNeg, //its solid
307  OhmicNegMaterial, //its material
308  "OhmicNeg"); //its name
309 
310  physiOhmicNeg = new G4PVPlacement(0,
312  (0.,
313  0.,
314  (PixelThickness+OhmicNegThickness)/2),
315  "OhmicNeg", //its name
316  logicOhmicNeg, //its logical volume
317  physiHPGe, //its mother
318  false, //no boulean operat
319  PixelCopyNb); //copy number
320 
321  }
322  // OhmicPos
323  solidOhmicPos=0; logicOhmicPos=0; physiOhmicPos=0;
324 
325  if (OhmicPosThickness > 0.)
326  { solidOhmicPos = new G4Box("OhmicPos", //its name
327  PixelSizeXY/2,PixelSizeXY/2,OhmicPosThickness/2);
328 
329  logicOhmicPos = new G4LogicalVolume(solidOhmicPos, //its solid
330  OhmicPosMaterial, //its material
331  "OhmicPos"); //its name
332 
333  physiOhmicPos = new G4PVPlacement(0,
334  G4ThreeVector(0.,
335  0.,
336  (-PixelThickness-OhmicPosThickness)/2),
337  "OhmicPos",
338  logicOhmicPos,
339  physiHPGe,
340  false,
341  PixelCopyNb);
342 
343  }
344 
345  PixelCopyNb += PixelCopyNb;
346  G4cout << "PixelCopyNb: " << PixelCopyNb << G4endl;
347  }
348 
349  }
350 
351  // Optics
352 
353  if (DeviceThickness > 0.)
354  {
355  solidOptic = new G4Tubs("DetectorOptic", //its name
356  0.,opticDia/2, opticThickness, 0.,2.*pi);//size
357 
358 
359  logicOptic = new G4LogicalVolume(solidOptic, //its solid
360  defaultMaterial, //its material
361  "DetectorOptic"); //its name
362 
363  //zRotPhiHPGe.rotateX(PhiHPGe);
364  G4double x,y,z;
365  z = distOptic * std::cos(ThetaHPGe);
366  y = distOptic * std::sin(ThetaHPGe);
367  x = 0.*cm;
368  physiOptic = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)),
369  "DetectorOptic", //its name
370  logicOptic, //its logical volume
371  physiWorld, //its mother volume
372  false, //no boolean operation
373  0); //copy number
374  }
375 
376 
377  // Screen
378 
379  if (DeviceThickness > 0.)
380  {
381  solidScreen = new G4Box("DetectorScreen", //its name
382  screenSizeXY/2,screenSizeXY/2,screenThickness/2);//size
383 
384 
385  logicScreen = new G4LogicalVolume(solidScreen, //its solid
386  defaultMaterial, //its material
387  "DetectorScreen"); //its name
388 
389  //zRotPhiHPGe.rotateX(PhiHPGe);
390  G4double x,y,z;
391  G4cout << "distScreen: "<< distScreen/m <<G4endl;
392  z = distScreen * std::cos(ThetaHPGe);
393  y = distScreen * std::sin(ThetaHPGe);
394  x = 0.*cm;
395  physiScreen = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)),
396  "DetectorScreen", //its name
397  logicScreen, //its logical volume
398  physiWorld, //its mother volume
399  false, //no boolean operation
400  0); //copy number
401  }
402 
403  //Mercury
404 
405 
406  solidMercury=0; logicMercury=0; physiMercury=0;
407  if (mercuryDia > 0.)
408  {
409 
410 
411 
412 
413 
414 
415  solidMercury = new G4Sphere("Mercury",0.,mercuryDia/2., 0., twopi, 0., pi);
416 
417  logicMercury= new G4LogicalVolume(solidMercury, //its solid
418  mercuryMaterial, //its material
419  "Mercury"); //its name
420 
421  physiMercury = new G4PVPlacement(0, //no rotation
422  G4ThreeVector(), //at (0,0,0)
423  "Mercury", //its name
424  logicMercury, //its logical volume
425  physiWorld, //its mother volume
426  false, //no boolean operation
427  0); //copy number
428 
429  }
430 
431 
432  // Visualization attributes
433 
434 
436  G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
437  G4VisAttributes * yellow= new G4VisAttributes( G4Colour(255/255. ,255/255. ,51/255. ));
438  G4VisAttributes * red= new G4VisAttributes( G4Colour(255/255. , 0/255. , 0/255. ));
439  G4VisAttributes * blue= new G4VisAttributes( G4Colour(0/255. , 0/255. , 255/255. ));
440  G4VisAttributes * grayc= new G4VisAttributes( G4Colour(128/255. , 128/255. , 128/255. ));
441  G4VisAttributes * darkGray= new G4VisAttributes( G4Colour(95/255. , 95/255. , 95/255. ));
442  //G4VisAttributes * green= new G4VisAttributes( G4Colour(25/255. , 255/255. , 25/255. ));
443  yellow->SetVisibility(true);
444  yellow->SetForceSolid(true);
445  red->SetVisibility(true);
446  red->SetForceSolid(true);
447  blue->SetVisibility(true);
448  grayc->SetVisibility(true);
449  grayc->SetForceSolid(true);
450  simpleBoxVisAtt->SetVisibility(true);
451 
452  //logicWorld->SetVisAttributes (simpleBoxVisAtt);
453 
454  logicPixel->SetVisAttributes(red);
456 
457  logicMercury->SetVisAttributes(darkGray);
458 
459 
460  logicScreen->SetVisAttributes(red);
461  logicOhmicNeg->SetVisAttributes(yellow);
462  logicOhmicPos->SetVisAttributes(yellow);
463  logicOptic->SetVisAttributes(grayc);
464 
465 
466  if (mercuryGranularity) logicGrain->SetVisAttributes(grayc);
467 
468  //always return the physical World
469 
471 
472  return physiWorld;
473 }
474 
475 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
476 
478 {
479  //
480  // Sensitive Detectors
481  //
482  if (HPGeSD.Get() == 0)
483  {
484  XrayFluoSD* SD = new XrayFluoSD ("HPGeSD",this);
485  HPGeSD.Put( SD );
486  }
488  if (logicPixel)
489  SetSensitiveDetector(logicPixel,HPGeSD.Get());
490 }
491 
492 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
493 
495 {
496  G4cout << "-----------------------------------------------------------------------"
497  << G4endl
498  << "The mercury is a sphere whose diamter is: "
499  << G4endl
500  << mercuryDia/km
501  << " Km "
502  << G4endl
503  <<" Material: " << logicMercury->GetMaterial()->GetName()
504  <<G4endl
505  <<"The Detector is a slice " << DeviceThickness/(1.e-6*m)
506  << " micron thick of " << pixelMaterial->GetName()<<G4endl
507  <<"-------------------------------------------------------------------------"
508  << G4endl;
509 }
510 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
511 
513 {
514 
519 
520  zRotPhiHPGe.rotateX(-1.*PhiHPGe);
521  ComputeApparateParameters();
522 
523  //Triggers a new call of Construct() and of all the geometry resets.
525 
526 }
527 
528 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
529 
531 {
532  G4cout << "New Mercury Material: " << newMaterial << G4endl;
533  logicMercury->SetMaterial(materials->GetMaterial(newMaterial));
535  //GeometryHasBeenModified is called by the messenger
536 }
537 
538 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
539 
540 
541 
542 
543 
544 
545 
546 
547 
548 
549 
static constexpr double km
Definition: G4SIunits.hh:133
static constexpr double mm
Definition: G4SIunits.hh:115
G4Material * GetMaterial() const
Definition: test07.cc:36
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
CLHEP::Hep3Vector G4ThreeVector
HepRotation & rotateX(double delta)
Definition: Rotation.cc:66
Definition: G4Box.hh:64
const G4String & GetName() const
Definition: G4Material.hh:178
value_type & Get() const
Definition: G4Cache.hh:282
Definition: G4Tubs.hh:85
static void Clean()
Definition: G4SolidStore.cc:79
tuple x
Definition: test.py:50
Definition: test07.cc:36
Definition: test07.cc:36
int G4int
Definition: G4Types.hh:78
static XrayFluoMercuryDetectorConstruction * GetInstance()
void SetForceSolid(G4bool=true)
static XrayFluoNistMaterials * GetInstance()
static constexpr double twopi
Definition: G4SIunits.hh:76
static XrayFluoSiLiDetectorType * GetInstance()
G4GLOB_DLL std::ostream G4cout
static constexpr double m
Definition: G4SIunits.hh:129
void SetVisibility(G4bool=true)
static constexpr double cm
Definition: G4SIunits.hh:119
HepGeom::Transform3D G4Transform3D
static G4GeometryManager * GetInstance()
G4Material * GetMaterial(G4String)
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
tuple z
Definition: test.py:28
static XrayFluoHPGeDetectorType * GetInstance()
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
static constexpr double pi
Definition: G4SIunits.hh:75
double G4double
Definition: G4Types.hh:76
static constexpr double deg
Definition: G4SIunits.hh:152
void SetMaterial(G4Material *pMaterial)
void Put(const value_type &val) const
Definition: G4Cache.hh:286
static const G4VisAttributes & GetInvisible()
void SetVisAttributes(const G4VisAttributes *pVA)