12 #include "G4RunManager.hh"
13 #include "G4UnitsTable.hh"
14 #include "G4IntersectionSolid.hh"
16 #include "G4Sphere.hh"
18 #include "G4LogicalSkinSurface.hh"
19 #include "G4SDManager.hh"
20 #include "G4Material.hh"
21 #include "G4MaterialTable.hh"
22 #include "G4Polyhedra.hh"
23 #include "G4BREPSolidPolyhedra.hh"
24 #include "G4LogicalVolume.hh"
25 #include "G4PVPlacement.hh"
26 #include "G4OpticalSurface.hh"
27 #include "G4LogicalBorderSurface.hh"
28 #include "G4ThreeVector.hh"
29 #include "G4VisAttributes.hh"
32 #include <utl/config.h>
33 #include "G4Version.hh"
36 using namespace TelescopeSimulatorLX;
42 const G4RunManager* runManager = G4RunManager::GetRunManager();
51 fMotherPhysicalVolume = mother;
76 const G4int nMercedes_col = 42;
77 const G4double deltaAz = 1.5*pi/180.;
78 const G4double deltaEl = 1.5*pi/180.*cos(pi/6.);
81 G4double offsetAz = 10.*deltaAz;
83 G4double offsetEl = -(11.*deltaEl)-deltaEl-deltaEl/3;
87 char mercedesname[32];
89 G4double elevation,azimuth;
93 G4double PMT_thick = 0.0;
94 G4VPhysicalVolume* PMT_phys;
95 G4RotationMatrix* PMTRot;
102 G4SDManager* SDmanager = G4SDManager::GetSDMpointer();
106 SDmanager->AddNewDetector(PMT_SD);
112 G4PVPlacement* Mercedes_phys = NULL;
116 G4OpticalSurface* OpticalAirMercedes =
new G4OpticalSurface(
"MercedesSurface");
117 OpticalAirMercedes->SetModel(unified);
118 OpticalAirMercedes->SetType(dielectric_metal);
120 G4MaterialPropertiesTable* MercedesMPT =
new G4MaterialPropertiesTable();
121 G4double Efficiency = fMercedesEfficiency;
122 MercedesMPT->AddProperty(
"REFLECTIVITY",
new G4MaterialPropertyVector());
123 MercedesMPT->AddEntry(
"REFLECTIVITY", 0.0*
eV,Efficiency);
124 MercedesMPT->AddEntry(
"REFLECTIVITY",10.0*
eV,Efficiency);
126 OpticalAirMercedes->SetMaterialPropertiesTable(MercedesMPT);
128 G4ThreeVector MercedesPos;
129 G4RotationMatrix* MercedesRot;
130 for(i=0; i<fMERCEDESCOUNT; i++){
131 sprintf(mercedesname,
"Mercedes_%03i",i);
135 MercedesRot=
new G4RotationMatrix();
136 MercedesRot->rotateZ(pi/2.0);
138 G4int row = (G4int)floor((
double)i/nMercedes_col);
139 G4int col= i%nMercedes_col;
141 if(col == 0) offsetEl=offsetEl+deltaEl;
142 azimuth = col*deltaAz/2.;
143 if ((row%2 == 0 && col%2 == 0) || (row%2 != 0 && col%2 != 0))
146 MercedesRot->rotateY(3.0*pi/2.0);
148 MercedesRot->rotateZ(((-offsetAz)+azimuth));
149 MercedesRot->rotateX(elevation);
153 elevation=offsetEl+deltaEl/3.;
154 MercedesRot->rotateY(pi/2.0);
156 MercedesRot->rotateZ(offsetAz-azimuth);
157 MercedesRot->rotateX(-elevation);
160 MercedesPos.setRThetaPhi(fCurvRadius,(pi/2.-offsetAz)+azimuth,elevation);
162 new G4PVPlacement(MercedesRot,MercedesPos,mercedesname,
163 Mercedes_log,fMotherPhysicalVolume,
false,numOfCopy++);
165 #if (G4VERSION_NUMBER>=800)
166 if (fVerbosity > 2 && Mercedes_phys)
167 Mercedes_phys->CheckOverlaps(10000);
171 new G4LogicalBorderSurface(
"MercedesSurface",
172 fMotherPhysicalVolume,Mercedes_phys,OpticalAirMercedes);
176 if (row != 22 && col < 40) {
177 if ((row%2 != 0 && col%2 ==0) || (row%2 ==0 && col%2!=0)){
187 colPMT = G4int(colPMT/2.);
190 PMT_id = fNumRows*(colPMT)+rowPMT+1;
191 sprintf(pmtname,
"PMT_%03i",PMT_id);
197 PMTRot =
new G4RotationMatrix();
198 PMTRot->rotateY(pi/2.0);
199 PMTRot->rotateZ(pi/2.0);
201 PMTRot->rotateX((-offsetAz)+azimuth+deltaAz/2.);
202 PMTRot->rotateY(-offsetEl-2*deltaEl/3.);
204 PMTPos.setRThetaPhi(fCurvRadius-Mercedes_height-PMT_thick/2.- 1.0*
mm,
205 (pi/2.-offsetAz)+azimuth+deltaAz/2.,
206 offsetEl+2*deltaEl/3.);
208 new G4PVPlacement(PMTRot,PMTPos,pmtname,PMT_log,fMotherPhysicalVolume,
false,PMT_id);
209 #if (G4VERSION_NUMBER>=800)
210 if (fVerbosity > 2 && PMT_phys)
211 PMT_phys->CheckOverlaps(10000);
213 if (PMT_log && PMT_SD) PMT_log->SetSensitiveDetector(PMT_SD);
215 PMT_log->SetVisAttributes(
new G4VisAttributes(
yellow));
217 PMT_log->SetVisAttributes(
new G4VisAttributes(
magenta));
226 G4VPhysicalVolume* Support_phys = NULL;
227 G4VPhysicalVolume* Foot1_phys = NULL;
228 G4VPhysicalVolume* Foot2_phys = NULL;
229 G4VPhysicalVolume* Electronics_phys = NULL;
233 G4double SupportPlaceX = fCurvRadius-Mercedes_height-PMT_thick - 1.0*
mm;
237 G4LogicalVolume* Support_log =
239 G4RotationMatrix* SupportRot =
240 new G4RotationMatrix(G4ThreeVector(0.,0.,1.),pi/2.0);
243 new G4PVPlacement(SupportRot,G4ThreeVector(),
"CameraSupport",Support_log,
244 fMotherPhysicalVolume,
false,0);
254 G4double angle = std::atan((Support->
GetHside())/2./fCurvRadius);
255 G4double FromCamera=22.58*
cm;
256 dx = dx - FromCamera*std::cos(angle);
258 G4double dz = (Support->
GetHside())/2.;
259 dz = dz - FromCamera*std::sin(angle);
261 G4ThreeVector FootPlace1 = G4ThreeVector(dx,0.,dz);
262 G4ThreeVector FootPlace2 = G4ThreeVector(dx,0.,-dz);
264 G4RotationMatrix* rot1 =
new G4RotationMatrix(G4ThreeVector(1.,0.,0.),pi);
265 G4RotationMatrix* rot2 =
new G4RotationMatrix(G4ThreeVector(1.,0.,0.),pi);
267 Foot1_phys =
new G4PVPlacement(rot1,FootPlace1,
"CameraFoot1",Foot_log,
268 fMotherPhysicalVolume,
false,0);
269 Foot2_phys =
new G4PVPlacement(rot2,FootPlace2,
"CameraFoot2",Foot_log,
270 fMotherPhysicalVolume,
false,1);
276 G4double dzEl = 2.0*((Support->
GetHside())/2. -
279 G4Box* Electronics =
new G4Box(
"Top",dxEl/2.,dyEl/2.,dzEl/2.);
281 const G4Material* ElectronicsMaterial = G4Material::GetMaterial(
"Aluminum");
283 G4LogicalVolume* Electronics_log =
284 new G4LogicalVolume(Electronics,(G4Material*)ElectronicsMaterial,
"CameraElectronics",0,0,0);
286 Electronics_log->SetVisAttributes(
new G4VisAttributes(
gray));
289 G4OpticalSurface* OpticalAirCameraElect=
new G4OpticalSurface(
"CameraElectSurface");
290 OpticalAirCameraElect->SetModel(unified);
291 OpticalAirCameraElect->SetType(dielectric_metal);
293 G4MaterialPropertiesTable* CameraElectMPT =
new G4MaterialPropertiesTable();
294 CameraElectMPT->AddProperty(
"REFLECTIVITY",
new G4MaterialPropertyVector());
295 CameraElectMPT->AddEntry(
"REFLECTIVITY", 0.0*
eV,0.);
296 CameraElectMPT->AddEntry(
"REFLECTIVITY",10.0*
eV,0.);
297 OpticalAirCameraElect->SetMaterialPropertiesTable(CameraElectMPT);
299 new G4LogicalSkinSurface(
"CameraElectSurface",Electronics_log,OpticalAirCameraElect);
300 G4ThreeVector ElPlace=G4ThreeVector(dx,0.,0.);
302 new G4PVPlacement(0,ElPlace,
"CameraElectronics",Electronics_log,
303 fMotherPhysicalVolume,
false,0);
305 #if (G4VERSION_NUMBER>=800)
307 if (Support_phys) Support_phys->CheckOverlaps(10000);
308 if (Foot1_phys) Foot1_phys->CheckOverlaps(10000);
309 if (Foot2_phys) Foot2_phys->CheckOverlaps(10000);
310 if (Electronics_phys) Electronics_phys->CheckOverlaps(10000);
317 (
dynamic_cast<const FDsimG4DetectorConstruction*
>((G4RunManager::GetRunManager())->GetUserDetectorConstruction()))->fUseSensitiveDetectors;
321 G4double rMax = fCurvRadius + 0.5*
mm;
322 G4double rMin = rMax - 0.1*
mm;
328 G4Material* Material = fMotherPhysicalVolume->GetLogicalVolume()->GetMaterial();
329 G4Sphere* FocalSurf =
330 new G4Sphere(
"sphere",rMin,rMax,ThetaMin,ThetaMax,PhiMin,PhiMax);
332 G4LogicalVolume* FocalSurface_log =
333 new G4LogicalVolume(FocalSurf,Material,
"VirtualFocalSurface",0,0,0);
335 G4VPhysicalVolume* FocalSurface_phys = NULL;
337 new G4PVPlacement(SupportRot,G4ThreeVector(),
"VirtualFocalSurface",
338 FocalSurface_log, fMotherPhysicalVolume,
false,0);
340 FocalSurface_log->SetVisAttributes(
new G4VisAttributes(
yellow));
342 SDmanager->AddNewDetector(FocalSurfaceSD);
343 FocalSurface_log->SetSensitiveDetector(FocalSurfaceSD);
345 #if (G4VERSION_NUMBER>=800)
346 if (fVerbosity > 2 && FocalSurface_phys)
347 FocalSurface_phys->CheckOverlaps(10000);
G4LogicalVolume * GetPMTLogicalVolume() const
G4LogicalVolume * GetMercedesLogicalVolume() const
G4double fCameraRadiusCurvature
G4double fMercedesEfficiency
static const G4Colour gray(0.5, 0.5, 0.5)
static const G4Colour magenta(1.0, 0.5, 1.0)
G4LogicalVolume * GetCameraSupportLogicalVolume() const
G4double GetThickness() const
G4double GetMercedesHeight()
static const G4double fgTOLERANCE
static const G4Colour yellow(1.0, 1.0, 0.5)