[807] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // |
---|
| 27 | // $Id: XrayFluoDetectorConstruction.cc |
---|
| 28 | // GEANT4 tag $Name: xray_fluo-V03-02-00 |
---|
| 29 | // |
---|
| 30 | // Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it) |
---|
| 31 | // |
---|
| 32 | // History: |
---|
| 33 | // ----------- |
---|
| 34 | // 28 Nov 2001 Elena Guardincerri Created |
---|
| 35 | // Nov 2002 Alfonso Mantero materials added, |
---|
| 36 | // Material selection implementation |
---|
| 37 | // 16 Jul 2003 Alfonso Mantero Detector type selection added + minor fixes |
---|
| 38 | // ------------------------------------------------------------------- |
---|
| 39 | |
---|
| 40 | #include "XrayFluoDetectorConstruction.hh" |
---|
| 41 | #include "XrayFluoDetectorMessenger.hh" |
---|
| 42 | #include "XrayFluoSD.hh" |
---|
| 43 | #include "G4Material.hh" |
---|
| 44 | #include "G4ThreeVector.hh" |
---|
| 45 | #include "G4Box.hh" |
---|
| 46 | #include "G4Sphere.hh" |
---|
| 47 | #include "G4Tubs.hh" |
---|
| 48 | #include "G4LogicalVolume.hh" |
---|
| 49 | #include "G4PVPlacement.hh" |
---|
| 50 | #include "G4TransportationManager.hh" |
---|
| 51 | #include "G4SDManager.hh" |
---|
| 52 | #include "G4RunManager.hh" |
---|
| 53 | #include "G4VisAttributes.hh" |
---|
| 54 | #include "G4Colour.hh" |
---|
| 55 | #include "G4ios.hh" |
---|
| 56 | #include "G4PVReplica.hh" |
---|
| 57 | #include "G4UserLimits.hh" |
---|
| 58 | #include "XrayFluoNistMaterials.hh" |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | #include "G4Region.hh" |
---|
| 62 | #include "G4RegionStore.hh" |
---|
| 63 | |
---|
| 64 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | XrayFluoDetectorConstruction::XrayFluoDetectorConstruction() |
---|
| 68 | : detectorType(0),sampleGranularity(false), phaseSpaceFlag(false), |
---|
| 69 | DeviceSizeX(0), DeviceSizeY(0),DeviceThickness(0), |
---|
| 70 | solidWorld(0),logicWorld(0),physiWorld(0), |
---|
| 71 | solidHPGe(0),logicHPGe(0),physiHPGe(0), |
---|
| 72 | solidSample (0),logicSample(0),physiSample (0), |
---|
| 73 | solidDia1(0),logicDia1(0),physiDia1(0), |
---|
| 74 | solidDia3(0),logicDia3(0),physiDia3(0), |
---|
| 75 | solidOhmicPos(0),logicOhmicPos(0), physiOhmicPos(0), |
---|
| 76 | solidOhmicNeg(0),logicOhmicNeg(0), physiOhmicNeg(0), |
---|
| 77 | solidPixel(0),logicPixel(0), physiPixel(0), |
---|
| 78 | OhmicPosMaterial(0), OhmicNegMaterial(0), |
---|
| 79 | pixelMaterial(0),sampleMaterial(0), |
---|
| 80 | Dia1Material(0),Dia3Material(0), |
---|
| 81 | defaultMaterial(0),HPGeSD(0) |
---|
| 82 | |
---|
| 83 | { |
---|
| 84 | materials = XrayFluoNistMaterials::GetInstance(); |
---|
| 85 | |
---|
| 86 | DefineDefaultMaterials(); |
---|
| 87 | |
---|
| 88 | NbOfPixelRows = 1; // should be 1 |
---|
| 89 | NbOfPixelColumns = 1; // should be 1 |
---|
| 90 | NbOfPixels = NbOfPixelRows*NbOfPixelColumns; |
---|
| 91 | PixelSizeXY = std::sqrt(40.) * mm; // should be std::sqrt(40) * mm |
---|
| 92 | PixelThickness = 3.5 * mm; //should be 3.5 mm |
---|
| 93 | |
---|
| 94 | G4cout << "PixelThickness(mm): "<< PixelThickness/mm << G4endl; |
---|
| 95 | G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/cm << G4endl; |
---|
| 96 | |
---|
| 97 | ContactSizeXY = std::sqrt(40.) * mm; //std::sqrt(40) * mm; //should be the same as PixelSizeXY |
---|
| 98 | SampleThickness = 4 * mm; |
---|
| 99 | SampleSizeXY = 3. * cm; |
---|
| 100 | Dia1Thickness = 1. *mm; |
---|
| 101 | Dia3Thickness = 1. *mm; |
---|
| 102 | Dia1SizeXY = 3. *cm; |
---|
| 103 | Dia3SizeXY = 3. *cm; |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | DiaInnerSize = 1.0 * mm; //(Hole in the detector's diaphragm) |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | OhmicNegThickness = 0.005*mm;// 0.005 |
---|
| 110 | OhmicPosThickness = 0.005*mm;// 0.005 |
---|
| 111 | ThetaHPGe = 135. * deg; |
---|
| 112 | PhiHPGe = 225. * deg; |
---|
| 113 | |
---|
| 114 | ThetaDia1 = 135. * deg; |
---|
| 115 | PhiDia1 = 90. * deg; |
---|
| 116 | AlphaDia1 = 225. * deg; |
---|
| 117 | |
---|
| 118 | AlphaDia3 = 180. * deg; |
---|
| 119 | Dia3Dist = 66.5 * mm; |
---|
| 120 | Dia3InnerSize = 1. * mm; |
---|
| 121 | ThetaDia3 = 180. * deg; |
---|
| 122 | PhiDia3 = 90. * deg; |
---|
| 123 | |
---|
| 124 | DistDia = 66.5 * mm; |
---|
| 125 | DistDe =DistDia+ (Dia1Thickness |
---|
| 126 | +PixelThickness)/2+OhmicPosThickness ; |
---|
| 127 | |
---|
| 128 | grainDia = 1 * mm; |
---|
| 129 | PixelCopyNb=0; |
---|
| 130 | grainCopyNb=0; |
---|
| 131 | G4String defaultDetectorType = "sili"; |
---|
| 132 | ComputeApparateParameters(); |
---|
| 133 | |
---|
| 134 | G4String regName = "SampleRegion"; |
---|
| 135 | sampleRegion = new G4Region(regName); |
---|
| 136 | |
---|
| 137 | if (!phaseSpaceFlag) SetDetectorType(defaultDetectorType); |
---|
| 138 | |
---|
| 139 | // create commands for interactive definition of the apparate |
---|
| 140 | |
---|
| 141 | detectorMessenger = new XrayFluoDetectorMessenger(this); |
---|
| 142 | |
---|
| 143 | G4cout << "XrayFluoDetectorConstruction created" << G4endl; |
---|
| 144 | } |
---|
| 145 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | XrayFluoDetectorConstruction* XrayFluoDetectorConstruction::instance = 0; |
---|
| 149 | |
---|
| 150 | XrayFluoDetectorConstruction* XrayFluoDetectorConstruction::GetInstance() |
---|
| 151 | { |
---|
| 152 | if (instance == 0) |
---|
| 153 | { |
---|
| 154 | instance = new XrayFluoDetectorConstruction; |
---|
| 155 | |
---|
| 156 | } |
---|
| 157 | return instance; |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | void XrayFluoDetectorConstruction::SetDetectorType(G4String type) |
---|
| 161 | { |
---|
| 162 | |
---|
| 163 | if (type=="sili") |
---|
| 164 | { |
---|
| 165 | detectorType = XrayFluoSiLiDetectorType::GetInstance(); |
---|
| 166 | } |
---|
| 167 | else if (type=="hpge") |
---|
| 168 | { |
---|
| 169 | detectorType = XrayFluoHPGeDetectorType::GetInstance(); |
---|
| 170 | } |
---|
| 171 | else |
---|
| 172 | { |
---|
| 173 | G4String excep = type + "detector type unknown"; |
---|
| 174 | G4Exception(excep); |
---|
| 175 | } |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | XrayFluoVDetectorType* XrayFluoDetectorConstruction::GetDetectorType() |
---|
| 179 | { |
---|
| 180 | return detectorType; |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 184 | |
---|
| 185 | XrayFluoDetectorConstruction::~XrayFluoDetectorConstruction() |
---|
| 186 | |
---|
| 187 | { |
---|
| 188 | delete detectorMessenger; |
---|
| 189 | delete detectorType; |
---|
| 190 | G4cout << "XrayFluoDetectorConstruction deleted" << G4endl; |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 194 | |
---|
| 195 | G4VPhysicalVolume* XrayFluoDetectorConstruction::Construct() |
---|
| 196 | { |
---|
| 197 | return ConstructApparate(); |
---|
| 198 | } |
---|
| 199 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 200 | |
---|
| 201 | void XrayFluoDetectorConstruction::DefineDefaultMaterials() |
---|
| 202 | { |
---|
| 203 | |
---|
| 204 | |
---|
| 205 | //define materials of the apparate |
---|
| 206 | |
---|
| 207 | sampleMaterial = materials->GetMaterial("Mars1"); |
---|
| 208 | Dia1Material = materials->GetMaterial("G4_Pb"); |
---|
| 209 | Dia3Material = materials->GetMaterial("Galactic"); |
---|
| 210 | pixelMaterial = materials->GetMaterial("G4_Si"); |
---|
| 211 | OhmicPosMaterial = materials->GetMaterial("G4_Cu"); |
---|
| 212 | OhmicNegMaterial = materials->GetMaterial("G4_Pb"); |
---|
| 213 | defaultMaterial = materials->GetMaterial("Galactic"); |
---|
| 214 | |
---|
| 215 | |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | void XrayFluoDetectorConstruction::SetOhmicPosThickness(G4double val) |
---|
| 219 | { |
---|
| 220 | |
---|
| 221 | if (!phaseSpaceFlag) { |
---|
| 222 | |
---|
| 223 | |
---|
| 224 | if (val == 0.0) { |
---|
| 225 | OhmicPosMaterial = materials->GetMaterial("Galactic"); |
---|
| 226 | } |
---|
| 227 | else { |
---|
| 228 | OhmicPosThickness = val; |
---|
| 229 | OhmicPosMaterial = materials->GetMaterial("Copper"); |
---|
| 230 | } |
---|
| 231 | |
---|
| 232 | } |
---|
| 233 | else{ |
---|
| 234 | G4cout << "Not available in this configuration" << G4cout; |
---|
| 235 | } |
---|
| 236 | |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | |
---|
| 240 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 241 | |
---|
| 242 | G4VPhysicalVolume* XrayFluoDetectorConstruction::ConstructApparate() |
---|
| 243 | { |
---|
| 244 | // complete the apparate parameters definition |
---|
| 245 | |
---|
| 246 | //ComputeApparateParameters(); |
---|
| 247 | |
---|
| 248 | //world |
---|
| 249 | |
---|
| 250 | solidWorld = new G4Box("World", //its name |
---|
| 251 | WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/2); //its size |
---|
| 252 | |
---|
| 253 | logicWorld = new G4LogicalVolume(solidWorld, //its solid |
---|
| 254 | defaultMaterial, //its material |
---|
| 255 | "World"); //its name |
---|
| 256 | physiWorld = new G4PVPlacement(0, //no rotation |
---|
| 257 | G4ThreeVector(), //at (0,0,0) |
---|
| 258 | "World", //its name |
---|
| 259 | logicWorld, //its logical volume |
---|
| 260 | 0, //its mother volume |
---|
| 261 | false, //no boolean operation |
---|
| 262 | 0); //copy number |
---|
| 263 | |
---|
| 264 | //HPGeDetector |
---|
| 265 | |
---|
| 266 | if (!phaseSpaceFlag) { |
---|
| 267 | |
---|
| 268 | solidHPGe = 0; physiHPGe = 0; logicHPGe=0; |
---|
| 269 | solidPixel=0; logicPixel=0; physiPixel=0; |
---|
| 270 | |
---|
| 271 | if (DeviceThickness > 0.) |
---|
| 272 | { |
---|
| 273 | solidHPGe = new G4Box("HPGeDetector", //its name |
---|
| 274 | DeviceSizeX/2,DeviceSizeY/2,DeviceThickness/2);//size |
---|
| 275 | |
---|
| 276 | |
---|
| 277 | logicHPGe = new G4LogicalVolume(solidHPGe, //its solid |
---|
| 278 | defaultMaterial, //its material |
---|
| 279 | "HPGeDetector"); //its name |
---|
| 280 | |
---|
| 281 | zRotPhiHPGe.rotateX(PhiHPGe); |
---|
| 282 | G4double x,y,z; |
---|
| 283 | z = DistDe * std::cos(ThetaHPGe); |
---|
| 284 | y =DistDe * std::sin(ThetaHPGe); |
---|
| 285 | x = 0.*cm; |
---|
| 286 | physiHPGe = new G4PVPlacement(G4Transform3D(zRotPhiHPGe,G4ThreeVector(x,y,z)), |
---|
| 287 | "HPGeDetector", //its name |
---|
| 288 | logicHPGe, //its logical volume |
---|
| 289 | physiWorld, //its mother volume |
---|
| 290 | false, //no boolean operation |
---|
| 291 | 0); //copy number |
---|
| 292 | } |
---|
| 293 | // Pixel |
---|
| 294 | |
---|
| 295 | |
---|
| 296 | |
---|
| 297 | |
---|
| 298 | for ( G4int j=0; j < NbOfPixelColumns ; j++ ) |
---|
| 299 | { for ( G4int i=0; i < NbOfPixelRows ; i++ ) |
---|
| 300 | { |
---|
| 301 | solidPixel=0; logicPixel=0; physiPixel=0; |
---|
| 302 | if (PixelThickness > 0.) |
---|
| 303 | solidPixel = new G4Box("Pixel", |
---|
| 304 | PixelSizeXY/2,PixelSizeXY/2, PixelThickness/2); |
---|
| 305 | |
---|
| 306 | logicPixel = new G4LogicalVolume(solidPixel, |
---|
| 307 | pixelMaterial, //its material |
---|
| 308 | "Pixel"); //its name |
---|
| 309 | |
---|
| 310 | /* |
---|
| 311 | zRotPhiHPGe.rotateX(PhiHPGe); |
---|
| 312 | G4double x,y,z; |
---|
| 313 | z = DistDe * std::cos(ThetaHPGe); |
---|
| 314 | y =DistDe * std::sin(ThetaHPGe); |
---|
| 315 | x = 0.*cm;*/ |
---|
| 316 | physiPixel = new G4PVPlacement(0, |
---|
| 317 | G4ThreeVector(0, |
---|
| 318 | i*PixelSizeXY, |
---|
| 319 | j*PixelSizeXY ), |
---|
| 320 | "Pixel", |
---|
| 321 | logicPixel, //its logical volume |
---|
| 322 | physiHPGe, //its mother volume |
---|
| 323 | false, //no boolean operation |
---|
| 324 | PixelCopyNb);//copy number |
---|
| 325 | |
---|
| 326 | |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | |
---|
| 330 | |
---|
| 331 | // OhmicNeg |
---|
| 332 | |
---|
| 333 | solidOhmicNeg=0; logicOhmicNeg=0; physiOhmicNeg=0; |
---|
| 334 | |
---|
| 335 | if (OhmicNegThickness > 0.) |
---|
| 336 | { solidOhmicNeg = new G4Box("OhmicNeg", //its name |
---|
| 337 | PixelSizeXY/2,PixelSizeXY/2,OhmicNegThickness/2); |
---|
| 338 | |
---|
| 339 | logicOhmicNeg = new G4LogicalVolume(solidOhmicNeg, //its solid |
---|
| 340 | OhmicNegMaterial, //its material |
---|
| 341 | "OhmicNeg"); //its name |
---|
| 342 | |
---|
| 343 | physiOhmicNeg = new G4PVPlacement(0, |
---|
| 344 | G4ThreeVector |
---|
| 345 | (0., |
---|
| 346 | 0., |
---|
| 347 | (PixelThickness+OhmicNegThickness)/2), |
---|
| 348 | "OhmicNeg", //its name |
---|
| 349 | logicOhmicNeg, //its logical volume |
---|
| 350 | physiHPGe, //its mother |
---|
| 351 | false, //no boulean operat |
---|
| 352 | PixelCopyNb); //copy number |
---|
| 353 | |
---|
| 354 | } |
---|
| 355 | // OhmicPos |
---|
| 356 | solidOhmicPos=0; logicOhmicPos=0; physiOhmicPos=0; |
---|
| 357 | |
---|
| 358 | if (OhmicPosThickness > 0.) |
---|
| 359 | { solidOhmicPos = new G4Box("OhmicPos", //its name |
---|
| 360 | PixelSizeXY/2,PixelSizeXY/2,OhmicPosThickness/2); |
---|
| 361 | |
---|
| 362 | logicOhmicPos = new G4LogicalVolume(solidOhmicPos, //its solid |
---|
| 363 | OhmicPosMaterial, //its material |
---|
| 364 | "OhmicPos"); //its name |
---|
| 365 | |
---|
| 366 | physiOhmicPos = new G4PVPlacement(0, |
---|
| 367 | G4ThreeVector(0., |
---|
| 368 | 0., |
---|
| 369 | (-PixelThickness-OhmicPosThickness)/2), |
---|
| 370 | "OhmicPos", |
---|
| 371 | logicOhmicPos, |
---|
| 372 | physiHPGe, |
---|
| 373 | false, |
---|
| 374 | PixelCopyNb); |
---|
| 375 | |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | PixelCopyNb += PixelCopyNb; |
---|
| 379 | G4cout << "PixelCopyNb: " << PixelCopyNb << G4endl; |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | } |
---|
| 383 | |
---|
| 384 | } |
---|
| 385 | |
---|
| 386 | //Sample |
---|
| 387 | |
---|
| 388 | if (sampleGranularity) { |
---|
| 389 | |
---|
| 390 | solidSample=0; logicSample=0; physiSample=0; |
---|
| 391 | if (SampleThickness > 0.) |
---|
| 392 | { |
---|
| 393 | solidSample = new G4Box("Sample", //its name |
---|
| 394 | SampleSizeXY/2,SampleSizeXY/2,SampleThickness/2);//size |
---|
| 395 | |
---|
| 396 | logicSample= new G4LogicalVolume(solidSample, //its solid |
---|
| 397 | defaultMaterial, //its material |
---|
| 398 | "Sample"); //its name |
---|
| 399 | |
---|
| 400 | physiSample = new G4PVPlacement(0, //no rotation |
---|
| 401 | G4ThreeVector(), //at (0,0,0) |
---|
| 402 | "Sample", //its name |
---|
| 403 | logicSample, //its logical volume |
---|
| 404 | physiWorld, //its mother volume |
---|
| 405 | false, //no boolean operation |
---|
| 406 | 0); //copy number |
---|
| 407 | |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | |
---|
| 411 | |
---|
| 412 | |
---|
| 413 | G4int nbOfGrainsX = ((G4int)(SampleSizeXY/grainDia)) -1 ; |
---|
| 414 | |
---|
| 415 | // y dim of a max density plane is 2rn-(n-1)ar, wehere a = (1-(std::sqrt(3)/2)), n is |
---|
| 416 | // number of rows and r the radius of the grain. so the Y-dim of the sample must |
---|
| 417 | // be greater or equal to this. It results that nmust be <= (SampleY-a)/(1-a). |
---|
| 418 | // Max Y shift of the planes superimposing along Z axis is minor (2/std::sqrt(3)r) |
---|
| 419 | |
---|
| 420 | G4double a = (1.-(std::sqrt(3.)/2.)); |
---|
| 421 | G4int nbOfGrainsY = (G4int) ( ((SampleSizeXY/(grainDia/2.)) -a)/(2.-a) ) -1; |
---|
| 422 | |
---|
| 423 | // same for the z axis, but a = 2 * (std::sqrt(3) - std::sqrt(2))/std::sqrt(3) |
---|
| 424 | |
---|
| 425 | G4double b = 2. * (std::sqrt(3.) - std::sqrt(2.))/std::sqrt(3.); |
---|
| 426 | G4int nbOfGrainsZ = (G4int) ( ((SampleThickness/(grainDia/2.)) -b)/(2.-b) )-1; |
---|
| 427 | |
---|
| 428 | if (SampleThickness > 0.){ |
---|
| 429 | |
---|
| 430 | solidGrain=0; logicGrain=0; physiGrain=0; |
---|
| 431 | solidGrain = new G4Sphere("Grain",0., |
---|
| 432 | grainDia/2,0., twopi, 0., pi); |
---|
| 433 | |
---|
| 434 | logicGrain = new G4LogicalVolume(solidGrain, |
---|
| 435 | sampleMaterial, //its material |
---|
| 436 | "Grain"); //its name |
---|
| 437 | G4ThreeVector grainPosition; |
---|
| 438 | G4double grainInitPositionX = 0; |
---|
| 439 | G4double grainInitPositionY = 0; |
---|
| 440 | G4double grainInitPositionZ = (-1.*SampleThickness/2.+grainDia/2.); |
---|
| 441 | G4double grainStepX = grainDia = 0; |
---|
| 442 | G4double grainStepY = grainDia*(1.-(0.5-(std::sqrt(3.)/4.))); |
---|
| 443 | G4double grainStepZ = grainDia*std::sqrt(2./3.); |
---|
| 444 | |
---|
| 445 | for ( G4int k=0; k < nbOfGrainsZ ; k++ ) { |
---|
| 446 | for ( G4int j=0; j < nbOfGrainsY ; j++ ) { |
---|
| 447 | for ( G4int i=0; i < nbOfGrainsX ; i++ ) { |
---|
| 448 | |
---|
| 449 | // Now we identify the layer and the row where the grain is , to place it in the right position |
---|
| 450 | |
---|
| 451 | |
---|
| 452 | |
---|
| 453 | if (k%3 == 0) { // first or (4-multiple)th layer: structure is ABCABC |
---|
| 454 | grainInitPositionY = (-1.*SampleSizeXY/2.+grainDia/2.); |
---|
| 455 | if (j%2 ==0) { //first or (3-multiple)th row |
---|
| 456 | grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia/2.); |
---|
| 457 | } |
---|
| 458 | |
---|
| 459 | else if ( ((j+1) % 2) == 0 ) { |
---|
| 460 | grainInitPositionX = (-1.*SampleSizeXY/2.+ grainDia); |
---|
| 461 | } |
---|
| 462 | |
---|
| 463 | } |
---|
| 464 | else if ( ((k+2) % 3) == 0 ) { // B-layer |
---|
| 465 | |
---|
| 466 | grainInitPositionY = ( (-1.*SampleSizeXY/2.) + (grainDia/2.)*(1. + (1./std::sqrt(3.)) ) ); |
---|
| 467 | |
---|
| 468 | if (j%2 ==0) { //first or (3-multiple)th row |
---|
| 469 | grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia); |
---|
| 470 | } |
---|
| 471 | |
---|
| 472 | else if ( (j+1)%2 == 0 ) { |
---|
| 473 | grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia/2); |
---|
| 474 | } |
---|
| 475 | |
---|
| 476 | } |
---|
| 477 | |
---|
| 478 | else if ( (k+1)%3 == 0 ) { // B-layer |
---|
| 479 | |
---|
| 480 | grainInitPositionY = (-1.*SampleSizeXY/2.+(grainDia/2.)*(1.+2./std::sqrt(3.)) ); |
---|
| 481 | |
---|
| 482 | if (j%2 ==0) { //first or (3-multiple)th row |
---|
| 483 | grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia/2.); |
---|
| 484 | } |
---|
| 485 | |
---|
| 486 | else if ( (j+1)%2 == 0 ) { |
---|
| 487 | grainInitPositionX = (-1.*SampleSizeXY/2.+grainDia); |
---|
| 488 | } |
---|
| 489 | |
---|
| 490 | } |
---|
| 491 | |
---|
| 492 | physiGrain = new G4PVPlacement(0, |
---|
| 493 | G4ThreeVector( grainInitPositionX + i*grainStepX, |
---|
| 494 | grainInitPositionY + j*grainStepY, |
---|
| 495 | grainInitPositionZ + k*grainStepZ), |
---|
| 496 | "Grain", |
---|
| 497 | logicGrain, //its logical volume |
---|
| 498 | physiSample, //its mother volume |
---|
| 499 | false, //no boolean operation |
---|
| 500 | grainCopyNb);//copy number |
---|
| 501 | |
---|
| 502 | grainCopyNb = grainCopyNb +1; |
---|
| 503 | } |
---|
| 504 | } |
---|
| 505 | } |
---|
| 506 | } |
---|
| 507 | } |
---|
| 508 | else { |
---|
| 509 | |
---|
| 510 | solidSample=0; logicSample=0; physiSample=0; |
---|
| 511 | if (SampleThickness > 0.) |
---|
| 512 | { |
---|
| 513 | solidSample = new G4Box("Sample", //its name |
---|
| 514 | SampleSizeXY/2,SampleSizeXY/2,SampleThickness/2);//size |
---|
| 515 | |
---|
| 516 | logicSample= new G4LogicalVolume(solidSample, //its solid |
---|
| 517 | sampleMaterial, //its material |
---|
| 518 | "Sample"); //its name |
---|
| 519 | |
---|
| 520 | physiSample = new G4PVPlacement(0, //no rotation |
---|
| 521 | G4ThreeVector(), //at (0,0,0) |
---|
| 522 | "Sample", //its name |
---|
| 523 | logicSample, //its logical volume |
---|
| 524 | physiWorld, //its mother volume |
---|
| 525 | false, //no boolean operation |
---|
| 526 | 0); //copy number |
---|
| 527 | |
---|
| 528 | } |
---|
| 529 | } |
---|
| 530 | |
---|
| 531 | if (!phaseSpaceFlag) { |
---|
| 532 | //Diaphragm1 |
---|
| 533 | |
---|
| 534 | solidDia1 = 0; physiDia1 = 0; logicDia1=0; |
---|
| 535 | |
---|
| 536 | if (Dia1Thickness > 0.) |
---|
| 537 | { |
---|
| 538 | solidDia1 = new G4Tubs("Diaphragm1", //its name |
---|
| 539 | DiaInnerSize/2, |
---|
| 540 | Dia1SizeXY/2, |
---|
| 541 | Dia1Thickness/2, |
---|
| 542 | 0, |
---|
| 543 | 360);//size |
---|
| 544 | |
---|
| 545 | |
---|
| 546 | logicDia1 = new G4LogicalVolume(solidDia1, //its solid |
---|
| 547 | Dia1Material, //its material |
---|
| 548 | "Diaphragm1"); //its name |
---|
| 549 | |
---|
| 550 | zRotPhiDia1.rotateX(AlphaDia1); |
---|
| 551 | G4double x,y,z; |
---|
| 552 | z = DistDia * std::cos(ThetaDia1); |
---|
| 553 | y =DistDia * std::sin(ThetaDia1); |
---|
| 554 | x = 0.*cm; |
---|
| 555 | physiDia1 = new G4PVPlacement(G4Transform3D(zRotPhiDia1,G4ThreeVector(x,y,z)), |
---|
| 556 | "Diaphragm1", //its name |
---|
| 557 | logicDia1, //its logical volume |
---|
| 558 | physiWorld, //its mother volume |
---|
| 559 | false, //no boolean operation |
---|
| 560 | 0); //copy number |
---|
| 561 | } |
---|
| 562 | |
---|
| 563 | //Diaphragm3 |
---|
| 564 | |
---|
| 565 | solidDia3 = 0; physiDia3 = 0; logicDia3 =0; |
---|
| 566 | |
---|
| 567 | if (Dia3Thickness > 0.) |
---|
| 568 | { |
---|
| 569 | solidDia3 = new G4Tubs("Diaphragm3", |
---|
| 570 | Dia3InnerSize/2, |
---|
| 571 | Dia3SizeXY/2, |
---|
| 572 | Dia3Thickness/2, |
---|
| 573 | 0, |
---|
| 574 | 360); |
---|
| 575 | |
---|
| 576 | |
---|
| 577 | logicDia3 = new G4LogicalVolume(solidDia3, //its solid |
---|
| 578 | Dia3Material, //its material |
---|
| 579 | "Diaphragm3"); //its name |
---|
| 580 | |
---|
| 581 | zRotPhiDia3.rotateX(AlphaDia3); |
---|
| 582 | G4double x,y,z; |
---|
| 583 | z = Dia3Dist * std::cos(ThetaDia3); |
---|
| 584 | y =Dia3Dist * std::sin(ThetaDia3); |
---|
| 585 | x = 0.*cm; |
---|
| 586 | physiDia3 = new G4PVPlacement(G4Transform3D(zRotPhiDia3,G4ThreeVector(x,y,z)), "Diaphragm3", //its name |
---|
| 587 | logicDia3, //its logical volume |
---|
| 588 | physiWorld, //its mother volume |
---|
| 589 | false, //no boolean operation |
---|
| 590 | 0); //copy number |
---|
| 591 | } |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | if (!phaseSpaceFlag) { |
---|
| 595 | |
---|
| 596 | G4SDManager* SDman = G4SDManager::GetSDMpointer(); |
---|
| 597 | |
---|
| 598 | |
---|
| 599 | if(!HPGeSD) |
---|
| 600 | { |
---|
| 601 | HPGeSD = new XrayFluoSD ("HPGeSD",this); |
---|
| 602 | SDman->AddNewDetector(HPGeSD); |
---|
| 603 | } |
---|
| 604 | |
---|
| 605 | |
---|
| 606 | if (logicPixel) |
---|
| 607 | { |
---|
| 608 | logicPixel->SetSensitiveDetector(HPGeSD); |
---|
| 609 | } |
---|
| 610 | } |
---|
| 611 | // cut per region |
---|
| 612 | |
---|
| 613 | logicSample->SetRegion(sampleRegion); |
---|
| 614 | sampleRegion->AddRootLogicalVolume(logicSample); |
---|
| 615 | |
---|
| 616 | |
---|
| 617 | |
---|
| 618 | // Visualization attributes |
---|
| 619 | |
---|
| 620 | logicWorld->SetVisAttributes (G4VisAttributes::Invisible); |
---|
| 621 | G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0)); |
---|
| 622 | G4VisAttributes * yellow= new G4VisAttributes( G4Colour(255/255. ,255/255. ,51/255. )); |
---|
| 623 | G4VisAttributes * red= new G4VisAttributes( G4Colour(255/255. , 0/255. , 0/255. )); |
---|
| 624 | G4VisAttributes * blue= new G4VisAttributes( G4Colour(0/255. , 0/255. , 255/255. )); |
---|
| 625 | G4VisAttributes * gray= new G4VisAttributes( G4Colour(128/255. , 128/255. , 128/255. )); |
---|
| 626 | G4VisAttributes * lightGray= new G4VisAttributes( G4Colour(178/255. , 178/255. , 178/255. )); |
---|
| 627 | yellow->SetVisibility(true); |
---|
| 628 | yellow->SetForceSolid(true); |
---|
| 629 | red->SetVisibility(true); |
---|
| 630 | red->SetForceSolid(true); |
---|
| 631 | blue->SetVisibility(true); |
---|
| 632 | gray->SetVisibility(true); |
---|
| 633 | gray->SetForceSolid(true); |
---|
| 634 | lightGray->SetVisibility(true); |
---|
| 635 | lightGray->SetForceSolid(true); |
---|
| 636 | simpleBoxVisAtt->SetVisibility(true); |
---|
| 637 | if (!phaseSpaceFlag) { |
---|
| 638 | logicPixel->SetVisAttributes(red); //modified!!! |
---|
| 639 | logicHPGe->SetVisAttributes(blue); |
---|
| 640 | |
---|
| 641 | logicDia1->SetVisAttributes(lightGray); |
---|
| 642 | logicDia3->SetVisAttributes(lightGray); |
---|
| 643 | |
---|
| 644 | logicOhmicNeg->SetVisAttributes(yellow); |
---|
| 645 | logicOhmicPos->SetVisAttributes(yellow); |
---|
| 646 | |
---|
| 647 | } |
---|
| 648 | logicSample->SetVisAttributes(simpleBoxVisAtt); |
---|
| 649 | |
---|
| 650 | if (sampleGranularity) logicSample->SetVisAttributes(simpleBoxVisAtt); // mandatory |
---|
| 651 | |
---|
| 652 | |
---|
| 653 | |
---|
| 654 | if (sampleGranularity) logicGrain->SetVisAttributes(gray); |
---|
| 655 | |
---|
| 656 | //always return the physical World |
---|
| 657 | |
---|
| 658 | PrintApparateParameters(); |
---|
| 659 | |
---|
| 660 | return physiWorld; |
---|
| 661 | } |
---|
| 662 | |
---|
| 663 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 664 | |
---|
| 665 | void XrayFluoDetectorConstruction::PrintApparateParameters() |
---|
| 666 | { |
---|
| 667 | G4cout << "-----------------------------------------------------------------------" |
---|
| 668 | << G4endl |
---|
| 669 | << "The sample is a box whose size is: " |
---|
| 670 | << G4endl |
---|
| 671 | << SampleThickness/cm |
---|
| 672 | << " cm * " |
---|
| 673 | << SampleSizeXY/cm |
---|
| 674 | << " cm * " |
---|
| 675 | << SampleSizeXY/cm |
---|
| 676 | << " cm" |
---|
| 677 | << G4endl |
---|
| 678 | <<" Material: " << logicSample->GetMaterial()->GetName() |
---|
| 679 | <<G4endl; |
---|
| 680 | if (!phaseSpaceFlag) { |
---|
| 681 | G4cout <<"The Detector is a slice " << DeviceThickness/(1.e-6*m) << " micron thick of " << pixelMaterial->GetName() |
---|
| 682 | <<G4endl |
---|
| 683 | << "The Anode is a slice " << OhmicPosThickness/mm << "mm thick of "<< OhmicPosMaterial->GetName() |
---|
| 684 | <<G4endl; |
---|
| 685 | } |
---|
| 686 | G4cout <<"-------------------------------------------------------------------------" |
---|
| 687 | << G4endl; |
---|
| 688 | } |
---|
| 689 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 690 | |
---|
| 691 | void XrayFluoDetectorConstruction::UpdateGeometry() |
---|
| 692 | { |
---|
| 693 | |
---|
| 694 | if (solidPixel) delete solidPixel; |
---|
| 695 | if (logicPixel) delete logicPixel; |
---|
| 696 | if (physiPixel) delete physiPixel; |
---|
| 697 | if (solidOhmicNeg) delete solidOhmicNeg; |
---|
| 698 | if (logicOhmicNeg) delete logicOhmicNeg; |
---|
| 699 | if (physiOhmicNeg) delete physiOhmicNeg; |
---|
| 700 | if (solidOhmicPos) delete solidOhmicPos; |
---|
| 701 | if (logicOhmicPos) delete logicOhmicPos; |
---|
| 702 | if (physiOhmicPos) delete physiOhmicPos; |
---|
| 703 | if (solidHPGe) delete solidHPGe; |
---|
| 704 | if (logicHPGe) delete logicHPGe; |
---|
| 705 | if (physiHPGe) delete physiHPGe; |
---|
| 706 | |
---|
| 707 | //if (sampleRegion) sampleRegion->RemoveRootLogicalVolume(logicSample); |
---|
| 708 | if (solidSample) delete solidSample; |
---|
| 709 | if (logicSample) delete logicSample; |
---|
| 710 | if (physiSample) delete physiSample; |
---|
| 711 | |
---|
| 712 | if (solidDia1) delete solidDia1; |
---|
| 713 | if (logicDia1) delete logicDia1; |
---|
| 714 | if (physiDia1) delete physiDia1; |
---|
| 715 | if (solidDia3) delete solidDia3; |
---|
| 716 | if (logicDia3) delete logicDia3; |
---|
| 717 | if (physiDia3) delete physiDia3; |
---|
| 718 | |
---|
| 719 | if (solidWorld) delete solidWorld; |
---|
| 720 | if (logicWorld) delete logicWorld; |
---|
| 721 | if (physiWorld) delete physiWorld; |
---|
| 722 | |
---|
| 723 | zRotPhiHPGe.rotateX(-1.*PhiHPGe); |
---|
| 724 | zRotPhiDia1.rotateX(-1.*AlphaDia1); |
---|
| 725 | zRotPhiDia3.rotateX(-1.*AlphaDia3); |
---|
| 726 | G4RunManager::GetRunManager()->DefineWorldVolume(ConstructApparate()); |
---|
| 727 | |
---|
| 728 | } |
---|
| 729 | |
---|
| 730 | |
---|
| 731 | void XrayFluoDetectorConstruction::DeleteGrainObjects() |
---|
| 732 | { |
---|
| 733 | if (sampleGranularity) { |
---|
| 734 | delete solidGrain; |
---|
| 735 | delete logicGrain; |
---|
| 736 | delete physiGrain; |
---|
| 737 | } |
---|
| 738 | |
---|
| 739 | } |
---|
| 740 | |
---|
| 741 | G4ThreeVector XrayFluoDetectorConstruction::GetDetectorPosition() |
---|
| 742 | { |
---|
| 743 | |
---|
| 744 | |
---|
| 745 | |
---|
| 746 | G4double z = DistDe * std::cos(ThetaHPGe); |
---|
| 747 | G4double y = DistDe * std::sin(ThetaHPGe); |
---|
| 748 | G4double x = 0.*cm; |
---|
| 749 | |
---|
| 750 | G4ThreeVector position(x,y,z); |
---|
| 751 | |
---|
| 752 | return position; |
---|
| 753 | |
---|
| 754 | } |
---|
| 755 | |
---|
| 756 | void XrayFluoDetectorConstruction::SetSampleMaterial(G4String newMaterial) |
---|
| 757 | { |
---|
| 758 | |
---|
| 759 | |
---|
| 760 | G4cout << "Material Change in Progress" << newMaterial << G4endl; |
---|
| 761 | sampleMaterial = materials->GetMaterial(newMaterial); |
---|
| 762 | logicSample->SetMaterial(sampleMaterial); |
---|
| 763 | PrintApparateParameters(); |
---|
| 764 | |
---|
| 765 | } |
---|
| 766 | |
---|
| 767 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... |
---|
| 768 | |
---|
| 769 | |
---|
| 770 | |
---|
| 771 | |
---|
| 772 | |
---|
| 773 | |
---|
| 774 | |
---|
| 775 | |
---|
| 776 | |
---|
| 777 | |
---|
| 778 | |
---|