SiTrackerRomanPot_geo.cpp
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
2 #include "DD4hep/Printout.h"
3 #include "DD4hep/Shapes.h"
4 #include "TMath.h"
5 #include "DDRec/Surface.h"
6 #include "DDRec/DetectorData.h"
7 
8 using namespace std;
9 using namespace dd4hep;
10 using namespace dd4hep::rec;
11 //using namespace DD4hep::Geometry;
12 //using namespace DD4hep::DDRec;
13 //using namespace DDSurfaces;
14 
15 static Ref_t create_detector(Detector& lcdd, xml_h e, SensitiveDetector sens)
16 {
17  typedef vector<PlacedVolume> Placements;
18 
19  xml_det_t x_det = e;
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;
27 
28  int det_id = x_det.id();
29  string det_name = x_det.nameStr();
30  PlacedVolume pv;
31 
32  DetElement sdet( det_name, det_id);
33  Assembly assembly(det_name + "_assembly");
34 
35  sens.setType("tracker");
36  string module_name = "RomanPot";
37 
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;
41 
42  double thickness = 0.01*dd4hep::cm;
43 
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);
50 
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);
56 
57  //ROOT::Math::RotationX rX(M_PI);
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) );
60 
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);
63 
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);
66 
67  SubtractionSolid sub1(rp_chamber_tee12,rp_chamber_tee22);
68  Volume rp_chamber_vol("rp_chamber_walls_vol", sub1, aluminum);
69 
70  Volume rp_vacuum_vol("rp_chamber_vacuum_vol", rp_chamber_tee22, vacuum);
71 
72  //DetElement chamberwalls_DE( sdet, "chamber_walls_volume", 1 );
73  pv = assembly.placeVolume( rp_chamber_vol );//, Transform3D(RotationZ(phi0_offset),Position(0.0,0.0,z)) );
74  //pv.addPhysVolID( "layer", 1 );
75  //chamberwalls_DE.setPlacement(pv);
76  //chamberwalls_DE.setAttributes(lcdd, rp_chamber_vol, "", "", "RedVis");
77 
78  //DetElement chamber_DE( sdet, "chamber_volume", 1 );
79  pv = assembly.placeVolume( rp_vacuum_vol );//, Transform3D(RotationZ(phi0_offset),Position(0.0,0.0,z)) );
80  pv.addPhysVolID( "layer", 2 );
81  //chamber_DE.setPlacement(pv);
82  //chamber_DE.setAttributes(lcdd, rp_vacuum_vol, "", "", "BlueVis");
83  //chamber_DE.setAttributes(lcdd, layer_assembly, "", "", "SiVertexLayerVis");
84 
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;
90 
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 );
93 
94 
95  // -------- create a measurement plane for the tracking surface attched to the sensitive volume -----
96  Vector3D u( 1. , 0. , 0. ) ;
97  Vector3D v( 0. , 1. , 0. ) ;
98  Vector3D n( 0. , 0. , 1. ) ;
99  //Vector3D o( 0. , 0. , 0. ) ;
100 
101  // compute the inner and outer thicknesses that need to be assigned to the tracking surface
102  // depending on wether the support is above or below the sensor
103  // The tracking surface is used in reconstruction. It provides material thickness
104  // and radation lengths needed for various algorithms, routines, etc.
105  double inner_thickness = supp_thickness/2.0;
106  double outer_thickness = supp_thickness/2.0;
107 
108  double z_shift = 5.0*dd4hep::mm;
109  double xy_shift = 15.0*dd4hep::mm;
110 
111  SurfaceType type( SurfaceType::Sensitive ) ;
112 
113  //for(int ii = 0; ii<4; ii++) {
114  //}
115 
116  // ------------- x1
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 ) ; //,o ) ;
120  sensor1_vol.setSensitiveDetector(sens);
121 
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 ) ;
126 
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 );
131 
132  // ------------- x2
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 ) ; //,o ) ;
136  sensor2_vol.setSensitiveDetector(sens);
137 
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 ) ;
142 
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 );
147 
148  // -------------x3
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 ) ; //,o ) ;
152  sensor3_vol.setSensitiveDetector(sens);
153 
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 ) ;
158 
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 );
163 
164  // -------------x4
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 ) ; //,o ) ;
168  sensor4_vol.setSensitiveDetector(sens);
169 
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 ) ;
174 
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 );
179 
180 
181 
182  //sdet.setAttributes(lcdd, assembly,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
183  //assembly.setVisAttributes(lcdd.invisible());
184 
185  pv = lcdd.pickMotherVolume(sdet).placeVolume(assembly, Position(0,0,z_offset));
186  pv.addPhysVolID("system", det_id); // Set the subdetector system ID.
187  sdet.setPlacement(pv);
188 
189  assembly->GetShape()->ComputeBBox() ;
190  return sdet;
191 }
192 
193 DECLARE_DETELEMENT(SiTrackerRomanPot, create_detector)
static Ref_t create_detector(Detector &lcdd, xml_h e, SensitiveDetector sens)
Detector
Definition: DDG4.py:69
Namespace for the AIDA detector description toolkit.