Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
XrayFluoPlaneDetectorConstruction.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 //
26 //
27 // $Id: XrayFluoPlaneDetectorConstruction.cc
28 // GEANT4 tag $Name: xray_fluo-V03-02-00
29 //
30 // Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
31 //
32 // History:
33 // -----------
34 // 29 aug 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 "G4LogicalVolume.hh"
48 #include "G4PVPlacement.hh"
50 #include "G4SDManager.hh"
51 #include "G4RunManager.hh"
52 #include "G4VisAttributes.hh"
53 #include "G4Colour.hh"
54 #include "G4PVReplica.hh"
55 #include "G4UserLimits.hh"
56 #include "G4GeometryManager.hh"
57 #include "G4PhysicalVolumeStore.hh"
58 #include "G4LogicalVolumeStore.hh"
59 #include "G4SolidStore.hh"
60 #include "G4SDManager.hh"
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
63 
64 
66  : detectorType(0),planeGranularity(false), DeviceSizeX(0),
67  DeviceSizeY(0),DeviceThickness(0),
68  solidWorld(0),logicWorld(0),physiWorld(0),
69  solidHPGe(0),logicHPGe(0),physiHPGe(0),
70  solidScreen(0),logicScreen(0),physiScreen(0),
71  solidPlane (0),logicPlane(0),physiPlane (0),
72  solidOhmicPos(0),logicOhmicPos(0), physiOhmicPos(0),
73  solidOhmicNeg(0),logicOhmicNeg(0), physiOhmicNeg(0),
74  solidPixel(0),logicPixel(0), physiPixel(0),
75  screenMaterial(0),OhmicPosMaterial(0), OhmicNegMaterial(0),
76  pixelMaterial(0),planeMaterial(0),
77  defaultMaterial(0),HPGeSD(0)
78 
79 {
81 
83 
84  NbOfPixelRows = 1; // should be 1
85  NbOfPixelColumns = 1; // should be 1
87  PixelSizeXY = 5 * cm; // should be 5
88  PixelThickness = 3.5 * mm; //changed should be 3.5 mm
89 
90  G4cout << "PixelThickness(mm): "<< PixelThickness/mm << G4endl;
91  G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/cm << G4endl;
92 
93  ContactSizeXY = 5 * cm; //should be the same as pixelSizeXY
94  planeThickness = 5 * cm;
95  planeSizeXY = 5. * m;
96 
97  OhmicNegThickness = 0.005*mm;
98  OhmicPosThickness = 0.005*mm;
99 
100  screenThickness = 5 * mm;
101 
102  ThetaHPGe = 0. * deg;
103  PhiHPGe = 0. * deg;
104 
105 
106  DistDe = 0.5 * m;
107 
109 
110  grainDia = 1 * mm;
111 
112 
113  PixelCopyNb=0;
114  grainCopyNb=0;
115  G4String defaultDetectorType = "sili";
117  SetDetectorType(defaultDetectorType);
118 
119  // create commands for interactive definition of the apparate
120 
122  G4cout << "XrayFluoPlaneDetectorConstruction created" << G4endl;
123 }
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
125 
126 
128 
130 {
131  if (instance == 0)
132  {
134 
135  }
136  return instance;
137 }
138 
140 {
141 
142  if (type=="sili")
143  {
145  }
146  else if (type=="hpge")
147  {
149  }
150  else
151  {
153  execp << type + "detector type unknown";
154  G4Exception("XrayFluoPlaneDetectorConstruction::SetDetectorType()","example-xray_fluorescence03",
155  FatalException, execp);
156  }
157 }
158 
159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
160 
162 {
163  return detectorType;
164 }
165 
166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
167 
169 
170 {
171  delete detectorMessenger;
172  delete detectorType;
173  G4cout << "XrayFluoPlaneDetectorConstruction deleted" << G4endl;
174 }
175 
176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
177 
179 {
180  return ConstructApparate();
181 }
182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
183 
185 {
186 
187 
188  //define materials of the apparate
189 
190  planeMaterial = materials->GetMaterial("Anorthosite");
192  pixelMaterial = materials->GetMaterial("G4_Si");
195  defaultMaterial = materials->GetMaterial("G4_Galactic");
196 }
197 
198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
199 
201 {
202  // complete the apparate parameters definition
203 
204  //ComputeApparateParameters();
205 
206  //world
207 
208  solidWorld = new G4Box("World", //its name
209  WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/2); //its size
210 
211  logicWorld = new G4LogicalVolume(solidWorld, //its solid
212  defaultMaterial, //its material
213  "World"); //its name
214  physiWorld = new G4PVPlacement(0, //no rotation
215  G4ThreeVector(), //at (0,0,0)
216  "World", //its name
217  logicWorld, //its logical volume
218  0, //its mother volume
219  false, //no boolean operation
220  0); //copy number
221 
222  //detector
223 
224  solidHPGe = 0; physiHPGe = 0; logicHPGe=0;
226 
227  if (DeviceThickness > 0.)
228  {
229  solidHPGe = new G4Box("HPGeDetector", //its name
231 
232 
233  logicHPGe = new G4LogicalVolume(solidHPGe, //its solid
234  defaultMaterial, //its material
235  "HPGeDetector"); //its name
236 
238  G4double x,y,z;
239 
240  z = -1. * DistDe; //* std::cos(ThetaHPGe);
241  y = 0.*cm; //distScreen * std::sin(ThetaHPGe);
242  x = 0.*cm;
243 
245  "HPGeDetector", //its name
246  logicHPGe, //its logical volume
247  physiWorld, //its mother volume
248  false, //no boolean operation
249  0); //copy number
250  }
251  // Pixel
252 
253 
254 
255 
256  for ( G4int j=0; j < NbOfPixelColumns ; j++ )
257  { for ( G4int i=0; i < NbOfPixelRows ; i++ )
258  {
260  if (PixelThickness > 0.)
261  solidPixel = new G4Box("Pixel",
263 
265  pixelMaterial, //its material
266  "Pixel"); //its name
267 
268  /*
269  zRotPhiHPGe.rotateX(PhiHPGe);
270  G4double x,y,z;
271  z = DistDe * std::cos(ThetaHPGe);
272  y =DistDe * std::sin(ThetaHPGe);
273  x = 0.*cm;*/
274  physiPixel = new G4PVPlacement(0,
275  G4ThreeVector(0,
276  i*PixelSizeXY,
277  j*PixelSizeXY ),
278  "Pixel",
279  logicPixel, //its logical volume
280  physiHPGe, //its mother volume
281  false, //no boolean operation
282  PixelCopyNb);//copy number
283 
284 
285 
286 
287 
288 
289  // OhmicNeg
290 
292 
293  if (OhmicNegThickness > 0.)
294  { solidOhmicNeg = new G4Box("OhmicNeg", //its name
295  PixelSizeXY/2,PixelSizeXY/2,OhmicNegThickness/2);
296 
297  logicOhmicNeg = new G4LogicalVolume(solidOhmicNeg, //its solid
298  OhmicNegMaterial, //its material
299  "OhmicNeg"); //its name
300 
303  (0.,
304  0.,
306  "OhmicNeg", //its name
307  logicOhmicNeg, //its logical volume
308  physiHPGe, //its mother
309  false, //no boulean operat
310  PixelCopyNb); //copy number
311 
312  }
313  // OhmicPos
315 
316  if (OhmicPosThickness > 0.)
317  { solidOhmicPos = new G4Box("OhmicPos", //its name
318  PixelSizeXY/2,PixelSizeXY/2,OhmicPosThickness/2);
319 
320  logicOhmicPos = new G4LogicalVolume(solidOhmicPos, //its solid
321  OhmicPosMaterial, //its material
322  "OhmicPos"); //its name
323 
324  physiOhmicPos = new G4PVPlacement(0,
325  G4ThreeVector(0.,
326  0.,
328  "OhmicPos",
330  physiHPGe,
331  false,
332  PixelCopyNb);
333 
334  }
335 
337  G4cout << "PixelCopyNb: " << PixelCopyNb << G4endl;
338  }
339 
340  }
341 
342  // Screen
343 
344  if (DeviceThickness > 0.)
345  {
346  solidScreen = new G4Box("DetectorScreen", //its name
348 
349 
350  logicScreen = new G4LogicalVolume(solidScreen, //its solid
351  defaultMaterial, //its material
352  "DetectorScreen"); //its name
353 
354  //zRotPhiHPGe.rotateX(PhiHPGe);
355  G4double x,y,z;
356  G4cout << "distScreen: "<< distScreen/m <<G4endl;
357  z = -1 * distScreen; //* std::cos(ThetaHPGe);
358  y = 0.*cm; //distScreen * std::sin(ThetaHPGe);
359  x = 0.*cm;
361  "DetectorScreen", //its name
362  logicScreen, //its logical volume
363  physiWorld, //its mother volume
364  false, //no boolean operation
365  0); //copy number
366  }
367 
368  //Plane
369 
370  if (planeGranularity) {
371 
373  if (planeThickness > 0.)
374  {
375  solidPlane = new G4Box("Plane", //its name
377 
378  logicPlane= new G4LogicalVolume(solidPlane, //its solid
379  defaultMaterial, //its material
380  "Plane"); //its name
381 
382  physiPlane = new G4PVPlacement(0, //no rotation
383  G4ThreeVector(), //at (0,0,0)
384  "Plane", //its name
385  logicPlane, //its logical volume
386  physiWorld, //its mother volume
387  false, //no boolean operation
388  0); //copy number
389 
390  }
391 
392 
393 
394 
395  G4int nbOfGrainsX = ((G4int)(planeSizeXY/grainDia)) -1 ;
396 
397  // y dim of a max density plane is 2rn-(n-1)ar, wehere a = (1-(std::sqrt(3)/2)), n is
398  // number of rows and r the radius of the grain. so the Y-dim of the plane must
399  // be greater or equal to this. It results that nmust be <= (PlaneY-a)/(1-a).
400  // Max Y shift of the planes superimposing along Z axis is minor (2/std::sqrt(3)r)
401 
402  G4double a = (1.-(std::sqrt(3.)/2.));
403  G4int nbOfGrainsY = (G4int) ( ((planeSizeXY/(grainDia/2.)) -a)/(2.-a) ) -1;
404 
405  // same for the z axis, but a = 2 * (std::sqrt(3) - std::sqrt(2))/std::sqrt(3)
406 
407  G4double b = 2. * (std::sqrt(3.) - std::sqrt(2.))/std::sqrt(3.);
408  G4int nbOfGrainsZ = (G4int) ( ((planeThickness/(grainDia/2.)) -b)/(2.-b) )-1;
409 
410  if (planeThickness > 0.){
411 
413  solidGrain = new G4Sphere("Grain",0.,
414  grainDia/2,0., twopi, 0., pi);
415 
417  planeMaterial, //its material
418  "Grain"); //its name
419  G4ThreeVector grainPosition;
420  G4double grainInitPositionX = 0;
421  G4double grainInitPositionY = 0;
422  G4double grainInitPositionZ = (-1.*planeThickness/2.+grainDia/2.);
423  G4double grainStepX = grainDia = 0;
424  G4double grainStepY = grainDia*(1.-(0.5-(std::sqrt(3.)/4.)));
425  G4double grainStepZ = grainDia*std::sqrt(2./3.);
426 
427  for ( G4int k=0; k < nbOfGrainsZ ; k++ ) {
428  for ( G4int j=0; j < nbOfGrainsY ; j++ ) {
429  for ( G4int i=0; i < nbOfGrainsX ; i++ ) {
430 
431  // Now we identify the layer and the row where the grain is , to place it in the right position
432 
433 
434 
435  if (k%3 == 0) { // first or (4-multiple)th layer: structure is ABCABC
436  grainInitPositionY = (-1.*planeSizeXY/2.+grainDia/2.);
437  if (j%2 ==0) { //first or (3-multiple)th row
438  grainInitPositionX = (-1.*planeSizeXY/2.+grainDia/2.);
439  }
440 
441  else if ( ((j+1) % 2) == 0 ) {
442  grainInitPositionX = (-1.*planeSizeXY/2.+ grainDia);
443  }
444 
445  }
446  else if ( ((k+2) % 3) == 0 ) { // B-layer
447 
448  grainInitPositionY = ( (-1.*planeSizeXY/2.) + (grainDia/2.)*(1. + (1./std::sqrt(3.)) ) );
449 
450  if (j%2 ==0) { //first or (3-multiple)th row
451  grainInitPositionX = (-1.*planeSizeXY/2.+grainDia);
452  }
453 
454  else if ( (j+1)%2 == 0 ) {
455  grainInitPositionX = (-1.*planeSizeXY/2.+grainDia/2);
456  }
457 
458  }
459 
460  else if ( (k+1)%3 == 0 ) { // B-layer
461 
462  grainInitPositionY = (-1.*planeSizeXY/2.+(grainDia/2.)*(1.+2./std::sqrt(3.)) );
463 
464  if (j%2 ==0) { //first or (3-multiple)th row
465  grainInitPositionX = (-1.*planeSizeXY/2.+grainDia/2.);
466  }
467 
468  else if ( (j+1)%2 == 0 ) {
469  grainInitPositionX = (-1.*planeSizeXY/2.+grainDia);
470  }
471 
472  }
473 
474  physiGrain = new G4PVPlacement(0,
475  G4ThreeVector( grainInitPositionX + i*grainStepX,
476  grainInitPositionY + j*grainStepY,
477  grainInitPositionZ + k*grainStepZ),
478  "Grain",
479  logicGrain, //its logical volume
480  physiPlane, //its mother volume
481  false, //no boolean operation
482  grainCopyNb);//copy number
483 
484  grainCopyNb = grainCopyNb +1;
485  }
486  }
487  }
488  }
489  }
490  else {
491 
493  if (planeThickness > 0.)
494  {
495  solidPlane = new G4Box("Plane", //its name
497 
498  logicPlane= new G4LogicalVolume(solidPlane, //its solid
499  planeMaterial, //its material
500  "Plane"); //its name
501 
502  physiPlane = new G4PVPlacement(0, //no rotation
503  G4ThreeVector(), //at (0,0,0)
504  "Plane", //its name
505  logicPlane, //its logical volume
506  physiWorld, //its mother volume
507  false, //no boolean operation
508  0); //copy number
509 
510  }
511  }
512 
513  // Visualization attributes
514 
516  G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
517  G4VisAttributes * yellow= new G4VisAttributes( G4Colour(255/255. ,255/255. ,51/255. ));
518  G4VisAttributes * red= new G4VisAttributes( G4Colour(255/255. , 0/255. , 0/255. ));
519  G4VisAttributes * blue= new G4VisAttributes( G4Colour(0/255. , 0/255. , 255/255. ));
520  G4VisAttributes * grayc= new G4VisAttributes( G4Colour(128/255. , 128/255. , 128/255. ));
521  G4VisAttributes * lightGray= new G4VisAttributes( G4Colour(178/255. , 178/255. , 178/255. ));
522  yellow->SetVisibility(true);
523  yellow->SetForceSolid(true);
524  red->SetVisibility(true);
525  red->SetForceSolid(true);
526  blue->SetVisibility(true);
527  grayc->SetVisibility(true);
528  grayc->SetForceSolid(true);
529  lightGray->SetVisibility(true);
530  lightGray->SetForceSolid(true);
531  simpleBoxVisAtt->SetVisibility(true);
532 
533  logicPixel->SetVisAttributes(red); //modified!!!
535 
536  logicPlane->SetVisAttributes(lightGray);
537 
538 
542 
543 
544 
546 
547  //always return the physical World
548 
550 
551  return physiWorld;
552 }
553 
554 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...
555 
557 {
558  //
559  // Sensitive Detectors
560  //
561  if (HPGeSD.Get() == 0)
562  {
563  XrayFluoSD* SD = new XrayFluoSD ("HPGeSD",this);
564  HPGeSD.Put( SD );
565  }
567  if (logicPixel)
569 }
570 
571 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
572 
574 {
575  G4cout << "-----------------------------------------------------------------------"
576  << G4endl
577  << "The plane is a box whose size is: "
578  << G4endl
579  << planeThickness/cm
580  << " cm * "
581  << planeSizeXY/cm
582  << " cm * "
583  << planeSizeXY/cm
584  << " cm"
585  << G4endl
586  <<" Material: " << logicPlane->GetMaterial()->GetName()
587  <<G4endl
588  <<"The Detector is a slice " << DeviceThickness/(1.e-6*m) << " micron thick of " << pixelMaterial->GetName()
589  <<G4endl
590 
591 
592 <<"-------------------------------------------------------------------------"
593  << G4endl;
594 }
595 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
596 
598 {
603 
605  //Triggers a new call of Construct() and of all the geometry resets.
607 }
608 
609 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
610 
612 {
613  if (planeGranularity) {
614  delete solidGrain;
615  delete logicGrain;
616  delete physiGrain;
617  }
618 
619 }
620 
621 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
622 
624 {
625  //G4cout << "Material!!!!" << newMaterial << G4endl;
628  //GeometryHasBeenModified is called by the messenger
629 
630 }
631 
632 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
633 
634 
635 
636 
637 
638 
639 
640 
641 
642 
643 
644 
Float_t x
Definition: compare.C:6
XrayFluoPlaneDetectorMessenger * detectorMessenger
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
static void Clean()
Definition: G4SolidStore.cc:73
CLHEP::Hep3Vector G4ThreeVector
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
std::vector< ExP01TrackerHit * > a
Definition: ExP01Classes.hh:33
Definition: test07.cc:36
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
HepGeom::Transform3D G4Transform3D
static constexpr double mm
Definition: G4SIunits.hh:115
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
#define G4endl
Definition: G4ios.hh:61
Float_t y
Definition: compare.C:6
static XrayFluoSiLiDetectorType * GetInstance()
Double_t z
XrayFluoVDetectorType * GetDetectorType() const
Definition: test07.cc:36
Definition: test07.cc:36
G4Material * GetMaterial() const
static const G4VisAttributes & GetInvisible()
static XrayFluoHPGeDetectorType * GetInstance()
const G4String & GetName() const
Definition: G4Material.hh:179
static constexpr double m
Definition: G4SIunits.hh:129
double G4double
Definition: G4Types.hh:76
static constexpr double deg
Definition: G4SIunits.hh:152
static XrayFluoPlaneDetectorConstruction * GetInstance()
static XrayFluoPlaneDetectorConstruction * instance
static G4GeometryManager * GetInstance()
Definition: G4Box.hh:64
static constexpr double twopi
Definition: G4SIunits.hh:76
value_type & Get() const
Definition: G4Cache.hh:314
void OpenGeometry(G4VPhysicalVolume *vol=0)
void SetVisAttributes(const G4VisAttributes *pVA)
void Put(const value_type &val) const
Definition: G4Cache.hh:318
void SetForceSolid(G4bool=true)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
void SetVisibility(G4bool=true)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
void SetMaterial(G4Material *pMaterial)
static constexpr double pi
Definition: G4SIunits.hh:75
HepRotation & rotateX(double delta)
Definition: Rotation.cc:66
G4Material * GetMaterial(G4String)
static XrayFluoNistMaterials * GetInstance()