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