11 #include <structure/geometry/GeoServiceMaterialCreator.h>
12 #include <geometry/CreatorFactory.h>
13 #include <geometry/Materials.h>
14 #include <simulation/background/BkgSensitiveDetector.h>
15 #include <framework/gearbox/GearDir.h>
16 #include <framework/logging/Logger.h>
17 #include <G4Transform3D.hh>
18 #include <G4LogicalVolume.hh>
19 #include <G4PVPlacement.hh>
20 #include "G4Polycone.hh"
36 using namespace geometry;
48 GearDir content0(content,
"GapMomVolTopBack");
52 const double rmin = GapVol.getLength(
"Rmin") / Unit::mm;
53 const double rmax = GapVol.getLength(
"Rmax") / Unit::mm;
54 const double z = GapVol.getLength(
"Z") / Unit::mm;
59 GearDir content1(content,
"GapMomVolEclCoilBarrel");
63 const double rmin = GapVol.getLength(
"Rmin") / Unit::mm;
64 const double rmax = GapVol.getLength(
"Rmax") / Unit::mm;
65 const double z = GapVol.getLength(
"Z") / Unit::mm;
66 MomVolEclCoilBarrelPar.
appendNode(rmin, rmax, z);
70 GearDir content2(content,
"GapMomVolBack");
74 const double rmin = GapVol.getLength(
"Rmin") / Unit::mm;
75 const double rmax = GapVol.getLength(
"Rmax") / Unit::mm;
76 const double z = GapVol.getLength(
"Z") / Unit::mm;
81 GearDir content3(content,
"GapMomVolFor");
85 const double rmin = GapVol.getLength(
"Rmin") / Unit::mm;
86 const double rmax = GapVol.getLength(
"Rmax") / Unit::mm;
87 const double z = GapVol.getLength(
"Z") / Unit::mm;
90 ServiceMaterialGeometryPar.
getMomVolFor() = MomVolForPar;
92 GearDir content4(content,
"ServiceGapsMaterials");
94 for (
const GearDir& material : content4.
getNodes(
"ServiceGapsMaterial")) {
96 material.getString(
"Name"),
97 material.getString(
"material"),
98 material.getInt(
"@id", 0),
99 material.getLength(
"InnerR"),
100 material.getLength(
"OuterR"),
101 material.getLength(
"BackwardZ"),
102 material.getLength(
"ForwardZ")
107 GearDir content5(content,
"ServiceGapsEclMaterials");
109 for (
const GearDir& material : content5.
getNodes(
"ServiceGapsMaterial")) {
111 material.getString(
"Name"),
112 material.getString(
"material"),
113 material.getInt(
"@id", 0),
114 material.getLength(
"InnerR1"),
115 material.getLength(
"OuterR1"),
116 material.getLength(
"InnerR2"),
117 material.getLength(
"OuterR2"),
118 material.getLength(
"BackwardZ"),
119 material.getLength(
"ForwardZ")
124 GearDir content6(content,
"TicknessDensity");
127 content6.
getInt(
"IRCDCBack"),
128 content6.
getInt(
"IPhiCDCBack"),
129 content6.
getInt(
"IRCDCFor"),
130 content6.
getInt(
"IPhiCDCFor"),
131 content6.
getInt(
"IRECLBack"),
132 content6.
getInt(
"IZECLBack"),
133 content6.
getInt(
"IPhiECLBack"),
134 content6.
getInt(
"IRECLFor"),
135 content6.
getInt(
"IZECLFor"),
136 content6.
getInt(
"IPhiECLFor"),
137 content6.
getInt(
"IZARICHFor"),
138 content6.
getInt(
"IPhiARICHFor"),
139 content6.
getInt(
"IPhiTOPBack"),
140 content6.
getInt(
"IPhiTOPFor"),
141 content6.
getInt(
"IZECLCOILBar"),
142 content6.
getInt(
"IPhiECLCOILBar"),
145 ServiceMaterialGeometryPar.
getthick() = ThickPar;
148 return ServiceMaterialGeometryPar;
154 G4Material* medAir = geometry::Materials::get(
"Air");
156 const auto& MomVolFor = parameters.getMomVolFor();
157 std::vector<double> motherforRmin = MomVolFor.getRmin();
158 std::vector<double> motherforRmax = MomVolFor.getRmax();
159 std::vector<double> motherforZ = MomVolFor.getZ() ;
161 G4Polycone* solid_gap_for =
new G4Polycone(
"ServiceMaterial.GAPFor", 0 * CLHEP::deg, 360.* CLHEP::deg, MomVolFor.getNNodes(),
162 motherforZ.data(), motherforRmin.data(), motherforRmax.data());
163 G4LogicalVolume* logical_gap_for =
new G4LogicalVolume(solid_gap_for, medAir,
"ServiceMaterial.GAPFor", 0, 0, 0);
164 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, 0.0), logical_gap_for,
"ServiceMaterial.GAPFor", &topVolume,
false, 1);
166 const auto& MomVolBack = parameters.getMomVolBack();
167 std::vector<double> motherbackRmin = MomVolBack.getRmin();
168 std::vector<double> motherbackRmax = MomVolBack.getRmax();
169 std::vector<double> motherbackZ = MomVolBack.getZ();
171 G4Polycone* solid_gap_back =
new G4Polycone(
"ServiceMaterial.GAPBack", 0 * CLHEP::deg, 360.* CLHEP::deg, MomVolBack.getNNodes(),
172 motherbackZ.data(), motherbackRmin.data(), motherbackRmax.data());
173 G4LogicalVolume* logical_gap_back =
new G4LogicalVolume(solid_gap_back, medAir,
"ServiceMaterial.GAPBack", 0, 0, 0);
174 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, 0.0), logical_gap_back,
"ServiceMaterial.GAPBack", &topVolume,
false, 1);
176 const auto& MomVolTopBack = parameters.getMomVolTopBack();
177 std::vector<double> mothertopbackRmin = MomVolTopBack.getRmin();
178 std::vector<double> mothertopbackRmax = MomVolTopBack.getRmax();
179 std::vector<double> mothertopbackZ = MomVolTopBack.getZ();
181 G4Polycone* solid_gap_topback =
new G4Polycone(
"ServiceMaterial.GAPTopBack", 0 * CLHEP::deg, 360.* CLHEP::deg,
182 MomVolTopBack.getNNodes(),
183 mothertopbackZ.data(), mothertopbackRmin.data(), mothertopbackRmax.data());
184 G4LogicalVolume* logical_gap_topback =
new G4LogicalVolume(solid_gap_topback, medAir,
"ServiceMaterial.GAPTopBack", 0, 0, 0);
185 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, 0.0), logical_gap_topback,
"ServiceMaterial.GAPTopBack", &topVolume,
false, 1);
187 const auto& MomVolEclCoilBarrel = parameters.getMomVolEclCoilBarrel();
188 std::vector<double> mothereclcoilbarrelRmin = MomVolEclCoilBarrel.getRmin();
189 std::vector<double> mothereclcoilbarrelRmax = MomVolEclCoilBarrel.getRmax();
190 std::vector<double> mothereclcoilbarrelZ = MomVolEclCoilBarrel.getZ();
192 G4Polycone* solid_gap_eclcoilbarrel =
new G4Polycone(
"ServiceMaterial.GAPEclCoilBarrel", 0 * CLHEP::deg, 360.* CLHEP::deg,
193 MomVolEclCoilBarrel.getNNodes(),
194 mothereclcoilbarrelZ.data(), mothereclcoilbarrelRmin.data(), mothereclcoilbarrelRmax.data());
195 G4LogicalVolume* logical_gap_eclcoilbarrel =
new G4LogicalVolume(solid_gap_eclcoilbarrel, medAir,
196 "ServiceMaterial.GAPEclCoilBarrel", 0, 0, 0);
197 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, 0.0), logical_gap_eclcoilbarrel,
"ServiceMaterial.GAPEclCoilBarrel", &topVolume,
false,
200 const auto& Thick = parameters.getthick();
201 std::vector<double> Thickness = Thick.getthickness();
202 int IRCDCB = Thick.getIRCDCB();
203 int IPhiCDCB = Thick.getIPhiCDCB();
204 int IRCDCF = Thick.getIRCDCF();
205 int IPhiCDCF = Thick.getIPhiCDCF();
206 int IRECLB = Thick.getIRECLB();
207 int IZECLB = Thick.getIZECLB();
208 int IPhiECLB = Thick.getIPhiECLB();
209 int IRECLF = Thick.getIRECLF();
210 int IZECLF = Thick.getIZECLF();
211 int IPhiECLF = Thick.getIPhiECLF();
212 int IZARICHF = Thick.getIZARICHF();
213 int IPhiARICHF = Thick.getIPhiARICHF();
214 int IPhiTOPB = Thick.getIPhiTOPB();
215 int IPhiTOPF = Thick.getIPhiTOPF();
216 int IPhiECLCOILB = Thick.getIPhiECLCOILB();
217 int IZECLCOILB = Thick.getIZECLCOILB();
220 const int materialID = material.getIdentifier();
221 const double materialInnerR = material.getInnerR() / Unit::mm;
222 const double materialOuterR = material.getOuterR() / Unit::mm;
223 const double materialBackwardZ = material.getBackwardZ() / Unit::mm;
224 const double materialForwardZ = material.getForwardZ() / Unit::mm;
226 if (materialID < 2) {
228 double IR = 0, IPhi = 0;
229 if (materialID < 1) {IR = IRCDCB; IPhi = IPhiCDCB;}
230 else {IR = IRCDCF; IPhi = IPhiCDCF;}
231 const double cellR = (materialOuterR - materialInnerR) / IRCDCB;
232 for (
int iR = 0; iR < IR; iR++) {
233 const double rmin = materialInnerR + iR * cellR;
234 const double rmax = materialInnerR + (iR + 1) * cellR;
235 for (
int iPhi = 0; iPhi < IPhi; iPhi++) {
236 const double SPhi = 360. / IPhi * iPhi;
237 const double DPhi = 360. / IPhi;
238 if (materialID < 1) {
239 const string storageName =
"Service_CDC_ECL_Bwd_" + to_string(iR) +
"_" + to_string(iPhi);
240 const double materialThick = Thickness[blockid] / Unit::mm;
241 const double materialPosZ = materialForwardZ - materialThick;
242 G4Material* mCDCGapback = geometry::Materials::get(
"CDCGapback");
243 createTube(rmin, rmax, SPhi, DPhi, materialThick, materialPosZ, mCDCGapback, storageName, logical_gap_back);
245 if (materialID >= 1) {
246 const string storageName =
"Service_CDC_ARICH_Fwd_" + to_string(iR) +
"_" + to_string(iPhi);
247 const double materialThick = Thickness[blockid + IRCDCB * IPhiCDCB] / Unit::mm;
248 const double materialPosZ = materialBackwardZ;
249 G4Material* mCDCGapfor = geometry::Materials::get(
"CDCGapfor");
250 createTube(rmin, rmax, SPhi, DPhi, materialThick, materialPosZ, mCDCGapfor, storageName, logical_gap_for);
257 if (materialID == 2) {
259 const double materialThick = fabs(materialForwardZ - materialBackwardZ) / IZARICHF;
260 for (
int iZ = 0; iZ < IZARICHF; iZ++) {
261 const double rmax = materialOuterR;
262 const double materialPosZ = materialBackwardZ + iZ * materialThick;
263 for (
int iPhi = 0; iPhi < IPhiARICHF; iPhi++) {
264 const double SPhi = 360. / IPhiARICHF * iPhi;
265 const double DPhi = 360. / IPhiARICHF;
266 const double materialRThick = Thickness[blockid + IRCDCB * IPhiCDCB + IRCDCF * IPhiCDCF] / Unit::mm;
267 const double rmin = rmax - materialRThick;
268 G4Material* ArichAir = geometry::Materials::get(
"Arich_TopGapfor");
269 const string storageName =
"Service_ARICH_TOP_Fwd_" + to_string(iZ) +
"_" + to_string(iPhi);
270 createTube(rmin, rmax, SPhi, DPhi, materialThick, materialPosZ, ArichAir, storageName, logical_gap_for);
276 if (materialID >= 3 && materialID < 5) {
279 if (materialID == 3) {IPhiTOP = IPhiTOPB;}
280 else {IPhiTOP = IPhiTOPF;}
281 const double rmin = materialInnerR;
282 const double rmax = materialOuterR;
283 for (
int iPhi = 0; iPhi < IPhiTOP; iPhi++) {
284 const double SPhi = 360. / IPhiTOP * iPhi;
285 const double DPhi = 360. / IPhiTOP;
286 if (materialID == 3) {
287 const double materialThick = Thickness[blockid + IRCDCB * IPhiCDCB + IRCDCF * IPhiCDCF + IZARICHF * IPhiARICHF] / Unit::mm;
288 const double materialPosZ = materialForwardZ - materialThick;
289 G4Material* TopbackAir = geometry::Materials::get(
"Top_ECLGapback");
290 const string storageName =
"Service_TOP_ECL_Bwd_" + to_string(iPhi);
291 createTube(rmin, rmax, SPhi, DPhi, materialThick, materialPosZ, TopbackAir, storageName, logical_gap_topback);
293 if (materialID == 4) {
294 const double materialThick = Thickness[blockid + IRCDCB * IPhiCDCB + IRCDCF * IPhiCDCF + IZARICHF * IPhiARICHF + IPhiTOPB] /
296 const double materialPosZ = materialBackwardZ;
297 G4Material* TopforAir = geometry::Materials::get(
"Top_ECLGapfor");
298 const string storageName =
"Service_TOP_ECL_Fwd_" + to_string(iPhi);
299 createTube(rmin, rmax, SPhi, DPhi, materialThick, materialPosZ, TopforAir, storageName, logical_gap_for);
305 if (materialID == 5) {
307 const double materialThick = fabs(materialForwardZ - materialBackwardZ) / IZECLCOILB;
308 for (
int iZ = 0; iZ < IZECLCOILB; iZ++) {
309 const double rmin = materialInnerR;
310 const double materialPosZ = materialBackwardZ + iZ * materialThick;
311 for (
int iPhi = 0; iPhi < IPhiECLCOILB; iPhi++) {
312 const double SPhi = 360. / IPhiECLCOILB * iPhi;
313 const double DPhi = 360. / IPhiECLCOILB;
314 const double materialRThick = Thickness[blockid + IRCDCB * IPhiCDCB + IRCDCF * IPhiCDCF + IZARICHF * IPhiARICHF + IPhiTOPB +
315 IPhiTOPF] / Unit::mm;
316 const double rmax = rmin + materialRThick;
317 G4Material* EclCoilAir = geometry::Materials::get(
"ECL_COILbarrel");
318 const string storageName =
"Service_ECL_COIL_Barrel_" + to_string(iZ) +
"_" + to_string(iPhi);
319 createTube(rmin, rmax, SPhi, DPhi, materialThick, materialPosZ, EclCoilAir, storageName, logical_gap_eclcoilbarrel);
329 int IRECL = 0, IZECL = 0, IPhiECL = 0;
330 const int materialID = material.getIdentifier();
331 if (materialID < 1) {IRECL = IRECLB; IZECL = IZECLB; IPhiECL = IPhiECLB;}
332 else {IRECL = IRECLF; IZECL = IZECLF; IPhiECL = IPhiECLF;}
333 const double materialInnerR1 = material.getInnerR1() / Unit::mm;
334 const double materialOuterR1 = material.getOuterR1() / Unit::mm;
335 const double materialInnerR2 = material.getInnerR2() / Unit::mm;
336 const double materialOuterR2 = material.getOuterR2() / Unit::mm;
337 const double materialBackwardZ = material.getBackwardZ() / Unit::mm;
338 const double materialForwardZ = material.getForwardZ() / Unit::mm;
339 const double interval = (materialForwardZ - materialBackwardZ) / IZECL ;
340 const double Hf1 = (materialOuterR1 - materialInnerR1) / IRECL;
341 const double Hf2 = (materialOuterR2 - materialInnerR2) / IRECL;
342 for (
int iR = 0; iR < IRECL; iR++) {
343 const double Rmin1 = materialInnerR1 + Hf1 * iR;
344 const double Rmax1 = materialInnerR1 + Hf1 * (iR + 1);
345 const double Rmin2 = materialInnerR2 + Hf2 * iR;
346 const double Rmax2 = materialInnerR2 + Hf2 * (iR + 1);
347 const double Hrmax = (Rmax2 - Rmax1) / IZECL;
348 const double Hrmin = (Rmin2 - Rmin1) / IZECL;
349 for (
int iZ = 0; iZ < IZECL; iZ++) {
350 const double BackwardposZ = materialBackwardZ + interval * iZ;
351 const double ForwardposZ = materialBackwardZ + interval * (iZ + 1);
352 for (
int iPhi = 0; iPhi < IPhiECL; iPhi++) {
353 const double SPhi = (360. / IPhiECL) * iPhi;
354 const double DPhi = 360. / IPhiECL;
355 if (materialID == 0) {
356 const double thick = Thickness[blockid + IRCDCB * IPhiCDCB + IRCDCF * IPhiCDCF + IZARICHF * IPhiARICHF + IPhiTOPB + IPhiTOPF +
357 IPhiECLCOILB * IZECLCOILB] / Unit::mm;
358 const double rmin2 = Rmin1 + Hrmin * (iZ + 1);
359 const double rmax2 = Rmax1 + Hrmax * (iZ + 1);
360 const double rmin1 = rmin2 - Hrmin * thick / interval ;
361 const double rmax1 = rmax2 - Hrmax * thick / interval ;
362 const double posZ = ForwardposZ - thick;
363 G4Material* ECLbackAir = geometry::Materials::get(
"ECLGapback");
364 const string storageName =
"Service_ECLGAPS_Bwd_" + to_string(iR) +
"_" + to_string(iZ) +
"_" + to_string(iPhi);
365 createCone(rmin1, rmax1, rmin2, rmax2, thick, SPhi, DPhi, posZ, ECLbackAir, storageName, logical_gap_back);
367 if (materialID == 1) {
368 const double thick = Thickness[blockid + IRCDCB * IPhiCDCB + IRCDCF * IPhiCDCF + IZARICHF * IPhiARICHF + IPhiTOPB + IPhiTOPF +
369 IPhiECLCOILB * IZECLCOILB + IZECLB * IRECLB * IPhiECLB ] / Unit::mm;
370 const double rmin1 = Rmin1 + Hrmin * iZ;
371 const double rmax1 = Rmax1 + Hrmax * iZ;
372 const double rmin2 = rmin1 + Hrmin * thick / interval;
373 const double rmax2 = rmax1 + Hrmax * thick / interval;
374 const double posZ = BackwardposZ;
375 G4Material* ECLforAir = geometry::Materials::get(
"ECLGapfor");
376 const string storageName =
"Service_ECLGAPS_Fwd_" + to_string(iR) +
"_" + to_string(iZ) +
"_" + to_string(iPhi);
377 createCone(rmin1, rmax1, rmin2, rmax2, thick, SPhi, DPhi, posZ, ECLforAir, storageName, logical_gap_for);
386 void GeoServiceMaterialCreator::createTube(
const double rmin,
const double rmax,
const double SPhi,
const double DPhi,
387 const double thick,
const double posZ, G4Material* med,
const string& name, G4LogicalVolume*& logical_gap)
389 const string solidName =
"solid_" + name;
390 const string logicalName =
"logical_" + name;
391 const string physicalName =
"physical_" + name;
392 G4Tubs* solidV =
new G4Tubs(solidName.c_str(), rmin * CLHEP::mm, rmax * CLHEP::mm,
393 thick * CLHEP::mm / 2.0, SPhi * CLHEP::deg, DPhi * CLHEP::deg);
394 G4LogicalVolume* logicalV =
new G4LogicalVolume(solidV, med, logicalName.c_str(), 0, 0, 0);
395 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, posZ * CLHEP::mm + thick * CLHEP::mm / 2.0), logicalV,
396 physicalName.c_str(), logical_gap,
false, 0);
399 void GeoServiceMaterialCreator::createCone(
const double rmin1,
const double rmax1,
const double rmin2,
401 const double thick,
const double SPhi,
const double DPhi,
const double posZ, G4Material* med,
402 const string& name, G4LogicalVolume*& top)
404 const string solidName =
"solid" + name;
405 const string logicalName =
"logical" + name;
406 const string physicalName =
"physical" + name;
407 G4Cons* storageConeShape =
new G4Cons(solidName.c_str(), rmin1 * CLHEP::mm, rmax1 * CLHEP::mm, rmin2 * CLHEP::mm,
408 rmax2 * CLHEP::mm, thick * CLHEP::mm / 2.0, SPhi * CLHEP::deg, DPhi * CLHEP::deg);
409 G4LogicalVolume* storageCone =
new G4LogicalVolume(storageConeShape, med, logicalName.c_str(), 0, 0, 0);
410 new G4PVPlacement(0, G4ThreeVector(0.0, 0.0, posZ * CLHEP::mm + thick * CLHEP::mm / 2.0), storageCone, physicalName.c_str(), top,