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