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