6 #include <phparameter/PHParameters.h>
10 #include <Geant4/G4Cons.hh>
11 #include <Geant4/G4GenericTrap.hh>
12 #include <Geant4/G4LogicalVolume.hh>
13 #include <Geant4/G4Material.hh>
14 #include <Geant4/G4PVPlacement.hh>
15 #include <Geant4/G4RotationMatrix.hh>
16 #include <Geant4/G4String.hh>
17 #include <Geant4/G4SubtractionSolid.hh>
18 #include <Geant4/G4SystemOfUnits.hh>
19 #include <Geant4/G4ThreeVector.hh>
20 #include <Geant4/G4Transform3D.hh>
21 #include <Geant4/G4Trd.hh>
22 #include <Geant4/G4TwoVector.hh>
23 #include <Geant4/G4Types.hh>
46 , _dx_front(41.44 *
mm)
47 , _dy_front(41.44 *
mm)
48 , _dx_back(48.97454545455 *
mm)
49 , _dy_back(48.97454545455 *
mm)
50 , _dz_crystal(90.000 *
mm)
51 , _crystallogicnameprefix(
"eEcalCrystal")
52 , m_IsActive(GetParams()->get_int_param(
"active"))
53 , m_AbsorberActive(GetParams()->get_int_param(
"absorberactive"))
85 cout <<
"PHG4ProjCrystalCalorimeterDetector: Begin Construction" << endl;
88 if (
GetParams()->get_string_param(
"mappingtower").empty())
90 cout <<
"ERROR in PHG4ProjCrystalCalorimeterDetector: No tower mapping file specified. Abort detector construction." << endl;
91 cout <<
"Please run set_string_param(\"mappingtower\", std::string filename ) first." << endl;
99 G4VSolid *ecal_envelope_cone =
new G4Cons(
"eEcal_envelope_solid",
105 G4LogicalVolume *ecal_envelope_log =
new G4LogicalVolume(ecal_envelope_cone, WorldMaterial, G4String(
"eEcal_envelope"), 0, 0, 0);
108 G4RotationMatrix ecal_rotm;
109 ecal_rotm.rotateX(
GetParams()->get_double_param(
"rot_x") * deg);
110 ecal_rotm.rotateY(
GetParams()->get_double_param(
"rot_y") * deg);
111 ecal_rotm.rotateZ(
GetParams()->get_double_param(
"rot_z") * deg);
114 new G4PVPlacement(G4Transform3D(ecal_rotm, G4ThreeVector(
GetParams()->get_double_param(
"place_x") *
cm,
GetParams()->get_double_param(
"place_y") *
cm,
GetParams()->get_double_param(
"place_z") *
cm)),
115 ecal_envelope_log,
"CrystalCalorimeter", logicWorld, 0,
false,
OverlapCheck());
125 adjust_width = 0.1258525627 *
mm;
126 adjust_length = 2.4824474402 *
mm;
132 CF_width = 0.18 *
mm;
156 G4double carbon_fiber_width, air_gap_carbon_fiber, air_gap_crystals;
160 G4double dx_front_small = (
_dx_front - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
161 G4double dy_front_small = (
_dy_front - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
162 G4double dx_back_small = (
_dx_back - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
163 G4double dy_back_small = (
_dy_back - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
167 std::vector<G4TwoVector> vertices;
168 vertices.push_back(G4TwoVector(0, 0));
169 vertices.push_back(G4TwoVector(0, dy_front_small));
170 vertices.push_back(G4TwoVector(dx_front_small, dy_front_small));
171 vertices.push_back(G4TwoVector(dx_front_small, 0));
172 vertices.push_back(G4TwoVector(0, 0));
173 vertices.push_back(G4TwoVector(0, dy_back_small));
174 vertices.push_back(G4TwoVector(dx_back_small, dy_back_small));
175 vertices.push_back(G4TwoVector(dx_back_small, 0));
178 G4VSolid *crystal_solid_small =
new G4GenericTrap(G4String(
"eEcal_crystal"),
182 G4LogicalVolume *crystal_logic_small =
new G4LogicalVolume(crystal_solid_small,
193 G4double TwoByTwo_dx1 = ((2.0 * dx_front_small) + (2.0 * air_gap_carbon_fiber) + air_gap_crystals) / 2.0;
194 G4double TwoByTwo_dx2 = ((2.0 * dx_back_small) + (2.0 * air_gap_carbon_fiber) + air_gap_crystals) / 2.0;
195 G4double TwoByTwo_dy1 = TwoByTwo_dx1;
196 G4double TwoByTwo_dy2 = TwoByTwo_dx2;
199 G4VSolid *Two_by_Two_solid =
new G4Trd(G4String(
"Two_by_Two_solid"),
206 G4LogicalVolume *Two_by_Two_logic =
new G4LogicalVolume(Two_by_Two_solid,
219 const int NumberOfIndices = 9;
222 int NumberOfLines = 0;
223 ifstream
in(
GetParams()->get_string_param(
"mapping4x4"));
227 <<
"*******************************************************************" << endl;
228 cout <<
"ERROR in 2 by 2 crystal mapping ";
230 cout <<
"*******************************************************************" << endl
241 in.open(
GetParams()->get_string_param(
"mapping4x4"));
242 G4int j_cry = NumberOfLines;
243 G4int k_cry = NumberOfIndices;
245 double TwoByTwo[j_cry][k_cry];
254 in >> TwoByTwo[j][
k];
267 G4double x_cent, y_cent, z_cent, rot_x, rot_y, rot_z;
273 MappingIndex = TwoByTwo[j][8];
274 if (MappingIndex == 1)
276 j_idx = TwoByTwo[j][0];
277 k_idx = TwoByTwo[j][1];
278 x_cent = TwoByTwo[j][2];
279 y_cent = TwoByTwo[j][3];
280 z_cent = TwoByTwo[j][4];
283 rot_z = TwoByTwo[j][7];
285 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent *
mm, y_cent * mm, z_cent * mm);
287 G4RotationMatrix *Rot =
new G4RotationMatrix();
288 Rot->rotateX(0 *
rad);
289 Rot->rotateY(0 *
rad);
290 Rot->rotateZ(rot_z *
rad);
293 int copyno = (j_idx << 16) + k_idx;
294 G4VPhysicalVolume *physvol =
new G4PVPlacement(Rot, Crystal_Center,
301 x_cent = y_cent = z_cent = rot_x = rot_y = rot_z = 0.0;
313 MappingIndex = TwoByTwo[j][8];
314 if (MappingIndex == 4)
316 j_idx = TwoByTwo[j][0];
317 k_idx = TwoByTwo[j][1];
318 x_cent = TwoByTwo[j][2];
319 y_cent = TwoByTwo[j][3];
320 z_cent = TwoByTwo[j][4];
321 rot_x = TwoByTwo[j][5];
322 rot_y = TwoByTwo[j][6];
323 rot_z = TwoByTwo[j][7];
325 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent *
mm, y_cent * mm, z_cent * mm);
327 G4RotationMatrix *Rot =
new G4RotationMatrix();
328 Rot->rotateX(rot_x *
rad);
329 Rot->rotateY(rot_y * rad);
330 Rot->rotateZ(0 * rad);
334 int copyno = (j_idx << 16) + k_idx;
335 new G4PVPlacement(Rot, Crystal_Center,
342 x_cent = y_cent = z_cent = rot_x = rot_y = 0.0;
354 G4double dx1, dy1, dx2, dy2, dz_whole, carbon_fiber_adjust_width, carbon_fiber_adjust_length;
358 dx1 =
_dx_front + carbon_fiber_adjust_width;
360 dx2 =
_dx_back - carbon_fiber_adjust_width;
362 dz_whole =
_dz_crystal - carbon_fiber_adjust_length;
364 G4VSolid *Carbon_hunk_solid =
new G4Trd(G4String(
"Carbon_hunk_solid"),
378 while (j_cry > counter)
380 MappingIndex = TwoByTwo[j][8];
381 if (MappingIndex != 4) j++;
385 x_cent = TwoByTwo[j][2];
386 y_cent = TwoByTwo[j][3];
387 z_cent = TwoByTwo[j][4];
388 rot_x = TwoByTwo[j][5];
389 rot_y = TwoByTwo[j][6];
392 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent *
mm, y_cent * mm, z_cent * mm);
394 G4RotationMatrix *Rot_1 =
new G4RotationMatrix();
395 Rot_1->rotateX(rot_x *
rad);
396 Rot_1->rotateY(rot_y * rad);
397 Rot_1->rotateZ(0 * rad);
399 G4SubtractionSolid *Carbon_Shell_1 =
new G4SubtractionSolid(G4String(
"Carbon_Shell_1"),
409 x_cent = TwoByTwo[j][2];
410 y_cent = TwoByTwo[j][3];
411 z_cent = TwoByTwo[j][4];
412 rot_x = TwoByTwo[j][5];
413 rot_y = TwoByTwo[j][6];
416 Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
418 G4RotationMatrix *Rot_2 =
new G4RotationMatrix();
419 Rot_2->rotateX(rot_x * rad);
420 Rot_2->rotateY(rot_y * rad);
421 Rot_2->rotateZ(0 * rad);
423 G4SubtractionSolid *Carbon_Shell_2 =
new G4SubtractionSolid(G4String(
"Carbon_Shell_2"),
433 x_cent = TwoByTwo[j][2];
434 y_cent = TwoByTwo[j][3];
435 z_cent = TwoByTwo[j][4];
436 rot_x = TwoByTwo[j][5];
437 rot_y = TwoByTwo[j][6];
440 Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
442 G4RotationMatrix *Rot_3 =
new G4RotationMatrix();
443 Rot_3->rotateX(rot_x * rad);
444 Rot_3->rotateY(rot_y * rad);
445 Rot_3->rotateZ(0 * rad);
447 G4SubtractionSolid *Carbon_Shell_3 =
new G4SubtractionSolid(G4String(
"Carbon_Shell_3"),
457 x_cent = TwoByTwo[j][2];
458 y_cent = TwoByTwo[j][3];
459 z_cent = TwoByTwo[j][4];
460 rot_x = TwoByTwo[j][5];
461 rot_y = TwoByTwo[j][6];
464 Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
466 G4RotationMatrix *Rot_4 =
new G4RotationMatrix();
467 Rot_4->rotateX(rot_x * rad);
468 Rot_4->rotateY(rot_y * rad);
469 Rot_4->rotateZ(0 * rad);
471 G4SubtractionSolid *Carbon_Shell_solid =
new G4SubtractionSolid(G4String(
"Carbon_Shell_solid"),
482 G4LogicalVolume *Carbon_Shell_logic =
new G4LogicalVolume(Carbon_Shell_solid,
484 "Carbon_Fiber_logic",
493 G4ThreeVector Carbon_Center = G4ThreeVector(0 * mm, 0 * mm, 0 * mm);
495 G4RotationMatrix *Rot_5 =
new G4RotationMatrix();
496 Rot_5->rotateX(0 * rad);
497 Rot_5->rotateY(0 * rad);
498 Rot_5->rotateZ(0 * rad);
500 G4VPhysicalVolume *physvol =
new G4PVPlacement(Rot_5, Carbon_Center,
502 "Carbon_Fiber_Shell",
533 G4double carbon_fiber_width, air_gap_carbon_fiber, air_gap_crystals;
537 G4double dx_front_small = (
_dx_front - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
538 G4double dy_front_small = (
_dy_front - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
539 G4double dx_back_small = (
_dx_back - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
540 G4double dy_back_small = (
_dy_back - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
544 std::vector<G4TwoVector> vertices;
545 vertices.push_back(G4TwoVector(0, 0));
546 vertices.push_back(G4TwoVector(0, dy_front_small));
547 vertices.push_back(G4TwoVector(dx_front_small, dy_front_small));
548 vertices.push_back(G4TwoVector(dx_front_small, 0));
549 vertices.push_back(G4TwoVector(0, 0));
550 vertices.push_back(G4TwoVector(0, dy_back_small));
551 vertices.push_back(G4TwoVector(dx_back_small, dy_back_small));
552 vertices.push_back(G4TwoVector(dx_back_small, 0));
555 G4VSolid *crystal_solid_small =
new G4GenericTrap(G4String(
"eEcal_crystal"),
559 G4LogicalVolume *crystal_logic_small =
new G4LogicalVolume(crystal_solid_small,
570 G4double TwoByTwo_dx1 = ((2.0 * dx_front_small) + (2.0 * air_gap_carbon_fiber) + air_gap_crystals) / 2.0;
571 G4double TwoByTwo_dx2 = ((2.0 * dx_back_small) + (2.0 * air_gap_carbon_fiber) + air_gap_crystals) / 2.0;
572 G4double TwoByTwo_dy1 = TwoByTwo_dx1;
573 G4double TwoByTwo_dy2 = TwoByTwo_dx2;
576 G4VSolid *Two_by_Two_solid =
new G4Trd(G4String(
"Two_by_Two_solid"),
583 G4LogicalVolume *Two_by_Two_logic =
new G4LogicalVolume(Two_by_Two_solid,
596 const int NumberOfIndices = 9;
599 int NumberOfLines = 0;
600 ifstream
in(
GetParams()->get_string_param(
"mapping4x4"));
604 <<
"*******************************************************************" << endl;
605 cout <<
"ERROR in 2 by 2 crystal mapping ";
607 cout <<
"*******************************************************************" << endl
618 in.open(
GetParams()->get_string_param(
"mapping4x4"));
619 G4int j_cry = NumberOfLines;
620 G4int k_cry = NumberOfIndices;
622 double TwoByTwo[j_cry][k_cry];
631 in >> TwoByTwo[j][
k];
643 G4double x_cent, y_cent, z_cent, rot_x, rot_y, rot_z;
649 MappingIndex = TwoByTwo[j][8];
650 if (MappingIndex == 1)
652 j_idx = TwoByTwo[j][0];
653 k_idx = TwoByTwo[j][1];
654 x_cent = TwoByTwo[j][2];
655 y_cent = TwoByTwo[j][3];
656 z_cent = TwoByTwo[j][4];
657 rot_x = TwoByTwo[j][5];
658 rot_y = TwoByTwo[j][6];
659 rot_z = TwoByTwo[j][7];
661 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent *
mm, y_cent * mm, z_cent * mm);
663 G4RotationMatrix *Rot =
new G4RotationMatrix();
664 Rot->rotateX(0 *
rad);
665 Rot->rotateY(0 *
rad);
666 Rot->rotateZ(rot_z *
rad);
669 int copyno = (j_idx << 16) + k_idx;
671 G4VPhysicalVolume *physvol =
new G4PVPlacement(Rot, Crystal_Center,
679 x_cent = y_cent = z_cent = rot_z = 0.0;
691 j_idx = TwoByTwo[j][0];
692 k_idx = TwoByTwo[j][1];
693 x_cent = TwoByTwo[j][2];
694 y_cent = TwoByTwo[j][3];
695 z_cent = TwoByTwo[j][4];
696 rot_x = TwoByTwo[j][5];
697 rot_y = TwoByTwo[j][6];
698 rot_z = TwoByTwo[j][7];
699 MappingIndex = TwoByTwo[j][8];
703 G4ThreeVector Crystal_Center = G4ThreeVector(0 *
mm, 0 *
mm, 0 *
mm);
705 G4RotationMatrix *Rot =
new G4RotationMatrix();
706 Rot->rotateX(0 *
rad);
707 Rot->rotateY(0 *
rad);
708 Rot->rotateZ(0 *
rad);
710 string Two_by_Two_name =
"TwoByTwo_j_0_k_0";
712 new G4PVPlacement(Rot, Crystal_Center,
718 else if (ident == 22)
720 if (MappingIndex == 22)
722 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent *
mm, y_cent * mm, z_cent * mm);
724 G4RotationMatrix *Rot =
new G4RotationMatrix();
725 Rot->rotateX(rot_x *
rad);
726 Rot->rotateY(0 * rad);
727 Rot->rotateZ(0 * rad);
730 int copyno = (j_idx << 16) + k_idx;
731 new G4PVPlacement(Rot, Crystal_Center,
738 else if (ident == 32)
740 if (MappingIndex == 32)
742 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent *
mm, y_cent * mm, z_cent * mm);
744 G4RotationMatrix *Rot =
new G4RotationMatrix();
745 Rot->rotateX(rot_x *
rad);
746 Rot->rotateY(rot_y * rad);
747 Rot->rotateZ(0 * rad);
750 int copyno = (j_idx << 16) + k_idx;
751 new G4PVPlacement(Rot, Crystal_Center,
761 <<
"Invalid Mapping Type: " << ident << endl;
766 x_cent = y_cent = z_cent = rot_x = rot_y = rot_z = 0.0;
774 G4double dx1, dx2, dy1, dy2;
779 G4VSolid *Carbon_hunk_solid =
new G4Trd(G4String(
"Carbon_hunk_solid"),
780 (dx1 / 2.00 + 0.0209292929),
781 (dx2 / 2.00 - 0.0209292929),
782 (dy1 / 2.00 + 0.0209292929),
783 (dy2 / 2.0 - 0.0209292929),
793 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent *
mm, y_cent * mm, z_cent * mm);
795 G4RotationMatrix *Rot_1 =
new G4RotationMatrix();
796 Rot_1->rotateX(rot_x *
rad);
797 Rot_1->rotateY(rot_y * rad);
798 Rot_1->rotateZ(rot_z * rad);
800 G4SubtractionSolid *Carbon_Shell_solid =
new G4SubtractionSolid(G4String(
"Carbon_Shell_solid"),
806 G4LogicalVolume *Carbon_Shell_logic =
new G4LogicalVolume(Carbon_Shell_solid,
808 "Carbon_Fiber_logic",
817 G4ThreeVector Carbon_Center = G4ThreeVector(0 * mm, 0 * mm, 0 * mm);
819 G4RotationMatrix *Rot_5 =
new G4RotationMatrix();
820 Rot_5->rotateX(0 * rad);
821 Rot_5->rotateY(0 * rad);
822 Rot_5->rotateZ(0 * rad);
824 G4VPhysicalVolume *physvol =
new G4PVPlacement(Rot_5, Carbon_Center,
826 "Carbon_Fiber_Shell",
831 else if (ident == 22)
833 G4double carbon_fiber_adjust_width;
834 G4double carbon_fiber_adjust_length;
836 G4double x_adjust = 0.0519558696 *
mm;
838 G4VSolid *Carbon_hunk_solid =
new G4Trd(G4String(
"Carbon_hunk_solid"),
839 (dx1 / 2.0 + (x_adjust)),
840 (dx2 / 2.0 - (x_adjust)),
841 (dy1 + carbon_fiber_adjust_width),
842 (dy2 - carbon_fiber_adjust_width),
843 (dz - carbon_fiber_adjust_length));
847 while (j_cry > counter)
849 MappingIndex = TwoByTwo[j][8];
850 if (MappingIndex != 22) j++;
856 x_cent = TwoByTwo[j][2];
857 y_cent = TwoByTwo[j][3];
858 z_cent = TwoByTwo[j][4];
859 rot_x = TwoByTwo[j][5];
860 rot_y = TwoByTwo[j][6];
861 rot_z = TwoByTwo[j][7];
863 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent *
mm, y_cent * mm, z_cent * mm);
865 G4RotationMatrix *Rot_1 =
new G4RotationMatrix();
866 Rot_1->rotateX(rot_x *
rad);
867 Rot_1->rotateY(0 * rad);
868 Rot_1->rotateZ(0 * rad);
870 G4SubtractionSolid *Carbon_Shell_1 =
new G4SubtractionSolid(G4String(
"Carbon_Shell_1"),
880 x_cent = TwoByTwo[j][2];
881 y_cent = TwoByTwo[j][3];
882 z_cent = TwoByTwo[j][4];
883 rot_x = TwoByTwo[j][5];
887 Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
889 G4RotationMatrix *Rot_2 =
new G4RotationMatrix();
890 Rot_2->rotateX(rot_x * rad);
891 Rot_2->rotateY(0 * rad);
892 Rot_2->rotateZ(0 * rad);
894 G4SubtractionSolid *Carbon_Shell_solid =
new G4SubtractionSolid(G4String(
"Carbon_Shell_solid"),
900 G4LogicalVolume *Carbon_Shell_logic =
new G4LogicalVolume(Carbon_Shell_solid,
902 "Carbon_Fiber_logic",
911 G4ThreeVector Carbon_Center = G4ThreeVector(0 * mm, 0 * mm, 0 * mm);
913 G4RotationMatrix *Rot_5 =
new G4RotationMatrix();
914 Rot_5->rotateX(0 * rad);
915 Rot_5->rotateY(0 * rad);
916 Rot_5->rotateZ(0 * rad);
918 G4VPhysicalVolume *physvol =
new G4PVPlacement(Rot_5, Carbon_Center,
920 "Carbon_Fiber_Shell",
925 else if (ident == 32)
927 x_cent = 22.6036363636 + 0.18000 * 2.0;
930 G4double rot_x = 0.020928529;
931 G4double rot_y = -1.0 * rot_x;
933 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent *
mm, y_cent * mm, z_cent * mm);
935 G4RotationMatrix *Rot_1 =
new G4RotationMatrix();
936 Rot_1->rotateX(rot_x *
rad);
937 Rot_1->rotateY(rot_y * rad);
938 Rot_1->rotateZ(0 * rad);
940 G4VSolid *FourByFour_hunk_solid =
new G4Trd(G4String(
"4x4_hunk_solid"),
948 G4double carbon_fiber_width, air_gap_carbon_fiber, air_gap_crystals;
952 G4double dx_front_small = (
_dx_front - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
954 G4double dx_back_small = (
_dx_back - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
957 G4double TwoByTwo_dx1 = ((2.0 * dx_front_small) + (2.0 * air_gap_carbon_fiber) + air_gap_crystals) / 2.0;
958 G4double TwoByTwo_dx2 = ((2.0 * dx_back_small) + (2.0 * air_gap_carbon_fiber) + air_gap_crystals) / 2.0;
959 G4double TwoByTwo_dy1 = TwoByTwo_dx1;
960 G4double TwoByTwo_dy2 = TwoByTwo_dx2;
963 G4VSolid *Two_by_Two_solid =
new G4Trd(G4String(
"Two_by_Two_solid"),
968 TwoByTwo_dz + 2 * mm);
970 G4SubtractionSolid *Carbon_hunk_solid =
new G4SubtractionSolid(G4String(
"Carbon_hunk_solid"),
971 FourByFour_hunk_solid,
981 while (j_cry > counter)
983 MappingIndex = TwoByTwo[j][8];
984 if (MappingIndex != 32) j++;
988 x_cent = TwoByTwo[j][2];
989 y_cent = TwoByTwo[j][3];
990 z_cent = TwoByTwo[j][4];
991 rot_x = TwoByTwo[j][5];
992 rot_y = TwoByTwo[j][6];
993 rot_z = TwoByTwo[j][7];
995 Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
997 G4RotationMatrix *Rot_6 =
new G4RotationMatrix();
998 Rot_6->rotateX(rot_x * rad);
999 Rot_6->rotateY(rot_y * rad);
1000 Rot_6->rotateZ(0 * rad);
1002 G4SubtractionSolid *Carbon_Shell_1 =
new G4SubtractionSolid(G4String(
"Carbon_Shell_1"),
1012 x_cent = TwoByTwo[j][2];
1013 y_cent = TwoByTwo[j][3];
1014 z_cent = TwoByTwo[j][4];
1015 rot_x = TwoByTwo[j][5];
1016 rot_y = TwoByTwo[j][6];
1019 Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1021 G4RotationMatrix *Rot_2 =
new G4RotationMatrix();
1022 Rot_2->rotateX(rot_x * rad);
1023 Rot_2->rotateY(rot_y * rad);
1024 Rot_2->rotateZ(0 * rad);
1026 G4SubtractionSolid *Carbon_Shell_2 =
new G4SubtractionSolid(G4String(
"Carbon_Shell_2"),
1036 x_cent = TwoByTwo[j][2];
1037 y_cent = TwoByTwo[j][3];
1038 z_cent = TwoByTwo[j][4];
1039 rot_x = TwoByTwo[j][5];
1040 rot_y = TwoByTwo[j][6];
1043 Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1045 G4RotationMatrix *Rot_3 =
new G4RotationMatrix();
1046 Rot_3->rotateX(rot_x * rad);
1047 Rot_3->rotateY(rot_y * rad);
1048 Rot_3->rotateZ(0 * rad);
1050 G4SubtractionSolid *Carbon_Shell_solid =
new G4SubtractionSolid(G4String(
"Carbon_Shell_solid"),
1056 G4LogicalVolume *Carbon_Shell_logic =
new G4LogicalVolume(Carbon_Shell_solid,
1058 "Carbon_Fiber_logic",
1067 G4ThreeVector Carbon_Center = G4ThreeVector(0 * mm, 0 * mm, 0 * mm);
1069 G4RotationMatrix *Rot_5 =
new G4RotationMatrix();
1070 Rot_5->rotateX(0 * rad);
1071 Rot_5->rotateY(0 * rad);
1072 Rot_5->rotateZ(0 * rad);
1074 G4VPhysicalVolume *physvol =
new G4PVPlacement(Rot_5, Carbon_Center,
1076 "Carbon_Fiber_Shell",
1084 <<
"This is an error message which should never be shown. You may have disabled an important portion of this code upsream. Sorry :)" << endl;
1094 G4int NumberOfLines;
1095 const G4int NumberOfIndices = 9;
1100 G4double x_cent, y_cent, z_cent, r_theta, r_phi;
1112 G4VSolid *crystal_solid =
new G4Trd(G4String(
"eEcal_crystal"),
1122 G4LogicalVolume *crystal_logic =
new G4LogicalVolume(crystal_solid,
1124 "eEcal_crystal_unit",
1129 G4VSolid *twelve_solid =
new G4Trd(G4String(
"12_solid"),
1136 G4LogicalVolume *twelve_logic =
new G4LogicalVolume(twelve_solid,
1143 G4VSolid *twentytwo_solid =
new G4Trd(G4String(
"22_solid"),
1150 G4LogicalVolume *twentytwo_logic =
new G4LogicalVolume(twentytwo_solid,
1157 x_cent = 22.6036363636 + 0.18000 * 2.0;
1160 G4double rot_x = 0.020928529;
1161 G4double rot_y = -1.0 * rot_x;
1162 G4double rot_z = 0.00;
1164 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent *
mm, y_cent * mm, z_cent * mm);
1166 G4RotationMatrix *Rot_1 =
new G4RotationMatrix();
1167 Rot_1->rotateX(rot_x *
rad);
1168 Rot_1->rotateY(rot_y * rad);
1169 Rot_1->rotateZ(0 * rad);
1171 G4VSolid *FourByFour_hunk_solid =
new G4Trd(G4String(
"4x4_hunk_solid"),
1179 G4double carbon_fiber_width = 0.18 *
mm;
1180 G4double air_gap_carbon_fiber = 0.24 *
mm;
1181 G4double air_gap_crystals = 0.60 *
mm;
1184 G4double dx_front_small = (
_dx_front - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
1186 G4double dx_back_small = (
_dx_back - (2.0 * carbon_fiber_width) - (2.0 * air_gap_carbon_fiber) - air_gap_crystals) / 2.0;
1189 G4double TwoByTwo_dx1 = ((2.0 * dx_front_small) + (2.0 * air_gap_carbon_fiber) + air_gap_crystals) / 2.0;
1190 G4double TwoByTwo_dx2 = ((2.0 * dx_back_small) + (2.0 * air_gap_carbon_fiber) + air_gap_crystals) / 2.0;
1191 G4double TwoByTwo_dy1 = TwoByTwo_dx1;
1192 G4double TwoByTwo_dy2 = TwoByTwo_dx2;
1195 G4VSolid *Two_by_Two_solid =
new G4Trd(G4String(
"Two_by_Two_solid"),
1200 TwoByTwo_dz + 5 * mm);
1202 G4SubtractionSolid *thirtytwo_solid =
new G4SubtractionSolid(G4String(
"32_solid"),
1203 FourByFour_hunk_solid,
1208 G4LogicalVolume *thirtytwo_logic =
new G4LogicalVolume(thirtytwo_solid,
1227 if (!datafile.is_open())
1229 datafile.open(
GetParams()->get_string_param(
"mappingtower"));
1233 <<
"*******************************************************************" << endl;
1235 cout <<
"*******************************************************************" << endl
1243 ifstream
in(
GetParams()->get_string_param(
"mappingtower"));
1248 j_cry = NumberOfLines;
1249 k_cry = NumberOfIndices;
1251 double Crystals[j_cry][k_cry];
1261 datafile >> Crystals[j][
k];
1274 MappingIndex = Crystals[j][8];
1275 if (Crystals[j][1] > k_max) k_max = Crystals[j][1];
1283 MappingIndex = Crystals[j][8];
1285 j_idx = Crystals[j][0];
1286 k_idx = Crystals[j][1];
1290 r_theta = Crystals[j][5];
1291 r_phi = Crystals[j][6];
1292 rot_z = Crystals[j][7];
1294 if (MappingIndex == 16)
1296 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1298 G4RotationMatrix *Rot =
new G4RotationMatrix();
1299 Rot->rotateX(r_phi * rad);
1300 Rot->rotateY(r_theta * rad);
1301 Rot->rotateZ(0 * rad);
1303 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1304 int copyno = (j_idx << 16) + k_idx;
1305 new G4PVPlacement(Rot, Crystal_Center,
1311 else if (MappingIndex == 32)
1313 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1315 if (j_idx == (k_max - 1) / 2 && k_idx == (k_max + 1) / 2) rot_z = rot_z / 2.0;
1317 G4RotationMatrix *Rot =
new G4RotationMatrix();
1318 Rot->rotateX(r_phi * rad);
1319 Rot->rotateY(r_theta * rad);
1320 Rot->rotateZ(rot_z * rad);
1322 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1323 int copyno = (j_idx << 16) + k_idx;
1325 new G4PVPlacement(Rot, Crystal_Center,
1331 else if (MappingIndex == 22)
1333 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1335 G4RotationMatrix *Rot =
new G4RotationMatrix();
1336 Rot->rotateX(r_phi * rad);
1337 Rot->rotateY(r_theta * rad);
1338 Rot->rotateZ(rot_z * rad);
1340 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1341 int copyno = (j_idx << 16) + k_idx;
1342 new G4PVPlacement(Rot, Crystal_Center,
1348 else if (MappingIndex == 12)
1350 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1352 G4RotationMatrix *Rot =
new G4RotationMatrix();
1353 Rot->rotateX(r_phi * rad);
1354 Rot->rotateY(r_theta * rad);
1355 Rot->rotateZ(rot_z * rad);
1357 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1358 int copyno = (j_idx << 16) + k_idx;
1360 new G4PVPlacement(Rot, Crystal_Center,
1374 MappingIndex = Crystals[j][8];
1376 j_idx = k_max - Crystals[j][0];
1377 k_idx = Crystals[j][1];
1381 r_theta = -1.0 * Crystals[j][5];
1382 r_phi = Crystals[j][6];
1383 rot_z = Crystals[j][7] / (-4.0);
1385 if (MappingIndex == 16)
1387 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1389 G4RotationMatrix *Rot =
new G4RotationMatrix();
1390 Rot->rotateX(r_phi * rad);
1391 Rot->rotateY(r_theta * rad);
1392 Rot->rotateZ(0 * rad);
1394 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1395 int copyno = (j_idx << 16) + k_idx;
1397 new G4PVPlacement(Rot, Crystal_Center,
1403 else if (MappingIndex == 32)
1405 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1407 if (j_idx == (k_max + 1) / 2 && k_idx == (k_max + 1) / 2) rot_z = rot_z * 3.0;
1409 G4RotationMatrix *Rot =
new G4RotationMatrix();
1410 Rot->rotateX(r_phi * rad);
1411 Rot->rotateY(r_theta * rad);
1412 Rot->rotateZ(rot_z * rad);
1414 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1415 int copyno = (j_idx << 16) + k_idx;
1416 new G4PVPlacement(Rot, Crystal_Center,
1422 else if (MappingIndex == 22)
1424 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1426 rot_z = Crystals[j][7] * (-1.0);
1428 G4RotationMatrix *Rot =
new G4RotationMatrix();
1429 Rot->rotateX(r_phi * rad);
1430 Rot->rotateY(r_theta * rad);
1431 Rot->rotateZ(rot_z * rad);
1433 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1434 int copyno = (j_idx << 16) + k_idx;
1436 new G4PVPlacement(Rot, Crystal_Center,
1442 else if (MappingIndex == 12)
1444 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1446 rot_z = rot_z * -4.0000;
1448 G4RotationMatrix *Rot =
new G4RotationMatrix();
1449 Rot->rotateX(r_phi * rad);
1450 Rot->rotateY(r_theta * rad);
1451 Rot->rotateZ(rot_z * rad);
1453 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1454 int copyno = (j_idx << 16) + k_idx;
1456 new G4PVPlacement(Rot, Crystal_Center,
1470 MappingIndex = Crystals[j][8];
1471 j_idx = k_max - Crystals[j][0];
1472 k_idx = k_max - Crystals[j][1];
1476 r_theta = -1.0 * Crystals[j][5];
1477 r_phi = -1.0 * Crystals[j][6];
1478 rot_z = Crystals[j][7] / 2.0;
1480 if (MappingIndex == 16)
1482 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1484 G4RotationMatrix *Rot =
new G4RotationMatrix();
1485 Rot->rotateX(r_phi * rad);
1486 Rot->rotateY(r_theta * rad);
1487 Rot->rotateZ(0 * rad);
1489 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1490 int copyno = (j_idx << 16) + k_idx;
1492 new G4PVPlacement(Rot, Crystal_Center,
1498 else if (MappingIndex == 32)
1500 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1502 if (j_idx == (k_max + 1) / 2 && k_idx == (k_max - 1) / 2) rot_z = rot_z * -2.0;
1504 G4RotationMatrix *Rot =
new G4RotationMatrix();
1505 Rot->rotateX(r_phi * rad);
1506 Rot->rotateY(r_theta * rad);
1507 Rot->rotateZ(rot_z * rad);
1509 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1510 int copyno = (j_idx << 16) + k_idx;
1512 new G4PVPlacement(Rot, Crystal_Center,
1518 else if (MappingIndex == 22)
1520 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1522 rot_z = Crystals[j][7] * (-1.0);
1524 G4RotationMatrix *Rot =
new G4RotationMatrix();
1525 Rot->rotateX(r_phi * rad);
1526 Rot->rotateY(r_theta * rad);
1527 Rot->rotateZ(rot_z * rad);
1529 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1530 int copyno = (j_idx << 16) + k_idx;
1532 new G4PVPlacement(Rot, Crystal_Center,
1538 else if (MappingIndex == 12)
1540 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1542 G4RotationMatrix *Rot =
new G4RotationMatrix();
1543 Rot->rotateX(r_phi * rad);
1544 Rot->rotateY(r_theta * rad);
1545 Rot->rotateZ(rot_z * rad);
1547 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1548 int copyno = (j_idx << 16) + k_idx;
1549 new G4PVPlacement(Rot, Crystal_Center,
1563 MappingIndex = Crystals[j][8];
1565 j_idx = Crystals[j][0];
1566 k_idx = k_max - Crystals[j][1];
1570 r_theta = Crystals[j][5];
1571 r_phi = -1.0 * Crystals[j][6];
1572 rot_z = Crystals[j][7] / 4.0;
1574 if (MappingIndex == 16)
1576 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1578 G4RotationMatrix *Rot =
new G4RotationMatrix();
1579 Rot->rotateX(r_phi * rad);
1580 Rot->rotateY(r_theta * rad);
1581 Rot->rotateZ(0 * rad);
1583 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1584 int copyno = (j_idx << 16) + k_idx;
1586 new G4PVPlacement(Rot, Crystal_Center,
1592 else if (MappingIndex == 32)
1594 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1596 if (j_idx == (k_max - 1) / 2 && k_idx == (k_max - 1) / 2) rot_z = rot_z * 3.0;
1598 G4RotationMatrix *Rot =
new G4RotationMatrix();
1599 Rot->rotateX(r_phi * rad);
1600 Rot->rotateY(r_theta * rad);
1601 Rot->rotateZ(rot_z * rad);
1603 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1604 int copyno = (j_idx << 16) + k_idx;
1606 new G4PVPlacement(Rot, Crystal_Center,
1612 else if (MappingIndex == 22)
1614 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1616 rot_z = Crystals[j][7] * (1.0);
1618 G4RotationMatrix *Rot =
new G4RotationMatrix();
1619 Rot->rotateX(r_phi * rad);
1620 Rot->rotateY(r_theta * rad);
1621 Rot->rotateZ(rot_z * rad);
1623 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1624 int copyno = (j_idx << 16) + k_idx;
1625 new G4PVPlacement(Rot, Crystal_Center,
1631 else if (MappingIndex == 12)
1633 G4ThreeVector Crystal_Center = G4ThreeVector(x_cent * mm, y_cent * mm, z_cent * mm);
1635 rot_z = rot_z * -4.0000;
1637 G4RotationMatrix *Rot =
new G4RotationMatrix();
1638 Rot->rotateX(r_phi * rad);
1639 Rot->rotateY(r_theta * rad);
1640 Rot->rotateZ(rot_z * rad);
1642 string FourByFourName =
"FourByFour_j_" +
to_string(j_idx) +
"_k_" +
to_string(k_idx);
1643 int copyno = (j_idx << 16) + k_idx;
1645 new G4PVPlacement(Rot, Crystal_Center,