source: trunk/source/processes/electromagnetic/lowenergy/test/fluoTest/src/XrayFluoDetectorConstruction.cc @ 1199

Last change on this file since 1199 was 1199, checked in by garnier, 15 years ago

nvx fichiers dans CVS

File size: 16.0 KB
Line 
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: XrayFluoDetectorConstruction.cc
28// GEANT4 tag $Name: xray_fluo-V03-02-00
29//
30// Author: Elena Guardincerri (Elena.Guardincerri@ge.infn.it)
31//
32// History:
33// -----------
34// 28 Nov 2001 Elena Guardincerri     Created
35//
36// -------------------------------------------------------------------
37
38#include "XrayFluoDetectorConstruction.hh"
39#include "XrayFluoDetectorMessenger.hh"
40#include "XrayFluoHPGeSD.hh"
41#include "G4Material.hh"
42#include "G4ThreeVector.hh"
43#include "G4Box.hh"
44#include "G4Tubs.hh"
45#include "G4LogicalVolume.hh"
46#include "G4PVPlacement.hh"
47#include "G4TransportationManager.hh"
48#include "G4SDManager.hh"
49#include "G4RunManager.hh"
50#include "G4VisAttributes.hh"
51#include "G4Colour.hh"
52#include "G4ios.hh"
53#include "G4PVReplica.hh"
54
55//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
56
57XrayFluoDetectorConstruction::XrayFluoDetectorConstruction()
58  : DeviceSizeX(0),DeviceSizeY(0),DeviceThickness(0),
59    solidWorld(0),logicWorld(0),physiWorld(0),
60    solidHPGe(0),logicHPGe(0),physiHPGe(0),
61    solidSample (0),logicSample(0),physiSample (0),
62    solidDia1(0),logicDia1(0),physiDia1(0),
63    solidDia3(0),logicDia3(0),physiDia3(0),
64    solidOhmicPos(0),logicOhmicPos(0), physiOhmicPos(0),
65    solidOhmicNeg(0),logicOhmicNeg(0), physiOhmicNeg(0),
66    solidPixel(0),logicPixel(0), physiPixel(0),
67    OhmicPosMaterial(0), OhmicNegMaterial(0),
68    pixelMaterial(0),sampleMaterial(0),
69    Dia1Material(0),Dia3Material(0),
70    defaultMaterial(0)
71  ,HPGeSD(0)
72 
73{ 
74  NbOfPixelRows     =  1;
75  NbOfPixelColumns  =  1;
76  NbOfPixels        =  NbOfPixelRows*NbOfPixelColumns;
77    PixelSizeXY       = 0.7 * cm;
78  PixelThickness =  1. * mm;
79  ContactSizeXY     = 0.005*mm;
80  SampleThickness = 0.25 * mm;
81  SampleSizeXY = 3. * cm;
82  Dia1Thickness = 1. *mm;
83  Dia3Thickness = 1. *mm;
84  Dia1SizeXY = 3. *cm;
85  Dia3SizeXY = 3. *cm;
86  DiaInnerSize = 1.4 * mm;
87  OhmicNegThickness = 0.005*mm;
88  OhmicPosThickness = 0.005*mm;
89  ThetaHPGe = 135. * deg;
90  Dia3Dist =  66.5 * mm;
91  Dia3InnerSize = 1. * mm;
92  PhiHPGe = 225. * deg;
93  ThetaDia1 = 135. * deg;
94  ThetaDia3 = 180. * deg;
95  PhiDia3 = 90. * deg;
96  DistDia = 66.5 * mm;
97  DistDe =DistDia+ (Dia1Thickness
98                    +PixelThickness)/2+OhmicPosThickness ;
99  PhiDia1 = 90. * deg;
100  AlphaDia1 = 225. * deg;
101  AlphaDia3 = 180. * deg;
102  PixelCopyNb=0;
103  ComputeApparateParameters();
104 
105  // create commands for interactive definition of the apparate
106 
107  detectorMessenger = new XrayFluoDetectorMessenger(this);
108}
109//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
110
111XrayFluoDetectorConstruction::~XrayFluoDetectorConstruction()
112{ delete detectorMessenger;}
113
114//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
115
116G4VPhysicalVolume* XrayFluoDetectorConstruction::Construct()
117{
118  DefineMaterials();
119  return ConstructApparate();
120}
121//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
122
123void XrayFluoDetectorConstruction::DefineMaterials()
124{
125  //define elements
126  G4String name, symbol;             //a=mass of a mole;
127  G4double a, z, density;            //z=mean number of protons; 
128 
129 
130  a = 74.9216 * g/mole;
131  G4Element * As = new G4Element( name="arsenic",symbol="As",z= 33.,a);
132 
133  a = 69.72* g/mole;
134  G4Element * Ga = new G4Element(name="gallium",symbol="Ga",z= 31.,a);
135 
136  a = 55.85*g/mole;
137  G4Element* Fe = new G4Element(name="Iron"  ,symbol="Fe", z=26., a);
138  //define hydrogen
139 
140  a = 1.01*g/mole;
141  G4Element* H  = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
142 
143  //define germanium
144  a = 72.61*g/mole;
145  G4Element* Ge = new G4Element(name="Germanium",symbol="Ge", z= 32.,a);
146  //define phosporus
147
148  a = 30.97*g/mole;
149  G4Element* P =  new G4Element(name="Phosporus",symbol="P", z= 15., a);
150 
151  density = 7.86 * g/cm3;
152 
153  G4int  natoms,ncomponents;
154  G4double temperature, pressure;
155 
156  G4Material * FeMaterial = new G4Material(name="Iron",density,ncomponents=1);
157  FeMaterial->AddElement(Fe,natoms=1);
158 
159  density = 5.32 * g/cm3;
160  G4Material * HPGe = new G4Material(name="HPGe",density,ncomponents=1);
161  HPGe ->AddElement(Ge,natoms=1);
162  //define gallium arsenide
163 
164  density = 5.32 * g/cm3;
165  G4Material * GaAs = new G4Material(name ="gallium arsenide",density,ncomponents=2);
166  GaAs->AddElement(Ga,natoms=1);
167  GaAs->AddElement(As,natoms=1);
168 
169  //define silicon
170 
171  density = 2.333*g/cm3;
172  a = 28.09*g/mole;
173  G4Material* Si = new G4Material(name="Silicon",z=14., a,density);
174 
175  //define copper
176 
177  density = 8.960*g/cm3;
178  a = 63.55*g/mole;
179  G4Material* Cu = new G4Material(name="Copper"   , z=29., a, density);
180 
181 
182  //define carbon
183 
184  a = 12.01*g/mole;
185  G4Element* C  = new G4Element(name="Carbon"  ,symbol="C" , z= 6., a);
186 
187 
188  //define scintillator
189 
190  density = 1.032*g/cm3;
191  G4Material* Sci = new G4Material(name="Scintillator", density, ncomponents=2);
192  Sci->AddElement(C, natoms=9);
193  Sci->AddElement(H, natoms=10);
194 
195  //define aluminium
196 
197  density = 2.700*g/cm3;
198  a = 26.98*g/mole;
199  G4Material* Al = new G4Material(name="Aluminium", z=13., a, density);
200 
201  //define titanium
202  density = 4.54 *g/cm3;
203 a = 47.867*g/mole;
204 G4Material* Ti  = new G4Material(name="Titanium",z=22.,a,density);
205
206
207
208//define lead
209 
210  density = 11.35*g/cm3;
211  a=207.19*g/mole;
212  G4Material* Pb = new G4Material(name="Lead",z=82.,a,density);
213 
214  //define air
215
216  a = 14.01*g/mole;
217  G4Element* N  = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
218 
219  a = 16.00*g/mole;
220  G4Element* O  = new G4Element(name="Oxygen"  ,symbol="O" , z= 8., a);
221 
222  G4double fractionmass;
223  density = 1.290*mg/cm3;
224  G4Material* Air = new G4Material(name="Air"  , density, ncomponents=2);
225  Air->AddElement(N, fractionmass=0.7);
226  Air->AddElement(O, fractionmass=0.3);
227 
228  //define vacuum
229 
230  density     = universe_mean_density;    //from PhysicalConstants.h
231  pressure    = 3.e-18*pascal;
232  temperature = 2.73*kelvin;
233  G4Material * Vacuum = new G4Material(name="Galactic", z=1., a=1.01*g/mole, density,
234                                       kStateGas,temperature,pressure);
235 
236  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
237 
238  //default materials of the apparate
239 
240  sampleMaterial = Ti;
241  Dia1Material = Pb;
242  Dia3Material = Pb;
243  pixelMaterial = HPGe;
244  OhmicPosMaterial = Cu;
245  OhmicNegMaterial = Pb;
246  defaultMaterial = Vacuum;
247 
248}
249
250//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
251
252G4VPhysicalVolume* XrayFluoDetectorConstruction::ConstructApparate()
253{
254  // complete the apparate parameters definition
255 
256  ComputeApparateParameters();
257 
258  //world
259 
260  solidWorld = new G4Box("World",                               //its name
261                         WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/2);     //its size
262 
263  logicWorld = new G4LogicalVolume(solidWorld,          //its solid
264                                   defaultMaterial,     //its material
265                                   "World");            //its name
266  physiWorld = new G4PVPlacement(0,                     //no rotation
267                                 G4ThreeVector(),       //at (0,0,0)
268                                 "World",               //its name
269                                 logicWorld,            //its logical volume
270                                 0,                     //its mother  volume
271                                 false,                 //no boolean operation
272                                 0);                    //copy number
273 
274  //HPGeDetector
275 
276  solidHPGe = 0;  physiHPGe = 0;  logicHPGe=0;
277  solidPixel=0; logicPixel=0; physiPixel=0;
278 
279  if (DeviceThickness > 0.) 
280    {
281      solidHPGe = new G4Box("HPGeDetector",             //its name
282                            DeviceSizeX/2,DeviceSizeY/2,DeviceThickness/2);//size
283     
284     
285      logicHPGe = new G4LogicalVolume(solidHPGe,        //its solid
286                                      defaultMaterial,  //its material
287                                      "HPGeDetector");  //its name
288     
289      zRotPhiHPGe.rotateX(PhiHPGe);
290      G4double x,y,z;
291      z = DistDe * std::cos(ThetaHPGe);
292      y =DistDe * std::sin(ThetaHPGe);
293      x = 0.*cm;
294      physiHPGe = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)),                                           "HPGeDetector",  //its name
295                                    logicHPGe,  //its logical volume
296                                    physiWorld, //its mother  volume
297                                    false,              //no boolean operation
298                                    0);         //copy number
299    }
300  // Pixel   
301 
302  for ( G4int j=0; j < NbOfPixelColumns ; j++ )
303    { for ( G4int i=0; i < NbOfPixelRows ; i++ )
304      { 
305        solidPixel=0; logicPixel=0;   physiPixel=0;
306        if (PixelThickness > 0.)
307          solidPixel = new G4Box("Pixel",                       
308                                 PixelSizeXY/2,PixelSizeXY/2, PixelThickness/2);
309       
310        logicPixel = new G4LogicalVolume(solidPixel,   
311                                         pixelMaterial, //its material
312                                         "Pixel");              //its name
313        zRotPhiHPGe.rotateX(PhiHPGe);
314        G4double x,y,z;
315        z = DistDe * std::cos(ThetaHPGe);
316        y =DistDe * std::sin(ThetaHPGe);
317        x = 0.*cm; 
318       
319        physiPixel = new G4PVPlacement(0,             
320                                       G4ThreeVector(0,
321                                                     i*PixelSizeXY,
322                                                     j*PixelSizeXY ),
323                                       "Pixel", 
324                                       logicPixel,       //its logical volume
325                                       physiHPGe, //its mother  volume
326                                       false,    //no boolean operation
327                                       PixelCopyNb);//copy number
328       
329        // OhmicNeg
330       
331        solidOhmicNeg=0; logicOhmicNeg=0; physiOhmicNeg=0; 
332       
333        if (OhmicNegThickness > 0.) 
334          { solidOhmicNeg = new G4Box("OhmicNeg",               //its name
335                                      PixelSizeXY/2,PixelSizeXY/2,OhmicNegThickness/2); 
336               
337          logicOhmicNeg = new G4LogicalVolume(solidOhmicNeg,    //its solid
338                                                    OhmicNegMaterial, //its material
339                                              "OhmicNeg");      //its name
340               
341          physiOhmicNeg = new G4PVPlacement(0,
342                                            G4ThreeVector
343                                            (0.,
344                                             0.,
345                                              (PixelThickness+OhmicNegThickness)/2),
346                                            "OhmicNeg",        //its name
347                                            logicOhmicNeg,     //its logical volume
348                                            physiHPGe,        //its mother
349                                            false,             //no boulean operat
350                                            PixelCopyNb);                //copy number
351         
352          }
353        // OhmicPos
354        solidOhmicPos=0; logicOhmicPos=0; physiOhmicPos=0; 
355       
356        if (OhmicPosThickness > 0.) 
357          { solidOhmicPos = new G4Box("OhmicPos",               //its name
358                                      ContactSizeXY/2,ContactSizeXY/2,OhmicPosThickness/2); 
359         
360          logicOhmicPos = new G4LogicalVolume(solidOhmicPos,    //its solid
361                                              OhmicPosMaterial, //its material
362                                              "OhmicPos");      //its name
363         
364          physiOhmicPos = new G4PVPlacement(0, 
365                                            G4ThreeVector(0.,
366                                                          0.,
367                                                          (-PixelThickness-OhmicPosThickness)/2), 
368                                            "OhmicPos", 
369                                            logicOhmicPos,
370                                            physiHPGe, 
371                                            false,     
372                                            PixelCopyNb); 
373         
374          }
375        PixelCopyNb += PixelCopyNb;
376      }
377    } 
378 
379    //Sample
380   
381    solidSample=0;  logicSample=0;  physiSample=0;
382   
383    if (SampleThickness > 0.) 
384      {
385        solidSample = new G4Box("Sample",               //its name
386                                SampleSizeXY/2,SampleSizeXY/2,SampleThickness/2);//size
387       
388        logicSample= new G4LogicalVolume(solidSample,   //its solid
389                                         sampleMaterial,        //its material
390                                       "Sample");       //its name
391       
392        physiSample = new G4PVPlacement(0,                      //no rotation
393                                        G4ThreeVector(),        //at (0,0,0)
394                                        "Sample",       //its name
395                                        logicSample,    //its logical volume
396                                      physiWorld,       //its mother  volume
397                                        false,          //no boolean operation
398                                        0);             //copy number
399       
400      }
401   
402    //Diaphragm1
403   
404  solidDia1 = 0;  physiDia1 = 0;  logicDia1=0;
405 
406  if (Dia1Thickness > 0.) 
407    {
408      solidDia1 = new G4Tubs("Diaphragm1",              //its name
409                             DiaInnerSize/2,
410                             Dia1SizeXY/2,
411                             Dia1Thickness/2,
412                             0,
413                             360);//size
414     
415   
416      logicDia1 = new G4LogicalVolume(solidDia1,        //its solid
417                                      Dia1Material,     //its material
418                                      "Diaphragm1");    //its name
419     
420      zRotPhiDia1.rotateX(AlphaDia1);
421      G4double x,y,z;
422      z = DistDia * std::cos(ThetaDia1);
423      y =DistDia * std::sin(ThetaDia1);
424      x = 0.*cm;
425      physiDia1 = new G4PVPlacement(G4Transform3D(zRotPhiDia1,G4ThreeVector(x,y,z)),                                           "Diaphragm1",    //its name
426                                    logicDia1,  //its logical volume
427                                    physiWorld, //its mother  volume
428                                    false,              //no boolean operation
429                                   0);          //copy number
430    } 
431 
432  //Diaphragm3
433 
434  solidDia3 = 0;  physiDia3 = 0;  logicDia3 =0;
435 
436  if (Dia3Thickness > 0.) 
437    {
438      solidDia3 = new G4Tubs("Diaphragm3",
439                             Dia3InnerSize/2,
440                             Dia3SizeXY/2,
441                             Dia3Thickness/2,
442                             0,
443                             360);
444     
445     
446      logicDia3 = new G4LogicalVolume(solidDia3,        //its solid
447                                      Dia3Material,     //its material
448                                      "Diaphragm3");    //its name
449     
450      zRotPhiDia3.rotateX(AlphaDia3);
451      G4double x,y,z;
452      z = Dia3Dist * std::cos(ThetaDia3);
453      y =Dia3Dist * std::sin(ThetaDia3);
454      x = 0.*cm;
455      physiDia3 = new G4PVPlacement(G4Transform3D(zRotPhiDia3,G4ThreeVector(x,y,z)),                                           "Diaphragm3",    //its name
456                                    logicDia3,  //its logical volume
457                                    physiWorld, //its mother  volume
458                                    false,              //no boolean operation
459                                    0);         //copy number
460    }   
461   
462  G4SDManager* SDman = G4SDManager::GetSDMpointer();
463 
464  if(!HPGeSD)
465    {
466      HPGeSD = new XrayFluoHPGeSD ("HPGeSD",this);
467      SDman->AddNewDetector(HPGeSD);
468    }
469 
470 
471  if (logicPixel)
472    {
473      logicPixel->SetSensitiveDetector(HPGeSD);
474    }
475 
476  // Visualization attributes
477 
478  logicWorld->SetVisAttributes (G4VisAttributes::Invisible);
479   G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
480   G4VisAttributes * yellow= new G4VisAttributes( G4Colour(255/255. ,255/255. ,51/255. ));
481  yellow->SetVisibility(true);
482  yellow->SetForceSolid(true);
483  simpleBoxVisAtt->SetVisibility(true);
484 
485  logicPixel->SetVisAttributes(simpleBoxVisAtt);
486  logicHPGe->SetVisAttributes(G4VisAttributes::Invisible );
487  logicSample->SetVisAttributes(simpleBoxVisAtt);
488 
489  logicDia1->SetVisAttributes(simpleBoxVisAtt);
490  logicDia3->SetVisAttributes(simpleBoxVisAtt);
491 
492  logicOhmicNeg->SetVisAttributes(yellow);
493  logicOhmicPos->SetVisAttributes(yellow);
494  //always return the physical World
495 
496 
497  PrintApparateParameters();
498  return physiWorld;
499}
500
501//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
502
503void XrayFluoDetectorConstruction::PrintApparateParameters()
504{
505  G4cout << "-----------------------------------------------------------------------"
506         << G4endl
507         << "The sample is a box whose size is: "
508         << G4endl     
509         << SampleThickness/cm
510         << " cm * "
511         << SampleSizeXY/cm
512         << " cm * "
513         << SampleSizeXY/cm
514         << " cm"
515         << G4endl
516         <<" Material: " << sampleMaterial->GetName() 
517         <<G4endl
518          <<"The HPGeDetector is a slice  " << DeviceThickness/(1.e-6*m) <<  " micron thick"
519         <<G4endl
520         
521
522<<"-------------------------------------------------------------------------"
523         << G4endl;
524}
525//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
526
527void XrayFluoDetectorConstruction::UpdateGeometry()
528{
529  G4RunManager::GetRunManager()->DefineWorldVolume(ConstructApparate());
530}
531
532//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
533
534
535
536
537
538
539
Note: See TracBrowser for help on using the repository browser.