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 9.2.p4)


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