1 #include "DD4hep/DetFactoryHelper.h"
2 #include "DD4hep/Printout.h"
3 #include "DD4hep/Shapes.h"
5 #include "DDRec/Surface.h"
6 #include "DDRec/DetectorData.h"
10 using namespace dd4hep::rec;
15 Material air = dtor.air();
16 Material carbon = dtor.material(
"CarbonFiber");
17 Material silicon = dtor.material(
"SiliconOxide");
18 Material aluminum = dtor.material(
"Aluminum");
19 Material vacuum = dtor.material(
"Vacuum");
20 Material supp_mat = carbon;
21 Material sens_mat = silicon;
23 int det_id = x_det.id();
24 string det_name = x_det.nameStr();
27 DetElement sdet( det_name, det_id);
28 Assembly assembly(det_name +
"_assembly");
30 sens.setType(
"tracker");
31 string module_name =
"RomanPot";
36 std::string vis0 = dd4hep::getAttrOrDefault(x_det, _Unicode(vis),
"BlueVis");
38 double z_offset = dd4hep::getAttrOrDefault(x_det, _Unicode(zoffset), 0.0);
40 double thickness = (x_det.hasAttr(_Unicode(thickness))) ? x_det.attr<
double>(_Unicode(thickness)) : 0.01*dd4hep::cm;
42 double rp_chamber_thickness = 5.0*dd4hep::mm;
43 double rp_chamber_radius = 5.0*dd4hep::cm;
44 double rp_chamber_length = 50.0*dd4hep::cm;
45 Tube rp_beam_pipe_tube(rp_chamber_radius, rp_chamber_radius+rp_chamber_thickness, rp_chamber_length/2.0);
46 Tube rp_beam_vacuum_tube(0.0, rp_chamber_radius+rp_chamber_thickness, rp_chamber_length/2.0);
47 Tube rp_beam_vacuum_tube2(0.0, rp_chamber_radius, rp_chamber_length/2.0);
49 double rp_detector_tube_radius = 2.5*dd4hep::cm;
50 double rp_detector_tube_length = 20.0*dd4hep::cm;
51 Tube rp_detector_tube(rp_detector_tube_radius, rp_detector_tube_radius+rp_chamber_thickness, rp_detector_tube_length/2.0);
52 Tube rp_detector_vacuum_tube(0.0, rp_detector_tube_radius+rp_chamber_thickness, rp_detector_tube_length/2.0);
53 Tube rp_detector_vacuum_tube2(0.0, rp_detector_tube_radius, rp_detector_tube_length/2.0);
56 ROOT::Math::Rotation3D rot_X( ROOT::Math::RotationX(M_PI/2.0) );
57 ROOT::Math::Rotation3D rot_Y( ROOT::Math::RotationY(M_PI/2.0) );
59 UnionSolid rp_chamber_tee1(rp_beam_vacuum_tube, rp_detector_vacuum_tube, rot_X);
60 UnionSolid rp_chamber_tee12(rp_chamber_tee1, rp_detector_vacuum_tube, rot_Y);
62 UnionSolid rp_chamber_tee2(rp_beam_vacuum_tube2, rp_detector_vacuum_tube2, rot_X);
63 UnionSolid rp_chamber_tee22(rp_chamber_tee2, rp_detector_vacuum_tube2, rot_Y);
65 SubtractionSolid sub1(rp_chamber_tee12,rp_chamber_tee22);
66 Volume rp_chamber_vol(
"rp_chamber_walls_vol", sub1, aluminum);
68 Volume rp_vacuum_vol(
"rp_chamber_vacuum_vol", rp_chamber_tee22, vacuum);
70 pv = assembly.placeVolume( rp_chamber_vol );
72 auto vacuum_pv = assembly.placeVolume( rp_vacuum_vol );
73 vacuum_pv.addPhysVolID(
"element", 1 );
75 rp_chamber_vol.setVisAttributes(vis0.c_str());
76 rp_vacuum_vol.setVisAttributes(dtor.invisible());
80 double supp_x_half = 1.0*dd4hep::cm;
81 double supp_y_half = 1.0*dd4hep::cm;
82 double supp_thickness = 1.0*dd4hep::mm;
83 double supp_gap_half_width = 1.0*dd4hep::mm;
84 double sens_thickness = 0.1*dd4hep::mm;
86 Box supp_box( supp_x_half, supp_y_half, supp_thickness/2.0 );
87 Box sens_box( supp_x_half-supp_gap_half_width, supp_y_half-supp_gap_half_width, sens_thickness/2.0 );
90 Vector3D u( 1. , 0. , 0. ) ;
91 Vector3D v( 0. , 1. , 0. ) ;
92 Vector3D n( 0. , 0. , 1. ) ;
99 double inner_thickness = supp_thickness/2.0;
100 double outer_thickness = supp_thickness/2.0;
102 double z_shift = 5.0*dd4hep::mm;
103 double xy_shift = 15.0*dd4hep::mm;
105 SurfaceType type( SurfaceType::Sensitive ) ;
108 Volume support1_vol(
"xsenseor_supp", supp_box, supp_mat );
109 Volume sensor1_vol(
"xsenseor_sens", sens_box, sens_mat );
110 VolPlane surf1( sensor1_vol, type, inner_thickness , outer_thickness , u,v,n ) ;
111 sensor1_vol.setSensitiveDetector(sens);
113 DetElement layer1_DE( sdet,
"layer1_DE", 1 );
114 pv = rp_vacuum_vol.placeVolume( support1_vol, Position(xy_shift,0, -z_shift) );
115 pv.addPhysVolID(
"layer", 1 );
116 layer1_DE.setPlacement( pv ) ;
118 DetElement mod1( layer1_DE ,
"module_1", 1 );
119 pv = support1_vol.placeVolume(sensor1_vol, Position(0,0,0));
120 pv.addPhysVolID(
"module", 1 );
121 mod1.setPlacement( pv );
124 Volume support2_vol(
"xsenseor_supp", supp_box, supp_mat );
125 Volume sensor2_vol(
"xsenseor_sens", sens_box, sens_mat );
126 VolPlane surf2( sensor2_vol, type, inner_thickness , outer_thickness , u,v,n ) ;
127 sensor2_vol.setSensitiveDetector(sens);
129 DetElement layer2_DE( sdet,
"layer2_DE", 2 );
130 pv = rp_vacuum_vol.placeVolume( support2_vol, Position(-xy_shift,0, -z_shift) );
131 pv.addPhysVolID(
"layer", 2 );
132 layer2_DE.setPlacement( pv ) ;
134 DetElement mod2( layer2_DE ,
"module_2", 2 );
135 pv = support2_vol.placeVolume(sensor2_vol, Position(0,0,0));
136 pv.addPhysVolID(
"module", 2 );
137 mod2.setPlacement( pv );
140 Volume support3_vol(
"xsenseor_supp", supp_box, supp_mat );
141 Volume sensor3_vol(
"xsenseor_sens", sens_box, sens_mat );
142 VolPlane surf3( sensor3_vol, type, inner_thickness , outer_thickness , u,v,n ) ;
143 sensor3_vol.setSensitiveDetector(sens);
145 DetElement layer3_DE( sdet,
"layer3_DE", 3 );
146 pv = rp_vacuum_vol.placeVolume( support3_vol, Position(0,xy_shift, z_shift) );
147 pv.addPhysVolID(
"layer", 3 );
148 layer3_DE.setPlacement( pv ) ;
150 DetElement mod3( layer3_DE ,
"module_3", 3 );
151 pv = support3_vol.placeVolume(sensor3_vol, Position(0,0,0));
152 pv.addPhysVolID(
"module", 3 );
153 mod3.setPlacement( pv );
156 Volume support4_vol(
"xsenseor_supp", supp_box, supp_mat );
157 Volume sensor4_vol(
"xsenseor_sens", sens_box, sens_mat );
158 VolPlane surf4( sensor4_vol, type, inner_thickness , outer_thickness , u,v,n ) ;
159 sensor4_vol.setSensitiveDetector(sens);
161 DetElement layer4_DE( sdet,
"layer4_DE", 4 );
162 pv = rp_vacuum_vol.placeVolume( support4_vol, Position(0,-xy_shift, z_shift) );
163 pv.addPhysVolID(
"layer", 4 );
164 layer4_DE.setPlacement( pv ) ;
166 DetElement mod4( layer4_DE ,
"module_4", 4 );
167 pv = support4_vol.placeVolume(sensor4_vol, Position(0,0,0));
168 pv.addPhysVolID(
"module", 4 );
169 mod4.setPlacement( pv );
174 pv = dtor.pickMotherVolume(sdet).placeVolume(assembly, Position(0,0,z_offset));
175 pv.addPhysVolID(
"system", det_id);
176 sdet.setPlacement(pv);
178 assembly->GetShape()->ComputeBBox() ;