ZeroDegreeCAL_geo.cpp
Go to the documentation of this file.
1 //==========================================================================
2 // Zero Degree Calorimeter Detector implementation
3 //--------------------------------------------------------------------------
4 // J.KIM 2020-05-14
5 // Created
6 // Modified 2020-05-27 4XY pairs of bar
7 // Modified 2020-05-28 Used Plastic Scintillation instead of GSO scint
8 // Modified 2020-06-05 Debugged errors while Geant4 simulation running
9 // Modified 2020-06-12 VolumeID - Ran Geant4 simulation w/o errors
10 //==========================================================================
11 #include "DD4hep/DetFactoryHelper.h"
12 #include "DD4hep/Printout.h"
13 #include <XML/Helper.h>
14 #include "TMath.h"
15 #include "DDRec/Surface.h"
16 #include "DDRec/DetectorData.h"
17 #include "XML/Layering.h"
18 
19 using namespace std;
20 using namespace dd4hep;
21 using namespace dd4hep::rec;
22 using namespace dd4hep::detail;
23 
41 static Ref_t createDetector(Detector& description, xml_h e, SensitiveDetector sens) {
42  xml_det_t x_det = e;
43  int det_id = x_det.id();
44  string det_name = x_det.nameStr();
45 
46  // Define assembly
47  Assembly assembly( det_name+"_assembly" );
48  DetElement det(det_name, det_id);
49  Assembly module_assembly( "module_assembly" );
50  PlacedVolume module_PV;
51  Assembly bar_assembly("bar_assembly");
52  PlacedVolume pv_bar;
53 
54  xml_dim_t pos = x_det.position();
55  double x_pos = dd4hep::getAttrOrDefault(pos, _Unicode(x),0.0);
56  double y_pos = dd4hep::getAttrOrDefault(pos, _Unicode(y),0.0);
57  double z_pos = dd4hep::getAttrOrDefault(pos, _Unicode(z),0.0);
58 
59  // Dimensions of RHICf/LHCf detector
60  double small_tower_length = 20*mm;
61  double large_tower_length = 40*mm;
62  double offset_btw_towers = 5*mm;
63  double bar_width = 1*mm;
64 
65  double tungsten_thickness = 7*mm;
66  double scintillator_thickness = 3*mm;
67  double dz_scint = scintillator_thickness/2.0 + tungsten_thickness/2.0;
68 
69  // Visualization Setting
70  auto gray_vis = description.visAttributes("GrayVis");
71  auto blue_vis = description.visAttributes("BlueVis");
72  auto red_vis = description.visAttributes("RedVis");
73 
74  // Tungsten plates
76  Box s_tungsten_layer_shape(small_tower_length/2.0, small_tower_length/2.0,tungsten_thickness/2.0);
77  Volume s_tungsten_layer_Vol("s_tungsten_layer_Vol", s_tungsten_layer_shape, description.material("TungstenDens24"));
78  s_tungsten_layer_Vol.setVisAttributes(gray_vis);
80  Box l_tungsten_layer_shape(large_tower_length/2.0, large_tower_length/2.0,tungsten_thickness/2.0);
81  Volume l_tungsten_layer_Vol("l_tungsten_layer_Vol", l_tungsten_layer_shape, description.material("TungstenDens24"));
82  l_tungsten_layer_Vol.setVisAttributes(gray_vis);
83 
84  // Scitillator plates
86  Box s_scint_layer_shape(small_tower_length/2.0, small_tower_length/2.0,scintillator_thickness/2.0);
87  Volume s_scint_layer_Vol("s_scint_layer_Vol", s_scint_layer_shape, description.material("PlasticScint"));
88  s_scint_layer_Vol.setVisAttributes(blue_vis);
90  Box l_scint_layer_shape(large_tower_length/2.0, large_tower_length/2.0,scintillator_thickness/2.0);
91  Volume l_scint_layer_Vol("l_scint_layer_Vol", l_scint_layer_shape, description.material("PlasticScint"));
92  l_scint_layer_Vol.setVisAttributes(blue_vis);
93 
94  // Position layers
96  Box sx_bar(bar_width/2.0, small_tower_length/2.0, bar_width/2.0);
97  Volume sx_bar_vol("sx_bar_volume", sx_bar, description.material("PlasticScint"));
98  sx_bar_vol.setVisAttributes(red_vis);
100  Box sy_bar(small_tower_length/2.0, bar_width/2.0, bar_width/2.0);
101  Volume sy_bar_vol("sy_bar_volume", sy_bar, description.material("PlasticScint"));
102  sy_bar_vol.setVisAttributes(red_vis);
104  Box lx_bar(bar_width/2.0, large_tower_length/2.0, bar_width/2.0);
105  Volume lx_bar_vol("lx_bar_volume", lx_bar, description.material("PlasticScint"));
106  lx_bar_vol.setVisAttributes(red_vis);
108  Box ly_bar(large_tower_length/2.0, bar_width/2.0, bar_width/2.0);
109  Volume ly_bar_vol("ly_bar_volume", ly_bar, description.material("PlasticScint"));
110  ly_bar_vol.setVisAttributes(red_vis);
111 
112  // Place each plate at a time
113  // The thickness of tungsten plates are different.
114  // The first 11 layers are 7mm each and the rest is 14mm each.
115  // In units of radiation and hadron interaction lengths the total length of a calorimeter
116  // 44 X_0 and 1.7 lambda
118  // Small Tower
120  double z_layer = tungsten_thickness/2.0;
121  auto tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
122  tungsten_PV.addPhysVolID("layer", 0).addPhysVolID("slice", 1);
123  sens.setType("calorimeter");
124  s_tungsten_layer_Vol.setSensitiveDetector(sens);
126  z_layer += dz_scint;
127  auto scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
128  scint_PV.addPhysVolID("layer", 1).addPhysVolID("slice", 2);
129  sens.setType("calorimeter");
130  s_scint_layer_Vol.setSensitiveDetector(sens);
132  z_layer += dz_scint;
133  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
134  tungsten_PV.addPhysVolID("layer", 2).addPhysVolID("slice", 1);
135  sens.setType("calorimeter");
136  s_tungsten_layer_Vol.setSensitiveDetector(sens);
138  z_layer += dz_scint;
139  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
140  scint_PV.addPhysVolID("layer", 3).addPhysVolID("slice", 2);
141  sens.setType("calorimeter");
142  s_scint_layer_Vol.setSensitiveDetector(sens);
144  z_layer += dz_scint;
145  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
146  tungsten_PV.addPhysVolID("layer", 4).addPhysVolID("slice", 1);
147  sens.setType("calorimeter");
148  s_tungsten_layer_Vol.setSensitiveDetector(sens);
150  z_layer += tungsten_thickness/2.0 + bar_width/2.0;
151  double pos_x = -1.0 + bar_width/2.0;
152  for(int ix=0; ix<20; ix++)
153  {
154  pv_bar = module_assembly.placeVolume(sx_bar_vol, Position(pos_x, 0.0, z_layer));
155  pv_bar.addPhysVolID("layer", 5+ix).addPhysVolID("slice",3);
156  sens.setType("calorimeter");
157  sx_bar_vol.setSensitiveDetector(sens);
158  pos_x += bar_width;
159  }
161  z_layer += bar_width;
162  double pos_y = -1.0 + bar_width/2.0;
163  for(int iy=0; iy<20; iy++)
164  {
165  pv_bar = module_assembly.placeVolume(sy_bar_vol, Position(0.0, pos_y, z_layer));
166  pv_bar.addPhysVolID("layer", 25+iy).addPhysVolID("slice",3);
167  sens.setType("calorimeter");
168  sy_bar_vol.setSensitiveDetector(sens);
169  pos_y += bar_width;
170  }
172  z_layer += 2.0*bar_width;
173  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
174  scint_PV.addPhysVolID("layer", 45).addPhysVolID("slice", 2);
175  sens.setType("calorimeter");
176  s_scint_layer_Vol.setSensitiveDetector(sens);
178  z_layer += dz_scint;
179  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
180  tungsten_PV.addPhysVolID("layer", 46).addPhysVolID("slice", 1);
181  sens.setType("calorimeter");
182  s_tungsten_layer_Vol.setSensitiveDetector(sens);
184  z_layer += dz_scint;
185  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
186  scint_PV.addPhysVolID("layer", 47).addPhysVolID("slice", 2);
187  sens.setType("calorimeter");
188  s_scint_layer_Vol.setSensitiveDetector(sens);
190  z_layer += dz_scint;
191  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
192  tungsten_PV.addPhysVolID("layer", 48).addPhysVolID("slice", 1);
193  sens.setType("calorimeter");
194  s_tungsten_layer_Vol.setSensitiveDetector(sens);
196  z_layer += tungsten_thickness/2.0 + bar_width/2.0;
197  pos_x = -1.0 + bar_width/2.0;
198  for(int ix=0; ix<20; ix++)
199  {
200  pv_bar = module_assembly.placeVolume(sx_bar_vol, Position(pos_x, 0.0, z_layer));
201  pv_bar.addPhysVolID("layer", 49+ix).addPhysVolID("slice",3);
202  sens.setType("calorimeter");
203  sx_bar_vol.setSensitiveDetector(sens);
204  pos_x += bar_width;
205  }
207  z_layer += bar_width;
208  pos_y = -1.0 + bar_width/2.0;
209  for(int iy=0; iy<20; iy++)
210  {
211  pv_bar = module_assembly.placeVolume(sy_bar_vol, Position(0.0, pos_y, z_layer));
212  pv_bar.addPhysVolID("layer", 69+iy).addPhysVolID("slice",3);
213  sens.setType("calorimeter");
214  sy_bar_vol.setSensitiveDetector(sens);
215  pos_y += bar_width;
216  }
218  z_layer += 2.0*bar_width;
219  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
220  scint_PV.addPhysVolID("layer", 89).addPhysVolID("slice", 2);
221  sens.setType("calorimeter");
222  s_scint_layer_Vol.setSensitiveDetector(sens);
224  z_layer += dz_scint;
225  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
226  tungsten_PV.addPhysVolID("layer", 90).addPhysVolID("slice", 1);
227  sens.setType("calorimeter");
228  s_tungsten_layer_Vol.setSensitiveDetector(sens);
230  z_layer += dz_scint;
231  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
232  scint_PV.addPhysVolID("layer", 91).addPhysVolID("slice", 2);
233  sens.setType("calorimeter");
234  s_scint_layer_Vol.setSensitiveDetector(sens);
236  z_layer += dz_scint;
237  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
238  tungsten_PV.addPhysVolID("layer", 92).addPhysVolID("slice", 1);
239  sens.setType("calorimeter");
240  s_tungsten_layer_Vol.setSensitiveDetector(sens);
242  z_layer += dz_scint;
243  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
244  scint_PV.addPhysVolID("layer", 93).addPhysVolID("slice", 2);
245  sens.setType("calorimeter");
246  s_scint_layer_Vol.setSensitiveDetector(sens);
248  z_layer += dz_scint;
249  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
250  tungsten_PV.addPhysVolID("layer", 94).addPhysVolID("slice", 1);
251  sens.setType("calorimeter");
252  s_tungsten_layer_Vol.setSensitiveDetector(sens);
254  z_layer += dz_scint;
255  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
256  scint_PV.addPhysVolID("layer", 95).addPhysVolID("slice", 2);
257  sens.setType("calorimeter");
258  s_scint_layer_Vol.setSensitiveDetector(sens);
260  z_layer += dz_scint;
261  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
262  tungsten_PV.addPhysVolID("layer", 96).addPhysVolID("slice", 1);
263  sens.setType("calorimeter");
264  s_tungsten_layer_Vol.setSensitiveDetector(sens);
266  z_layer += dz_scint;
267  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
268  scint_PV.addPhysVolID("layer", 97).addPhysVolID("slice", 2);
269  sens.setType("calorimeter");
270  s_scint_layer_Vol.setSensitiveDetector(sens);
272  z_layer += dz_scint;
273  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
274  tungsten_PV.addPhysVolID("layer", 98).addPhysVolID("slice", 1);
275  sens.setType("calorimeter");
276  s_tungsten_layer_Vol.setSensitiveDetector(sens);
278  z_layer += dz_scint;
279  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
280  scint_PV.addPhysVolID("layer", 99).addPhysVolID("slice", 2);
281  sens.setType("calorimeter");
282  s_scint_layer_Vol.setSensitiveDetector(sens);
284  z_layer += dz_scint;
285  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
286  tungsten_PV.addPhysVolID("layer", 100).addPhysVolID("slice", 1);
287  sens.setType("calorimeter");
288  s_tungsten_layer_Vol.setSensitiveDetector(sens);
290  z_layer += dz_scint;
291  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
292  scint_PV.addPhysVolID("layer", 101).addPhysVolID("slice", 2);
293  sens.setType("calorimeter");
294  s_scint_layer_Vol.setSensitiveDetector(sens);
296  z_layer += dz_scint;
297  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
298  tungsten_PV.addPhysVolID("layer", 102).addPhysVolID("slice", 1);
299  sens.setType("calorimeter");
300  s_tungsten_layer_Vol.setSensitiveDetector(sens);
302  z_layer += tungsten_thickness;
303  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
304  tungsten_PV.addPhysVolID("layer", 103).addPhysVolID("slice", 1);
305  sens.setType("calorimeter");
306  s_tungsten_layer_Vol.setSensitiveDetector(sens);
308  z_layer += dz_scint;
309  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
310  scint_PV.addPhysVolID("layer", 104).addPhysVolID("slice", 2);
311  sens.setType("calorimeter");
312  s_scint_layer_Vol.setSensitiveDetector(sens);
314  z_layer += dz_scint;
315  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
316  tungsten_PV.addPhysVolID("layer", 105).addPhysVolID("slice", 1);
317  sens.setType("calorimeter");
318  s_tungsten_layer_Vol.setSensitiveDetector(sens);
320  z_layer += tungsten_thickness;
321  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
322  tungsten_PV.addPhysVolID("layer", 106).addPhysVolID("slice", 1);
323  sens.setType("calorimeter");
324  s_tungsten_layer_Vol.setSensitiveDetector(sens);
326  z_layer += tungsten_thickness/2.0 + bar_width/2.0;
327  pos_x = -1.0 + bar_width/2.0;
328  for(int ix=0; ix<20; ix++)
329  {
330  pv_bar = module_assembly.placeVolume(sx_bar_vol, Position(pos_x, 0.0, z_layer));
331  pv_bar.addPhysVolID("layer", 107+ix).addPhysVolID("slice",3);
332  sens.setType("calorimeter");
333  sx_bar_vol.setSensitiveDetector(sens);
334  pos_x += bar_width;
335  }
337  z_layer += bar_width;
338  pos_y = -1.0 + bar_width/2.0;
339  for(int iy=0; iy<20; iy++)
340  {
341  pv_bar = module_assembly.placeVolume(sy_bar_vol, Position(0.0, pos_y, z_layer));
342  pv_bar.addPhysVolID("layer", 127+iy).addPhysVolID("slice",3);
343  sens.setType("calorimeter");
344  sy_bar_vol.setSensitiveDetector(sens);
345  pos_y += bar_width;
346  }
348  z_layer += 2.0*bar_width;
349  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
350  scint_PV.addPhysVolID("layer", 147).addPhysVolID("slice", 2);
351  sens.setType("calorimeter");
352  s_scint_layer_Vol.setSensitiveDetector(sens);
354  z_layer += dz_scint;
355  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
356  tungsten_PV.addPhysVolID("layer", 148).addPhysVolID("slice", 1);
357  sens.setType("calorimeter");
358  s_tungsten_layer_Vol.setSensitiveDetector(sens);
360  z_layer += tungsten_thickness;
361  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
362  tungsten_PV.addPhysVolID("layer", 149).addPhysVolID("slice", 1);
363  sens.setType("calorimeter");
364  s_tungsten_layer_Vol.setSensitiveDetector(sens);
366  z_layer += dz_scint;
367  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
368  scint_PV.addPhysVolID("layer", 150).addPhysVolID("slice", 2);
369  sens.setType("calorimeter");
370  s_scint_layer_Vol.setSensitiveDetector(sens);
372  z_layer += dz_scint;
373  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
374  tungsten_PV.addPhysVolID("layer", 151).addPhysVolID("slice", 1);
375  sens.setType("calorimeter");
376  s_tungsten_layer_Vol.setSensitiveDetector(sens);
378  z_layer += tungsten_thickness;
379  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
380  tungsten_PV.addPhysVolID("layer", 152).addPhysVolID("slice", 1);
381  sens.setType("calorimeter");
382  s_tungsten_layer_Vol.setSensitiveDetector(sens);
384  z_layer += dz_scint;
385  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
386  scint_PV.addPhysVolID("layer", 153).addPhysVolID("slice", 2);
387  sens.setType("calorimeter");
388  s_scint_layer_Vol.setSensitiveDetector(sens);
390  z_layer += dz_scint;
391  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
392  tungsten_PV.addPhysVolID("layer", 154).addPhysVolID("slice", 1);
393  sens.setType("calorimeter");
394  s_tungsten_layer_Vol.setSensitiveDetector(sens);
396  z_layer += tungsten_thickness;
397  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
398  tungsten_PV.addPhysVolID("layer", 155).addPhysVolID("slice", 1);
399  sens.setType("calorimeter");
400  s_tungsten_layer_Vol.setSensitiveDetector(sens);
402  z_layer += tungsten_thickness/2.0 + bar_width/2.0;
403  pos_x = -1.0 + bar_width/2.0;
404  for(int ix=0; ix<20; ix++)
405  {
406  pv_bar = module_assembly.placeVolume(sx_bar_vol, Position(pos_x, 0.0, z_layer));
407  pv_bar.addPhysVolID("layer", 156+ix).addPhysVolID("slice",3);
408  sens.setType("calorimeter");
409  sx_bar_vol.setSensitiveDetector(sens);
410  pos_x += bar_width;
411  }
413  z_layer += bar_width;
414  pos_y = -1.0 + bar_width/2.0;
415  for(int iy=0; iy<20; iy++)
416  {
417  pv_bar = module_assembly.placeVolume(sy_bar_vol, Position(0.0, pos_y, z_layer));
418  pv_bar.addPhysVolID("layer", 176+iy).addPhysVolID("slice",3);
419  sens.setType("calorimeter");
420  sy_bar_vol.setSensitiveDetector(sens);
421  pos_y += bar_width;
422  }
424  z_layer += 2.0*bar_width;
425  scint_PV = module_assembly.placeVolume(s_scint_layer_Vol, Position(0.0, 0.0, z_layer));
426  scint_PV.addPhysVolID("layer", 196).addPhysVolID("slice", 2);
427  sens.setType("calorimeter");
428  s_scint_layer_Vol.setSensitiveDetector(sens);
430  z_layer += dz_scint;
431  tungsten_PV = module_assembly.placeVolume(s_tungsten_layer_Vol, Position(0.0, 0.0, z_layer));
432  tungsten_PV.addPhysVolID("layer", 197).addPhysVolID("slice", 1);
433  sens.setType("calorimeter");
434  s_tungsten_layer_Vol.setSensitiveDetector(sens);
435 
436 
438  // Large Tower
440  double x_layer = offset_btw_towers/sqrt(2) + (small_tower_length + large_tower_length)/2.0;
441  double y_layer = offset_btw_towers/sqrt(2) + (small_tower_length + large_tower_length)/2.0;
443  z_layer = tungsten_thickness/2.0;
444  auto l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer, y_layer, z_layer));
445  l_tungsten_PV.addPhysVolID("layer", 198).addPhysVolID("slice", 1);
446  sens.setType("calorimeter");
447  l_tungsten_layer_Vol.setSensitiveDetector(sens);
449  z_layer += dz_scint;
450  auto l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer, y_layer, z_layer));
451  l_scint_PV.addPhysVolID("layer", 199).addPhysVolID("slice", 2);
452  sens.setType("calorimeter");
453  l_scint_layer_Vol.setSensitiveDetector(sens);
455  z_layer += dz_scint;
456  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer, y_layer, z_layer));
457  l_tungsten_PV.addPhysVolID("layer", 200).addPhysVolID("slice", 1);
458  sens.setType("calorimeter");
459  l_tungsten_layer_Vol.setSensitiveDetector(sens);
461  z_layer += dz_scint;
462  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer, y_layer, z_layer));
463  l_scint_PV.addPhysVolID("layer", 201).addPhysVolID("slice", 2);
464  sens.setType("calorimeter");
465  l_scint_layer_Vol.setSensitiveDetector(sens);
467  z_layer += dz_scint;
468  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer, y_layer, z_layer));
469  l_tungsten_PV.addPhysVolID("layer", 202).addPhysVolID("slice", 1);
470  sens.setType("calorimeter");
471  l_tungsten_layer_Vol.setSensitiveDetector(sens);
473  z_layer += tungsten_thickness/2.0 + bar_width/2.0;
474  pos_x = 1.0 + offset_btw_towers/sqrt(2) + bar_width/2.0;
475  for(int ix=0; ix<40; ix++)
476  {
477  pv_bar = module_assembly.placeVolume(lx_bar_vol, Position(pos_x, y_layer, z_layer));
478  pv_bar.addPhysVolID("layer", 203+ix).addPhysVolID("slice",3);
479  sens.setType("calorimeter");
480  lx_bar_vol.setSensitiveDetector(sens);
481  pos_x += bar_width;
482  }
484  z_layer += bar_width;
485  pos_y = 1.0 + offset_btw_towers/sqrt(2) + bar_width/2.0;
486  for(int iy=0; iy<40; iy++)
487  {
488  pv_bar = module_assembly.placeVolume(ly_bar_vol, Position(x_layer, pos_y, z_layer));
489  pv_bar.addPhysVolID("layer", 243+iy).addPhysVolID("slice",3);
490  sens.setType("calorimeter");
491  ly_bar_vol.setSensitiveDetector(sens);
492  pos_y += bar_width;
493  }
495  z_layer += 2.0*bar_width;
496  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer, y_layer, z_layer));
497  l_scint_PV.addPhysVolID("layer", 283).addPhysVolID("slice", 2);
498  sens.setType("calorimeter");
499  l_scint_layer_Vol.setSensitiveDetector(sens);
501  z_layer += dz_scint;
502  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
503  l_tungsten_PV.addPhysVolID("layer", 284).addPhysVolID("slice", 1);
504  sens.setType("calorimeter");
505  s_tungsten_layer_Vol.setSensitiveDetector(sens);
507  z_layer += dz_scint;
508  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
509  l_scint_PV.addPhysVolID("layer", 285).addPhysVolID("slice", 2);
510  sens.setType("calorimeter");
511  l_scint_layer_Vol.setSensitiveDetector(sens);
513  z_layer += dz_scint;
514  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
515  l_tungsten_PV.addPhysVolID("layer", 286).addPhysVolID("slice", 1);
516  sens.setType("calorimeter");
517  l_tungsten_layer_Vol.setSensitiveDetector(sens);
519  z_layer += tungsten_thickness/2.0 + bar_width/2.0;
520  pos_x = 1.0 + offset_btw_towers/sqrt(2) + bar_width/2.0;
521  for(int ix=0; ix<40; ix++)
522  {
523  pv_bar = module_assembly.placeVolume(lx_bar_vol, Position(pos_x, y_layer, z_layer));
524  pv_bar.addPhysVolID("layer", 287+ix).addPhysVolID("slice",3);
525  sens.setType("calorimeter");
526  lx_bar_vol.setSensitiveDetector(sens);
527  pos_x += bar_width;
528  }
530  z_layer += bar_width;
531  pos_y = 1.0 + offset_btw_towers/sqrt(2) + bar_width/2.0;
532  for(int iy=0; iy<40; iy++)
533  {
534  pv_bar = module_assembly.placeVolume(ly_bar_vol, Position(x_layer, pos_y, z_layer));
535  pv_bar.addPhysVolID("layer", 327+iy).addPhysVolID("slice",3);
536  sens.setType("calorimeter");
537  ly_bar_vol.setSensitiveDetector(sens);
538  pos_y += bar_width;
539  }
541  z_layer += 2.0*bar_width;
542  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
543  l_scint_PV.addPhysVolID("layer", 367).addPhysVolID("slice", 2);
544  sens.setType("calorimeter");
545  l_scint_layer_Vol.setSensitiveDetector(sens);
547  z_layer += dz_scint;
548  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
549  l_tungsten_PV.addPhysVolID("layer", 368).addPhysVolID("slice", 1);
550  sens.setType("calorimeter");
551  l_tungsten_layer_Vol.setSensitiveDetector(sens);
553  z_layer += dz_scint;
554  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
555  l_scint_PV.addPhysVolID("layer", 369).addPhysVolID("slice", 2);
556  sens.setType("calorimeter");
557  l_scint_layer_Vol.setSensitiveDetector(sens);
559  z_layer += dz_scint;
560  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
561  l_tungsten_PV.addPhysVolID("layer", 370).addPhysVolID("slice", 1);
562  sens.setType("calorimeter");
563  l_tungsten_layer_Vol.setSensitiveDetector(sens);
565  z_layer += dz_scint;
566  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
567  l_scint_PV.addPhysVolID("layer", 371).addPhysVolID("slice", 2);
568  sens.setType("calorimeter");
569  l_scint_layer_Vol.setSensitiveDetector(sens);
571  z_layer += dz_scint;
572  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
573  l_tungsten_PV.addPhysVolID("layer", 372).addPhysVolID("slice", 1);
574  sens.setType("calorimeter");
575  l_tungsten_layer_Vol.setSensitiveDetector(sens);
577  z_layer += dz_scint;
578  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
579  l_scint_PV.addPhysVolID("layer", 373).addPhysVolID("slice", 2);
580  sens.setType("calorimeter");
581  l_scint_layer_Vol.setSensitiveDetector(sens);
583  z_layer += dz_scint;
584  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
585  l_tungsten_PV.addPhysVolID("layer", 374).addPhysVolID("slice", 1);
586  sens.setType("calorimeter");
587  l_tungsten_layer_Vol.setSensitiveDetector(sens);
589  z_layer += dz_scint;
590  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
591  l_scint_PV.addPhysVolID("layer", 375).addPhysVolID("slice", 2);
592  sens.setType("calorimeter");
593  l_scint_layer_Vol.setSensitiveDetector(sens);
595  z_layer += dz_scint;
596  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
597  l_tungsten_PV.addPhysVolID("layer", 376).addPhysVolID("slice", 1);
598  sens.setType("calorimeter");
599  l_tungsten_layer_Vol.setSensitiveDetector(sens);
601  z_layer += dz_scint;
602  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
603  l_scint_PV.addPhysVolID("layer", 377).addPhysVolID("slice", 2);
604  sens.setType("calorimeter");
605  l_scint_layer_Vol.setSensitiveDetector(sens);
607  z_layer += dz_scint;
608  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
609  l_tungsten_PV.addPhysVolID("layer", 378).addPhysVolID("slice", 1);
610  sens.setType("calorimeter");
611  l_tungsten_layer_Vol.setSensitiveDetector(sens);
613  z_layer += dz_scint;
614  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
615  l_scint_PV.addPhysVolID("layer", 379).addPhysVolID("slice", 2);
616  sens.setType("calorimeter");
617  l_scint_layer_Vol.setSensitiveDetector(sens);
619  z_layer += dz_scint;
620  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
621  l_tungsten_PV.addPhysVolID("layer", 380).addPhysVolID("slice", 1);
622  sens.setType("calorimeter");
623  l_tungsten_layer_Vol.setSensitiveDetector(sens);
625  z_layer += tungsten_thickness;
626  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
627  l_tungsten_PV.addPhysVolID("layer", 381).addPhysVolID("slice", 1);
628  sens.setType("calorimeter");
629  l_tungsten_layer_Vol.setSensitiveDetector(sens);
631  z_layer += dz_scint;
632  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
633  l_scint_PV.addPhysVolID("layer", 382).addPhysVolID("slice", 2);
634  sens.setType("calorimeter");
635  l_scint_layer_Vol.setSensitiveDetector(sens);
637  z_layer += dz_scint;
638  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
639  l_tungsten_PV.addPhysVolID("layer", 383).addPhysVolID("slice", 1);
640  sens.setType("calorimeter");
641  l_tungsten_layer_Vol.setSensitiveDetector(sens);
643  z_layer += tungsten_thickness;
644  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
645  l_tungsten_PV.addPhysVolID("layer", 384).addPhysVolID("slice", 1);
646  sens.setType("calorimeter");
647  l_tungsten_layer_Vol.setSensitiveDetector(sens);
649  z_layer += tungsten_thickness/2.0 + bar_width/2.0;
650  pos_x = 1.0 + offset_btw_towers/sqrt(2) + bar_width/2.0;
651  for(int ix=0; ix<40; ix++)
652  {
653  pv_bar = module_assembly.placeVolume(lx_bar_vol, Position(pos_x, y_layer, z_layer));
654  pv_bar.addPhysVolID("layer", 385+ix).addPhysVolID("slice",3);
655  sens.setType("calorimeter");
656  lx_bar_vol.setSensitiveDetector(sens);
657  pos_x += bar_width;
658  }
660  z_layer += bar_width;
661  pos_y = 1.0 + offset_btw_towers/sqrt(2) + bar_width/2.0;
662  for(int iy=0; iy<40; iy++)
663  {
664  pv_bar = module_assembly.placeVolume(ly_bar_vol, Position(x_layer, pos_y, z_layer));
665  pv_bar.addPhysVolID("layer", 425+iy).addPhysVolID("slice",3);
666  sens.setType("calorimeter");
667  ly_bar_vol.setSensitiveDetector(sens);
668  pos_y += bar_width;
669  }
671  z_layer += 2.0*bar_width;
672  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
673  l_scint_PV.addPhysVolID("layer", 465).addPhysVolID("slice", 2);
674  sens.setType("calorimeter");
675  l_scint_layer_Vol.setSensitiveDetector(sens);
677  z_layer += dz_scint;
678  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
679  l_tungsten_PV.addPhysVolID("layer", 466).addPhysVolID("slice", 1);
680  sens.setType("calorimeter");
681  l_tungsten_layer_Vol.setSensitiveDetector(sens);
683  z_layer += tungsten_thickness;
684  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
685  l_tungsten_PV.addPhysVolID("layer", 467).addPhysVolID("slice", 1);
686  sens.setType("calorimeter");
687  l_tungsten_layer_Vol.setSensitiveDetector(sens);
689  z_layer += dz_scint;
690  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
691  l_scint_PV.addPhysVolID("layer", 468).addPhysVolID("slice", 2);
692  sens.setType("calorimeter");
693  l_scint_layer_Vol.setSensitiveDetector(sens);
695  z_layer += dz_scint;
696  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
697  l_tungsten_PV.addPhysVolID("layer", 469).addPhysVolID("slice", 1);
698  sens.setType("calorimeter");
699  l_tungsten_layer_Vol.setSensitiveDetector(sens);
701  z_layer += tungsten_thickness;
702  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
703  l_tungsten_PV.addPhysVolID("layer", 470).addPhysVolID("slice", 1);
704  sens.setType("calorimeter");
705  l_tungsten_layer_Vol.setSensitiveDetector(sens);
707  z_layer += dz_scint;
708  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
709  l_scint_PV.addPhysVolID("layer", 471).addPhysVolID("slice", 2);
710  sens.setType("calorimeter");
711  l_scint_layer_Vol.setSensitiveDetector(sens);
713  z_layer += dz_scint;
714  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
715  l_tungsten_PV.addPhysVolID("layer", 472).addPhysVolID("slice", 1);
716  sens.setType("calorimeter");
717  l_tungsten_layer_Vol.setSensitiveDetector(sens);
719  z_layer += tungsten_thickness;
720  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer,y_layer, z_layer));
721  l_tungsten_PV.addPhysVolID("layer", 473).addPhysVolID("slice", 1);
722  sens.setType("calorimeter");
723  l_tungsten_layer_Vol.setSensitiveDetector(sens);
725  z_layer += tungsten_thickness/2.0 + bar_width/2.0;
726  pos_x = 1.0 + offset_btw_towers/sqrt(2) + bar_width/2.0;
727  for(int ix=0; ix<40; ix++)
728  {
729  pv_bar = module_assembly.placeVolume(lx_bar_vol, Position(pos_x, y_layer, z_layer));
730  pv_bar.addPhysVolID("layer", 474+ix).addPhysVolID("slice",3);
731  sens.setType("calorimeter");
732  lx_bar_vol.setSensitiveDetector(sens);
733  pos_x += bar_width;
734  }
736  z_layer += bar_width;
737  pos_y = 1.0 + offset_btw_towers/sqrt(2) + bar_width/2.0;
738  for(int iy=0; iy<40; iy++)
739  {
740  pv_bar = module_assembly.placeVolume(ly_bar_vol, Position(x_layer, pos_y, z_layer));
741  pv_bar.addPhysVolID("layer", 514+iy).addPhysVolID("slice",3);
742  sens.setType("calorimeter");
743  ly_bar_vol.setSensitiveDetector(sens);
744  pos_y += bar_width;
745  }
747  z_layer += 2.0*bar_width;
748  l_scint_PV = module_assembly.placeVolume(l_scint_layer_Vol, Position(x_layer,y_layer, z_layer));
749  l_scint_PV.addPhysVolID("layer", 554).addPhysVolID("slice", 2);
750  sens.setType("calorimeter");
751  l_scint_layer_Vol.setSensitiveDetector(sens);
753  z_layer += dz_scint;
754  l_tungsten_PV = module_assembly.placeVolume(l_tungsten_layer_Vol, Position(x_layer, y_layer, z_layer));
755  l_tungsten_PV.addPhysVolID("layer", 555).addPhysVolID("slice", 1);
756  sens.setType("calorimeter");
757  l_tungsten_layer_Vol.setSensitiveDetector(sens);
759 
760  module_PV = assembly.placeVolume(module_assembly, Position(x_pos,y_pos,z_pos));
761  module_PV.addPhysVolID("module", 0);
762 
763  Volume motherVol = description.pickMotherVolume(det);
764  PlacedVolume envPV = motherVol.placeVolume(assembly, Transform3D(RotationZ(M_PI/4.0), Position(0, 0, 0)));
765  //PlacedVolume envPV = motherVol.placeVolume(assembly, Position(0, 0, 0));
766  envPV.addPhysVolID("system", det_id);
767  det.setPlacement(envPV);
768  return det;
769 }
770 
771 DECLARE_DETELEMENT(ZeroDegreeCAL, createDetector)
Detector
Definition: DDG4.py:69
Namespace for the AIDA detector description toolkit.
static Ref_t createDetector(Detector &description, xml_h e, SensitiveDetector sens)