Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/xray_fluorescence/src/XrayFluoDetectorConstruction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/xray_fluorescence/src/XrayFluoDetectorConstruction.cc (Version 11.3.0) and /examples/advanced/xray_fluorescence/src/XrayFluoDetectorConstruction.cc (Version 5.1.p1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 //                                                
 28 // Author: Alfonso Mantero (Alfonso.Mantero@ge    
 29 //                                                
 30 // History:                                       
 31 // -----------                                    
 32 // 28 Nov 2001 Elena Guardincerri     Created     
 33 //    Nov 2002 Alfonso Mantero materials added    
 34 //             Material selection implementati    
 35 // 16 Jul 2003 Alfonso Mantero Detector type s    
 36 // -------------------------------------------    
 37                                                   
 38 #include "XrayFluoDetectorConstruction.hh"        
 39 #include "XrayFluoDetectorMessenger.hh"           
 40 #include "XrayFluoSD.hh"                          
 41 #include "G4PhysicalConstants.hh"                 
 42 #include "G4SystemOfUnits.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 "G4GeometryManager.hh"                   
 59 #include "G4PhysicalVolumeStore.hh"               
 60 #include "G4LogicalVolumeStore.hh"                
 61 #include "G4SolidStore.hh"                        
 62 #include "XrayFluoNistMaterials.hh"               
 63 #include "G4SDManager.hh"                         
 64                                                   
 65 // #include "G4Region.hh"                         
 66 // #include "G4RegionStore.hh"                    
 67                                                   
 68 //....oooOO0OOooo........oooOO0OOooo........oo    
 69                                                   
 70                                                   
 71 XrayFluoDetectorConstruction::XrayFluoDetector    
 72   : aNavigator(0), detectorType(0),sampleGranu    
 73     DeviceSizeX(0), DeviceSizeY(0),DeviceThick    
 74     solidWorld(0),logicWorld(0),physiWorld(0),    
 75     solidHPGe(0),logicHPGe(0),physiHPGe(0),       
 76     solidSample (0),logicSample(0),physiSample    
 77     solidDia1(0),logicDia1(0),physiDia1(0),       
 78     solidDia3(0),logicDia3(0),physiDia3(0),       
 79     solidOhmicPos(0),logicOhmicPos(0), physiOh    
 80     solidWindow(0), logicWindow(0), physiWindo    
 81     solidOhmicNeg(0),logicOhmicNeg(0), physiOh    
 82     solidPixel(0),logicPixel(0), physiPixel(0)    
 83     OhmicPosMaterial(0), OhmicNegMaterial(0),     
 84     pixelMaterial(0),sampleMaterial(0),           
 85     Dia1Material(0),Dia3Material(0),              
 86     defaultMaterial(0), windowMaterial (0)        
 87 {                                                 
 88   materials = XrayFluoNistMaterials::GetInstan    
 89                                                   
 90   HPGeSD.Put(0);                                  
 91                                                   
 92   aNavigator = new G4Navigator();                 
 93                                                   
 94   DefineDefaultMaterials();                       
 95                                                   
 96   NbOfPixelRows     =  1; // should be 1          
 97   NbOfPixelColumns  =  1; // should be 1          
 98   NbOfPixels        =  NbOfPixelRows*NbOfPixel    
 99   PixelSizeXY       =  std::sqrt(40.) * mm;       
100   PixelThickness = 2.7 * mm; //should be 3.5 m    
101                                                   
102   G4cout << "PixelThickness(mm): "<< PixelThic    
103   G4cout << "PixelSizeXY(cm): "<< PixelSizeXY/    
104                                                   
105   ContactSizeXY     = PixelSizeXY; //std::sqrt    
106   SampleThickness = 4 * mm;                       
107   SampleSizeXY = 3. * cm;                         
108   Dia1Thickness = 1. *mm;                         
109   Dia3Thickness = 1. *mm;                         
110   Dia1SizeXY = 3. *cm;                            
111   Dia3SizeXY = 3. *cm;                            
112                                                   
113                                                   
114   DiaInnerSize = 2.9 * cm; //(Hole in the dete    
115                                                   
116                                                   
117   OhmicNegThickness = 1e-6*cm;// 0.005            
118   OhmicPosThickness = 1e-6*cm;// 0.005            
119   windowThickness = 0.008 * cm; //value for ai    
120   ThetaHPGe = 135. * deg;                         
121   PhiHPGe = 225. * deg;                           
122                                                   
123   ThetaDia1 = 135. * deg;                         
124   PhiDia1 = 90. * deg;                            
125   AlphaDia1 = 225. * deg;                         
126                                                   
127   AlphaDia3 = 180. * deg;                         
128   Dia3Dist =  66.5 * mm;                          
129   Dia3InnerSize = 1. * mm;                        
130   ThetaDia3 = 180. * deg;                         
131   PhiDia3 = 90. * deg;                            
132                                                   
133   DistDia = 66.5 * mm;                            
134   DistDe =DistDia+ (Dia1Thickness                 
135         +PixelThickness)/2+OhmicPosThickness+w    
136                                                   
137   grainDia = 1 * mm;                              
138   PixelCopyNb=0;                                  
139   grainCopyNb=0;                                  
140   G4String defaultDetectorType = "sili";          
141   ComputeApparateParameters();                    
142                                                   
143 //   G4String regName = "SampleRegion";           
144 //   sampleRegion = new G4Region(regName);        
145                                                   
146   if (!phaseSpaceFlag) SetDetectorType(default    
147                                                   
148   // create commands for interactive definitio    
149                                                   
150   detectorMessenger = new XrayFluoDetectorMess    
151                                                   
152   G4cout << "XrayFluoDetectorConstruction crea    
153 }                                                 
154 //....oooOO0OOooo........oooOO0OOooo........oo    
155                                                   
156                                                   
157 XrayFluoDetectorConstruction* XrayFluoDetector    
158                                                   
159 XrayFluoDetectorConstruction* XrayFluoDetector    
160 {                                                 
161   if (instance == 0)                              
162     {                                             
163       instance = new XrayFluoDetectorConstruct    
164                                                   
165     }                                             
166   return instance;                                
167 }                                                 
168                                                   
169 //....oooOO0OOooo........oooOO0OOooo........oo    
170                                                   
171 void XrayFluoDetectorConstruction::SetDetector    
172 {                                                 
173   if (type=="sili")                               
174     {                                             
175       detectorType = XrayFluoSiLiDetectorType:    
176     }                                             
177    else if (type=="hpge")                         
178      {                                            
179        detectorType = XrayFluoHPGeDetectorType    
180     }/*                                           
181    else if (type=="aifira")                       
182      {                                            
183        detectorType = XrayFluoAifSiLi::GetInst    
184        }*/                                        
185   else                                            
186     {                                             
187       G4ExceptionDescription execp;               
188       execp << type + "detector type unknown";    
189       G4Exception("XrayFluoDataSet::LoadData()    
190     FatalException, execp);                       
191     }                                             
192   //GeometryHasBeenModified invoked by the mes    
193                                                   
194 }                                                 
195                                                   
196 XrayFluoVDetectorType* XrayFluoDetectorConstru    
197 {                                                 
198   return detectorType;                            
199 }                                                 
200                                                   
201 //....oooOO0OOooo........oooOO0OOooo........oo    
202                                                   
203 XrayFluoDetectorConstruction::~XrayFluoDetecto    
204                                                   
205 {                                                 
206   delete detectorMessenger;                       
207   delete detectorType;                            
208   G4cout << "XrayFluoDetectorConstruction dele    
209 }                                                 
210                                                   
211 //....oooOO0OOooo........oooOO0OOooo........oo    
212                                                   
213 G4VPhysicalVolume* XrayFluoDetectorConstructio    
214 {                                                 
215   return ConstructApparate();                     
216 }                                                 
217                                                   
218 //....oooOO0OOooo........oooOO0OOooo........oo    
219                                                   
220 void XrayFluoDetectorConstruction::DefineDefau    
221 {                                                 
222                                                   
223                                                   
224   //define materials of the apparate              
225                                                   
226   sampleMaterial = materials->GetMaterial("Dol    
227   Dia1Material = materials->GetMaterial("G4_Pb    
228   Dia3Material = materials->GetMaterial("G4_Ga    
229   pixelMaterial = materials->GetMaterial("SiLi    
230   //OhmicPosMaterial = materials->GetMaterial(    
231   OhmicPosMaterial = materials->GetMaterial("G    
232   OhmicNegMaterial = materials->GetMaterial("G    
233   defaultMaterial = materials->GetMaterial("G4    
234   windowMaterial = materials->GetMaterial("G4_    
235 }                                                 
236                                                   
237 void XrayFluoDetectorConstruction::SetOhmicPos    
238 {                                                 
239                                                   
240   if (!phaseSpaceFlag) {                          
241                                                   
242                                                   
243     if (val == 0.0) {                             
244       OhmicPosMaterial = materials->GetMateria    
245     }                                             
246     else {                                        
247       OhmicPosThickness = val;                    
248       //OhmicPosMaterial = materials->GetMater    
249       OhmicPosMaterial = materials->GetMateria    
250     }                                             
251                                                   
252   }                                               
253   else{                                           
254     G4cout << "Not available in this configura    
255   }                                               
256                                                   
257 }                                                 
258                                                   
259                                                   
260 //....oooOO0OOooo........oooOO0OOooo........oo    
261                                                   
262 G4VPhysicalVolume* XrayFluoDetectorConstructio    
263 {                                                 
264   // complete the apparate parameters definiti    
265                                                   
266   //ComputeApparateParameters();                  
267                                                   
268   //world and associated navigator                
269                                                   
270   solidWorld = new G4Box("World",                 
271        WorldSizeXY/2,WorldSizeXY/2,WorldSizeZ/    
272                                                   
273   logicWorld = new G4LogicalVolume(solidWorld,    
274                                    defaultMate    
275                                    "World");      
276   physiWorld = new G4PVPlacement(0,     //no r    
277          G4ThreeVector(), //at (0,0,0)            
278          "World",   //its name                    
279          logicWorld,    //its logical volume      
280          0,     //its mother  volume              
281          false,     //no boolean operation        
282          0);      //copy number                   
283                                                   
284   aNavigator->SetWorldVolume(physiWorld);         
285                                                   
286                                                   
287   //HPGeDetector                                  
288                                                   
289   if (!phaseSpaceFlag) {                          
290                                                   
291     solidHPGe = 0;  physiHPGe = 0;  logicHPGe=    
292     solidPixel=0; logicPixel=0; physiPixel=0;     
293                                                   
294     if (DeviceThickness > 0.)                     
295       {                                           
296   solidHPGe = new G4Box("HPGeDetector",   //it    
297             DeviceSizeX/2,DeviceSizeY/2,Device    
298                                                   
299                                                   
300   logicHPGe = new G4LogicalVolume(solidHPGe,      
301           defaultMaterial,  //its material        
302           "HPGeDetector");  //its name            
303                                                   
304   zRotPhiHPGe.rotateX(PhiHPGe);                   
305   G4double x,y,z;                                 
306   z = DistDe * std::cos(ThetaHPGe);               
307   y =DistDe * std::sin(ThetaHPGe);                
308   x = 0.*cm;                                      
309   physiHPGe = new G4PVPlacement(G4Transform3D(    
310               "HPGeDetector", //its name          
311               logicHPGe,  //its logical volume    
312               physiWorld, //its mother  volume    
313               false,    //no boolean operation    
314               0);   //copy number                 
315       }                                           
316     // Pixel                                      
317                                                   
318                                                   
319                                                   
320                                                   
321     for ( G4int j=0; j < NbOfPixelColumns ; j+    
322       { for ( G4int i=0; i < NbOfPixelRows ; i    
323   {                                               
324     solidPixel=0; logicPixel=0;   physiPixel=0    
325     if (PixelThickness > 0.)                      
326       solidPixel = new G4Box("Pixel",             
327            PixelSizeXY/2,PixelSizeXY/2, PixelT    
328                                                   
329     logicPixel = new G4LogicalVolume(solidPixe    
330              pixelMaterial, //its material        
331              "Pixel");          //its name        
332                                                   
333     /*                                            
334       zRotPhiHPGe.rotateX(PhiHPGe);               
335       G4double x,y,z;                             
336       z = DistDe * std::cos(ThetaHPGe);           
337       y =DistDe * std::sin(ThetaHPGe);            
338       x = 0.*cm;*/                                
339     physiPixel = new G4PVPlacement(0,             
340            G4ThreeVector(0,                       
341                    i*PixelSizeXY,                 
342                    j*PixelSizeXY ),               
343            "Pixel",                               
344            logicPixel,   //its logical volume     
345            physiHPGe, //its mother  volume        
346            false,  //no boolean operation         
347            PixelCopyNb);//copy number             
348                                                   
349                                                   
350                                                   
351                                                   
352                                                   
353                                                   
354     // OhmicNeg                                   
355                                                   
356     solidOhmicNeg=0; logicOhmicNeg=0; physiOhm    
357                                                   
358     if (OhmicNegThickness > 0.)                   
359       { solidOhmicNeg = new G4Box("OhmicNeg",     
360           PixelSizeXY/2,PixelSizeXY/2,OhmicNeg    
361                                                   
362       logicOhmicNeg = new G4LogicalVolume(soli    
363             OhmicNegMaterial, //its material      
364             "OhmicNeg");      //its name          
365                                                   
366       physiOhmicNeg = new G4PVPlacement(0,        
367                 G4ThreeVector                     
368                 (0.,                              
369                  0.,                              
370                  (PixelThickness+OhmicNegThick    
371                 "OhmicNeg",        //its name     
372                 logicOhmicNeg,     //its logic    
373                 physiHPGe,        //its mother    
374                 false,             //no boulea    
375                 PixelCopyNb);                /    
376                                                   
377       }                                           
378     // OhmicPos                                   
379     solidOhmicPos=0; logicOhmicPos=0; physiOhm    
380                                                   
381     if (OhmicPosThickness > 0.)                   
382       { solidOhmicPos = new G4Box("OhmicPos",     
383           PixelSizeXY/2,PixelSizeXY/2,OhmicPos    
384                                                   
385       logicOhmicPos = new G4LogicalVolume(soli    
386             OhmicPosMaterial, //its material      
387             "OhmicPos");      //its name          
388                                                   
389       physiOhmicPos = new G4PVPlacement(0,        
390                 G4ThreeVector(0.,                 
391                   0.,                             
392                   (-PixelThickness-OhmicPosThi    
393                 "OhmicPos",                       
394                 logicOhmicPos,                    
395                 physiHPGe,                        
396                 false,                            
397                 PixelCopyNb);                     
398                                                   
399       }                                           
400                                                   
401     /////////// widow place here! ////////////    
402     // OhmicPos                                   
403     solidWindow=0; logicWindow=0; physiWindow=    
404                                                   
405     if (windowThickness > 0.)                     
406       { solidWindow = new G4Box("Window",   //    
407           PixelSizeXY/2,PixelSizeXY/2,windowTh    
408                                                   
409       logicWindow = new G4LogicalVolume(solidW    
410             windowMaterial, //its material        
411             "Window");      //its name            
412                                                   
413       physiWindow = new G4PVPlacement(0,          
414                 G4ThreeVector(0.,                 
415                   0.,                             
416                   ((-PixelThickness-windowThic    
417                   -OhmicPosThickness),            
418                 "OhmicWindow",                    
419                 logicWindow,                      
420                 physiHPGe,                        
421                 false,                            
422                 PixelCopyNb);                     
423                                                   
424       }                                           
425                                                   
426                                                   
427                                                   
428     PixelCopyNb += PixelCopyNb;                   
429     G4cout << "PixelCopyNb: " << PixelCopyNb <    
430   }                                               
431                                                   
432       }                                           
433                                                   
434   }                                               
435                                                   
436   //Sample                                        
437                                                   
438   if (sampleGranularity) {                        
439                                                   
440     solidSample=0;  logicSample=0;  physiSampl    
441     if (SampleThickness > 0.)                     
442       {                                           
443   solidSample = new G4Box("Sample",   //its na    
444         SampleSizeXY/2,SampleSizeXY/2,SampleTh    
445                                                   
446   logicSample= new G4LogicalVolume(solidSample    
447            defaultMaterial, //its material        
448            "Sample"); //its name                  
449                                                   
450   physiSample = new G4PVPlacement(0,      //no    
451           G4ThreeVector(),  //at (0,0,0)          
452           "Sample", //its name                    
453           logicSample,  //its logical volume      
454           physiWorld, //its mother  volume        
455           false,    //no boolean operation        
456           0);   //copy number                     
457                                                   
458       }                                           
459                                                   
460                                                   
461                                                   
462                                                   
463     G4int nbOfGrainsX = ((G4int)(SampleSizeXY/    
464                                                   
465     // y dim of a max density plane is 2rn-(n-    
466     // number of rows and r the radius of the     
467     // be greater or equal to this. It results    
468     // Max Y shift of the planes superimposing    
469                                                   
470     G4double a = (1.-(std::sqrt(3.)/2.));         
471     G4int nbOfGrainsY =  (G4int) ( ((SampleSiz    
472                                                   
473     // same for the z axis, but a = 2 * (std::    
474                                                   
475     G4double b = 2. * (std::sqrt(3.) - std::sq    
476     G4int nbOfGrainsZ =  (G4int) ( ((SampleThi    
477                                                   
478     if (SampleThickness > 0.){                    
479                                                   
480       solidGrain=0; logicGrain=0; physiGrain=0    
481       solidGrain = new G4Sphere("Grain",0.,       
482         grainDia/2,0., twopi, 0., pi);            
483                                                   
484       logicGrain = new G4LogicalVolume(solidGr    
485                sampleMaterial,  //its material    
486                "Grain");          //its name      
487       G4ThreeVector grainPosition;                
488       G4double grainInitPositionX = 0;            
489       G4double grainInitPositionY = 0;            
490       G4double grainInitPositionZ = (-1.*Sampl    
491       G4double grainStepX = grainDia = 0;         
492       G4double grainStepY = grainDia*(1.-(0.5-    
493       G4double grainStepZ = grainDia*std::sqrt    
494                                                   
495       for ( G4int k=0; k < nbOfGrainsZ ; k++ )    
496   for ( G4int j=0; j < nbOfGrainsY ; j++ ) {      
497     for ( G4int i=0; i < nbOfGrainsX ; i++ ) {    
498                                                   
499       // Now we identify the layer and the row    
500                                                   
501                                                   
502                                                   
503       if (k%3 == 0) { // first or (4-multiple)    
504         grainInitPositionY = (-1.*SampleSizeXY    
505         if (j%2 ==0) { //first or (3-multiple)    
506     grainInitPositionX = (-1.*SampleSizeXY/2.+    
507         }                                         
508                                                   
509         else if ( ((j+1) % 2)  == 0 ) {           
510     grainInitPositionX = (-1.*SampleSizeXY/2.+    
511         }                                         
512                                                   
513       }                                           
514       else if ( ((k+2) % 3) == 0 ) { // B-laye    
515                                                   
516         grainInitPositionY = ( (-1.*SampleSize    
517                                                   
518         if (j%2 ==0) { //first or (3-multiple)    
519     grainInitPositionX = (-1.*SampleSizeXY/2.+    
520         }                                         
521                                                   
522         else if ( (j+1)%2  == 0 ) {               
523     grainInitPositionX = (-1.*SampleSizeXY/2.+    
524         }                                         
525                                                   
526       }                                           
527                                                   
528       else if ( (k+1)%3 == 0 ) { // B-layer       
529                                                   
530         grainInitPositionY = (-1.*SampleSizeXY    
531                                                   
532         if (j%2 ==0) { //first or (3-multiple)    
533     grainInitPositionX = (-1.*SampleSizeXY/2.+    
534         }                                         
535                                                   
536         else if ( (j+1)%2  == 0 ) {               
537     grainInitPositionX = (-1.*SampleSizeXY/2.+    
538         }                                         
539                                                   
540       }                                           
541                                                   
542       physiGrain = new G4PVPlacement(0,           
543              G4ThreeVector( grainInitPositionX    
544                 grainInitPositionY + j*grainSt    
545                 grainInitPositionZ + k*grainSt    
546              "Grain",                             
547              logicGrain,   //its logical volum    
548              physiSample, //its mother  volume    
549              false,  //no boolean operation       
550              grainCopyNb);//copy number           
551                                                   
552       grainCopyNb = grainCopyNb +1;               
553     }                                             
554   }                                               
555       }                                           
556     }                                             
557   }                                               
558   else {                                          
559                                                   
560     solidSample=0;  logicSample=0;  physiSampl    
561     if (SampleThickness > 0.)                     
562       {                                           
563   solidSample = new G4Box("Sample",   //its na    
564         SampleSizeXY/2,SampleSizeXY/2,SampleTh    
565                                                   
566   logicSample= new G4LogicalVolume(solidSample    
567            sampleMaterial,  //its material        
568            "Sample"); //its name                  
569                                                   
570   physiSample = new G4PVPlacement(0,      //no    
571           G4ThreeVector(),  //at (0,0,0)          
572           "Sample", //its name                    
573           logicSample,  //its logical volume      
574           physiWorld, //its mother  volume        
575           false,    //no boolean operation        
576           0);   //copy number                     
577                                                   
578       }                                           
579   }                                               
580                                                   
581   if (!phaseSpaceFlag) {                          
582     //Diaphragm1                                  
583                                                   
584     solidDia1 = 0;  physiDia1 = 0;  logicDia1=    
585                                                   
586     if (Dia1Thickness > 0.)                       
587       {                                           
588   solidDia1 = new G4Tubs("Diaphragm1",    //it    
589              DiaInnerSize/2,                      
590              Dia1SizeXY/2,                        
591              Dia1Thickness/2,                     
592              0,                                   
593              360*deg);//size                      
594                                                   
595                                                   
596   logicDia1 = new G4LogicalVolume(solidDia1,      
597           Dia1Material, //its material            
598           "Diaphragm1");  //its name              
599                                                   
600   zRotPhiDia1.rotateX(AlphaDia1);                 
601   G4double x,y,z;                                 
602   z = DistDia * std::cos(ThetaDia1);              
603   y =DistDia * std::sin(ThetaDia1);               
604   x = 0.*cm;                                      
605   physiDia1 = new G4PVPlacement(G4Transform3D(    
606               "Diaphragm1", //its name            
607               logicDia1,  //its logical volume    
608               physiWorld, //its mother  volume    
609               false,    //no boolean operation    
610               0);   //copy number                 
611       }                                           
612                                                   
613     //Diaphragm3                                  
614                                                   
615     solidDia3 = 0;  physiDia3 = 0;  logicDia3     
616                                                   
617     if (Dia3Thickness > 0.)                       
618       {                                           
619   solidDia3 = new G4Tubs("Diaphragm3",            
620              Dia3InnerSize/2,                     
621              Dia3SizeXY/2,                        
622              Dia3Thickness/2,                     
623              0,                                   
624              360*deg);                            
625                                                   
626                                                   
627       logicDia3 = new G4LogicalVolume(solidDia    
628               Dia3Material, //its material        
629               "Diaphragm3");  //its name          
630                                                   
631       zRotPhiDia3.rotateX(AlphaDia3);             
632       G4double x,y,z;                             
633       z = Dia3Dist * std::cos(ThetaDia3);         
634       y =Dia3Dist * std::sin(ThetaDia3);          
635       x = 0.*cm;                                  
636       physiDia3 = new G4PVPlacement(G4Transfor    
637             logicDia3,  //its logical volume      
638             physiWorld, //its mother  volume      
639             false,    //no boolean operation      
640             0);   //copy number                   
641       }                                           
642   }                                               
643                                                   
644                                                   
645                                                   
646   // Visualization attributes                     
647                                                   
648   logicWorld->SetVisAttributes (G4VisAttribute    
649   G4VisAttributes* simpleBoxVisAtt= new G4VisA    
650   G4VisAttributes * yellow= new G4VisAttribute    
651   G4VisAttributes * red= new G4VisAttributes(     
652   G4VisAttributes * blue= new G4VisAttributes(    
653   G4VisAttributes * grayc= new G4VisAttributes    
654   G4VisAttributes * lightGray= new G4VisAttrib    
655   G4VisAttributes * green= new G4VisAttributes    
656                                                   
657   yellow->SetVisibility(true);                    
658   yellow->SetForceSolid(true);                    
659   red->SetVisibility(true);                       
660   red->SetForceSolid(true);                       
661   blue->SetVisibility(true);                      
662   green->SetVisibility(true);                     
663   green->SetForceSolid(true);                     
664   grayc->SetVisibility(true);                     
665   grayc->SetForceSolid(true);                     
666   lightGray->SetVisibility(true);                 
667   lightGray->SetForceSolid(true);                 
668   simpleBoxVisAtt->SetVisibility(true);           
669   if (!phaseSpaceFlag) {                          
670     logicPixel->SetVisAttributes(red); //modif    
671     logicHPGe->SetVisAttributes(blue);            
672                                                   
673     logicDia1->SetVisAttributes(lightGray);       
674     logicDia3->SetVisAttributes(lightGray);       
675                                                   
676     logicOhmicNeg->SetVisAttributes(yellow);      
677     logicOhmicPos->SetVisAttributes(yellow);      
678                                                   
679     logicWindow->SetVisAttributes(green);         
680                                                   
681   }                                               
682   logicSample->SetVisAttributes(simpleBoxVisAt    
683                                                   
684   if (sampleGranularity) logicSample->SetVisAt    
685                                                   
686                                                   
687                                                   
688   if (sampleGranularity)  logicGrain->SetVisAt    
689                                                   
690   //always return the physical World              
691                                                   
692   PrintApparateParameters();                      
693                                                   
694   return physiWorld;                              
695 }                                                 
696                                                   
697 //....oooOO0OOooo........oooOO0OOooo........oo    
698                                                   
699 void XrayFluoDetectorConstruction::ConstructSD    
700 {                                                 
701   if (!phaseSpaceFlag)                            
702     {                                             
703                                                   
704       //                                          
705       // Sensitive Detectors                      
706       //                                          
707       if (HPGeSD.Get() == 0)                      
708   {                                               
709     XrayFluoSD* SD = new XrayFluoSD ("HPGeSD",    
710     HPGeSD.Put( SD );                             
711   }                                               
712       G4SDManager::GetSDMpointer()->AddNewDete    
713       if (logicPixel)                             
714   SetSensitiveDetector(logicPixel,HPGeSD.Get()    
715     }                                             
716   return;                                         
717 }                                                 
718                                                   
719 //....oooOO0OOooo........oooOO0OOooo........oo    
720                                                   
721 void XrayFluoDetectorConstruction::PrintAppara    
722 {                                                 
723   G4cout << "---------------------------------    
724    << G4endl                                      
725    << "The sample is a box whose size is: "       
726    << G4endl                                      
727    << SampleThickness/cm                          
728    << " cm * "                                    
729    << SampleSizeXY/cm                             
730    << " cm * "                                    
731    << SampleSizeXY/cm                             
732    << " cm"                                       
733    << G4endl                                      
734    <<" Material: " << logicSample->GetMaterial    
735    <<G4endl;                                      
736   if (!phaseSpaceFlag) {                          
737     G4cout <<"The Detector is a slice  " << De    
738      <<G4endl                                     
739      << "The Anode is a slice " << OhmicPosThi    
740      <<G4endl;                                    
741       }                                           
742   G4cout <<"----------------------------------    
743    << G4endl;                                     
744 }                                                 
745 //....oooOO0OOooo........oooOO0OOooo........oo    
746                                                   
747 void XrayFluoDetectorConstruction::UpdateGeome    
748 {                                                 
749   G4GeometryManager::GetInstance()->OpenGeomet    
750   G4PhysicalVolumeStore::Clean();                 
751   G4LogicalVolumeStore::Clean();                  
752   G4SolidStore::Clean();                          
753                                                   
754   if (sampleRegion)                               
755     sampleRegion->RemoveRootLogicalVolume(logi    
756                                                   
757   zRotPhiHPGe.rotateX(-1.*PhiHPGe);               
758   zRotPhiDia1.rotateX(-1.*AlphaDia1);             
759   zRotPhiDia3.rotateX(-1.*AlphaDia3);             
760                                                   
761   //Triggers a new call of Construct() and of     
762   G4RunManager::GetRunManager()->ReinitializeG    
763 }                                                 
764                                                   
765 //....oooOO0OOooo........oooOO0OOooo........oo    
766                                                   
767 void XrayFluoDetectorConstruction::DeleteGrain    
768 {                                                 
769   if (sampleGranularity) {                        
770     delete solidGrain;                            
771     delete logicGrain;                            
772     delete physiGrain;                            
773   }                                               
774                                                   
775 }                                                 
776                                                   
777 //....oooOO0OOooo........oooOO0OOooo........oo    
778                                                   
779 G4ThreeVector XrayFluoDetectorConstruction::Ge    
780 {                                                 
781   G4double  z = DistDe * std::cos(ThetaHPGe);     
782   G4double  y = DistDe * std::sin(ThetaHPGe);     
783   G4double  x = 0.*cm;                            
784                                                   
785   G4ThreeVector position(x,y,z);                  
786                                                   
787   return position;                                
788                                                   
789 }                                                 
790                                                   
791 //....oooOO0OOooo........oooOO0OOooo........oo    
792                                                   
793 void XrayFluoDetectorConstruction::SetSampleMa    
794 {                                                 
795     G4cout << "Material Change in Progress " <    
796     sampleMaterial = materials->GetMaterial(ne    
797     logicSample->SetMaterial(sampleMaterial);     
798     PrintApparateParameters();                    
799     //GeometryHasBeenModified is called by the    
800 }                                                 
801                                                   
802 //....oooOO0OOooo........oooOO0OOooo........oo    
803                                                   
804                                                   
805                                                   
806                                                   
807                                                   
808                                                   
809                                                   
810                                                   
811                                                   
812                                                   
813                                                   
814