IRChamber_geo.cpp
Go to the documentation of this file.
1 //==========================================================================
2 //
3 // <detector name ="DetName" type="Beampipe" >
4 // <layer id="#(int)" inner_r="#(double)" outer_z="#(double)" >
5 // <slice material="string" thickness="#(double)" >
6 // </layer>
7 // </detector>
8 //==========================================================================
9 #include "DD4hep/DetFactoryHelper.h"
10 #include "DD4hep/Printout.h"
11 #include "TMath.h"
12 
13 using namespace std;
14 using namespace dd4hep;
15 
30 static Ref_t create_detector(Detector& det, xml_h e, SensitiveDetector sens) {
31 
32  using namespace ROOT::Math;
33  xml_det_t x_det = e;
34  string det_name = x_det.nameStr();
35  Material air = det.air();
36  DetElement sdet (det_name,x_det.id());
37  Assembly assembly (det_name+"_assembly");
38  Material m_Cu = det.material("Copper");
39  Material m_Al = det.material("Aluminum");
40  Material m_Be = det.material("Beryllium");
41 
42  int n = 0;
43 
44  // IP
45  double IP_beampipe_OD = 55.00 * mm;
46  double IP_beampipe_thickness = 4.00 * mm;
47  double IP_beampipe_ID = IP_beampipe_OD - IP_beampipe_thickness;
48  double crossing_angle = 0.025;
49 
50  // upstream parameters
51  double upstream_straight_length = 685.0 * mm;
52  double upstream_total_length = 4500.0 * mm;
53  double upstream_conic_length = upstream_total_length - upstream_straight_length;
54  double upstream_beampipe_exit_OD = 229.96 * mm;
55  double upstream_beampipe_exit_ID = upstream_beampipe_exit_OD - IP_beampipe_thickness;
56  double upstream_epipe_thickness = 4.0*mm;
57 
58  // downstream parameters
59  double downstream_straight_length = 1300.0 * mm;
60  double downstream_taper_length = 310.0 * mm;
61  double downstream_total_length = 4500.0 * mm;
62  double downstream_conic_length = downstream_total_length - downstream_straight_length ;
63  double downstream_cone_rmax = 110.00*mm/2.0;
64  double downstream_epipe_thickness = 4.0*mm; // just a guess
65  double downstream_beampipe_exit_OD = 62.0 * mm;
66  double downstream_beampipe_exit_ID = downstream_beampipe_exit_OD - downstream_epipe_thickness;
67  double downstream_hpipe_OD = IP_beampipe_ID/2; // just a guess
68  double downstream_hpipe_thickness = 4.0*mm; // just a guess
69 
70  double upstream_delta_r = upstream_conic_length*std::tan(crossing_angle/2.0);
71  double downstream_delta_r = (downstream_conic_length+downstream_straight_length)*std::tan(crossing_angle);
72 
73 
74  // -----------------------------
75  // IP beampipe
76  Tube downstream_IP_tube(IP_beampipe_ID/2.0, IP_beampipe_OD/2.0, downstream_straight_length/2.0);
77  Tube downstream_IP_vacuum(0.0, IP_beampipe_ID/2.0, downstream_straight_length/2.0);
78  Tube upstream_IP_tube(IP_beampipe_ID/2.0, IP_beampipe_OD/2.0, upstream_straight_length/2.0);
79  Tube upstream_IP_vacuum(0.0, IP_beampipe_OD/2.0, upstream_straight_length/2.0);
80 
81  Volume v_upstream_IP_tube("v_upstream_IP_tube", upstream_IP_tube, m_Al);
82  Volume v_downstream_IP_tube("v_downstream_IP_tube", downstream_IP_tube, m_Al);
83 
84  //v_upstream_IP_tube.setVisAttributes(det,"GrayVis");
85  //v_downstream_IP_tube.setVisAttributes(det,"RedVis");
86  sdet.setAttributes(det, v_upstream_IP_tube , x_det.regionStr(), x_det.limitsStr(), "OrangeVis");
87  sdet.setAttributes(det, v_downstream_IP_tube, x_det.regionStr(), x_det.limitsStr(), "OrangeVis");
88 
89  auto pv_upstream_IP_tube = assembly.placeVolume(
90  v_upstream_IP_tube, Position(0, 0, -upstream_straight_length / 2.0));
91 
92  auto pv_downstream_IP_tube = assembly.placeVolume(
93  v_downstream_IP_tube, Position(0, 0, downstream_straight_length / 2.0));
94 
95  // -----------------------------
96  // upstream
97  Tube upstream_electron_tube(IP_beampipe_ID/2.0 - upstream_epipe_thickness,
98  IP_beampipe_ID/2.0, upstream_conic_length/2.0);
99  Cone upstream_conic_section(upstream_conic_length / 2.0,
100  IP_beampipe_ID / 2.0, IP_beampipe_OD / 2.0,
101  IP_beampipe_ID / 2.0 + upstream_delta_r,
102  IP_beampipe_OD / 2.0+ upstream_delta_r + IP_beampipe_thickness);
103  Cone upstream_conic_section_vacuum(upstream_conic_length / 2.0,
104  0.0, IP_beampipe_ID / 2.0,
105  0.0, IP_beampipe_ID / 2.0 + upstream_delta_r);
106  Volume v_upstream_conic_section("v_upstream_conic_section", upstream_conic_section, m_Al);
107  Volume v_upstream_electron_tube("v_upstream_conic_section", upstream_electron_tube, m_Al);
108  sdet.setAttributes(det, v_upstream_conic_section, x_det.regionStr(), x_det.limitsStr(), "OrangeVis");
109  sdet.setAttributes(det, v_upstream_electron_tube, x_det.regionStr(), x_det.limitsStr(), "OrangeVis");
110  //Volume v_upstream_conic_section_vacuum("v_upstream_conic_section_vacuum", upstream_electron_tube, m_Al);
111 
112  auto pv_upstream_conic_section = assembly.placeVolume(
113  v_upstream_conic_section,
114  Transform3D(
115  Position(-upstream_delta_r/2.0,0, -upstream_straight_length - upstream_conic_length / 2.0)) *
116  RotationY(crossing_angle / 2.0) * RotationX(M_PI));
117  auto pv_upstream_electron_tube =
118  assembly.placeVolume(v_upstream_electron_tube,
119  Position(0, 0, -upstream_straight_length - upstream_conic_length / 2.0));
120  //DetElement de_upstream_conic_section(sdet,"de_upstream_conic_section",1);
121  //de_upstream_conic_section.setPlacement(pv_upstream_conic_section);
122 
123  // -----------------------------
124  // downstream
125  Tube downstream_hadron_tube(downstream_hpipe_OD/2.0 - downstream_epipe_thickness,
126  downstream_hpipe_OD/2.0, downstream_conic_length / 2.0);
127  Cone downstream_conic_section(downstream_conic_length / 2.0, IP_beampipe_ID / 2.0,
128  IP_beampipe_OD / 2.0, downstream_cone_rmax,
129  downstream_cone_rmax + downstream_epipe_thickness);
130  Cone downstream_taper_section(downstream_taper_length / 2.0,
131  downstream_cone_rmax, downstream_cone_rmax + downstream_epipe_thickness,
132  downstream_beampipe_exit_ID/2.0, downstream_beampipe_exit_OD/2.0);
133 
134  UnionSolid downstream_pipe_split0(downstream_conic_section, downstream_hadron_tube,
135  Transform3D(Position(downstream_delta_r / 2.0, 0.0, 0.0)) *
136  RotationY(crossing_angle));
137 
138  // Vacuum
139  Cone downstream_conic_section_vacuum(downstream_conic_length / 2.0,
140  0.0, IP_beampipe_ID / 2.0,
141  0.0, downstream_cone_rmax);
142  Tube downstream_hadron_vacuum(0.0, downstream_hpipe_OD / 2.0 - downstream_epipe_thickness,
143  downstream_conic_length / 1.9);
144  UnionSolid downstream_pipe_vacuum_split0(downstream_conic_section_vacuum, downstream_hadron_vacuum,
145  Transform3D(Position(downstream_delta_r / 2.0, 0.0, 0.0)) *
146  RotationY(crossing_angle));
147  SubtractionSolid downstream_pipe_split1(downstream_pipe_split0,
148  downstream_pipe_vacuum_split0);
149  Volume v_downstream_pipe_split1("v_downstream_pipe_split1", downstream_pipe_split1, m_Al);
150  sdet.setAttributes(det, v_downstream_pipe_split1, x_det.regionStr(), x_det.limitsStr(), "OrangeVis");
151  auto pv_downstream_pipe_split1 = assembly.placeVolume(v_downstream_pipe_split1,
152  Position(0, 0,
153  downstream_straight_length +
154  downstream_conic_length / 2.0));
155  Volume v_downstream_taper_section("v_downstream_taper_section", downstream_taper_section, m_Al);
156  sdet.setAttributes(det, v_downstream_taper_section, x_det.regionStr(), x_det.limitsStr(), "OrangeVis");
157  auto pv_downstream_taper_section = assembly.placeVolume(
158  v_downstream_taper_section, Position(0, 0,
159  downstream_straight_length + downstream_conic_length +
160  downstream_taper_length / 2.0));
161 
162  //Volume v_downstream_conic_section("v_downstream_conic_section", downstream_conic_section, m_Al);
163  //Volume v_downstream_hadron_tube("v_downstream_hadron_tube", downstream_hadron_tube, m_Al);
164  //auto pv_downstream_hadron_tube = assembly.placeVolume(
165  // v_downstream_hadron_tube,
166  // Transform3D(Position(downstream_delta_r / 2.0, 0,
167  // downstream_straight_length + downstream_conic_length / 2.0)) *
168  // RotationY(crossing_angle) );
169 
170  //auto pv_downstream_conic_section = assembly.placeVolume(
171  // v_downstream_conic_section, Position(0, 0, downstream_straight_length + downstream_conic_length / 2.0));
172  //DetElement de_downstream_conic_section(sdet,"de_downstream_conic_section",1);
173  //de_downstream_conic_section.setPlacement(pv_downstream_conic_section);
174 
175  auto pv_assembly = det.pickMotherVolume(sdet).placeVolume(assembly);
176  pv_assembly.addPhysVolID("system",sdet.id()).addPhysVolID("barrel",0);
177  sdet.setPlacement(pv_assembly);
178  assembly->GetShape()->ComputeBBox() ;
179  return sdet;
180 }
181 
182 DECLARE_DETELEMENT(IRChamber,create_detector)
static Ref_t create_detector(Detector &det, xml_h e, SensitiveDetector sens)
Detector
Definition: DDG4.py:69
Namespace for the AIDA detector description toolkit.