3 #include <phparameter/PHParameters.h>
9 #include <Geant4/G4Box.hh>
10 #include <Geant4/G4Element.hh>
11 #include <Geant4/G4LogicalVolume.hh>
12 #include <Geant4/G4Material.hh>
13 #include <Geant4/G4PVPlacement.hh>
14 #include <Geant4/G4PhysicalConstants.hh>
15 #include <Geant4/G4String.hh>
16 #include <Geant4/G4SubtractionSolid.hh>
17 #include <Geant4/G4SystemOfUnits.hh>
18 #include <Geant4/G4ThreeVector.hh>
19 #include <Geant4/G4Tubs.hh>
20 #include <Geant4/G4UnionSolid.hh>
21 #include <Geant4/G4UserLimits.hh>
22 #include <Geant4/G4VisAttributes.hh>
40 , m_Params(parameters)
41 , m_CylinderPhysicalVolume(nullptr)
65 set<G4VPhysicalVolume *>::const_iterator iter =
79 set<G4VPhysicalVolume *>::const_iterator iter =
97 std::cout <<
"Error: Can not set Micromegas Gas" << std::endl;
134 map<int, float> thick;
135 thick[coverlay] = 0.0050000 *
cm;
136 thick[CuGround] = 0.0001580 *
cm;
137 thick[PCB] = 0.0100000 *
cm;
138 thick[CuStrips] = 0.0012000 *
cm;
139 thick[KaptonStrips] = 0.0075000 *
cm;
140 thick[ResistiveStrips] = 0.0020000 *
cm;
143 thick[Mesh] = 0.0018000 *
cm;
146 thick[DriftCuElectrode] = 0.0005000 *
cm;
147 thick[DriftKapton] = 0.0250000 *
cm;
148 thick[DriftCuGround] = 0.0000410 *
cm;
151 map<int, G4Material *> media;
158 media[Gas1] = TrackerMaterial;
160 media[Gas2] = TrackerMaterial;
166 map<int, G4Colour>
color;
167 color[coverlay] = G4Colour(204 / 255., 153 / 255., 0);
168 color[CuGround] = G4Colour::Brown();
169 color[PCB] = G4Colour::Green();
170 color[CuStrips] = G4Colour::Brown();
171 color[KaptonStrips] = G4Colour::Brown();
172 color[ResistiveStrips] = G4Colour::Black();
173 color[Gas1] = G4Colour::Grey();
174 color[Mesh] = G4Colour::White();
175 color[Gas2] = G4Colour::Grey();
176 color[DriftCuElectrode] = G4Colour::Brown();
177 color[DriftKapton] = G4Colour::Brown();
178 color[DriftCuGround] = G4Colour(51 / 255., 26 / 255., 0);
191 G4String names_meca[] = {
199 map<int, float> thick_meca;
200 thick_meca[Cu1_meca] = 25 *
um;
201 thick_meca[FR4_1_meca] = 100 *
um;
202 thick_meca[Cu2_meca] = 25 *
um;
203 thick_meca[FR4_2_meca] = 100 *
um;
204 thick_meca[Cu3_meca] = 9 *
um;
207 map<int, G4Material *> media_meca;
215 map<int, G4Colour> color_meca;
216 color_meca[Cu1_meca] = G4Colour::Brown();
217 color_meca[FR4_1_meca] = G4Colour::Green();
218 color_meca[Cu2_meca] = G4Colour::Brown();
219 color_meca[FR4_2_meca] = G4Colour::Green();
220 color_meca[Cu3_meca] = G4Colour::Brown();
236 thick[CuStrips] = 9 *
um;
237 else if (nCZlayer == 1)
238 thick[CuStrips] = 25 *
um;
241 for (map<int, float>::iterator iter = thick.begin(); iter != thick.end(); ++iter)
246 cout <<
"The tile thickness is " <<
thickness /
mm <<
" mm" << endl;
255 radius = radius - gap / 2. -
thickness / 2. * nCZlayer;
257 double spaceforhollowbar = 6 *
mm;
259 G4VSolid *cylinder_solid =
new G4Tubs(G4String(
GetName()),
260 radius - 0.001 *
mm - spaceforhollowbar / 2,
261 radius +
thickness * nCZlayer + gap + 0.001 *
mm + spaceforhollowbar / 2,
263 G4LogicalVolume *cylinder_logic =
new G4LogicalVolume(cylinder_solid,
266 G4VisAttributes *vis =
new G4VisAttributes(G4Color(G4Colour::Grey()));
267 vis->SetForceSolid(
false);
268 vis->SetVisibility(
false);
269 vis->SetForceLineSegmentsPerCircle(30);
270 cylinder_logic->SetVisAttributes(vis);
279 float maxTileWidth = 50. *
cm;
280 float spacer = 2. *
cm;
283 int Ntiles = ceil(circumference / (maxTileWidth + spacer));
285 float tileW = (circumference - Ntiles * spacer) / Ntiles;
287 cout << setw(10) << radius << setw(10) <<
"Ntiles: " << Ntiles << setw(20) <<
"tileW: " << tileW << endl;
292 float deltaPhi = tileW / radius * TMath::RadToDeg();
293 spacer = radius * 360. / Ntiles * deg - tileW;
295 G4UserLimits *g4userlimits =
nullptr;
296 if (isfinite(steplimits))
298 g4userlimits =
new G4UserLimits(steplimits);
301 G4VSolid *tile_o =
new G4Tubs(G4String(
GetName()) +
"_tile",
302 radius - 0.001 * mm - spaceforhollowbar / 2,
303 radius +
thickness * nCZlayer + gap + 0.001 * mm + spaceforhollowbar / 2,
305 G4LogicalVolume *tile_o_logic =
new G4LogicalVolume(tile_o,
307 G4String(
GetName()) +
"_tile_logic");
308 tile_o_logic->SetVisAttributes(vis);
310 double thickness_mecaPCB = 25 *
um + 100 *
um + 25 *
um + 100 *
um + 9 *
um;
311 double radius_mecaPCB = radius +
thickness / 2. - thickness_mecaPCB / 2.;
313 G4VSolid *mecaPCB_solid =
new G4Tubs(
"mecaPCB_solid",
314 radius_mecaPCB - 0.1 * um,
315 radius_mecaPCB + thickness_mecaPCB + 0.1 * um,
317 360. / Ntiles * deg - (spacer - 2 *
barwidth + 1 *
mm) / radius_mecaPCB * radian,
318 (spacer - 2 *
barwidth) / (radius_mecaPCB) *radian);
319 G4VSolid *MM_solid =
new G4Tubs(
"MM_solid",
323 barwidth / radius * radian - 0.5 * mm / radius * radian,
324 deltaPhi * deg + 0.5 * mm / radius * radian);
327 G4RotationMatrix *zrot =
new G4RotationMatrix;
328 double rotang_bar2 =
barwidth / 2. / radius * radian;
329 zrot->rotateZ(rotang_bar2);
330 G4VSolid *u1 =
new G4UnionSolid(
"MM+bar1", MM_solid, bar_solid, G4Transform3D(*zrot, G4ThreeVector((radius +
thickness / 2.) * TMath::Cos(rotang_bar2), (radius +
thickness / 2.) * TMath::Sin(rotang_bar2), 0)));
332 rotang_bar2 = 360. / Ntiles * deg + rotang_bar2 - ((spacer -
barwidth) / radius * radian) - 0.5 * mm / radius * radian;
333 zrot->setDelta(
twopi - (360. / Ntiles * deg - ((spacer -
barwidth) / radius * radian) - 90 * deg));
334 u1 =
new G4UnionSolid(
"MM+bar1+bar2", u1, bar_solid, zrot, G4ThreeVector((radius +
thickness / 2.) * TMath::Cos(rotang_bar2), (radius +
thickness / 2.) * TMath::Sin(rotang_bar2), 0));
338 u1 =
new G4UnionSolid(
"MM+bar1+bar2+arch1+arch2+meca", u1, mecaPCB_solid);
340 G4LogicalVolume *u1_C_logic =
new G4LogicalVolume(u1,
344 vis =
new G4VisAttributes(G4Color(G4Colour::Grey()));
345 vis->SetForceSolid(
false);
346 vis->SetVisibility(
true);
347 vis->SetForceLineSegmentsPerCircle(30);
348 u1_C_logic->SetVisAttributes(vis);
350 new G4PVPlacement(G4Transform3D(*zrot, G4ThreeVector(0, 0, 0)),
357 float Rm_meca = radius_mecaPCB;
358 float RM_meca = Rm_meca;
360 G4VSolid *tile_o_comp =
nullptr;
361 G4LogicalVolume *tile_o_comp_logic =
nullptr;
363 for (
int ic = 0; ic < kNcomponents; ic++)
365 G4UserLimits *g4userlimits_gas =
nullptr;
367 g4userlimits_gas = g4userlimits;
369 G4String cname = G4String(
GetName()) +
"_tileC" +
"_" + names[ic];
371 zrot->setDelta(
barwidth / radius * radian);
372 G4VPhysicalVolume *phys =
nullptr;
374 vis =
new G4VisAttributes(G4Color(color[ic]));
375 vis->SetForceSolid(
true);
376 vis->SetVisibility(
true);
377 vis->SetForceLineSegmentsPerCircle(30);
382 for (
int ii = 0; ii < nhit; ii++)
385 tile_o_comp =
new G4Tubs(cname +
"_solid",
388 m_Params->
get_double_param(
"length") *
cm / 2. - gas_deadzone, gas_deadzone / Rm * radian, deltaPhi * deg - 2 * gas_deadzone / Rm * radian);
389 tile_o_comp_logic =
new G4LogicalVolume(tile_o_comp,
395 tile_o_comp_logic->SetVisAttributes(vis);
397 phys =
new G4PVPlacement(G4Transform3D(*zrot, G4ThreeVector(0, 0, 0)),
406 tile_o_comp =
new G4Tubs(cname +
"_solid",
410 tile_o_comp_logic =
new G4LogicalVolume(tile_o_comp,
416 tile_o_comp_logic->SetVisAttributes(vis);
418 phys =
new G4PVPlacement(G4Transform3D(*zrot, G4ThreeVector(0, 0, 0)),
427 for (
int ic = 0; ic < kNcomponents_meca; ic++)
429 G4String cname = G4String(
GetName()) +
"_tileC" +
"_" + names_meca[ic];
431 RM_meca = Rm_meca + thick_meca[ic];
433 tile_o_comp =
new G4Tubs(cname +
"_solid",
438 (spacer - 2 *
barwidth - 0.001 *
mm) / (radius_mecaPCB) *radian);
439 tile_o_comp_logic =
new G4LogicalVolume(tile_o_comp,
442 vis =
new G4VisAttributes(G4Color(color_meca[ic]));
443 vis->SetForceSolid(
true);
444 vis->SetVisibility(
true);
445 vis->SetForceLineSegmentsPerCircle(30);
446 tile_o_comp_logic->SetVisAttributes(vis);
447 G4RotationMatrix *zrot_tmp =
new G4RotationMatrix();
448 zrot_tmp->rotateZ(360. / Ntiles * deg - (spacer - 2 *
barwidth + 1 * mm) / radius_mecaPCB * radian);
449 new G4PVPlacement(G4Transform3D(*zrot_tmp,
450 G4ThreeVector(0, 0, 0)),
468 Rm_meca = radius_mecaPCB;
471 G4LogicalVolume *u1_Z_logic =
new G4LogicalVolume(u1,
474 vis =
new G4VisAttributes(G4Color(G4Colour::Grey()));
475 vis->SetForceSolid(
false);
476 vis->SetVisibility(
true);
477 vis->SetForceLineSegmentsPerCircle(30);
478 u1_Z_logic->SetVisAttributes(vis);
479 new G4PVPlacement(0, G4ThreeVector((gap +
thickness) * TMath::Cos(360. / Ntiles * deg / 2.), (gap +
thickness) * TMath::Sin(360. / Ntiles * deg / 2.), 0),
483 for (
int ic = 0; ic < kNcomponents; ic++)
485 G4UserLimits *g4userlimits_gas =
nullptr;
487 g4userlimits_gas = g4userlimits;
489 G4String cname = G4String(
GetName()) +
"_tileZ" +
"_" + names[ic];
496 for (
int ii = 0; ii < nhit; ii++)
499 tile_o_comp =
new G4Tubs(cname +
"_solid",
502 m_Params->
get_double_param(
"length") *
cm / 2. - gas_deadzone, gas_deadzone / Rm * radian, deltaPhi * deg - 2 * gas_deadzone / Rm * radian);
503 tile_o_comp_logic =
new G4LogicalVolume(tile_o_comp,
515 tile_o_comp =
new G4Tubs(cname +
"_solid",
519 tile_o_comp_logic =
new G4LogicalVolume(tile_o_comp,
527 vis =
new G4VisAttributes(G4Color(color[ic]));
528 vis->SetForceSolid(
true);
529 vis->SetVisibility(
true);
530 vis->SetForceLineSegmentsPerCircle(30);
531 tile_o_comp_logic->SetVisAttributes(vis);
532 zrot->setDelta(
barwidth / radius * radian);
533 G4VPhysicalVolume *phys =
new G4PVPlacement(G4Transform3D(*zrot, G4ThreeVector(0, 0, 0)),
540 for (
int ic = 0; ic < kNcomponents_meca; ic++)
542 G4String cname = G4String(
GetName()) +
"_tileZ" +
"_" + names_meca[ic];
544 RM_meca = Rm_meca + thick_meca[ic];
546 tile_o_comp =
new G4Tubs(cname +
"_solid",
551 (spacer - 2 *
barwidth - 0.001 *
mm) / (radius_mecaPCB) *radian);
552 tile_o_comp_logic =
new G4LogicalVolume(tile_o_comp,
555 vis =
new G4VisAttributes(G4Color(color_meca[ic]));
556 vis->SetForceSolid(
true);
557 vis->SetVisibility(
true);
558 vis->SetForceLineSegmentsPerCircle(30);
559 tile_o_comp_logic->SetVisAttributes(vis);
560 G4RotationMatrix *zrot_tmp2 =
new G4RotationMatrix();
561 zrot_tmp2->rotateZ(360. / Ntiles * deg - (spacer - 2 *
barwidth + 1 * mm) / radius_mecaPCB * radian);
562 new G4PVPlacement(G4Transform3D(*zrot_tmp2,
563 G4ThreeVector(0, 0, 0)),
575 for (
int i = 0; i < Ntiles; i++)
577 G4RotationMatrix *yRot =
new G4RotationMatrix;
578 yRot->rotateZ(i * 360. / Ntiles * deg);
579 new G4PVPlacement(G4Transform3D(*yRot, G4ThreeVector(0, 0, 0)),
581 G4String(
GetName()) +
"_tile_phys",
589 G4RotationMatrix *yRot0 =
new G4RotationMatrix;
590 yRot0->rotateZ(phi0);
625 G4double temperature = 298.15 * kelvin;
626 G4double pressure = 1. * atmosphere;
631 G4Material *myAir =
new G4Material(
"myAir", 0.001205 *
g /
cm3, ncomponents = 2, kStateGas, temperature, pressure);
632 myAir->AddMaterial(G4_N, fraction = 0.77);
633 myAir->AddMaterial(G4_O, fraction = 0.23);
639 G4Material *myFR4 =
new G4Material(
"myFR4", 1.860 *
g /
cm3, ncomponents = 4, kStateSolid);
640 myFR4->AddMaterial(G4_C, fraction = 0.43550);
641 myFR4->AddMaterial(G4_H, fraction = 0.03650);
642 myFR4->AddMaterial(G4_O, fraction = 0.28120);
643 myFR4->AddMaterial(G4_Si, fraction = 0.24680);
649 G4Material *myKapton =
new G4Material(
"myKapton", 1.420 *
g /
cm3, ncomponents = 4, kStateSolid);
650 myKapton->AddMaterial(G4_C, 0.6911330);
651 myKapton->AddMaterial(G4_H, 0.0263620);
652 myKapton->AddMaterial(G4_N, 0.0732700);
653 myKapton->AddMaterial(G4_O, 0.2092350);
659 G4Material *myMMGas =
new G4Material(
"myMMGas", 0.00170335 *
g /
cm3, ncomponents = 3, kStateGas, temperature, pressure);
660 myMMGas->AddMaterial(G4_Ar, 0.900);
661 myMMGas->AddMaterial(G4_C, 0.0826586);
662 myMMGas->AddMaterial(G4_H, 0.0173414);
668 G4Material *myMMMesh =
new G4Material(
"myMMMesh", 2.8548 *
g /
cm3, ncomponents = 5, kStateSolid);
669 myMMMesh->AddMaterial(G4_Cr, 0.1900);
670 myMMMesh->AddMaterial(G4_Fe, 0.6800);
671 myMMMesh->AddMaterial(G4_Mn, 0.0200);
672 myMMMesh->AddMaterial(G4_Ni, 0.1000);
673 myMMMesh->AddMaterial(G4_Si, 0.0100);
679 G4Material *myMMStrips =
new G4Material(
"myMMStrips", 5.248414 *
g /
cm3, G4_Cu, kStateSolid);
680 cout << myMMStrips->GetName() << endl;
686 G4Material *myMMResistivePaste =
new G4Material(
"myMMResistivePaste", 0.77906 *
g /
cm3, G4_C, kStateSolid);
687 cout << myMMResistivePaste->GetName() << endl;
693 G4Material *myCopper =
new G4Material(
"myCopper", 8.9600 *
g /
cm3, G4_Cu, kStateSolid);
694 cout << myCopper->GetName() << endl;
700 G4Material *myCfiber =
new G4Material(
"myCfiber", 1.80 *
g /
cm3, G4_C, kStateSolid);
701 cout << myCfiber->GetName() << endl;
709 G4VSolid *box2 =
new G4Box(
"bar1", 1 *
mm / 2, 1 *
mm / 2, (length +
barwidth * 2) / 2 + 1 *
mm);
710 G4VSolid *bar =
new G4SubtractionSolid(
"HollowBar", box1, box2);