Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/xray_fluorescence/src/XrayFluoMercuryDetectorConstruction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/xray_fluorescence/src/XrayFluoMercuryDetectorConstruction.cc (Version 11.3.0) and /examples/advanced/xray_fluorescence/src/XrayFluoMercuryDetectorConstruction.cc (Version 10.0.p3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
                                                   >>  27 // $Id: XrayFluoMercuryDetectorConstruction.cc
                                                   >>  28 // GEANT4 tag $Name: XrayFluo-V05-02-06
 27 //                                                 29 //
 28 // Author: Alfonso Mantero (Alfonso.Mantero@ge     30 // Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
 29 //                                                 31 //
 30 // History:                                        32 // History:
 31 // -----------                                     33 // -----------
 32 // 08 Sep 2003 Alfonso Mantero Created             34 // 08 Sep 2003 Alfonso Mantero Created
 33 // -------------------------------------------     35 // -------------------------------------------------------------------
 34                                                    36 
 35 #include "XrayFluoMercuryDetectorConstruction.     37 #include "XrayFluoMercuryDetectorConstruction.hh"
 36 #include "XrayFluoMercuryDetectorMessenger.hh"     38 #include "XrayFluoMercuryDetectorMessenger.hh"
 37 #include "XrayFluoSD.hh"                           39 #include "XrayFluoSD.hh"
 38 #include "XrayFluoNistMaterials.hh"                40 #include "XrayFluoNistMaterials.hh"
 39 #include "G4PhysicalConstants.hh"                  41 #include "G4PhysicalConstants.hh"
 40 #include "G4SystemOfUnits.hh"                      42 #include "G4SystemOfUnits.hh"
 41 #include "G4Material.hh"                           43 #include "G4Material.hh"
 42 #include "G4ThreeVector.hh"                        44 #include "G4ThreeVector.hh"
 43 #include "G4Box.hh"                                45 #include "G4Box.hh"
 44 #include "G4Sphere.hh"                             46 #include "G4Sphere.hh"
 45 #include "G4Tubs.hh"                               47 #include "G4Tubs.hh"
 46 #include "G4LogicalVolume.hh"                      48 #include "G4LogicalVolume.hh"
 47 #include "G4PVPlacement.hh"                        49 #include "G4PVPlacement.hh"
 48 #include "G4TransportationManager.hh"              50 #include "G4TransportationManager.hh"
 49 #include "G4SDManager.hh"                          51 #include "G4SDManager.hh"
 50 #include "G4RunManager.hh"                         52 #include "G4RunManager.hh"
 51 #include "G4VisAttributes.hh"                      53 #include "G4VisAttributes.hh"
 52 #include "G4Colour.hh"                             54 #include "G4Colour.hh"
 53 #include "G4ios.hh"                                55 #include "G4ios.hh"
 54 #include "G4PVReplica.hh"                          56 #include "G4PVReplica.hh"
 55 #include "G4UserLimits.hh"                         57 #include "G4UserLimits.hh"
 56 #include "G4GeometryManager.hh"                <<  58 
 57 #include "G4PhysicalVolumeStore.hh"            << 
 58 #include "G4LogicalVolumeStore.hh"             << 
 59 #include "G4SolidStore.hh"                     << 
 60 #include "G4SDManager.hh"                      << 
 61 //....oooOO0OOooo........oooOO0OOooo........oo     59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 62                                                    60 
 63                                                    61 
 64 XrayFluoMercuryDetectorConstruction::XrayFluoM     62 XrayFluoMercuryDetectorConstruction::XrayFluoMercuryDetectorConstruction()
 65   : detectorType(0),mercuryGranularity(false),     63   : detectorType(0),mercuryGranularity(false), DeviceSizeX(0),
 66     DeviceSizeY(0),DeviceThickness(0),             64     DeviceSizeY(0),DeviceThickness(0),
 67     solidWorld(0),logicWorld(0),physiWorld(0),     65     solidWorld(0),logicWorld(0),physiWorld(0),
 68     solidHPGe(0),logicHPGe(0),physiHPGe(0),        66     solidHPGe(0),logicHPGe(0),physiHPGe(0),
 69     solidScreen(0),logicScreen(0),physiScreen(     67     solidScreen(0),logicScreen(0),physiScreen(0),
 70     solidMercury (0),logicMercury(0),physiMerc     68     solidMercury (0),logicMercury(0),physiMercury (0),
 71     solidOhmicPos(0),logicOhmicPos(0), physiOh     69     solidOhmicPos(0),logicOhmicPos(0), physiOhmicPos(0),
 72     solidOhmicNeg(0),logicOhmicNeg(0), physiOh     70     solidOhmicNeg(0),logicOhmicNeg(0), physiOhmicNeg(0),
 73     solidPixel(0),logicPixel(0), physiPixel(0)     71     solidPixel(0),logicPixel(0), physiPixel(0),
 74     screenMaterial(0),OhmicPosMaterial(0), Ohm     72     screenMaterial(0),OhmicPosMaterial(0), OhmicNegMaterial(0),
 75     pixelMaterial(0),mercuryMaterial(0),           73     pixelMaterial(0),mercuryMaterial(0),
 76     defaultMaterial(0),HPGeSD(0)                   74     defaultMaterial(0),HPGeSD(0)
 77                                                    75   
 78 {                                                  76 { 
 79   materials = XrayFluoNistMaterials::GetInstan     77   materials = XrayFluoNistMaterials::GetInstance();
 80                                                    78 
 81   DefineDefaultMaterials();                        79   DefineDefaultMaterials();
 82                                                    80 
 83   NbOfPixelRows     =  1; // should be 1           81   NbOfPixelRows     =  1; // should be 1
 84   NbOfPixelColumns  =  1; // should be 1           82   NbOfPixelColumns  =  1; // should be 1
 85   NbOfPixels        =  NbOfPixelRows*NbOfPixel     83   NbOfPixels        =  NbOfPixelRows*NbOfPixelColumns;
 86   PixelSizeXY       = std::sqrt(40.) * mm *0.5     84   PixelSizeXY       = std::sqrt(40.) * mm *0.5e6; // should be std::sqrt(40) * mm
 87   PixelThickness = 3.5 * mm * 1e6; //should be     85   PixelThickness = 3.5 * mm * 1e6; //should be 3.5 mm
 88                                                    86   
 89   G4cout << "PixelThickness(mm): "<< PixelThic     87   G4cout << "PixelThickness(mm): "<< PixelThickness/mm << G4endl;
 90   G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/     88   G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/cm << G4endl;
 91                                                    89   
 92   ContactSizeXY  = std::sqrt(40.) * mm * 0.5e6     90   ContactSizeXY  = std::sqrt(40.) * mm * 0.5e6; //should be the same as PixelSize or lower 
 93                                                    91 
 94   mercuryDia = 2 * 4880 * km ;                     92   mercuryDia = 2 * 4880 * km ;
 95   sunDia =  1390000 * km ;                         93   sunDia =  1390000 * km ;
 96   mercurySunDistance = 57910000 * km ;             94   mercurySunDistance = 57910000 * km ;
 97                                                    95 
 98                                                    96   
 99   OhmicNegThickness = 0.005*mm *0.5e6 ;            97   OhmicNegThickness = 0.005*mm *0.5e6 ;
100   OhmicPosThickness = 0.005*mm *0.5e6 ;            98   OhmicPosThickness = 0.005*mm *0.5e6 ;
101                                                    99   
102   screenThickness = 5 * mm *0.5e6;                100   screenThickness = 5 * mm *0.5e6;
103                                                   101   
104   ThetaHPGe = 135. * deg ;                        102   ThetaHPGe = 135. * deg ;
105   PhiHPGe = 225. * deg  ;                         103   PhiHPGe = 225. * deg  ;
106                                                   104   
107                                                   105   
108   distDe = (mercuryDia/2 + 400 * km);             106   distDe = (mercuryDia/2 + 400 * km);
109                                                   107   
110   distScreen = distDe + (screenThickness+Pixel    108   distScreen = distDe + (screenThickness+PixelThickness)/2+OhmicPosThickness ;
111                                                   109 
112   distOptic = distDe - 1.*m * 1e5;//!!!           110   distOptic = distDe - 1.*m * 1e5;//!!!
113                                                   111   
114   opticThickness = 1.* cm *0.5e6;                 112   opticThickness = 1.* cm *0.5e6;
115   opticDia = 21. * cm *0.5e6;                     113   opticDia = 21. * cm *0.5e6;  
116   opticAperture = 1. * deg;                       114   opticAperture = 1. * deg;
117                                                   115 
118   PixelCopyNb=0;                                  116   PixelCopyNb=0;
119   grainCopyNb=0;                                  117   grainCopyNb=0;
120   G4String defaultDetectorType = "sili";          118   G4String defaultDetectorType = "sili";
121   ComputeApparateParameters();                    119   ComputeApparateParameters();
122   SetDetectorType(defaultDetectorType);           120   SetDetectorType(defaultDetectorType);
123                                                   121   
124   // create commands for interactive definitio    122   // create commands for interactive definition of the apparate
125                                                   123   
126   detectorMessenger = new XrayFluoMercuryDetec    124   detectorMessenger = new XrayFluoMercuryDetectorMessenger(this);
127   G4cout << "XrayFluoMercuryDetectorConstructi    125   G4cout << "XrayFluoMercuryDetectorConstruction created" << G4endl;
128 }                                                 126 }
129 //....oooOO0OOooo........oooOO0OOooo........oo    127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
130                                                   128 
131                                                   129 
132 XrayFluoMercuryDetectorConstruction* XrayFluoM    130 XrayFluoMercuryDetectorConstruction* XrayFluoMercuryDetectorConstruction::instance = 0;
133                                                   131 
134 XrayFluoMercuryDetectorConstruction* XrayFluoM    132 XrayFluoMercuryDetectorConstruction* XrayFluoMercuryDetectorConstruction::GetInstance()
135 {                                                 133 {
136   if (instance == 0)                              134   if (instance == 0)
137     {                                             135     {
138       instance = new XrayFluoMercuryDetectorCo    136       instance = new XrayFluoMercuryDetectorConstruction;
139                                                   137       
140     }                                             138     }
141   return instance;                                139   return instance;
142 }                                                 140 }
143                                                   141 
144 void XrayFluoMercuryDetectorConstruction::SetD    142 void XrayFluoMercuryDetectorConstruction::SetDetectorType(G4String type)
145 {                                                 143 {
146                                                   144   
147   if (type=="sili")                               145   if (type=="sili")
148     {                                             146     {
149       detectorType = XrayFluoSiLiDetectorType:    147       detectorType = XrayFluoSiLiDetectorType::GetInstance();
150     }                                             148     }
151   else if (type=="hpge")                          149   else if (type=="hpge")
152     {                                             150     {
153       detectorType = XrayFluoHPGeDetectorType:    151       detectorType = XrayFluoHPGeDetectorType::GetInstance();
154     }                                             152     }
155   else                                            153   else 
156     {                                             154     {
157       G4ExceptionDescription execp;               155       G4ExceptionDescription execp;
158       execp <<  type + "detector type unknown"    156       execp <<  type + "detector type unknown";
159       G4Exception("XrayFluoMercuryDetectorCons    157       G4Exception("XrayFluoMercuryDetectorConstruction::SetDetectorType()","example-xray_fluorescence05",
160     FatalException, execp);                       158     FatalException, execp);
161     }                                             159     }
162 }                                                 160 }
163                                                   161 
164 //....oooOO0OOooo........oooOO0OOooo........oo << 162 XrayFluoVDetectorType* XrayFluoMercuryDetectorConstruction::GetDetectorType()
165                                                << 
166 XrayFluoVDetectorType* XrayFluoMercuryDetector << 
167 {                                                 163 {
168   return detectorType;                            164   return detectorType;
169 }                                                 165 }
170                                                   166 
171 //....oooOO0OOooo........oooOO0OOooo........oo    167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
172                                                   168 
173 XrayFluoMercuryDetectorConstruction::~XrayFluo    169 XrayFluoMercuryDetectorConstruction::~XrayFluoMercuryDetectorConstruction()
174                                                   170   
175 {                                                 171 { 
176   delete detectorMessenger;                       172   delete detectorMessenger;
177   delete detectorType;                            173   delete detectorType;
178   G4cout << "XrayFluoMercuryDetectorConstructi    174   G4cout << "XrayFluoMercuryDetectorConstruction deleted" << G4endl;
179 }                                                 175 }
180                                                   176 
181 //....oooOO0OOooo........oooOO0OOooo........oo    177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
182                                                   178 
183 G4VPhysicalVolume* XrayFluoMercuryDetectorCons    179 G4VPhysicalVolume* XrayFluoMercuryDetectorConstruction::Construct()
184 {                                                 180 {
185   return ConstructApparate();                     181   return ConstructApparate();
186 }                                                 182 }
187 //....oooOO0OOooo........oooOO0OOooo........oo    183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
188                                                   184 
189 void XrayFluoMercuryDetectorConstruction::Defi    185 void XrayFluoMercuryDetectorConstruction::DefineDefaultMaterials()
190 {                                                 186 {
191                                                   187   
192                                                   188   
193   //define materials of the apparate              189   //define materials of the apparate
194                                                   190   
195   mercuryMaterial = materials->GetMaterial("An    191   mercuryMaterial = materials->GetMaterial("Anorthosite");
196   screenMaterial = materials->GetMaterial("G4_    192   screenMaterial = materials->GetMaterial("G4_Pb");
197   pixelMaterial = materials->GetMaterial("G4_S    193   pixelMaterial = materials->GetMaterial("G4_Si");
198   OhmicPosMaterial = materials->GetMaterial("G    194   OhmicPosMaterial = materials->GetMaterial("G4_Cu");
199   OhmicNegMaterial = materials->GetMaterial("G    195   OhmicNegMaterial = materials->GetMaterial("G4_Pb");
200   defaultMaterial = materials->GetMaterial("G4    196   defaultMaterial = materials->GetMaterial("G4_Galactic");
201                                                   197   
202                                                   198   
203 }                                                 199 }
204                                                   200 
205 //....oooOO0OOooo........oooOO0OOooo........oo    201 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 
206                                                   202 
207 G4VPhysicalVolume* XrayFluoMercuryDetectorCons    203 G4VPhysicalVolume* XrayFluoMercuryDetectorConstruction::ConstructApparate()
208 {                                                 204 {
209   // complete the apparate parameters definiti    205   // complete the apparate parameters definition 
210                                                   206   
211   ComputeApparateParameters();                    207   ComputeApparateParameters();
212                                                   208   
213   //world                                         209   //world
214                                                   210   
215   solidWorld = new G4Box("World",                 211   solidWorld = new G4Box("World",                   //its name
216        WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/    212        WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/2); //its size
217                                                   213   
218   logicWorld = new G4LogicalVolume(solidWorld,    214   logicWorld = new G4LogicalVolume(solidWorld,    //its solid
219                                    defaultMate    215                                    defaultMaterial, //its material
220                                    "World");      216                                    "World");    //its name
221   physiWorld = new G4PVPlacement(0,     //no r    217   physiWorld = new G4PVPlacement(0,     //no rotation
222          G4ThreeVector(), //at (0,0,0)            218          G4ThreeVector(), //at (0,0,0)
223          "World",   //its name                    219          "World",   //its name
224          logicWorld,    //its logical volume      220          logicWorld,    //its logical volume
225          0,     //its mother  volume              221          0,     //its mother  volume
226          false,     //no boolean operation        222          false,     //no boolean operation
227          0);      //copy number                   223          0);      //copy number
228                                                   224   
229   //detector                                      225   //detector
230                                                   226   
231   solidHPGe = 0;  physiHPGe = 0;  logicHPGe=0;    227   solidHPGe = 0;  physiHPGe = 0;  logicHPGe=0;
232   solidPixel=0; logicPixel=0; physiPixel=0;       228   solidPixel=0; logicPixel=0; physiPixel=0;
233                                                   229   
234   if (DeviceThickness > 0.)                       230   if (DeviceThickness > 0.)  
235     {                                             231     {
236       solidHPGe = new G4Box("HPGeDetector",       232       solidHPGe = new G4Box("HPGeDetector",   //its name
237           DeviceSizeX/2,DeviceSizeY/2,DeviceTh    233           DeviceSizeX/2,DeviceSizeY/2,DeviceThickness/2);//size
238                                                   234       
239                                                   235       
240       logicHPGe = new G4LogicalVolume(solidHPG    236       logicHPGe = new G4LogicalVolume(solidHPGe,  //its solid
241               defaultMaterial,  //its material    237               defaultMaterial,  //its material 
242               "HPGeDetector");  //its name        238               "HPGeDetector");  //its name
243                                                   239       
244       zRotPhiHPGe.rotateX(PhiHPGe);               240       zRotPhiHPGe.rotateX(PhiHPGe);
245       G4double x,y,z;                             241       G4double x,y,z;
246                                                   242       
247       z = distDe * std::cos(ThetaHPGe);           243       z = distDe * std::cos(ThetaHPGe);
248       y = distScreen * std::sin(ThetaHPGe);       244       y = distScreen * std::sin(ThetaHPGe);
249       x = 0.*cm;                                  245       x = 0.*cm;
250                                                   246       
251       physiHPGe = new G4PVPlacement(G4Transfor    247       physiHPGe = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)), 
252             "HPGeDetector", //its name            248             "HPGeDetector", //its name
253             logicHPGe,  //its logical volume      249             logicHPGe,  //its logical volume
254             physiWorld, //its mother  volume      250             physiWorld, //its mother  volume
255             false,    //no boolean operation      251             false,    //no boolean operation
256             0);   //copy number                   252             0);   //copy number
257     }                                             253     }
258   // Pixel                                        254   // Pixel
259                                                   255   
260                                                   256   
261                                                   257   
262                                                   258   
263   for ( G4int j=0; j < NbOfPixelColumns ; j++     259   for ( G4int j=0; j < NbOfPixelColumns ; j++ )
264     { for ( G4int i=0; i < NbOfPixelRows ; i++    260     { for ( G4int i=0; i < NbOfPixelRows ; i++ )
265       {                                           261       { 
266   solidPixel=0; logicPixel=0;   physiPixel=0;     262   solidPixel=0; logicPixel=0;   physiPixel=0;
267   if (PixelThickness > 0.)                        263   if (PixelThickness > 0.)
268     solidPixel = new G4Box("Pixel",               264     solidPixel = new G4Box("Pixel",     
269          PixelSizeXY/2,PixelSizeXY/2, PixelThi    265          PixelSizeXY/2,PixelSizeXY/2, PixelThickness/2);
270                                                   266   
271   logicPixel = new G4LogicalVolume(solidPixel,    267   logicPixel = new G4LogicalVolume(solidPixel,  
272            pixelMaterial, //its material          268            pixelMaterial, //its material
273            "Pixel");          //its name          269            "Pixel");          //its name
274                                                   270   
275   /*                                              271   /*
276     zRotPhiHPGe.rotateX(PhiHPGe);                 272     zRotPhiHPGe.rotateX(PhiHPGe);
277     G4double x,y,z;                               273     G4double x,y,z;
278     z = distDe * std::cos(ThetaHPGe);             274     z = distDe * std::cos(ThetaHPGe);
279     y =distDe * std::sin(ThetaHPGe);              275     y =distDe * std::sin(ThetaHPGe);
280     x = 0.*cm;*/                                  276     x = 0.*cm;*/ 
281   physiPixel = new G4PVPlacement(0,               277   physiPixel = new G4PVPlacement(0,        
282                G4ThreeVector(0,                   278                G4ThreeVector(0,
283                  i*PixelSizeXY,                   279                  i*PixelSizeXY, 
284                  j*PixelSizeXY ),                 280                  j*PixelSizeXY ),
285                "Pixel",                           281                "Pixel",  
286                logicPixel,   //its logical vol    282                logicPixel,   //its logical volume
287                physiHPGe, //its mother  volume    283                physiHPGe, //its mother  volume
288                false,  //no boolean operation     284                false,  //no boolean operation
289                PixelCopyNb);//copy number         285                PixelCopyNb);//copy number
290                                                   286   
291                                                   287   
292                                                   288   
293                                                   289   
294                                                   290   
295                                                   291   
296   // OhmicNeg                                     292   // OhmicNeg
297                                                   293   
298   solidOhmicNeg=0; logicOhmicNeg=0; physiOhmic    294   solidOhmicNeg=0; logicOhmicNeg=0; physiOhmicNeg=0;  
299                                                   295   
300   if (OhmicNegThickness > 0.)                     296   if (OhmicNegThickness > 0.) 
301     { solidOhmicNeg = new G4Box("OhmicNeg",       297     { solidOhmicNeg = new G4Box("OhmicNeg",   //its name
302               PixelSizeXY/2,PixelSizeXY/2,Ohmi    298               PixelSizeXY/2,PixelSizeXY/2,OhmicNegThickness/2); 
303                                                   299     
304     logicOhmicNeg = new G4LogicalVolume(solidO    300     logicOhmicNeg = new G4LogicalVolume(solidOhmicNeg,    //its solid
305                 OhmicNegMaterial, //its materi    301                 OhmicNegMaterial, //its material
306                 "OhmicNeg");      //its name      302                 "OhmicNeg");      //its name
307                                                   303     
308     physiOhmicNeg = new G4PVPlacement(0,          304     physiOhmicNeg = new G4PVPlacement(0,
309               G4ThreeVector                       305               G4ThreeVector
310               (0.,                                306               (0.,
311                0.,                                307                0.,
312                (PixelThickness+OhmicNegThickne    308                (PixelThickness+OhmicNegThickness)/2),
313               "OhmicNeg",        //its name       309               "OhmicNeg",        //its name
314               logicOhmicNeg,     //its logical    310               logicOhmicNeg,     //its logical volume
315               physiHPGe,        //its mother      311               physiHPGe,        //its mother
316               false,             //no boulean     312               false,             //no boulean operat
317               PixelCopyNb);                //c    313               PixelCopyNb);                //copy number
318                                                   314     
319     }                                             315     }
320   // OhmicPos                                     316   // OhmicPos
321   solidOhmicPos=0; logicOhmicPos=0; physiOhmic    317   solidOhmicPos=0; logicOhmicPos=0; physiOhmicPos=0;  
322                                                   318   
323   if (OhmicPosThickness > 0.)                     319   if (OhmicPosThickness > 0.) 
324     { solidOhmicPos = new G4Box("OhmicPos",       320     { solidOhmicPos = new G4Box("OhmicPos",   //its name
325               PixelSizeXY/2,PixelSizeXY/2,Ohmi    321               PixelSizeXY/2,PixelSizeXY/2,OhmicPosThickness/2); 
326                                                   322     
327     logicOhmicPos = new G4LogicalVolume(solidO    323     logicOhmicPos = new G4LogicalVolume(solidOhmicPos,    //its solid
328                 OhmicPosMaterial, //its materi    324                 OhmicPosMaterial, //its material
329                 "OhmicPos");      //its name      325                 "OhmicPos");      //its name
330                                                   326     
331     physiOhmicPos = new G4PVPlacement(0,          327     physiOhmicPos = new G4PVPlacement(0,  
332               G4ThreeVector(0.,                   328               G4ThreeVector(0.,
333                 0.,                               329                 0.,
334                 (-PixelThickness-OhmicPosThick    330                 (-PixelThickness-OhmicPosThickness)/2),  
335               "OhmicPos",                         331               "OhmicPos",  
336               logicOhmicPos,                      332               logicOhmicPos,
337               physiHPGe,                          333               physiHPGe,  
338               false,                              334               false,     
339               PixelCopyNb);                       335               PixelCopyNb); 
340                                                   336     
341     }                                             337     }
342                                                   338   
343   PixelCopyNb += PixelCopyNb;                     339   PixelCopyNb += PixelCopyNb; 
344   G4cout << "PixelCopyNb: " << PixelCopyNb <<     340   G4cout << "PixelCopyNb: " << PixelCopyNb << G4endl;
345       }                                           341       }
346                                                   342     
347     }                                             343     }
348                                                   344   
349   // Optics                                       345   // Optics
350                                                   346 
351   if (DeviceThickness > 0.)                       347   if (DeviceThickness > 0.)  
352     {                                             348     {
353       solidOptic = new G4Tubs("DetectorOptic",    349       solidOptic = new G4Tubs("DetectorOptic",    //its name
354             0.,opticDia/2, opticThickness, 0.,    350             0.,opticDia/2, opticThickness, 0.,2.*pi);//size
355                                                   351       
356                                                   352       
357       logicOptic = new G4LogicalVolume(solidOp    353       logicOptic = new G4LogicalVolume(solidOptic,  //its solid
358                defaultMaterial, //its material    354                defaultMaterial, //its material 
359                "DetectorOptic");  //its name      355                "DetectorOptic");  //its name
360                                                   356       
361       //zRotPhiHPGe.rotateX(PhiHPGe);             357       //zRotPhiHPGe.rotateX(PhiHPGe);
362       G4double x,y,z;                             358       G4double x,y,z;
363       z = distOptic * std::cos(ThetaHPGe);        359       z = distOptic * std::cos(ThetaHPGe);
364       y = distOptic * std::sin(ThetaHPGe);        360       y = distOptic * std::sin(ThetaHPGe);
365       x = 0.*cm;                                  361       x = 0.*cm;
366       physiOptic = new G4PVPlacement(G4Transfo    362       physiOptic = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)), 
367               "DetectorOptic",  //its name        363               "DetectorOptic",  //its name
368               logicOptic, //its logical volume    364               logicOptic, //its logical volume
369               physiWorld, //its mother  volume    365               physiWorld, //its mother  volume
370               false,    //no boolean operation    366               false,    //no boolean operation
371               0);   //copy number                 367               0);   //copy number
372     }                                             368     }
373                                                   369   
374                                                   370 
375   // Screen                                       371   // Screen
376                                                   372   
377   if (DeviceThickness > 0.)                       373   if (DeviceThickness > 0.)  
378     {                                             374     {
379       solidScreen = new G4Box("DetectorScreen"    375       solidScreen = new G4Box("DetectorScreen",   //its name
380             screenSizeXY/2,screenSizeXY/2,scre    376             screenSizeXY/2,screenSizeXY/2,screenThickness/2);//size
381                                                   377       
382                                                   378       
383       logicScreen = new G4LogicalVolume(solidS    379       logicScreen = new G4LogicalVolume(solidScreen,  //its solid
384           defaultMaterial,  //its material        380           defaultMaterial,  //its material 
385           "DetectorScreen");  //its name          381           "DetectorScreen");  //its name
386                                                   382       
387       //zRotPhiHPGe.rotateX(PhiHPGe);             383       //zRotPhiHPGe.rotateX(PhiHPGe);
388       G4double x,y,z;                             384       G4double x,y,z;
389       G4cout << "distScreen: "<< distScreen/m     385       G4cout << "distScreen: "<< distScreen/m <<G4endl;
390       z = distScreen * std::cos(ThetaHPGe);       386       z = distScreen * std::cos(ThetaHPGe);
391       y = distScreen * std::sin(ThetaHPGe);       387       y = distScreen * std::sin(ThetaHPGe);
392       x = 0.*cm;                                  388       x = 0.*cm;
393       physiScreen = new G4PVPlacement(G4Transf    389       physiScreen = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)), 
394               "DetectorScreen", //its name        390               "DetectorScreen", //its name
395               logicScreen,  //its logical volu    391               logicScreen,  //its logical volume
396               physiWorld, //its mother  volume    392               physiWorld, //its mother  volume
397               false,    //no boolean operation    393               false,    //no boolean operation
398               0);   //copy number                 394               0);   //copy number
399     }                                             395     }
400                                                   396   
401   //Mercury                                       397   //Mercury
402                                                   398   
403                                                   399   
404   solidMercury=0;  logicMercury=0;  physiMercu    400   solidMercury=0;  logicMercury=0;  physiMercury=0;
405   if (mercuryDia > 0.)                            401   if (mercuryDia > 0.)  
406     {                                             402     {
407                                                   403 
408                                                   404 
409                                                   405         
410                                                   406 
411                                                   407 
412                                                   408 
413       solidMercury = new G4Sphere("Mercury",0.    409       solidMercury = new G4Sphere("Mercury",0.,mercuryDia/2., 0., twopi, 0., pi);
414                                                   410             
415       logicMercury= new G4LogicalVolume(solidM    411       logicMercury= new G4LogicalVolume(solidMercury, //its solid
416           mercuryMaterial,  //its material        412           mercuryMaterial,  //its material
417           "Mercury"); //its name                  413           "Mercury"); //its name
418                                                   414       
419       physiMercury = new G4PVPlacement(0,         415       physiMercury = new G4PVPlacement(0,     //no rotation
420                G4ThreeVector(), //at (0,0,0)      416                G4ThreeVector(), //at (0,0,0)
421                "Mercury", //its name              417                "Mercury", //its name
422                logicMercury,  //its logical vo    418                logicMercury,  //its logical volume
423                physiWorld,  //its mother  volu    419                physiWorld,  //its mother  volume
424                false,   //no boolean operation    420                false,   //no boolean operation
425                0);    //copy number               421                0);    //copy number
426                                                   422       
427     }                                             423     }  
428                                                   424   
429                                                << 425   
                                                   >> 426   G4SDManager* SDman = G4SDManager::GetSDMpointer();    
                                                   >> 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   
430   // Visualization attributes                     440   // Visualization attributes
431                                                   441   
432                                                   442 
433   logicWorld->SetVisAttributes (G4VisAttribute << 443   logicWorld->SetVisAttributes (G4VisAttributes::Invisible);
434   G4VisAttributes* simpleBoxVisAtt= new G4VisA    444   G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
435   G4VisAttributes * yellow= new G4VisAttribute    445   G4VisAttributes * yellow= new G4VisAttributes( G4Colour(255/255. ,255/255. ,51/255. ));
436   G4VisAttributes * red= new G4VisAttributes(     446   G4VisAttributes * red= new G4VisAttributes( G4Colour(255/255. , 0/255. , 0/255. ));
437   G4VisAttributes * blue= new G4VisAttributes(    447   G4VisAttributes * blue= new G4VisAttributes( G4Colour(0/255. , 0/255. ,  255/255. ));
438   G4VisAttributes * grayc= new G4VisAttributes    448   G4VisAttributes * grayc= new G4VisAttributes( G4Colour(128/255. , 128/255. ,  128/255. ));
439   G4VisAttributes * darkGray= new G4VisAttribu    449   G4VisAttributes * darkGray= new G4VisAttributes( G4Colour(95/255. , 95/255. ,  95/255. ));
440   //G4VisAttributes * green= new G4VisAttribut    450   //G4VisAttributes * green= new G4VisAttributes( G4Colour(25/255. , 255/255. ,  25/255. ));
441   yellow->SetVisibility(true);                    451   yellow->SetVisibility(true);
442   yellow->SetForceSolid(true);                    452   yellow->SetForceSolid(true);
443   red->SetVisibility(true);                       453   red->SetVisibility(true);
444   red->SetForceSolid(true);                       454   red->SetForceSolid(true);
445   blue->SetVisibility(true);                      455   blue->SetVisibility(true);
446   grayc->SetVisibility(true);                     456   grayc->SetVisibility(true);
447   grayc->SetForceSolid(true);                     457   grayc->SetForceSolid(true);
448   simpleBoxVisAtt->SetVisibility(true);           458   simpleBoxVisAtt->SetVisibility(true);
449                                                   459 
450   //logicWorld->SetVisAttributes (simpleBoxVis    460   //logicWorld->SetVisAttributes (simpleBoxVisAtt);
451                                                   461   
452   logicPixel->SetVisAttributes(red);              462   logicPixel->SetVisAttributes(red);
453   logicHPGe->SetVisAttributes(G4VisAttributes: << 463   logicHPGe->SetVisAttributes(G4VisAttributes::Invisible);
454                                                   464   
455   logicMercury->SetVisAttributes(darkGray);       465   logicMercury->SetVisAttributes(darkGray);
456                                                   466   
457                                                   467 
458   logicScreen->SetVisAttributes(red);             468   logicScreen->SetVisAttributes(red);
459   logicOhmicNeg->SetVisAttributes(yellow);        469   logicOhmicNeg->SetVisAttributes(yellow);
460   logicOhmicPos->SetVisAttributes(yellow);        470   logicOhmicPos->SetVisAttributes(yellow);
461   logicOptic->SetVisAttributes(grayc);            471   logicOptic->SetVisAttributes(grayc);
462                                                   472 
463                                                   473 
464   if (mercuryGranularity)  logicGrain->SetVisA    474   if (mercuryGranularity)  logicGrain->SetVisAttributes(grayc);
465                                                   475 
466   //always return the physical World              476   //always return the physical World
467                                                   477     
468   PrintApparateParameters();                      478   PrintApparateParameters();
469                                                   479 
470   return physiWorld;                              480   return physiWorld;
471 }                                                 481 }
472                                                   482 
473 //....oooOO0OOooo........oooOO0OOooo........oo    483 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
474                                                   484 
475 void XrayFluoMercuryDetectorConstruction::Cons << 
476 {                                              << 
477    //                                          << 
478   // Sensitive Detectors                       << 
479   //                                           << 
480   if (HPGeSD.Get() == 0)                       << 
481     {                                          << 
482       XrayFluoSD* SD = new XrayFluoSD ("HPGeSD << 
483       HPGeSD.Put( SD );                        << 
484     }                                          << 
485   G4SDManager::GetSDMpointer()->AddNewDetector << 
486   if (logicPixel)                              << 
487     SetSensitiveDetector(logicPixel,HPGeSD.Get << 
488 }                                              << 
489                                                << 
490 //....oooOO0OOooo........oooOO0OOooo........oo << 
491                                                << 
492 void XrayFluoMercuryDetectorConstruction::Prin    485 void XrayFluoMercuryDetectorConstruction::PrintApparateParameters()
493 {                                                 486 {
494   G4cout << "---------------------------------    487   G4cout << "-----------------------------------------------------------------------"
495    << G4endl                                      488    << G4endl
496    << "The mercury is a sphere whose diamter i    489    << "The mercury is a sphere whose diamter is: "
497    << G4endl                                      490    << G4endl      
498    << mercuryDia/km                               491    << mercuryDia/km
499    << " Km "                                      492    << " Km "
500    << G4endl                                      493    << G4endl
501    <<" Material: " << logicMercury->GetMateria    494    <<" Material: " << logicMercury->GetMaterial()->GetName() 
502    <<G4endl                                       495    <<G4endl
503    <<"The Detector is a slice  " << DeviceThic    496    <<"The Detector is a slice  " << DeviceThickness/(1.e-6*m) 
504    << " micron thick of " << pixelMaterial->Ge    497    << " micron thick of " << pixelMaterial->GetName()<<G4endl
505    <<"----------------------------------------    498    <<"-------------------------------------------------------------------------"
506    << G4endl;                                     499    << G4endl;
507 }                                                 500 }
508 //....oooOO0OOooo........oooOO0OOooo........oo    501 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
509                                                   502 
510 void XrayFluoMercuryDetectorConstruction::Upda    503 void XrayFluoMercuryDetectorConstruction::UpdateGeometry()
511 {                                                 504 {
512                                                   505 
513   G4GeometryManager::GetInstance()->OpenGeomet << 506 
514   G4PhysicalVolumeStore::Clean();              << 507   delete solidHPGe;
515   G4LogicalVolumeStore::Clean();               << 508   delete logicHPGe;
516   G4SolidStore::Clean();                       << 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;
517                                                   531 
518   zRotPhiHPGe.rotateX(-1.*PhiHPGe);               532   zRotPhiHPGe.rotateX(-1.*PhiHPGe);
519   ComputeApparateParameters();                    533   ComputeApparateParameters();  
520                                                << 534   G4RunManager::GetRunManager()->DefineWorldVolume(ConstructApparate());
521   //Triggers a new call of Construct() and of  << 
522   G4RunManager::GetRunManager()->ReinitializeG << 
523                                                << 
524 }                                                 535 }
525                                                   536 
526 //....oooOO0OOooo........oooOO0OOooo........oo << 
527                                                << 
528 void XrayFluoMercuryDetectorConstruction::SetM    537 void XrayFluoMercuryDetectorConstruction::SetMercuryMaterial(G4String newMaterial)
529 {                                                 538 {
530   G4cout << "New Mercury Material: " << newMat << 539 
531   logicMercury->SetMaterial(materials->GetMate << 540 
532   PrintApparateParameters();                   << 541     G4cout << "New Mercury Material: " << newMaterial << G4endl;
533    //GeometryHasBeenModified is called by the  << 542     logicMercury->SetMaterial(materials->GetMaterial(newMaterial));
                                                   >> 543     PrintApparateParameters();
                                                   >> 544   
534 }                                                 545 }
535                                                   546 
536 //....oooOO0OOooo........oooOO0OOooo........oo    547 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
537                                                   548 
538                                                   549 
539                                                   550 
540                                                   551 
541                                                   552 
542                                                   553 
543                                                   554 
544                                                   555 
545                                                   556 
546                                                   557 
547                                                   558 
548                                                   559