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;
17 typedef vector<PlacedVolume> Placements;
20 Material air = lcdd.air();
21 Material carbon = lcdd.material(
"CarbonFiber");
22 Material silicon = lcdd.material(
"SiliconOxide");
23 Material aluminum = lcdd.material(
"Aluminum");
24 Material vacuum = lcdd.material(
"Vacuum");
25 Material supp_mat = carbon;
26 Material sens_mat = silicon;
28 int det_id = x_det.id();
29 string det_name = x_det.nameStr();
32 DetElement sdet( det_name, det_id);
33 Assembly assembly(det_name +
"_assembly");
35 sens.setType(
"tracker");
36 string module_name =
"RomanPot";
38 double z_offset = x_det.attr<
double>( _Unicode(zoffset) );
39 double nz = ( x_det.hasAttr(_Unicode(nz)) ) ? x_det.attr<
double>(_Unicode(zoffset)) : 5.0;
40 std::cout <<
" NZ = " << nz << std::endl;
42 double thickness = 0.01*dd4hep::cm;
44 double rp_chamber_thickness = 5.0*dd4hep::mm;
45 double rp_chamber_radius = 5.0*dd4hep::cm;
46 double rp_chamber_length = 50.0*dd4hep::cm;
47 Tube rp_beam_pipe_tube(rp_chamber_radius, rp_chamber_radius+rp_chamber_thickness, rp_chamber_length/2.0);
48 Tube rp_beam_vacuum_tube(0.0, rp_chamber_radius+rp_chamber_thickness, rp_chamber_length/2.0);
49 Tube rp_beam_vacuum_tube2(0.0, rp_chamber_radius, rp_chamber_length/2.0);
51 double rp_detector_tube_radius = 2.5*dd4hep::cm;
52 double rp_detector_tube_length = 20.0*dd4hep::cm;
53 Tube rp_detector_tube(rp_detector_tube_radius, rp_detector_tube_radius+rp_chamber_thickness, rp_detector_tube_length/2.0);
54 Tube rp_detector_vacuum_tube(0.0, rp_detector_tube_radius+rp_chamber_thickness, rp_detector_tube_length/2.0);
55 Tube rp_detector_vacuum_tube2(0.0, rp_detector_tube_radius, rp_detector_tube_length/2.0);
58 ROOT::Math::Rotation3D rot_X( ROOT::Math::RotationX(M_PI/2.0) );
59 ROOT::Math::Rotation3D rot_Y( ROOT::Math::RotationY(M_PI/2.0) );
61 UnionSolid rp_chamber_tee1(rp_beam_vacuum_tube, rp_detector_vacuum_tube, rot_X);
62 UnionSolid rp_chamber_tee12(rp_chamber_tee1, rp_detector_vacuum_tube, rot_Y);
64 UnionSolid rp_chamber_tee2(rp_beam_vacuum_tube2, rp_detector_vacuum_tube2, rot_X);
65 UnionSolid rp_chamber_tee22(rp_chamber_tee2, rp_detector_vacuum_tube2, rot_Y);
67 SubtractionSolid sub1(rp_chamber_tee12,rp_chamber_tee22);
68 Volume rp_chamber_vol(
"rp_chamber_walls_vol", sub1, aluminum);
70 Volume rp_vacuum_vol(
"rp_chamber_vacuum_vol", rp_chamber_tee22, vacuum);
73 pv = assembly.placeVolume( rp_chamber_vol );
79 pv = assembly.placeVolume( rp_vacuum_vol );
80 pv.addPhysVolID(
"layer", 2 );
85 double supp_x_half = 1.0*dd4hep::cm;
86 double supp_y_half = 1.0*dd4hep::cm;
87 double supp_thickness = 1.0*dd4hep::mm;
88 double supp_gap_half_width = 1.0*dd4hep::mm;
89 double sens_thickness = 0.1*dd4hep::mm;
91 Box supp_box( supp_x_half, supp_y_half, supp_thickness/2.0 );
92 Box sens_box( supp_x_half-supp_gap_half_width, supp_y_half-supp_gap_half_width, sens_thickness/2.0 );
96 Vector3D u( 1. , 0. , 0. ) ;
97 Vector3D v( 0. , 1. , 0. ) ;
98 Vector3D n( 0. , 0. , 1. ) ;
105 double inner_thickness = supp_thickness/2.0;
106 double outer_thickness = supp_thickness/2.0;
108 double z_shift = 5.0*dd4hep::mm;
109 double xy_shift = 15.0*dd4hep::mm;
111 SurfaceType type( SurfaceType::Sensitive ) ;
117 Volume support1_vol(
"xsenseor_supp", supp_box, supp_mat );
118 Volume sensor1_vol(
"xsenseor_sens", sens_box, sens_mat );
119 VolPlane surf1( sensor1_vol, type, inner_thickness , outer_thickness , u,v,n ) ;
120 sensor1_vol.setSensitiveDetector(sens);
122 DetElement layer1_DE( sdet,
"layer1_DE", 1 );
123 pv = rp_vacuum_vol.placeVolume( support1_vol, Position(xy_shift,0, -z_shift) );
124 pv.addPhysVolID(
"layer", 1 );
125 layer1_DE.setPlacement( pv ) ;
127 DetElement mod1( layer1_DE ,
"module_1", 1 );
128 pv = support1_vol.placeVolume(sensor1_vol, Position(0,0,0));
129 pv.addPhysVolID(
"module", 1 );
130 mod1.setPlacement( pv );
133 Volume support2_vol(
"xsenseor_supp", supp_box, supp_mat );
134 Volume sensor2_vol(
"xsenseor_sens", sens_box, sens_mat );
135 VolPlane surf2( sensor2_vol, type, inner_thickness , outer_thickness , u,v,n ) ;
136 sensor2_vol.setSensitiveDetector(sens);
138 DetElement layer2_DE( sdet,
"layer2_DE", 2 );
139 pv = rp_vacuum_vol.placeVolume( support2_vol, Position(-xy_shift,0, -z_shift) );
140 pv.addPhysVolID(
"layer", 2 );
141 layer2_DE.setPlacement( pv ) ;
143 DetElement mod2( layer2_DE ,
"module_2", 2 );
144 pv = support2_vol.placeVolume(sensor2_vol, Position(0,0,0));
145 pv.addPhysVolID(
"module", 2 );
146 mod2.setPlacement( pv );
149 Volume support3_vol(
"xsenseor_supp", supp_box, supp_mat );
150 Volume sensor3_vol(
"xsenseor_sens", sens_box, sens_mat );
151 VolPlane surf3( sensor3_vol, type, inner_thickness , outer_thickness , u,v,n ) ;
152 sensor3_vol.setSensitiveDetector(sens);
154 DetElement layer3_DE( sdet,
"layer3_DE", 3 );
155 pv = rp_vacuum_vol.placeVolume( support3_vol, Position(0,xy_shift, z_shift) );
156 pv.addPhysVolID(
"layer", 3 );
157 layer3_DE.setPlacement( pv ) ;
159 DetElement mod3( layer3_DE ,
"module_3", 3 );
160 pv = support3_vol.placeVolume(sensor3_vol, Position(0,0,0));
161 pv.addPhysVolID(
"module", 3 );
162 mod3.setPlacement( pv );
165 Volume support4_vol(
"xsenseor_supp", supp_box, supp_mat );
166 Volume sensor4_vol(
"xsenseor_sens", sens_box, sens_mat );
167 VolPlane surf4( sensor4_vol, type, inner_thickness , outer_thickness , u,v,n ) ;
168 sensor4_vol.setSensitiveDetector(sens);
170 DetElement layer4_DE( sdet,
"layer4_DE", 4 );
171 pv = rp_vacuum_vol.placeVolume( support4_vol, Position(0,-xy_shift, z_shift) );
172 pv.addPhysVolID(
"layer", 4 );
173 layer4_DE.setPlacement( pv ) ;
175 DetElement mod4( layer4_DE ,
"module_4", 4 );
176 pv = support4_vol.placeVolume(sensor4_vol, Position(0,0,0));
177 pv.addPhysVolID(
"module", 4 );
178 mod4.setPlacement( pv );
185 pv = lcdd.pickMotherVolume(sdet).placeVolume(assembly, Position(0,0,z_offset));
186 pv.addPhysVolID(
"system", det_id);
187 sdet.setPlacement(pv);
189 assembly->GetShape()->ComputeBBox() ;