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 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/XrayFluoMercuryDetectorConstruction.cc (Version 11.3.0) and /examples/advanced/xray_fluorescence/src/XrayFluoMercuryDetectorConstruction.cc (Version 6.1)


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