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