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: XrayFluoPlaneDetectorConstruction.cc >> 28 // GEANT4 tag $Name: xray_fluo-V03-02-00 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 // 29 aug 2003 Alfonso Mantero Created 34 // 29 aug 2003 Alfonso Mantero Created 33 // ------------------------------------------- 35 // ------------------------------------------------------------------- 34 36 35 #include "XrayFluoPlaneDetectorConstruction.hh 37 #include "XrayFluoPlaneDetectorConstruction.hh" 36 #include "XrayFluoPlaneDetectorMessenger.hh" 38 #include "XrayFluoPlaneDetectorMessenger.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 "G4LogicalVolume.hh" 47 #include "G4LogicalVolume.hh" 46 #include "G4PVPlacement.hh" 48 #include "G4PVPlacement.hh" 47 #include "G4TransportationManager.hh" 49 #include "G4TransportationManager.hh" 48 #include "G4SDManager.hh" 50 #include "G4SDManager.hh" 49 #include "G4RunManager.hh" 51 #include "G4RunManager.hh" 50 #include "G4VisAttributes.hh" 52 #include "G4VisAttributes.hh" 51 #include "G4Colour.hh" 53 #include "G4Colour.hh" 52 #include "G4PVReplica.hh" 54 #include "G4PVReplica.hh" 53 #include "G4UserLimits.hh" 55 #include "G4UserLimits.hh" 54 #include "G4GeometryManager.hh" 56 #include "G4GeometryManager.hh" 55 #include "G4PhysicalVolumeStore.hh" 57 #include "G4PhysicalVolumeStore.hh" 56 #include "G4LogicalVolumeStore.hh" 58 #include "G4LogicalVolumeStore.hh" 57 #include "G4SolidStore.hh" 59 #include "G4SolidStore.hh" 58 #include "G4SDManager.hh" 60 #include "G4SDManager.hh" 59 61 60 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 61 63 62 64 63 XrayFluoPlaneDetectorConstruction::XrayFluoPla 65 XrayFluoPlaneDetectorConstruction::XrayFluoPlaneDetectorConstruction() 64 : detectorType(0),planeGranularity(false), D 66 : detectorType(0),planeGranularity(false), DeviceSizeX(0), 65 DeviceSizeY(0),DeviceThickness(0), 67 DeviceSizeY(0),DeviceThickness(0), 66 solidWorld(0),logicWorld(0),physiWorld(0), 68 solidWorld(0),logicWorld(0),physiWorld(0), 67 solidHPGe(0),logicHPGe(0),physiHPGe(0), 69 solidHPGe(0),logicHPGe(0),physiHPGe(0), 68 solidScreen(0),logicScreen(0),physiScreen( 70 solidScreen(0),logicScreen(0),physiScreen(0), 69 solidPlane (0),logicPlane(0),physiPlane (0 71 solidPlane (0),logicPlane(0),physiPlane (0), 70 solidOhmicPos(0),logicOhmicPos(0), physiOh 72 solidOhmicPos(0),logicOhmicPos(0), physiOhmicPos(0), 71 solidOhmicNeg(0),logicOhmicNeg(0), physiOh 73 solidOhmicNeg(0),logicOhmicNeg(0), physiOhmicNeg(0), 72 solidPixel(0),logicPixel(0), physiPixel(0) 74 solidPixel(0),logicPixel(0), physiPixel(0), 73 screenMaterial(0),OhmicPosMaterial(0), Ohm 75 screenMaterial(0),OhmicPosMaterial(0), OhmicNegMaterial(0), 74 pixelMaterial(0),planeMaterial(0), 76 pixelMaterial(0),planeMaterial(0), 75 defaultMaterial(0),HPGeSD(0) 77 defaultMaterial(0),HPGeSD(0) 76 78 77 { 79 { 78 materials = XrayFluoNistMaterials::GetInstan 80 materials = XrayFluoNistMaterials::GetInstance(); 79 81 80 DefineDefaultMaterials(); 82 DefineDefaultMaterials(); 81 83 82 NbOfPixelRows = 1; // should be 1 84 NbOfPixelRows = 1; // should be 1 83 NbOfPixelColumns = 1; // should be 1 85 NbOfPixelColumns = 1; // should be 1 84 NbOfPixels = NbOfPixelRows*NbOfPixel 86 NbOfPixels = NbOfPixelRows*NbOfPixelColumns; 85 PixelSizeXY = 5 * cm; // should be 5 87 PixelSizeXY = 5 * cm; // should be 5 86 PixelThickness = 3.5 * mm; //changed should 88 PixelThickness = 3.5 * mm; //changed should be 3.5 mm 87 89 88 G4cout << "PixelThickness(mm): "<< PixelThic 90 G4cout << "PixelThickness(mm): "<< PixelThickness/mm << G4endl; 89 G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/ 91 G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/cm << G4endl; 90 92 91 ContactSizeXY = 5 * cm; //should be the sam 93 ContactSizeXY = 5 * cm; //should be the same as pixelSizeXY 92 planeThickness = 5 * cm; 94 planeThickness = 5 * cm; 93 planeSizeXY = 5. * m; 95 planeSizeXY = 5. * m; 94 96 95 OhmicNegThickness = 0.005*mm; 97 OhmicNegThickness = 0.005*mm; 96 OhmicPosThickness = 0.005*mm; 98 OhmicPosThickness = 0.005*mm; 97 99 98 screenThickness = 5 * mm; 100 screenThickness = 5 * mm; 99 101 100 ThetaHPGe = 0. * deg; 102 ThetaHPGe = 0. * deg; 101 PhiHPGe = 0. * deg; 103 PhiHPGe = 0. * deg; 102 104 103 105 104 DistDe = 0.5 * m; 106 DistDe = 0.5 * m; 105 107 106 distScreen = DistDe + (screenThickness+Pixel 108 distScreen = DistDe + (screenThickness+PixelThickness)/2+OhmicPosThickness ; 107 109 108 grainDia = 1 * mm; 110 grainDia = 1 * mm; 109 111 110 112 111 PixelCopyNb=0; 113 PixelCopyNb=0; 112 grainCopyNb=0; 114 grainCopyNb=0; 113 G4String defaultDetectorType = "sili"; 115 G4String defaultDetectorType = "sili"; 114 ComputeApparateParameters(); 116 ComputeApparateParameters(); 115 SetDetectorType(defaultDetectorType); 117 SetDetectorType(defaultDetectorType); 116 118 117 // create commands for interactive definitio 119 // create commands for interactive definition of the apparate 118 120 119 detectorMessenger = new XrayFluoPlaneDetecto 121 detectorMessenger = new XrayFluoPlaneDetectorMessenger(this); 120 G4cout << "XrayFluoPlaneDetectorConstruction 122 G4cout << "XrayFluoPlaneDetectorConstruction created" << G4endl; 121 } 123 } 122 //....oooOO0OOooo........oooOO0OOooo........oo 124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 123 125 124 126 125 XrayFluoPlaneDetectorConstruction* XrayFluoPla 127 XrayFluoPlaneDetectorConstruction* XrayFluoPlaneDetectorConstruction::instance = 0; 126 128 127 XrayFluoPlaneDetectorConstruction* XrayFluoPla 129 XrayFluoPlaneDetectorConstruction* XrayFluoPlaneDetectorConstruction::GetInstance() 128 { 130 { 129 if (instance == 0) 131 if (instance == 0) 130 { 132 { 131 instance = new XrayFluoPlaneDetectorCons 133 instance = new XrayFluoPlaneDetectorConstruction; 132 134 133 } 135 } 134 return instance; 136 return instance; 135 } 137 } 136 138 137 void XrayFluoPlaneDetectorConstruction::SetDet 139 void XrayFluoPlaneDetectorConstruction::SetDetectorType(G4String type) 138 { 140 { 139 141 140 if (type=="sili") 142 if (type=="sili") 141 { 143 { 142 detectorType = XrayFluoSiLiDetectorType: 144 detectorType = XrayFluoSiLiDetectorType::GetInstance(); 143 } 145 } 144 else if (type=="hpge") 146 else if (type=="hpge") 145 { 147 { 146 detectorType = XrayFluoHPGeDetectorType 148 detectorType = XrayFluoHPGeDetectorType::GetInstance(); 147 } 149 } 148 else 150 else 149 { 151 { 150 G4ExceptionDescription execp; 152 G4ExceptionDescription execp; 151 execp << type + "detector type unknown"; 153 execp << type + "detector type unknown"; 152 G4Exception("XrayFluoPlaneDetectorConstr 154 G4Exception("XrayFluoPlaneDetectorConstruction::SetDetectorType()","example-xray_fluorescence03", 153 FatalException, execp); 155 FatalException, execp); 154 } 156 } 155 } 157 } 156 158 157 //....oooOO0OOooo........oooOO0OOooo........oo 159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 158 160 159 XrayFluoVDetectorType* XrayFluoPlaneDetectorCo 161 XrayFluoVDetectorType* XrayFluoPlaneDetectorConstruction::GetDetectorType() const 160 { 162 { 161 return detectorType; 163 return detectorType; 162 } 164 } 163 165 164 //....oooOO0OOooo........oooOO0OOooo........oo 166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 165 167 166 XrayFluoPlaneDetectorConstruction::~XrayFluoPl 168 XrayFluoPlaneDetectorConstruction::~XrayFluoPlaneDetectorConstruction() 167 169 168 { 170 { 169 delete detectorMessenger; 171 delete detectorMessenger; 170 delete detectorType; 172 delete detectorType; 171 G4cout << "XrayFluoPlaneDetectorConstruction 173 G4cout << "XrayFluoPlaneDetectorConstruction deleted" << G4endl; 172 } 174 } 173 175 174 //....oooOO0OOooo........oooOO0OOooo........oo 176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 175 177 176 G4VPhysicalVolume* XrayFluoPlaneDetectorConstr 178 G4VPhysicalVolume* XrayFluoPlaneDetectorConstruction::Construct() 177 { 179 { 178 return ConstructApparate(); 180 return ConstructApparate(); 179 } 181 } 180 //....oooOO0OOooo........oooOO0OOooo........oo 182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 181 183 182 void XrayFluoPlaneDetectorConstruction::Define 184 void XrayFluoPlaneDetectorConstruction::DefineDefaultMaterials() 183 { 185 { 184 186 185 187 186 //define materials of the apparate 188 //define materials of the apparate 187 189 188 planeMaterial = materials->GetMaterial("Anor 190 planeMaterial = materials->GetMaterial("Anorthosite"); 189 screenMaterial = materials->GetMaterial("G4_ 191 screenMaterial = materials->GetMaterial("G4_Pb"); 190 pixelMaterial = materials->GetMaterial("G4_S 192 pixelMaterial = materials->GetMaterial("G4_Si"); 191 OhmicPosMaterial = materials->GetMaterial("G 193 OhmicPosMaterial = materials->GetMaterial("G4_Cu"); 192 OhmicNegMaterial = materials->GetMaterial("G 194 OhmicNegMaterial = materials->GetMaterial("G4_Pb"); 193 defaultMaterial = materials->GetMaterial("G4 195 defaultMaterial = materials->GetMaterial("G4_Galactic"); 194 } 196 } 195 197 196 //....oooOO0OOooo........oooOO0OOooo........oo 198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 197 199 198 G4VPhysicalVolume* XrayFluoPlaneDetectorConstr 200 G4VPhysicalVolume* XrayFluoPlaneDetectorConstruction::ConstructApparate() 199 { 201 { 200 // complete the apparate parameters definiti 202 // complete the apparate parameters definition 201 203 202 //ComputeApparateParameters(); 204 //ComputeApparateParameters(); 203 205 204 //world 206 //world 205 207 206 solidWorld = new G4Box("World", 208 solidWorld = new G4Box("World", //its name 207 WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/ 209 WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/2); //its size 208 210 209 logicWorld = new G4LogicalVolume(solidWorld, 211 logicWorld = new G4LogicalVolume(solidWorld, //its solid 210 defaultMate 212 defaultMaterial, //its material 211 "World"); 213 "World"); //its name 212 physiWorld = new G4PVPlacement(0, //no r 214 physiWorld = new G4PVPlacement(0, //no rotation 213 G4ThreeVector(), //at (0,0,0) 215 G4ThreeVector(), //at (0,0,0) 214 "World", //its name 216 "World", //its name 215 logicWorld, //its logical volume 217 logicWorld, //its logical volume 216 0, //its mother volume 218 0, //its mother volume 217 false, //no boolean operation 219 false, //no boolean operation 218 0); //copy number 220 0); //copy number 219 221 220 //detector 222 //detector 221 223 222 solidHPGe = 0; physiHPGe = 0; logicHPGe=0; 224 solidHPGe = 0; physiHPGe = 0; logicHPGe=0; 223 solidPixel=0; logicPixel=0; physiPixel=0; 225 solidPixel=0; logicPixel=0; physiPixel=0; 224 226 225 if (DeviceThickness > 0.) 227 if (DeviceThickness > 0.) 226 { 228 { 227 solidHPGe = new G4Box("HPGeDetector", 229 solidHPGe = new G4Box("HPGeDetector", //its name 228 DeviceSizeX/2,DeviceSizeY/2,DeviceTh 230 DeviceSizeX/2,DeviceSizeY/2,DeviceThickness/2);//size 229 231 230 232 231 logicHPGe = new G4LogicalVolume(solidHPG 233 logicHPGe = new G4LogicalVolume(solidHPGe, //its solid 232 defaultMaterial, //its material 234 defaultMaterial, //its material 233 "HPGeDetector"); //its name 235 "HPGeDetector"); //its name 234 236 235 zRotPhiHPGe.rotateX(PhiHPGe); 237 zRotPhiHPGe.rotateX(PhiHPGe); 236 G4double x,y,z; 238 G4double x,y,z; 237 239 238 z = -1. * DistDe; //* std::cos(ThetaHPGe 240 z = -1. * DistDe; //* std::cos(ThetaHPGe); 239 y = 0.*cm; //distScreen * std::sin(Theta 241 y = 0.*cm; //distScreen * std::sin(ThetaHPGe); 240 x = 0.*cm; 242 x = 0.*cm; 241 243 242 physiHPGe = new G4PVPlacement(G4Transfor 244 physiHPGe = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)), 243 "HPGeDetector", //its name 245 "HPGeDetector", //its name 244 logicHPGe, //its logical volume 246 logicHPGe, //its logical volume 245 physiWorld, //its mother volume 247 physiWorld, //its mother volume 246 false, //no boolean operation 248 false, //no boolean operation 247 0); //copy number 249 0); //copy number 248 } 250 } 249 // Pixel 251 // Pixel 250 252 251 253 252 254 253 255 254 for ( G4int j=0; j < NbOfPixelColumns ; j++ 256 for ( G4int j=0; j < NbOfPixelColumns ; j++ ) 255 { for ( G4int i=0; i < NbOfPixelRows ; i++ 257 { for ( G4int i=0; i < NbOfPixelRows ; i++ ) 256 { 258 { 257 solidPixel=0; logicPixel=0; physiPixel=0; 259 solidPixel=0; logicPixel=0; physiPixel=0; 258 if (PixelThickness > 0.) 260 if (PixelThickness > 0.) 259 solidPixel = new G4Box("Pixel", 261 solidPixel = new G4Box("Pixel", 260 PixelSizeXY/2,PixelSizeXY/2, PixelThi 262 PixelSizeXY/2,PixelSizeXY/2, PixelThickness/2); 261 263 262 logicPixel = new G4LogicalVolume(solidPixel, 264 logicPixel = new G4LogicalVolume(solidPixel, 263 pixelMaterial, //its material 265 pixelMaterial, //its material 264 "Pixel"); //its name 266 "Pixel"); //its name 265 267 266 /* 268 /* 267 zRotPhiHPGe.rotateX(PhiHPGe); 269 zRotPhiHPGe.rotateX(PhiHPGe); 268 G4double x,y,z; 270 G4double x,y,z; 269 z = DistDe * std::cos(ThetaHPGe); 271 z = DistDe * std::cos(ThetaHPGe); 270 y =DistDe * std::sin(ThetaHPGe); 272 y =DistDe * std::sin(ThetaHPGe); 271 x = 0.*cm;*/ 273 x = 0.*cm;*/ 272 physiPixel = new G4PVPlacement(0, 274 physiPixel = new G4PVPlacement(0, 273 G4ThreeVector(0, 275 G4ThreeVector(0, 274 i*PixelSizeXY, 276 i*PixelSizeXY, 275 j*PixelSizeXY ), 277 j*PixelSizeXY ), 276 "Pixel", 278 "Pixel", 277 logicPixel, //its logical vol 279 logicPixel, //its logical volume 278 physiHPGe, //its mother volume 280 physiHPGe, //its mother volume 279 false, //no boolean operation 281 false, //no boolean operation 280 PixelCopyNb);//copy number 282 PixelCopyNb);//copy number 281 283 282 284 283 285 284 286 285 287 286 288 287 // OhmicNeg 289 // OhmicNeg 288 290 289 solidOhmicNeg=0; logicOhmicNeg=0; physiOhmic 291 solidOhmicNeg=0; logicOhmicNeg=0; physiOhmicNeg=0; 290 292 291 if (OhmicNegThickness > 0.) 293 if (OhmicNegThickness > 0.) 292 { solidOhmicNeg = new G4Box("OhmicNeg", 294 { solidOhmicNeg = new G4Box("OhmicNeg", //its name 293 PixelSizeXY/2,PixelSizeXY/2,Ohmi 295 PixelSizeXY/2,PixelSizeXY/2,OhmicNegThickness/2); 294 296 295 logicOhmicNeg = new G4LogicalVolume(solidO 297 logicOhmicNeg = new G4LogicalVolume(solidOhmicNeg, //its solid 296 OhmicNegMaterial, //its materi 298 OhmicNegMaterial, //its material 297 "OhmicNeg"); //its name 299 "OhmicNeg"); //its name 298 300 299 physiOhmicNeg = new G4PVPlacement(0, 301 physiOhmicNeg = new G4PVPlacement(0, 300 G4ThreeVector 302 G4ThreeVector 301 (0., 303 (0., 302 0., 304 0., 303 (PixelThickness+OhmicNegThickn 305 (PixelThickness+OhmicNegThickness)/2), 304 "OhmicNeg", //its name 306 "OhmicNeg", //its name 305 logicOhmicNeg, //its logical 307 logicOhmicNeg, //its logical volume 306 physiHPGe, //its mother 308 physiHPGe, //its mother 307 false, //no boulean 309 false, //no boulean operat 308 PixelCopyNb); //c 310 PixelCopyNb); //copy number 309 311 310 } 312 } 311 // OhmicPos 313 // OhmicPos 312 solidOhmicPos=0; logicOhmicPos=0; physiOhmic 314 solidOhmicPos=0; logicOhmicPos=0; physiOhmicPos=0; 313 315 314 if (OhmicPosThickness > 0.) 316 if (OhmicPosThickness > 0.) 315 { solidOhmicPos = new G4Box("OhmicPos", 317 { solidOhmicPos = new G4Box("OhmicPos", //its name 316 PixelSizeXY/2,PixelSizeXY/2,Ohmi 318 PixelSizeXY/2,PixelSizeXY/2,OhmicPosThickness/2); 317 319 318 logicOhmicPos = new G4LogicalVolume(solidO 320 logicOhmicPos = new G4LogicalVolume(solidOhmicPos, //its solid 319 OhmicPosMaterial, //its materi 321 OhmicPosMaterial, //its material 320 "OhmicPos"); //its name 322 "OhmicPos"); //its name 321 323 322 physiOhmicPos = new G4PVPlacement(0, 324 physiOhmicPos = new G4PVPlacement(0, 323 G4ThreeVector(0., 325 G4ThreeVector(0., 324 0., 326 0., 325 (-PixelThickness-OhmicPosThick 327 (-PixelThickness-OhmicPosThickness)/2), 326 "OhmicPos", 328 "OhmicPos", 327 logicOhmicPos, 329 logicOhmicPos, 328 physiHPGe, 330 physiHPGe, 329 false, 331 false, 330 PixelCopyNb); 332 PixelCopyNb); 331 333 332 } 334 } 333 335 334 PixelCopyNb += PixelCopyNb; 336 PixelCopyNb += PixelCopyNb; 335 G4cout << "PixelCopyNb: " << PixelCopyNb << 337 G4cout << "PixelCopyNb: " << PixelCopyNb << G4endl; 336 } 338 } 337 339 338 } 340 } 339 341 340 // Screen 342 // Screen 341 343 342 if (DeviceThickness > 0.) 344 if (DeviceThickness > 0.) 343 { 345 { 344 solidScreen = new G4Box("DetectorScreen" 346 solidScreen = new G4Box("DetectorScreen", //its name 345 screenSizeXY/2,screenSizeXY/2,screen 347 screenSizeXY/2,screenSizeXY/2,screenThickness/2);//size 346 348 347 349 348 logicScreen = new G4LogicalVolume(solidS 350 logicScreen = new G4LogicalVolume(solidScreen, //its solid 349 defaultMaterial, //its material 351 defaultMaterial, //its material 350 "DetectorScreen"); //its name 352 "DetectorScreen"); //its name 351 353 352 //zRotPhiHPGe.rotateX(PhiHPGe); 354 //zRotPhiHPGe.rotateX(PhiHPGe); 353 G4double x,y,z; 355 G4double x,y,z; 354 G4cout << "distScreen: "<< distScreen/m 356 G4cout << "distScreen: "<< distScreen/m <<G4endl; 355 z = -1 * distScreen; //* std::cos(ThetaH 357 z = -1 * distScreen; //* std::cos(ThetaHPGe); 356 y = 0.*cm; //distScreen * std::sin(Theta 358 y = 0.*cm; //distScreen * std::sin(ThetaHPGe); 357 x = 0.*cm; 359 x = 0.*cm; 358 physiScreen = new G4PVPlacement(G4Transf 360 physiScreen = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)), 359 "DetectorScreen", //its name 361 "DetectorScreen", //its name 360 logicScreen, //its logical volume 362 logicScreen, //its logical volume 361 physiWorld, //its mother volume 363 physiWorld, //its mother volume 362 false, //no boolean operation 364 false, //no boolean operation 363 0); //copy number 365 0); //copy number 364 } 366 } 365 367 366 //Plane 368 //Plane 367 369 368 if (planeGranularity) { 370 if (planeGranularity) { 369 371 370 solidPlane=0; logicPlane=0; physiPlane=0 372 solidPlane=0; logicPlane=0; physiPlane=0; 371 if (planeThickness > 0.) 373 if (planeThickness > 0.) 372 { 374 { 373 solidPlane = new G4Box("Plane", //its name 375 solidPlane = new G4Box("Plane", //its name 374 planeSizeXY/2,planeSizeXY/2,planeThick 376 planeSizeXY/2,planeSizeXY/2,planeThickness/2);//size 375 377 376 logicPlane= new G4LogicalVolume(solidPlane, 378 logicPlane= new G4LogicalVolume(solidPlane, //its solid 377 defaultMaterial, //its material 379 defaultMaterial, //its material 378 "Plane"); //its name 380 "Plane"); //its name 379 381 380 physiPlane = new G4PVPlacement(0, //no r 382 physiPlane = new G4PVPlacement(0, //no rotation 381 G4ThreeVector(), //at (0,0,0) 383 G4ThreeVector(), //at (0,0,0) 382 "Plane", //its name 384 "Plane", //its name 383 logicPlane, //its logical volume 385 logicPlane, //its logical volume 384 physiWorld, //its mother volume 386 physiWorld, //its mother volume 385 false, //no boolean operation 387 false, //no boolean operation 386 0); //copy number 388 0); //copy number 387 389 388 } 390 } 389 391 390 392 391 393 392 394 393 G4int nbOfGrainsX = ((G4int)(planeSizeXY/g 395 G4int nbOfGrainsX = ((G4int)(planeSizeXY/grainDia)) -1 ; 394 396 395 // y dim of a max density plane is 2rn-(n- 397 // y dim of a max density plane is 2rn-(n-1)ar, wehere a = (1-(std::sqrt(3)/2)), n is 396 // number of rows and r the radius of the 398 // number of rows and r the radius of the grain. so the Y-dim of the plane must 397 // be greater or equal to this. It results 399 // be greater or equal to this. It results that nmust be <= (PlaneY-a)/(1-a). 398 // Max Y shift of the planes superimposing 400 // Max Y shift of the planes superimposing along Z axis is minor (2/std::sqrt(3)r) 399 401 400 G4double a = (1.-(std::sqrt(3.)/2.)); 402 G4double a = (1.-(std::sqrt(3.)/2.)); 401 G4int nbOfGrainsY = (G4int) ( ((planeSize 403 G4int nbOfGrainsY = (G4int) ( ((planeSizeXY/(grainDia/2.)) -a)/(2.-a) ) -1; 402 404 403 // same for the z axis, but a = 2 * (std:: 405 // same for the z axis, but a = 2 * (std::sqrt(3) - std::sqrt(2))/std::sqrt(3) 404 406 405 G4double b = 2. * (std::sqrt(3.) - std::sq 407 G4double b = 2. * (std::sqrt(3.) - std::sqrt(2.))/std::sqrt(3.); 406 G4int nbOfGrainsZ = (G4int) ( ((planeThic 408 G4int nbOfGrainsZ = (G4int) ( ((planeThickness/(grainDia/2.)) -b)/(2.-b) )-1; 407 409 408 if (planeThickness > 0.){ 410 if (planeThickness > 0.){ 409 411 410 solidGrain=0; logicGrain=0; physiGrain=0 412 solidGrain=0; logicGrain=0; physiGrain=0; 411 solidGrain = new G4Sphere("Grain",0., 413 solidGrain = new G4Sphere("Grain",0., 412 grainDia/2,0., twopi, 0., pi); 414 grainDia/2,0., twopi, 0., pi); 413 415 414 logicGrain = new G4LogicalVolume(solidGr 416 logicGrain = new G4LogicalVolume(solidGrain, 415 planeMaterial, //its material 417 planeMaterial, //its material 416 "Grain"); //its name 418 "Grain"); //its name 417 G4ThreeVector grainPosition; 419 G4ThreeVector grainPosition; 418 G4double grainInitPositionX = 0; 420 G4double grainInitPositionX = 0; 419 G4double grainInitPositionY = 0; 421 G4double grainInitPositionY = 0; 420 G4double grainInitPositionZ = (-1.*plane 422 G4double grainInitPositionZ = (-1.*planeThickness/2.+grainDia/2.); 421 G4double grainStepX = grainDia = 0; 423 G4double grainStepX = grainDia = 0; 422 G4double grainStepY = grainDia*(1.-(0.5- 424 G4double grainStepY = grainDia*(1.-(0.5-(std::sqrt(3.)/4.))); 423 G4double grainStepZ = grainDia*std::sqrt 425 G4double grainStepZ = grainDia*std::sqrt(2./3.); 424 426 425 for ( G4int k=0; k < nbOfGrainsZ ; k++ ) 427 for ( G4int k=0; k < nbOfGrainsZ ; k++ ) { 426 for ( G4int j=0; j < nbOfGrainsY ; j++ ) { 428 for ( G4int j=0; j < nbOfGrainsY ; j++ ) { 427 for ( G4int i=0; i < nbOfGrainsX ; i++ ) { 429 for ( G4int i=0; i < nbOfGrainsX ; i++ ) { 428 430 429 // Now we identify the layer and the row 431 // Now we identify the layer and the row where the grain is , to place it in the right position 430 432 431 433 432 434 433 if (k%3 == 0) { // first or (4-multiple) 435 if (k%3 == 0) { // first or (4-multiple)th layer: structure is ABCABC 434 grainInitPositionY = (-1.*planeSizeXY/ 436 grainInitPositionY = (-1.*planeSizeXY/2.+grainDia/2.); 435 if (j%2 ==0) { //first or (3-multiple) 437 if (j%2 ==0) { //first or (3-multiple)th row 436 grainInitPositionX = (-1.*planeSizeXY/2.+g 438 grainInitPositionX = (-1.*planeSizeXY/2.+grainDia/2.); 437 } 439 } 438 440 439 else if ( ((j+1) % 2) == 0 ) { 441 else if ( ((j+1) % 2) == 0 ) { 440 grainInitPositionX = (-1.*planeSizeXY/2.+ 442 grainInitPositionX = (-1.*planeSizeXY/2.+ grainDia); 441 } 443 } 442 444 443 } 445 } 444 else if ( ((k+2) % 3) == 0 ) { // B-laye 446 else if ( ((k+2) % 3) == 0 ) { // B-layer 445 447 446 grainInitPositionY = ( (-1.*planeSizeX 448 grainInitPositionY = ( (-1.*planeSizeXY/2.) + (grainDia/2.)*(1. + (1./std::sqrt(3.)) ) ); 447 449 448 if (j%2 ==0) { //first or (3-multiple) 450 if (j%2 ==0) { //first or (3-multiple)th row 449 grainInitPositionX = (-1.*planeSizeXY/2.+g 451 grainInitPositionX = (-1.*planeSizeXY/2.+grainDia); 450 } 452 } 451 453 452 else if ( (j+1)%2 == 0 ) { 454 else if ( (j+1)%2 == 0 ) { 453 grainInitPositionX = (-1.*planeSizeXY/2.+g 455 grainInitPositionX = (-1.*planeSizeXY/2.+grainDia/2); 454 } 456 } 455 457 456 } 458 } 457 459 458 else if ( (k+1)%3 == 0 ) { // B-layer 460 else if ( (k+1)%3 == 0 ) { // B-layer 459 461 460 grainInitPositionY = (-1.*planeSizeXY/ 462 grainInitPositionY = (-1.*planeSizeXY/2.+(grainDia/2.)*(1.+2./std::sqrt(3.)) ); 461 463 462 if (j%2 ==0) { //first or (3-multiple) 464 if (j%2 ==0) { //first or (3-multiple)th row 463 grainInitPositionX = (-1.*planeSizeXY/2.+g 465 grainInitPositionX = (-1.*planeSizeXY/2.+grainDia/2.); 464 } 466 } 465 467 466 else if ( (j+1)%2 == 0 ) { 468 else if ( (j+1)%2 == 0 ) { 467 grainInitPositionX = (-1.*planeSizeXY/2.+g 469 grainInitPositionX = (-1.*planeSizeXY/2.+grainDia); 468 } 470 } 469 471 470 } 472 } 471 473 472 physiGrain = new G4PVPlacement(0, 474 physiGrain = new G4PVPlacement(0, 473 G4ThreeVector( grainInitPositionX 475 G4ThreeVector( grainInitPositionX + i*grainStepX, 474 grainInitPositionY + j*grainSt 476 grainInitPositionY + j*grainStepY, 475 grainInitPositionZ + k*grainSt 477 grainInitPositionZ + k*grainStepZ), 476 "Grain", 478 "Grain", 477 logicGrain, //its logical volum 479 logicGrain, //its logical volume 478 physiPlane, //its mother volume 480 physiPlane, //its mother volume 479 false, //no boolean operation 481 false, //no boolean operation 480 grainCopyNb);//copy number 482 grainCopyNb);//copy number 481 483 482 grainCopyNb = grainCopyNb +1; 484 grainCopyNb = grainCopyNb +1; 483 } 485 } 484 } 486 } 485 } 487 } 486 } 488 } 487 } 489 } 488 else { 490 else { 489 491 490 solidPlane=0; logicPlane=0; physiPlane=0 492 solidPlane=0; logicPlane=0; physiPlane=0; 491 if (planeThickness > 0.) 493 if (planeThickness > 0.) 492 { 494 { 493 solidPlane = new G4Box("Plane", //its name 495 solidPlane = new G4Box("Plane", //its name 494 planeSizeXY/2,planeSizeXY/2,planeThick 496 planeSizeXY/2,planeSizeXY/2,planeThickness/2);//size 495 497 496 logicPlane= new G4LogicalVolume(solidPlane, 498 logicPlane= new G4LogicalVolume(solidPlane, //its solid 497 planeMaterial, //its material 499 planeMaterial, //its material 498 "Plane"); //its name 500 "Plane"); //its name 499 501 500 physiPlane = new G4PVPlacement(0, //no r 502 physiPlane = new G4PVPlacement(0, //no rotation 501 G4ThreeVector(), //at (0,0,0) 503 G4ThreeVector(), //at (0,0,0) 502 "Plane", //its name 504 "Plane", //its name 503 logicPlane, //its logical volume 505 logicPlane, //its logical volume 504 physiWorld, //its mother volume 506 physiWorld, //its mother volume 505 false, //no boolean operation 507 false, //no boolean operation 506 0); //copy number 508 0); //copy number 507 509 508 } 510 } 509 } 511 } 510 512 511 // Visualization attributes 513 // Visualization attributes 512 514 513 logicWorld->SetVisAttributes (G4VisAttribute 515 logicWorld->SetVisAttributes (G4VisAttributes::GetInvisible()); 514 G4VisAttributes* simpleBoxVisAtt= new G4Vis 516 G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); 515 G4VisAttributes * yellow= new G4VisAttribut 517 G4VisAttributes * yellow= new G4VisAttributes( G4Colour(255/255. ,255/255. ,51/255. )); 516 G4VisAttributes * red= new G4VisAttributes( 518 G4VisAttributes * red= new G4VisAttributes( G4Colour(255/255. , 0/255. , 0/255. )); 517 G4VisAttributes * blue= new G4VisAttributes 519 G4VisAttributes * blue= new G4VisAttributes( G4Colour(0/255. , 0/255. , 255/255. )); 518 G4VisAttributes * grayc= new G4VisAttribute 520 G4VisAttributes * grayc= new G4VisAttributes( G4Colour(128/255. , 128/255. , 128/255. )); 519 G4VisAttributes * lightGray= new G4VisAttri 521 G4VisAttributes * lightGray= new G4VisAttributes( G4Colour(178/255. , 178/255. , 178/255. )); 520 yellow->SetVisibility(true); 522 yellow->SetVisibility(true); 521 yellow->SetForceSolid(true); 523 yellow->SetForceSolid(true); 522 red->SetVisibility(true); 524 red->SetVisibility(true); 523 red->SetForceSolid(true); 525 red->SetForceSolid(true); 524 blue->SetVisibility(true); 526 blue->SetVisibility(true); 525 grayc->SetVisibility(true); 527 grayc->SetVisibility(true); 526 grayc->SetForceSolid(true); 528 grayc->SetForceSolid(true); 527 lightGray->SetVisibility(true); 529 lightGray->SetVisibility(true); 528 lightGray->SetForceSolid(true); 530 lightGray->SetForceSolid(true); 529 simpleBoxVisAtt->SetVisibility(true); 531 simpleBoxVisAtt->SetVisibility(true); 530 532 531 logicPixel->SetVisAttributes(red); //modifie 533 logicPixel->SetVisAttributes(red); //modified!!! 532 logicHPGe->SetVisAttributes(blue); 534 logicHPGe->SetVisAttributes(blue); 533 535 534 logicPlane->SetVisAttributes(lightGray); 536 logicPlane->SetVisAttributes(lightGray); 535 537 536 538 537 logicScreen->SetVisAttributes(grayc); 539 logicScreen->SetVisAttributes(grayc); 538 logicOhmicNeg->SetVisAttributes(yellow); 540 logicOhmicNeg->SetVisAttributes(yellow); 539 logicOhmicPos->SetVisAttributes(yellow); 541 logicOhmicPos->SetVisAttributes(yellow); 540 542 541 543 542 544 543 if (planeGranularity) logicGrain->SetVisAtt 545 if (planeGranularity) logicGrain->SetVisAttributes(grayc); 544 546 545 //always return the physical World 547 //always return the physical World 546 548 547 PrintApparateParameters(); 549 PrintApparateParameters(); 548 550 549 return physiWorld; 551 return physiWorld; 550 } 552 } 551 553 552 //....oooOO0OOooo........oooOO0OOooo........oo 554 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo... 553 555 554 void XrayFluoPlaneDetectorConstruction::Constr 556 void XrayFluoPlaneDetectorConstruction::ConstructSDandField() 555 { 557 { 556 // 558 // 557 // Sensitive Detectors 559 // Sensitive Detectors 558 // 560 // 559 if (HPGeSD.Get() == 0) 561 if (HPGeSD.Get() == 0) 560 { 562 { 561 XrayFluoSD* SD = new XrayFluoSD ("HPGeSD 563 XrayFluoSD* SD = new XrayFluoSD ("HPGeSD",this); 562 HPGeSD.Put( SD ); 564 HPGeSD.Put( SD ); 563 } 565 } 564 G4SDManager::GetSDMpointer()->AddNewDetector 566 G4SDManager::GetSDMpointer()->AddNewDetector(HPGeSD.Get()); 565 if (logicPixel) 567 if (logicPixel) 566 SetSensitiveDetector(logicPixel,HPGeSD.Get 568 SetSensitiveDetector(logicPixel,HPGeSD.Get()); 567 } 569 } 568 570 569 //....oooOO0OOooo........oooOO0OOooo........oo 571 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 570 572 571 void XrayFluoPlaneDetectorConstruction::PrintA 573 void XrayFluoPlaneDetectorConstruction::PrintApparateParameters() 572 { 574 { 573 G4cout << "--------------------------------- 575 G4cout << "-----------------------------------------------------------------------" 574 << G4endl 576 << G4endl 575 << "The plane is a box whose size is: " 577 << "The plane is a box whose size is: " 576 << G4endl 578 << G4endl 577 << planeThickness/cm 579 << planeThickness/cm 578 << " cm * " 580 << " cm * " 579 << planeSizeXY/cm 581 << planeSizeXY/cm 580 << " cm * " 582 << " cm * " 581 << planeSizeXY/cm 583 << planeSizeXY/cm 582 << " cm" 584 << " cm" 583 << G4endl 585 << G4endl 584 <<" Material: " << logicPlane->GetMaterial( 586 <<" Material: " << logicPlane->GetMaterial()->GetName() 585 <<G4endl 587 <<G4endl 586 <<"The Detector is a slice " << DeviceThi 588 <<"The Detector is a slice " << DeviceThickness/(1.e-6*m) << " micron thick of " << pixelMaterial->GetName() 587 <<G4endl 589 <<G4endl 588 590 589 591 590 <<"------------------------------------------- 592 <<"-------------------------------------------------------------------------" 591 << G4endl; 593 << G4endl; 592 } 594 } 593 //....oooOO0OOooo........oooOO0OOooo........oo 595 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 594 596 595 void XrayFluoPlaneDetectorConstruction::Update 597 void XrayFluoPlaneDetectorConstruction::UpdateGeometry() 596 { 598 { 597 G4GeometryManager::GetInstance()->OpenGeomet 599 G4GeometryManager::GetInstance()->OpenGeometry(); 598 G4PhysicalVolumeStore::Clean(); 600 G4PhysicalVolumeStore::Clean(); 599 G4LogicalVolumeStore::Clean(); 601 G4LogicalVolumeStore::Clean(); 600 G4SolidStore::Clean(); 602 G4SolidStore::Clean(); 601 603 602 zRotPhiHPGe.rotateX(-1.*PhiHPGe); 604 zRotPhiHPGe.rotateX(-1.*PhiHPGe); 603 //Triggers a new call of Construct() and of 605 //Triggers a new call of Construct() and of all the geometry resets. 604 G4RunManager::GetRunManager()->ReinitializeG 606 G4RunManager::GetRunManager()->ReinitializeGeometry(); 605 } 607 } 606 608 607 //....oooOO0OOooo........oooOO0OOooo........oo 609 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 608 610 609 void XrayFluoPlaneDetectorConstruction::Delete 611 void XrayFluoPlaneDetectorConstruction::DeleteGrainObjects() 610 { 612 { 611 if (planeGranularity) { 613 if (planeGranularity) { 612 delete solidGrain; 614 delete solidGrain; 613 delete logicGrain; 615 delete logicGrain; 614 delete physiGrain; 616 delete physiGrain; 615 } 617 } 616 618 617 } 619 } 618 620 619 //....oooOO0OOooo........oooOO0OOooo........oo 621 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 620 622 621 void XrayFluoPlaneDetectorConstruction::SetPla 623 void XrayFluoPlaneDetectorConstruction::SetPlaneMaterial(G4String newMaterial) 622 { 624 { 623 //G4cout << "Material!!!!" << newMaterial << 625 //G4cout << "Material!!!!" << newMaterial << G4endl; 624 logicPlane->SetMaterial(materials->GetMateri 626 logicPlane->SetMaterial(materials->GetMaterial(newMaterial)); 625 PrintApparateParameters(); 627 PrintApparateParameters(); 626 //GeometryHasBeenModified is called by the m 628 //GeometryHasBeenModified is called by the messenger 627 629 628 } 630 } 629 631 630 //....oooOO0OOooo........oooOO0OOooo........oo 632 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 631 633 632 634 633 635 634 636 635 637 636 638 637 639 638 640 639 641 640 642 641 643 642 644 643 645