23 #include "G4SDManager.hh"
24 #include "G4Material.hh"
25 #include "G4MaterialTable.hh"
26 #include "G4Element.hh"
27 #include "G4ElementTable.hh"
28 #include "G4UserLimits.hh"
32 #include "G4Sphere.hh"
34 #include "G4UnionSolid.hh"
35 #include "G4SubtractionSolid.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4AssemblyVolume.hh"
38 #include "G4RotationMatrix.hh"
39 #include "G4ThreeVector.hh"
40 #include "G4Transform3D.hh"
41 #include "G4PVPlacement.hh"
42 #include "G4VisAttributes.hh"
43 #include "G4Colour.hh"
44 #include "G4RunManager.hh"
47 #include <utl/config.h>
48 #include <utl/ErrorLogger.h>
49 #include <det/Detector.h>
50 #include <fdet/FDetector.h>
52 #include <fdet/Telescope.h>
53 #include <fdet/Corrector.h>
54 #include <fdet/Diaphragm.h>
55 #include <fdet/Camera.h>
57 #include "G4Version.hh"
60 #if (G4VERSION_NUMBER>=900)
62 #include "G4GeometryTolerance.hh"
65 using namespace TelescopeSimulatorLX;
72 fXMLManager(XMLManager),
75 fTelescopeMother_phys(NULL),
76 fLensFilterMother_phys(NULL),
79 fHasCorrectorRing(false),
80 fCorrectorRingInnerRadius(0.0*
mm),
81 fCorrectorRingOuterRadius(0.0*
mm),
84 fUseSensitiveDetectors(false)
118 G4cerr <<
"# #" << G4endl;
119 G4cerr <<
"# Done geometry #" << G4endl;
120 G4cerr <<
"# #" << G4endl;
125 G4VisAttributes* UniverseVisAtt =
new G4VisAttributes(G4Colour(1.0,1.0,1.0));
126 UniverseVisAtt->SetVisibility(
false);
127 fWorld_phys->GetLogicalVolume()->SetVisAttributes(UniverseVisAtt);
130 G4cerr << *(G4Material::GetMaterialTable()) << G4endl;
131 G4cerr <<
"Tree of Sensitive Detectors: " << G4endl;
132 (G4SDManager::GetSDMpointer())->ListTree();
147 G4LogicalVolume * World_log
150 return new G4PVPlacement(0,G4ThreeVector(),
"World",World_log,0,
false,0);
160 G4LogicalVolume * TelMother_log
161 =
new G4LogicalVolume(TelMotherBox,
fWorldMaterial,
"TelMother",0,0,0,
true);
163 TelMother_log->SetSmartless(50);
165 G4ThreeVector TelMotherPos = G4ThreeVector(0.0*
mm,0.0*
mm,0.0*
mm);
166 G4RotationMatrix *TelMotherRot =
new G4RotationMatrix();
170 TelMotherRot->rotateZ(pi/2.);
173 G4VisAttributes* tmpVisAtt =
new G4VisAttributes();
174 tmpVisAtt->SetVisibility(
false);
175 TelMother_log->SetVisAttributes(tmpVisAtt);
178 G4VPhysicalVolume* telMother_phys =
179 new G4PVPlacement(TelMotherRot,TelMotherPos,
"TelescopeMother",TelMother_log,
fWorld_phys,
false,0);
180 #if (G4VERSION_NUMBER>=800)
182 telMother_phys ->CheckOverlaps(10000);
192 G4Box* LensFilterSolid =
193 new G4Box(
"LensFilterMother",xSize/2.0,ySize/2.0,zSize/2.0);
195 G4LogicalVolume * LensFilterMother_log
196 =
new G4LogicalVolume(LensFilterSolid,
fWorldMaterial,
"LensFilterMother",0,0,0,
true);
198 LensFilterMother_log->SetSmartless(50);
201 new G4PVPlacement(0,
fCorrectorRingPosition,
"LensFilterMother",LensFilterMother_log,telMother_phys,
false,0);
203 #if (G4VERSION_NUMBER>=800)
209 G4VisAttributes* VisAtt =
new G4VisAttributes(
yellow);
210 VisAtt->SetVisibility(
false);
211 LensFilterMother_log->SetVisAttributes(VisAtt);
214 return telMother_phys;
228 G4Exception(
"Error !!! Filter logical volume does not exhist !!!");
233 G4double FilterSDThick = 0.1*
mm;
235 G4double inRadius = 0.0*
mm;
237 G4double dZ = FilterSDThick;
238 G4double sPhi = 0.0*
deg;
239 G4double dPhi = 360.0*
deg;
242 G4Tubs* FilterSDTubs =
new G4Tubs(
"FilterSD",inRadius,ouRadius,dZ/2.0,sPhi,dPhi);
243 G4LogicalVolume * FilterSD_log =
244 new G4LogicalVolume(FilterSDTubs,
fWorldMaterial,
"FilterSD",0,0,0);
246 G4ThreeVector FilterSDPos =
249 G4PVPlacement* filterSD_phys =
255 (G4SDManager::GetSDMpointer())->AddNewDetector(FilterSD);
256 FilterSD_log->SetSensitiveDetector(FilterSD);
258 #if (G4VERSION_NUMBER>=800)
260 filterSD_phys->CheckOverlaps(10000);
264 G4VisAttributes* tmpVisAtt =
new G4VisAttributes(
yellow);
265 tmpVisAtt->SetVisibility(
false);
266 FilterSD_log ->SetVisAttributes(tmpVisAtt);
277 const double kAngTolerance = G4GeometryTolerance::GetInstance()->GetAngularTolerance();
280 G4double inRadius = 1000.0*
mm;
281 G4double ouRadius = 2900.0*
mm;
282 G4double sPhi = -50.*
deg;
283 G4double dPhi = 100.*
deg-kAngTolerance;
284 G4double sTheta = 50.*
deg;
285 G4double dTheta = 80.0*
deg-kAngTolerance;
287 G4Sphere *cameraSphere =
288 new G4Sphere(
"CameraMother",inRadius,ouRadius,sPhi,dPhi,sTheta,dTheta);
290 G4LogicalVolume* mother_log
291 =
new G4LogicalVolume(cameraSphere,
fWorldMaterial,
"CameraMother",0,0,0,
true);
293 mother_log->SetSmartless(50);
295 G4ThreeVector motherPos(0.0*
mm,0.0*
mm,0.0*
mm);
296 G4RotationMatrix* motherRot =
new G4RotationMatrix();
298 motherRot->rotateY(-pi/2.0);
300 G4PVPlacement* mother_phys =
304 G4VisAttributes* tmpVisAtt =
new G4VisAttributes();
305 tmpVisAtt->SetVisibility(
false);
306 mother_log->SetVisAttributes(tmpVisAtt);
311 #if (G4VERSION_NUMBER>=800)
313 mother_phys->CheckOverlaps(10000);
323 G4bool kUseOptimization =
true;
325 G4RotationMatrix *MirrorRot =
new G4RotationMatrix();
326 MirrorRot->rotateY(-pi/2.0);
329 const double kAngTolerance = G4GeometryTolerance::GetInstance()->GetAngularTolerance();
332 G4double inRadius = 3000.0*
mm;
333 G4double ouRadius = 3500.0*
mm;
334 G4double sPhi = -40.*
deg;
335 G4double dPhi = 80.*
deg-kAngTolerance;
336 G4double sTheta = 50.*
deg;
337 G4double dTheta = 80.0*
deg-kAngTolerance;
339 G4Sphere* mirrorSphere =
new G4Sphere(
"MirrorMother",
340 inRadius,ouRadius,sPhi,dPhi,sTheta,dTheta);
342 G4LogicalVolume* mirrorMother_log =
343 new G4LogicalVolume(mirrorSphere,
fWorldMaterial,
"MirrorMother",0,0,0);
345 mirrorMother_log -> SetOptimisation(kUseOptimization);
347 if (kUseOptimization){
348 mirrorMother_log->SetSmartless(50);
351 G4VPhysicalVolume* mirrorMother_phys =
352 new G4PVPlacement(MirrorRot, G4ThreeVector(),
"MirrorMother", mirrorMother_log,
356 G4VisAttributes* tmpVisAtt =
new G4VisAttributes(
yellow);
357 tmpVisAtt->SetVisibility(
false);
358 mirrorMother_log->SetVisAttributes(tmpVisAtt);
363 #if (G4VERSION_NUMBER>=800)
365 mirrorMother_phys->CheckOverlaps(10000);
383 const G4int kNumPoints = 1000;
404 G4Exception(
"Error in FDsimG4DetectorConstruction::ConstructCorrectorRing: unknown profile !!!");
407 G4PVPlacement * Lens_phys = NULL;
412 G4RotationMatrix * Rotation =
new G4RotationMatrix();
413 G4double angle = 2.0*pi/fCorrectorRingNumPetals * ii;
415 Rotation->rotateZ(angle);
417 Lens_phys =
new G4PVPlacement(Rotation,G4ThreeVector(),
"CorrectorRing",ring_log,
420 #if (G4VERSION_NUMBER>=800)
422 Lens_phys->CheckOverlaps(10000);
430 return CorrectorRing;
439 G4double LensSDThick = 0.1*
mm;
441 G4double inRadius = 0.0*
mm;
443 G4double dZ = LensSDThick;
444 G4double sPhi = 0.0*
deg;
445 G4double dPhi = 360.0*
deg;
447 G4Tubs* LensSDTubs =
new G4Tubs(
"LensSD",inRadius,ouRadius,dZ/2.0,sPhi,dPhi);
449 G4LogicalVolume* LensSD_log =
new G4LogicalVolume(LensSDTubs,
fWorldMaterial,
"LensSD",0,0,0);
451 G4ThreeVector LensSDPos =
454 G4PVPlacement* LensSD_phys =
457 #if (G4VERSION_NUMBER>=800)
459 LensSD_phys->CheckOverlaps(10000);
464 (G4SDManager::GetSDMpointer())->AddNewDetector(LensSD);
465 LensSD_log->SetSensitiveDetector(LensSD);
467 G4VisAttributes* tmpVisAtt =
new G4VisAttributes(
yellow);
468 tmpVisAtt->SetVisibility(
false);
469 LensSD_log ->SetVisAttributes(tmpVisAtt);
477 G4double DomeThick = 20.0*
cm;
478 G4ThreeVector DomeSize(5000.0*
mm,5000.0*
mm,5000.0*
mm);
479 G4ThreeVector DomeInnerSize =
480 DomeSize-G4ThreeVector(2.0*DomeThick,2.0*DomeThick,2.0*DomeThick);
482 G4Box* DomeOuterBox =
483 new G4Box(
"TelDome",DomeSize.x()/2.,DomeSize.y()/2.,DomeSize.z()/2.);
487 new G4Box(
"Hole",DomeHoleSide/2.0,DomeHoleSide/2.0,DomeThick/2.0 + 1.0*
mm);
489 G4ThreeVector FilterHolePosition(0.0*
mm,0.0*
mm,DomeInnerSize.z()/2+DomeThick/2.0);
490 G4Box* DomeInnerBox =
491 new G4Box(
"TelDomeIn",DomeInnerSize.x()/2.0,DomeInnerSize.y()/2.0,DomeInnerSize.z()/2.0);
493 G4UnionSolid* DomeVoid =
494 new G4UnionSolid(
"TelescopeDomeVoid",DomeInnerBox,DomeHole,0,FilterHolePosition);
495 G4SubtractionSolid* DomeBox =
496 new G4SubtractionSolid(
"TelescopeDome",DomeOuterBox,DomeVoid);
498 G4Material* material = G4Material::GetMaterial(
"Aluminum");
499 G4LogicalVolume* Dome_log =
new G4LogicalVolume(DomeBox,material,
"TelescopeDome",0,0,0,
true);
502 G4VisAttributes* DomeVisAtt =
new G4VisAttributes(
yellow);
503 DomeVisAtt->SetVisibility(
false);
504 Dome_log->SetVisAttributes(DomeVisAtt);
507 G4double domePosX = 0.0*
mm;
508 G4double domePosY = 0.0*
mm;
509 G4double domePosZ = -DomeSize.z()/2. + DomeThick/2.0 +
fFilterPosition.z();
510 G4ThreeVector DomePosition(domePosX,domePosY,domePosZ);
512 G4PVPlacement* Dome_phys =
515 #if (G4VERSION_NUMBER>=800)
517 Dome_phys->CheckOverlaps(10000);
524 G4Box* LensFrameTemp =
new G4Box(
"LensSupport",
525 LensFrameX/2.0,LensFrameY/2.0,LensFrameZ/2.0);
528 G4double inRadius = 0.0*
mm;
531 G4double sPhi = 0.0*
deg;
532 G4double dPhi = 360.0*
deg;
533 G4Tubs* LensFrameHole =
new G4Tubs(
"LensHole",inRadius,ouRadius,dZ/2.0,sPhi,dPhi);
535 G4SubtractionSolid* LensFrameSolid =
536 new G4SubtractionSolid(
"LensFrame",LensFrameTemp,LensFrameHole);
538 material = G4Material::GetMaterial(
"Aluminum");
539 G4LogicalVolume* LensFrame_log =
540 new G4LogicalVolume(LensFrameSolid,material,
"LensFrame",0,0,0,
true);
541 G4PVPlacement* LensFrame_phys =
543 #if (G4VERSION_NUMBER>=800)
545 LensFrame_phys->CheckOverlaps(10000);
548 G4VisAttributes* LensVisAtt =
new G4VisAttributes(
gray);
549 LensVisAtt->SetVisibility(
true);
550 LensFrame_log ->SetVisAttributes(LensVisAtt);
561 if (name ==
"LL") eyeName =
"Los Leones";
563 if (name ==
"LM") eyeName =
"Los Morados";
565 if (name ==
"LA") eyeName =
"Loma Amarilla";
567 if (name ==
"CO") eyeName =
"Coihueco";
633 #ifdef __TELESCOPE_SIMULATOR_LX_USE_ROOT__
637 string profile =
"KG";
649 string MirrorDataFile;
651 G4Exception (
"Name of mirror data file not found in configuration file !");
659 string MirrorReflectionType =
"Specular";
666 vector<double> wavelength;
667 vector<double> SpecularLobe;
668 vector<double> SpecularSpike;
669 vector<double> Backscatter;
670 vector<double> Reflectivity;
686 G4Exception (
"Mirror diffusive surface required but one or several parameters are missing.");
690 unsigned size = wavelength.size();
696 for (
unsigned i = 0 ; i < size ; i++) {
708 vector<double> wavelength;
709 vector<double> Reflectivity;
716 unsigned size = wavelength.size();
720 for (
unsigned i = 0 ; i < size ; i++) {
723 fFilterFrameReflectivity[i] = Reflectivity[i];
726 string FilterFrameReflectionType =
"Specular";
732 vector<double> wavelength;
733 vector<double> SpecularLobe;
734 vector<double> SpecularSpike;
735 vector<double> Backscatter;
751 G4Exception(
"Diffusive surface for filter frame required but one or several parameters are missing.");
755 size = wavelength.size();
761 for (
unsigned i = 0 ; i < size ; i++) {
772 string photocathodeMode =
"reflectivity";
773 vector<double> wavelength;
774 vector<double> reflectivity;
775 vector<double> reRindex;
776 vector<double> imRindex;
785 if (photocathodeMode ==
"RefractiveIndex") {
796 G4Exception(
"RefractiveIndex mode chosen for photocathode but one or several parameters are missing.");
805 G4Exception(
"Reflectivity mode chosen for photocathode but one or several parameters are missing.");
808 unsigned size = wavelength.size();
815 for (
unsigned i = 0 ; i < size ; i++) {
818 fPhotocathodeImRindex[i] = imRindex[i];
823 for (
unsigned i = 0 ; i < size ; i++) {
FDsimG4VCorrectorRing * fCorrectorRing
G4bool fPhotocathodeUseReflectivity
G4double fCorrectorRingFrameSize
std::vector< G4double > Backscatter
FDsimG4XMLManager fXMLManager
FDsimG4Camera * ConstructCamera()
std::vector< G4double > SpecularSpike
const Diaphragm & GetDiaphragm() const
Get the diaphragm that belongs to the telescope.
SurfaceRoughness fFilterFrameRoughness
double GetInnerRadius() const
Inner radius of the ring.
std::vector< G4double > fPhotocathodeReRindex
G4double fMirrorSegmentTiltSigma
G4double fDiaphragmRadius
const Corrector & GetCorrector() const
Get the Corrector (corrector ring) object that belongs to the telescope.
G4VPhysicalVolume * fWorld_phys
G4double fCameraRadiusCurvature
G4double fMercedesEfficiency
G4double fCorrectorRingPetalSize
static const G4Colour gray(0.5, 0.5, 0.5)
FDsimG4Filter * ConstructFilter()
double GetMercedesHeight() const
Height of the Mercedes.
const Eye & GetEye(const unsigned int eyeId) const
Find eye by numerical Id.
Detector description interface for Eye-related data.
G4LogicalVolume * GetLogicalVolume()
friend class FDsimG4Mirror
const Camera & GetCamera() const
Get the Camera object that belongs to the telescope.
unsigned int GetFirstColumn() const
Detector description interface for FDetector-related data.
bool HasCorrectorRing() const
flag for corrector ring presence
G4bool fPhotocathodeUseThinFilm
double GetMercedesEfficiency() const
Average efficiency of the Mercedes.
constexpr double nanometer
G4VPhysicalVolume * ConstructWorld()
G4String fCorrectorRingProfile
FDsimG4DetectorConstruction(const G4String &TelescopeName, const FDsimG4XMLManager manager)
G4double fCorrectorRingThickness
double GetOuterRadius() const
Outer radius of the ring.
~FDsimG4DetectorConstruction()
std::vector< G4double > SpecularLobe
friend class FDsimG4Camera
G4double fFilterThickness
G4double fFilterFrameThickness
std::vector< G4double > fFilterFrameWavelength
FDsimG4Mirror * ConstructMirror()
const Telescope & GetTelescope(const unsigned int telescopeId) const
Find Telescope by numerical Id.
Top of the hierarchy of the detector description interface.
const fdet::FDetector & GetFDetector() const
FDsimG4VCorrectorRing * ConstructCorrectorRing()
G4Material * fFilterMaterial
unsigned int GetLastRow() const
Description of a corrector ring.
Status GetData(T &returnData, const std::string &componentProperty, const std::string &componentName) const
Return data as a TabulatedFunction.
std::vector< G4double > fPhotocathodeReflectivity
SurfaceRoughness fMirrorRoughness
std::vector< G4double > Wavelength
G4VPhysicalVolume * ConstructTelescopeMother()
G4int fCorrectorRingNumPetals
G4LogicalVolume * GetLogicalVolume() const
G4VPhysicalVolume * fTelescopeMother_phys
G4double fCorrectorRingOuterRadius
Manager for specific FD description parameters in XML file.
double GetMercedesBase() const
Base of the Mercedes.
Detector description interface for Telescope-related data.
G4double fFilterFrameSize
G4double fCorrectorRingInnerRadius
G4Material * fCorrectorRingMaterial
G4VPhysicalVolume * Construct()
G4bool fPhotocathodeUseComplexRindex
std::vector< G4double > fFilterFrameReflectivity
G4bool fUseSensitiveDetectors
std::vector< G4double > fPhotocathodeWavelength
double GetRadius() const
Radius of the diaphragm.
FDsimG4Materials * fMaterials
Description of the diaphragm.
G4Material * fWorldMaterial
unsigned int GetLastColumn() const
G4ThreeVector fFilterPosition
G4String fMirrorReflectionType
G4VPhysicalVolume * fLensFilterMother_phys
G4double fPhotocathodeThickness
double GetMeanLensThickness() const
Mean thickness of the lens.
static const G4double fgTOLERANCE
std::vector< G4double > fPhotocathodeImRindex
double GetRadiusFocal() const
Radius of focal surface of the camera.
friend class FDsimG4Filter
static const G4Colour yellow(1.0, 1.0, 0.5)
unsigned int GetFirstRow() const
G4ThreeVector fCorrectorRingPosition
G4double fCorrectorRingFrameThickness
G4String fFilterFrameReflectionType
friend class FDsimG4Materials