Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/extended/optical/wls/src/WLSDetectorConstruction.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/extended/optical/wls/src/WLSDetectorConstruction.cc (Version 11.3.0) and /examples/extended/optical/wls/src/WLSDetectorConstruction.cc (Version 4.0.p2)


  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 /// \file optical/wls/src/WLSDetectorConstruct    
 28 /// \brief Implementation of the WLSDetectorCo    
 29 //                                                
 30 //                                                
 31                                                   
 32 #include "WLSDetectorConstruction.hh"             
 33                                                   
 34 #include "WLSDetectorMessenger.hh"                
 35 #include "WLSMaterials.hh"                        
 36 #include "WLSPhotonDetSD.hh"                      
 37                                                   
 38 #include "G4Box.hh"                               
 39 #include "G4Colour.hh"                            
 40 #include "G4EllipticalTube.hh"                    
 41 #include "G4GeometryManager.hh"                   
 42 #include "G4LogicalBorderSurface.hh"              
 43 #include "G4LogicalSkinSurface.hh"                
 44 #include "G4LogicalVolume.hh"                     
 45 #include "G4LogicalVolumeStore.hh"                
 46 #include "G4Material.hh"                          
 47 #include "G4NistManager.hh"                       
 48 #include "G4OpticalSurface.hh"                    
 49 #include "G4PVPlacement.hh"                       
 50 #include "G4PhysicalConstants.hh"                 
 51 #include "G4PhysicalVolumeStore.hh"               
 52 #include "G4RunManager.hh"                        
 53 #include "G4SDManager.hh"                         
 54 #include "G4SolidStore.hh"                        
 55 #include "G4SystemOfUnits.hh"                     
 56 #include "G4Tubs.hh"                              
 57 #include "G4UserLimits.hh"                        
 58 #include "G4VisAttributes.hh"                     
 59 #include "G4ios.hh"                               
 60 #include "globals.hh"                             
 61                                                   
 62 //....oooOO0OOooo........oooOO0OOooo........oo    
 63                                                   
 64 WLSDetectorConstruction::WLSDetectorConstructi    
 65 {                                                 
 66   fDetectorMessenger = new WLSDetectorMessenge    
 67                                                   
 68   fMPPCHalfL = fWLSfiberRY;                       
 69   fClrfiberZ = fMPPCZ + 10. * nm;                 
 70   fHoleLength = fBarLength;                       
 71 }                                                 
 72                                                   
 73 //....oooOO0OOooo........oooOO0OOooo........oo    
 74                                                   
 75 WLSDetectorConstruction::~WLSDetectorConstruct    
 76 {                                                 
 77   delete fDetectorMessenger;                      
 78   delete fMaterials;                              
 79   for (auto visAttributes : fVisAttributes) {     
 80     delete visAttributes;                         
 81   }                                               
 82 }                                                 
 83                                                   
 84 //....oooOO0OOooo........oooOO0OOooo........oo    
 85                                                   
 86 G4VPhysicalVolume* WLSDetectorConstruction::Co    
 87 {                                                 
 88   if (fPhysiWorld) {                              
 89     G4GeometryManager::GetInstance()->OpenGeom    
 90     G4PhysicalVolumeStore::GetInstance()->Clea    
 91     G4LogicalVolumeStore::GetInstance()->Clean    
 92     G4SolidStore::GetInstance()->Clean();         
 93     G4LogicalSkinSurface::CleanSurfaceTable();    
 94     G4LogicalBorderSurface::CleanSurfaceTable(    
 95   }                                               
 96                                                   
 97   fMaterials = WLSMaterials::GetInstance();       
 98   UpdateGeometryParameters();                     
 99                                                   
100   return ConstructDetector();                     
101 }                                                 
102                                                   
103 //....oooOO0OOooo........oooOO0OOooo........oo    
104                                                   
105 G4VPhysicalVolume* WLSDetectorConstruction::Co    
106 {                                                 
107   auto air = FindMaterial("G4_AIR");              
108   // G4cout << "\nMaterial Properties Table fo    
109   // air->GetMaterialPropertiesTable()->DumpTa    
110                                                   
111   //------------------------------------------    
112   // World                                        
113   //------------------------------------------    
114                                                   
115   G4VSolid* solidWorld = new G4Box("World", fW    
116                                                   
117   fLogicWorld = new G4LogicalVolume(solidWorld    
118                                                   
119   fPhysiWorld =                                   
120     new G4PVPlacement(nullptr, G4ThreeVector()    
121                                                   
122   //------------------------------------------    
123   // Extrusion                                    
124   //------------------------------------------    
125                                                   
126   auto coating = FindMaterial("Coating");         
127                                                   
128   G4VSolid* solidExtrusion =                      
129     new G4Box("Extrusion", GetBarBase() / 2.,     
130                                                   
131   auto logicExtrusion = new G4LogicalVolume(so    
132                                                   
133   auto TiO2Surface =                              
134     new G4OpticalSurface("TiO2Surface", glisur    
135                                                   
136   auto TiO2SurfaceProperty = new G4MaterialPro    
137                                                   
138   std::vector<G4double> p_TiO2 = {2.00 * eV, 3    
139                                                   
140   std::vector<G4double> refl_TiO2 = {fExtrusio    
141   std::vector<G4double> effi_TiO2 = {0., 0.};     
142                                                   
143   TiO2SurfaceProperty->AddProperty("REFLECTIVI    
144   TiO2SurfaceProperty->AddProperty("EFFICIENCY    
145                                                   
146   TiO2Surface->SetMaterialPropertiesTable(TiO2    
147                                                   
148   new G4PVPlacement(nullptr, G4ThreeVector(),     
149                                                   
150   new G4LogicalSkinSurface("TiO2Surface", logi    
151                                                   
152   //------------------------------------------    
153   // Scintillator                                 
154   //------------------------------------------    
155                                                   
156   auto polystyrene = FindMaterial("Polystyrene    
157   // G4cout << "\nMaterial Properties Table fo    
158   // polystyrene->GetMaterialPropertiesTable()    
159                                                   
160   G4VSolid* solidScintillator =                   
161     new G4Box("Scintillator", GetBarBase() / 2    
162               GetBarBase() / 2. - GetCoatingTh    
163                                                   
164   auto logicScintillator = new G4LogicalVolume    
165                                                   
166   new G4PVPlacement(nullptr, G4ThreeVector(),     
167                     false, 0);                    
168                                                   
169   G4LogicalVolume* logicScintSide = nullptr;      
170   G4LogicalVolume* logicScintCrnr = nullptr;      
171   if (GetCoatingRadius() > 0.) {                  
172     G4VSolid* solidScintside =                    
173       new G4Box("SideOfBar", GetBarBase() / 2.    
174                 GetCoatingRadius() / 2., GetBa    
175                                                   
176     G4VSolid* solidScintcrnr = new G4Tubs("Crn    
177                                           GetB    
178                                                   
179     logicScintSide = new G4LogicalVolume(solid    
180                                                   
181     logicScintCrnr = new G4LogicalVolume(solid    
182                                                   
183     G4double pos = GetBarBase() / 2. - GetCoat    
184                                                   
185     new G4PVPlacement(nullptr, G4ThreeVector(0    
186                       logicExtrusion, false, 0    
187                                                   
188     new G4PVPlacement(nullptr, G4ThreeVector(0    
189                       logicExtrusion, false, 1    
190                                                   
191     auto rot1 = new G4RotationMatrix();           
192     rot1->rotateZ(-90. * deg);                    
193                                                   
194     new G4PVPlacement(rot1, G4ThreeVector(pos,    
195                       false, 2);                  
196                                                   
197     new G4PVPlacement(rot1, G4ThreeVector(-pos    
198                       logicExtrusion, false, 3    
199                                                   
200     pos = GetBarBase() / 2. - GetCoatingThickn    
201                                                   
202     new G4PVPlacement(nullptr, G4ThreeVector(p    
203                       logicExtrusion, false, 0    
204                                                   
205     new G4PVPlacement(rot1, G4ThreeVector(-pos    
206                       logicExtrusion, false, 1    
207                                                   
208     auto rot2 = new G4RotationMatrix();           
209     rot2->rotateZ(-180. * deg);                   
210                                                   
211     new G4PVPlacement(rot2, G4ThreeVector(-pos    
212                       logicExtrusion, false, 2    
213                                                   
214     auto rot3 = new G4RotationMatrix();           
215     rot3->rotateZ(-270. * deg);                   
216                                                   
217     new G4PVPlacement(rot3, G4ThreeVector(pos,    
218                       logicExtrusion, false, 3    
219   }                                               
220                                                   
221   if (GetFiberRadius() < GetHoleRadius()) {       
222     G4VSolid* solidHole =                         
223       new G4Tubs("Hole", 0., GetHoleRadius(),     
224                                                   
225     fLogicHole = new G4LogicalVolume(solidHole    
226                                                   
227     fPhysiHole =                                  
228       new G4PVPlacement(nullptr, G4ThreeVector    
229   }                                               
230                                                   
231   //------------------------------------------    
232   // Fiber                                        
233   //------------------------------------------    
234                                                   
235   if (!(fLogicHole) || !(fPhysiHole)) {           
236     G4ExceptionDescription ed;                    
237     ed << "The Fiber Hole has not been constru    
238     G4Exception("WLSDetectorConstruction", "wl    
239   }                                               
240                                                   
241   // Pointers to the most recently constructed    
242   G4LogicalVolume* logicPlacement = fLogicHole    
243   G4VPhysicalVolume* physiPlacement = fPhysiHo    
244                                                   
245   //------------------------------------------    
246   // Fiber Construction                           
247   //------------------------------------------    
248                                                   
249   // Boundary Surface Properties                  
250   G4OpticalSurface* opSurface = nullptr;          
251                                                   
252   if (fSurfaceRoughness < 1.)                     
253     opSurface = new G4OpticalSurface("RoughSur    
254                                      fSurfaceR    
255                                                   
256   G4LogicalVolume* logicWLSfiber = nullptr;       
257   G4LogicalVolume* logicClad1 = nullptr;          
258   G4LogicalVolume* logicClad2 = nullptr;          
259   G4VPhysicalVolume* physiClad1 = nullptr;        
260   G4VPhysicalVolume* physiClad2 = nullptr;        
261                                                   
262   auto fpethylene = FindMaterial("FPethylene")    
263   auto pethylene = FindMaterial("Pethylene");     
264   auto pmma = FindMaterial("PMMA");               
265                                                   
266   // Determine the number of cladding layers t    
267   switch (fNumOfCladLayers) {                     
268     case 2:                                       
269                                                   
270       //--------------------------------------    
271       // Cladding 2                               
272       //--------------------------------------    
273                                                   
274       // G4cout << "\nMaterial Properties Tabl    
275       // fpethylene->GetMaterialPropertiesTabl    
276                                                   
277       G4VSolid* solidClad2;                       
278                                                   
279       if (fXYRatio == 1.)                         
280         solidClad2 = new G4Tubs("Clad2", 0., f    
281       else                                        
282         solidClad2 = new G4EllipticalTube("Cla    
283                                                   
284       logicClad2 = new G4LogicalVolume(solidCl    
285                                                   
286       physiClad2 = new G4PVPlacement(nullptr,     
287                                      "Clad2",     
288                                                   
289       // Place the rough surface only if neede    
290       if (opSurface) {                            
291         new G4LogicalBorderSurface("surfaceCla    
292         new G4LogicalBorderSurface("surfaceCla    
293       }                                           
294                                                   
295       logicPlacement = logicClad2;                
296       physiPlacement = physiClad2;                
297       [[fallthrough]];                            
298                                                   
299     case 1:                                       
300                                                   
301       //--------------------------------------    
302       // Cladding 1                               
303       //--------------------------------------    
304                                                   
305       // G4cout << "\nMaterial Properties Tabl    
306       // pethylene->GetMaterialPropertiesTable    
307                                                   
308       G4VSolid* solidClad1;                       
309                                                   
310       if (fXYRatio == 1.)                         
311         solidClad1 = new G4Tubs("Clad1", 0., f    
312       else                                        
313         solidClad1 = new G4EllipticalTube("Cla    
314                                                   
315       logicClad1 = new G4LogicalVolume(solidCl    
316                                                   
317       physiClad1 = new G4PVPlacement(nullptr,     
318                                      "Clad1",     
319                                                   
320       // Place the rough surface only if neede    
321       if (opSurface) {                            
322         new G4LogicalBorderSurface("surfaceCla    
323                                                   
324         new G4LogicalBorderSurface("surfaceCla    
325       }                                           
326                                                   
327       logicPlacement = logicClad1;                
328       physiPlacement = physiClad1;                
329       [[fallthrough]];                            
330                                                   
331     default:                                      
332                                                   
333       //--------------------------------------    
334       // WLS Fiber                                
335       //--------------------------------------    
336                                                   
337       // G4cout << "\nMaterial Properties Tabl    
338       // pmma->GetMaterialPropertiesTable()->D    
339                                                   
340       G4VSolid* solidWLSfiber;                    
341                                                   
342       if (fXYRatio == 1.) {                       
343         solidWLSfiber = new G4Tubs("WLSFiber",    
344       }                                           
345       else {                                      
346         solidWLSfiber = new G4EllipticalTube("    
347       }                                           
348                                                   
349       logicWLSfiber = new G4LogicalVolume(soli    
350                                                   
351       logicWLSfiber->SetUserLimits(new G4UserL    
352                                                   
353       G4VPhysicalVolume* physiWLSfiber =          
354         new G4PVPlacement(nullptr, G4ThreeVect    
355                           "WLSFiber", logicPla    
356                                                   
357       // Place the rough surface only if neede    
358       if (opSurface) {                            
359         new G4LogicalBorderSurface("surfaceWLS    
360                                                   
361         new G4LogicalBorderSurface("surfaceWLS    
362       }                                           
363   }                                               
364                                                   
365   //------------------------------------------    
366   // Mirror for reflection at one of the end      
367   //------------------------------------------    
368                                                   
369   // Place the mirror only if the user wants t    
370   G4LogicalVolume* logicMirror = nullptr;         
371                                                   
372   auto aluminum = FindMaterial("G4_Al");          
373                                                   
374   if (fMirrorToggle) {                            
375     G4VSolid* solidMirror = new G4Box("Mirror"    
376                                                   
377     logicMirror = new G4LogicalVolume(solidMir    
378                                                   
379     auto mirrorSurface =                          
380       new G4OpticalSurface("MirrorSurface", gl    
381                                                   
382     auto mirrorSurfaceProperty = new G4Materia    
383                                                   
384     std::vector<G4double> p_mirror = {2.00 * e    
385     std::vector<G4double> refl_mirror = {fMirr    
386     std::vector<G4double> effi_mirror = {0., 0    
387                                                   
388     mirrorSurfaceProperty->AddProperty("REFLEC    
389     mirrorSurfaceProperty->AddProperty("EFFICI    
390                                                   
391     mirrorSurface->SetMaterialPropertiesTable(    
392                                                   
393     new G4PVPlacement(nullptr, G4ThreeVector(0    
394                       fLogicWorld, false, 0);     
395                                                   
396     new G4LogicalSkinSurface("MirrorSurface",     
397   }                                               
398                                                   
399   //------------------------------------------    
400   // Coupling at the read-out end                 
401   //------------------------------------------    
402                                                   
403   // Clear Fiber (Coupling Layer)                 
404   G4VSolid* solidCouple = new G4Box("Couple",     
405                                                   
406   auto logicCouple = new G4LogicalVolume(solid    
407                                                   
408   new G4PVPlacement(nullptr, G4ThreeVector(0.,    
409                     fLogicWorld, false, 0);       
410                                                   
411   //------------------------------------------    
412   // A logical layer in front of PhotonDet        
413   //------------------------------------------    
414                                                   
415   // Purpose: Preventing direct dielectric to     
416                                                   
417   // Check for valid placement of PhotonDet       
418   if (fMPPCTheta > std::atan(fMPPCDist / fMPPC    
419     fMPPCTheta = 0.;                              
420     fMPPCOriginX = std::sin(fMPPCTheta) * (fMP    
421     fMPPCOriginZ = -fCoupleZ + std::cos(fMPPCT    
422     G4ExceptionDescription ed;                    
423     ed << "Invalid alignment.  Alignment reset    
424     G4Exception("WLSDetectorConstruction", "wl    
425   }                                               
426                                                   
427   // Clear Fiber (Coupling Layer)                 
428   G4VSolid* solidClrfiber;                        
429                                                   
430   if (fMPPCShape == "Square") {                   
431     solidClrfiber = new G4Box("ClearFiber", fC    
432   }                                               
433   else {                                          
434     solidClrfiber = new G4Tubs("ClearFiber", 0    
435   }                                               
436                                                   
437   auto logicClrfiber = new G4LogicalVolume(sol    
438                                                   
439   new G4PVPlacement(new G4RotationMatrix(CLHEP    
440                     G4ThreeVector(fMPPCOriginX    
441                     logicCouple, false, 0);       
442                                                   
443   //------------------------------------------    
444   // PhotonDet (Sensitive Detector)               
445   //------------------------------------------    
446                                                   
447   // Physical Construction                        
448   G4VSolid* solidPhotonDet = nullptr;             
449                                                   
450   if (fMPPCShape == "Square")                     
451     solidPhotonDet = new G4Box("PhotonDet", fM    
452   else                                            
453     solidPhotonDet = new G4Tubs("PhotonDet", 0    
454                                                   
455   auto logicPhotonDet = new G4LogicalVolume(so    
456                                                   
457   new G4PVPlacement(nullptr, G4ThreeVector(0.,    
458                     false, 0);                    
459                                                   
460   // PhotonDet Surface Properties                 
461   auto photonDetSurface =                         
462     new G4OpticalSurface("PhotonDetSurface", g    
463                                                   
464   auto photonDetSurfaceProperty = new G4Materi    
465                                                   
466   std::vector<G4double> p_mppc = {2.00 * eV, 3    
467   std::vector<G4double> refl_mppc = {fMPPCRefl    
468   std::vector<G4double> effi_mppc = {1., 1.};     
469                                                   
470   photonDetSurfaceProperty->AddProperty("REFLE    
471   photonDetSurfaceProperty->AddProperty("EFFIC    
472                                                   
473   photonDetSurface->SetMaterialPropertiesTable    
474                                                   
475   new G4LogicalSkinSurface("PhotonDetSurface",    
476                                                   
477   // visualization attributes ----------------    
478                                                   
479   auto visAttributes = new G4VisAttributes(G4C    
480   visAttributes->SetVisibility(false);            
481   fLogicWorld->SetVisAttributes(visAttributes)    
482   fVisAttributes.push_back(visAttributes);        
483                                                   
484   visAttributes = new G4VisAttributes(G4Colour    
485   visAttributes->SetVisibility(true);             
486   logicExtrusion->SetVisAttributes(visAttribut    
487   fVisAttributes.push_back(visAttributes);        
488                                                   
489   visAttributes = new G4VisAttributes(G4Colour    
490   visAttributes->SetVisibility(true);             
491   logicScintillator->SetVisAttributes(visAttri    
492   fVisAttributes.push_back(visAttributes);        
493                                                   
494   visAttributes = new G4VisAttributes(G4Colour    
495   visAttributes->SetVisibility(true);             
496   logicScintSide->SetVisAttributes(visAttribut    
497   fVisAttributes.push_back(visAttributes);        
498                                                   
499   visAttributes = new G4VisAttributes(G4Colour    
500   visAttributes->SetVisibility(true);             
501   logicScintCrnr->SetVisAttributes(visAttribut    
502   fVisAttributes.push_back(visAttributes);        
503                                                   
504   visAttributes = new G4VisAttributes(G4Colour    
505   visAttributes->SetVisibility(true);             
506   fLogicHole->SetVisAttributes(visAttributes);    
507   fVisAttributes.push_back(visAttributes);        
508                                                   
509   if (logicClad1 != nullptr) {                    
510     visAttributes = new G4VisAttributes(G4Colo    
511     visAttributes->SetVisibility(true);           
512     logicClad1->SetVisAttributes(visAttributes    
513     fVisAttributes.push_back(visAttributes);      
514   }                                               
515                                                   
516   if (logicClad2 != nullptr) {                    
517     visAttributes = new G4VisAttributes(G4Colo    
518     visAttributes->SetVisibility(true);           
519     logicClad2->SetVisAttributes(visAttributes    
520     fVisAttributes.push_back(visAttributes);      
521   }                                               
522                                                   
523   visAttributes = new G4VisAttributes(G4Colour    
524   visAttributes->SetVisibility(true);             
525   logicWLSfiber->SetVisAttributes(visAttribute    
526   fVisAttributes.push_back(visAttributes);        
527                                                   
528   if (fMirrorToggle == true) {                    
529     visAttributes = new G4VisAttributes(G4Colo    
530     visAttributes->SetVisibility(true);           
531     logicMirror->SetVisAttributes(visAttribute    
532     fVisAttributes.push_back(visAttributes);      
533   }                                               
534                                                   
535   visAttributes = new G4VisAttributes(G4Colour    
536   visAttributes->SetVisibility(true);             
537   logicCouple->SetVisAttributes(visAttributes)    
538   fVisAttributes.push_back(visAttributes);        
539                                                   
540   visAttributes = new G4VisAttributes(G4Colour    
541   visAttributes->SetVisibility(true);             
542   logicClrfiber->SetVisAttributes(visAttribute    
543   fVisAttributes.push_back(visAttributes);        
544                                                   
545   visAttributes = new G4VisAttributes(G4Colour    
546   visAttributes->SetVisibility(true);             
547   logicPhotonDet->SetVisAttributes(visAttribut    
548   fVisAttributes.push_back(visAttributes);        
549                                                   
550   return fPhysiWorld;                             
551 }                                                 
552                                                   
553 //....oooOO0OOooo........oooOO0OOooo........oo    
554                                                   
555 void WLSDetectorConstruction::ConstructSDandFi    
556 {                                                 
557   if (!fmppcSD.Get()) {                           
558     G4String mppcSDName = "WLS/PhotonDet";        
559     auto mppcSD = new WLSPhotonDetSD(mppcSDNam    
560     G4SDManager::GetSDMpointer()->AddNewDetect    
561     fmppcSD.Put(mppcSD);                          
562   }                                               
563   SetSensitiveDetector("PhotonDet_LV", fmppcSD    
564 }                                                 
565                                                   
566 //....oooOO0OOooo........oooOO0OOooo........oo    
567                                                   
568 void WLSDetectorConstruction::UpdateGeometryPa    
569 {                                                 
570   fWLSfiberRX = fXYRatio * fWLSfiberRY;           
571                                                   
572   fClad1RX = fWLSfiberRX + 0.03 * fWLSfiberRX;    
573   fClad1RY = fWLSfiberRY + 0.03 * fWLSfiberRY;    
574   fClad1Z = fWLSfiberZ;                           
575                                                   
576   fClad2RX = fClad1RX + 0.03 * fWLSfiberRX;       
577   fClad2RY = fClad1RY + 0.03 * fWLSfiberRY;       
578   fClad2Z = fWLSfiberZ;                           
579                                                   
580   fWorldSizeX = fClad2RX + fMPPCDist + fMPPCHa    
581   fWorldSizeY = fClad2RY + fMPPCDist + fMPPCHa    
582   fWorldSizeZ = fWLSfiberZ + fMPPCDist + fMPPC    
583                                                   
584   fCoupleRX = fWorldSizeX;                        
585   fCoupleRY = fWorldSizeY;                        
586   fCoupleZ = (fWorldSizeZ - fWLSfiberZ) / 2.;     
587                                                   
588   fClrfiberHalfL = fMPPCHalfL;                    
589                                                   
590   fMirrorRmax = fClad2RY;                         
591                                                   
592   fCoupleOrigin = fWLSfiberOrigin + fWLSfiberZ    
593   fMirrorOrigin = fWLSfiberOrigin - fWLSfiberZ    
594   fMPPCOriginX = std::sin(fMPPCTheta) * (fMPPC    
595   fMPPCOriginZ = -fCoupleZ + std::cos(fMPPCThe    
596 }                                                 
597                                                   
598 //....oooOO0OOooo........oooOO0OOooo........oo    
599                                                   
600 void WLSDetectorConstruction::SetPhotonDetGeom    
601 // Set the Geometry of the PhotonDet detector     
602 // Pre:  shape must be either "Circle" and "Sq    
603 {                                                 
604   if (shape == "Circle" || shape == "Square")     
605   G4RunManager::GetRunManager()->GeometryHasBe    
606 }                                                 
607                                                   
608 //....oooOO0OOooo........oooOO0OOooo........oo    
609                                                   
610 void WLSDetectorConstruction::SetNumberOfCladd    
611 // Set the number of claddings                    
612 // Pre: 0 <= num <= 2                             
613 {                                                 
614   fNumOfCladLayers = num;                         
615   G4RunManager::GetRunManager()->GeometryHasBe    
616 }                                                 
617                                                   
618 //....oooOO0OOooo........oooOO0OOooo........oo    
619                                                   
620 void WLSDetectorConstruction::SetWLSLength(G4d    
621 // Set the TOTAL length of the WLS fiber          
622 {                                                 
623   fWLSfiberZ = length;                            
624   G4RunManager::GetRunManager()->GeometryHasBe    
625 }                                                 
626                                                   
627 //....oooOO0OOooo........oooOO0OOooo........oo    
628                                                   
629 void WLSDetectorConstruction::SetWLSRadius(G4d    
630 // Set the Y radius of WLS fiber                  
631 {                                                 
632   fWLSfiberRY = radius;                           
633   G4RunManager::GetRunManager()->GeometryHasBe    
634 }                                                 
635                                                   
636 //....oooOO0OOooo........oooOO0OOooo........oo    
637                                                   
638 void WLSDetectorConstruction::SetClad1Radius(G    
639 // Set the Y radius of Cladding 1                 
640 {                                                 
641   fClad1RY = radius;                              
642   G4RunManager::GetRunManager()->GeometryHasBe    
643 }                                                 
644                                                   
645 //....oooOO0OOooo........oooOO0OOooo........oo    
646                                                   
647 void WLSDetectorConstruction::SetClad2Radius(G    
648 // Set the Y radius of Cladding 2                 
649 {                                                 
650   fClad2RY = radius;                              
651   G4RunManager::GetRunManager()->GeometryHasBe    
652 }                                                 
653                                                   
654 //....oooOO0OOooo........oooOO0OOooo........oo    
655                                                   
656 void WLSDetectorConstruction::SetPhotonDetHalf    
657 // Set the half length of the PhotonDet detect    
658 // The half length will be the radius if Photo    
659 {                                                 
660   fMPPCHalfL = halfL;                             
661   G4RunManager::GetRunManager()->GeometryHasBe    
662 }                                                 
663                                                   
664 //....oooOO0OOooo........oooOO0OOooo........oo    
665                                                   
666 void WLSDetectorConstruction::SetGap(G4double     
667 // Set the distance between fiber end and Phot    
668 {                                                 
669   fMPPCDist = gap;                                
670   G4RunManager::GetRunManager()->GeometryHasBe    
671 }                                                 
672                                                   
673 //....oooOO0OOooo........oooOO0OOooo........oo    
674                                                   
675 void WLSDetectorConstruction::SetPhotonDetAlig    
676 // Set the Aligment of PhotonDet with respect     
677 // If theta is 0 deg, then the detector is per    
678 // PhotonDet will be deviated by theta from z     
679 // facing towards the center of the fiber         
680 {                                                 
681   fMPPCTheta = theta;                             
682   G4RunManager::GetRunManager()->GeometryHasBe    
683 }                                                 
684                                                   
685 //....oooOO0OOooo........oooOO0OOooo........oo    
686                                                   
687 void WLSDetectorConstruction::SetSurfaceRoughn    
688 // Set the Surface Roughness between Cladding     
689 // Pre: 0 < roughness <= 1                        
690 {                                                 
691   fSurfaceRoughness = roughness;                  
692   G4RunManager::GetRunManager()->GeometryHasBe    
693 }                                                 
694                                                   
695 //....oooOO0OOooo........oooOO0OOooo........oo    
696                                                   
697 void WLSDetectorConstruction::SetMirrorPolish(    
698 // Set the Polish of the mirror, polish of 1 i    
699 // Pre: 0 < polish <= 1                           
700 {                                                 
701   fMirrorPolish = polish;                         
702   G4RunManager::GetRunManager()->GeometryHasBe    
703 }                                                 
704                                                   
705 //....oooOO0OOooo........oooOO0OOooo........oo    
706                                                   
707 void WLSDetectorConstruction::SetMirrorReflect    
708 // Set the Reflectivity of the mirror, reflect    
709 // Pre: 0 < reflectivity <= 1                     
710 {                                                 
711   fMirrorReflectivity = reflectivity;             
712   G4RunManager::GetRunManager()->GeometryHasBe    
713 }                                                 
714                                                   
715 //....oooOO0OOooo........oooOO0OOooo........oo    
716                                                   
717 void WLSDetectorConstruction::SetPhotonDetPoli    
718 // Set the Polish of the PhotonDet, polish of     
719 // Pre: 0 < polish <= 1                           
720 {                                                 
721   fMPPCPolish = polish;                           
722   G4RunManager::GetRunManager()->GeometryHasBe    
723 }                                                 
724                                                   
725 //....oooOO0OOooo........oooOO0OOooo........oo    
726                                                   
727 void WLSDetectorConstruction::SetPhotonDetRefl    
728 // Set the Reflectivity of the PhotonDet, refl    
729 // Pre: 0 < reflectivity <= 1                     
730 {                                                 
731   fMPPCReflectivity = reflectivity;               
732   G4RunManager::GetRunManager()->GeometryHasBe    
733 }                                                 
734                                                   
735 //....oooOO0OOooo........oooOO0OOooo........oo    
736                                                   
737 void WLSDetectorConstruction::SetMirror(G4bool    
738 // Toggle to place the mirror or not at one en    
739 // True means place the mirror, false means ot    
740 {                                                 
741   fMirrorToggle = flag;                           
742   G4RunManager::GetRunManager()->GeometryHasBe    
743 }                                                 
744                                                   
745 //....oooOO0OOooo........oooOO0OOooo........oo    
746                                                   
747 void WLSDetectorConstruction::SetXYRatio(G4dou    
748 // Set the ratio of the x and y radius of the     
749 // a ratio of 1 would produce a circle            
750 {                                                 
751   fXYRatio = r;                                   
752   G4RunManager::GetRunManager()->GeometryHasBe    
753 }                                                 
754                                                   
755 //....oooOO0OOooo........oooOO0OOooo........oo    
756                                                   
757 void WLSDetectorConstruction::SetBarLength(G4d    
758 // Set the length of the scintillator bar         
759 {                                                 
760   fBarLength = length;                            
761   G4RunManager::GetRunManager()->GeometryHasBe    
762 }                                                 
763                                                   
764 //....oooOO0OOooo........oooOO0OOooo........oo    
765                                                   
766 void WLSDetectorConstruction::SetBarBase(G4dou    
767 // Set the side of the scintillator bar           
768 {                                                 
769   fBarBase = side;                                
770   G4RunManager::GetRunManager()->GeometryHasBe    
771 }                                                 
772                                                   
773 //....oooOO0OOooo........oooOO0OOooo........oo    
774                                                   
775 void WLSDetectorConstruction::SetHoleRadius(G4    
776 // Set the radius of the fiber hole               
777 {                                                 
778   fHoleRadius = radius;                           
779   G4RunManager::GetRunManager()->GeometryHasBe    
780 }                                                 
781                                                   
782 //....oooOO0OOooo........oooOO0OOooo........oo    
783                                                   
784 void WLSDetectorConstruction::SetCoatingThickn    
785 // Set thickness of the coating on the bars       
786 {                                                 
787   fCoatingThickness = thick;                      
788   G4RunManager::GetRunManager()->GeometryHasBe    
789 }                                                 
790                                                   
791 //....oooOO0OOooo........oooOO0OOooo........oo    
792                                                   
793 void WLSDetectorConstruction::SetCoatingRadius    
794 // Set inner radius of the corner bar coating     
795 {                                                 
796   fCoatingRadius = radius;                        
797   G4RunManager::GetRunManager()->GeometryHasBe    
798 }                                                 
799                                                   
800 //....oooOO0OOooo........oooOO0OOooo........oo    
801                                                   
802 G4double WLSDetectorConstruction::GetWLSFiberL    
803 {                                                 
804   return fWLSfiberZ;                              
805 }                                                 
806                                                   
807 //....oooOO0OOooo........oooOO0OOooo........oo    
808                                                   
809 G4double WLSDetectorConstruction::GetBarLength    
810 {                                                 
811   return fBarLength;                              
812 }                                                 
813                                                   
814 //....oooOO0OOooo........oooOO0OOooo........oo    
815                                                   
816 G4double WLSDetectorConstruction::GetBarBase()    
817 {                                                 
818   return fBarBase;                                
819 }                                                 
820                                                   
821 //....oooOO0OOooo........oooOO0OOooo........oo    
822                                                   
823 G4double WLSDetectorConstruction::GetHoleRadiu    
824 {                                                 
825   return fHoleRadius;                             
826 }                                                 
827                                                   
828 //....oooOO0OOooo........oooOO0OOooo........oo    
829                                                   
830 G4double WLSDetectorConstruction::GetHoleLengt    
831 {                                                 
832   return fHoleLength;                             
833 }                                                 
834                                                   
835 //....oooOO0OOooo........oooOO0OOooo........oo    
836                                                   
837 G4double WLSDetectorConstruction::GetFiberRadi    
838 {                                                 
839   return GetWLSFiberRMax();                       
840 }                                                 
841                                                   
842 //....oooOO0OOooo........oooOO0OOooo........oo    
843                                                   
844 G4double WLSDetectorConstruction::GetCoatingTh    
845 {                                                 
846   return fCoatingThickness;                       
847 }                                                 
848                                                   
849 //....oooOO0OOooo........oooOO0OOooo........oo    
850                                                   
851 G4double WLSDetectorConstruction::GetCoatingRa    
852 {                                                 
853   return fCoatingRadius;                          
854 }                                                 
855                                                   
856 //....oooOO0OOooo........oooOO0OOooo........oo    
857                                                   
858 G4double WLSDetectorConstruction::GetWLSFiberE    
859 {                                                 
860   return fWLSfiberOrigin + fWLSfiberZ;            
861 }                                                 
862                                                   
863 //....oooOO0OOooo........oooOO0OOooo........oo    
864                                                   
865 G4double WLSDetectorConstruction::GetWLSFiberR    
866 {                                                 
867   if (fNumOfCladLayers == 2) return fClad2RY;     
868   if (fNumOfCladLayers == 1) return fClad1RY;     
869   return fWLSfiberRY;                             
870 }                                                 
871                                                   
872 //....oooOO0OOooo........oooOO0OOooo........oo    
873                                                   
874 G4double WLSDetectorConstruction::GetSurfaceRo    
875 {                                                 
876   return fSurfaceRoughness;                       
877 }                                                 
878                                                   
879 //....oooOO0OOooo........oooOO0OOooo........oo    
880                                                   
881 // Return True if the fiber construction is id    
882 G4bool WLSDetectorConstruction::IsPerfectFiber    
883 {                                                 
884   return fSurfaceRoughness == 1. && fXYRatio =    
885          && (!fMirrorToggle || (fMirrorPolish     
886 }                                                 
887                                                   
888 //....oooOO0OOooo........oooOO0OOooo........oo    
889                                                   
890 G4Material* WLSDetectorConstruction::FindMater    
891 {                                                 
892   G4Material* material = G4Material::GetMateri    
893   return material;                                
894 }                                                 
895