Download DD4hep manual
Transcript
Advanced European Infrastructures for Detectors at Accelerators
20 Volume
envelopeVol(det_name+"_envelope",envelope,air);
21 int
layer_num = 1;
22 PlacedVolume pv;
23
24 // Set attributes of slice
25 for(xml_coll_t c(x_det,_U(layer)); c; ++c) {
26
xml_comp_t x_layer = c;
27
double layerWidth = 0;
28
for(xml_coll_t l(x_layer,_U(slice)); l; ++l)
29
layerWidth += xml_comp_t(l).thickness();
30
31
for(int i=0, m=0, repeat=x_layer.repeat(); i<repeat; ++i, m=0) {
32
double
zlayer = z;
33
string
layer_name = det_name + _toString(layer_num,"_layer%d");
34
Volume
layer_vol(layer_name,Tube(rmin,rmax,layerWidth),air);
35
36
for(xml_coll_t l(x_layer,_U(slice)); l; ++l, ++m) {
37
xml_comp_t x_slice = l;
38
double
w = x_slice.thickness();
39
string
slice_name = layer_name + _toString(m+1,"slice%d");
40
Material
slice_mat = lcdd.material(x_slice.materialStr());
41
Volume
slice_vol (slice_name,Tube(rmin,rmax,w),slice_mat);
42
43
if ( x_slice.isSensitive() ) {
44
sens.setType("calorimeter");
45
slice_vol.setSensitiveDetector(sens);
46
}
47
slice_vol.setAttributes(lcdd,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
48
pv = layer_vol.placeVolume(slice_vol,Position(0,0,z-zlayer-layerWidth/2+w/2));
49
pv.addPhysVolID("slice",m+1);
50
z += w;
51
}
52
layer_vol.setVisAttributes(lcdd,x_layer.visStr());
53
Position layer_pos(0,0,zlayer-zmin-totWidth/2+layerWidth/2);
54
pv = envelopeVol.placeVolume(layer_vol,layer_pos);
55
pv.addPhysVolID("layer",layer_num);
56
++layer_num;
57
}
58 }
59 // Set attributes of slice
60 envelopeVol.setAttributes(lcdd,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
61
62 DetElement
sdet(det_name,x_det.id());
63 Volume
motherVol = lcdd.pickMotherVolume(sdet);
64 PlacedVolume phv = motherVol.placeVolume(envelopeVol,Position(0,0,zmin+totWidth/2));
65 phv.addPhysVolID("system",sdet.id())
66
.addPhysVolID("barrel",1);
67 sdet.setPlacement(phv);
68 if ( reflect )
{
69
phv=motherVol.placeVolume(envelopeVol,Transform3D(RotationZ(M_PI),Position(0,0,-zmin-totWidth/2)));
70
phv.addPhysVolID("system",sdet.id())
71
.addPhysVolID("barrel",2);
72 }
73 return sdet;
74 }
75
76 DECLARE_DETELEMENT(CylindricalEndcapCalorimeter,create_detector);
DD4hep User Manual
33