Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//==========================================================================
// AIDA Detector description implementation
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
// Author : M.Frank
//
//==========================================================================
//
// Specialized generic detector constructor
//
//==========================================================================
#include "DD4hep/DetFactoryHelper.h"
using namespace std;
using namespace dd4hep;
using namespace dd4hep::detail;
static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens) {
xml_det_t x_det = e;
string det_name = x_det.nameStr();
Material air = description.air();
DetElement sdet (det_name,x_det.id());
Assembly assembly (det_name+"_assembly");
PlacedVolume pv;
int n = 0;
xml::Component pos = x_det.position();
for(xml_coll_t i(x_det,_U(layer)); i; ++i, ++n) {
xml_comp_t x_layer = i;
string l_name = det_name+_toString(n,"_layer%d");
double z = x_layer.outer_z();
double rmin = x_layer.inner_r();
double r = rmin;
DetElement layer(sdet,_toString(n,"layer%d"),x_layer.id());
Tube l_tub (rmin,2*rmin,z);
Volume l_vol(l_name,l_tub,air);
int im = 0;
for(xml_coll_t j(x_layer,_U(slice)); j; ++j, ++im) {
xml_comp_t x_slice = j;
Material mat = description.material(x_slice.materialStr());
string s_name= l_name+_toString(im,"_slice%d");
double thickness = x_slice.thickness();
Tube s_tub(r,r+thickness,z,2*M_PI);
Volume s_vol(s_name, s_tub, mat);
r += thickness;
if ( x_slice.isSensitive() ) {
sens.setType("tracker");
s_vol.setSensitiveDetector(sens);
}
// Set Attributes
s_vol.setAttributes(description,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
pv = l_vol.placeVolume(s_vol);
// Slices have no extra id. Take the ID of the layer!
pv.addPhysVolID("slice",im);
}
l_tub.setDimensions(rmin,r,z);
//cout << l_name << " " << rmin << " " << r << " " << z << endl;
l_vol.setVisAttributes(description,x_layer.visStr());
pv = assembly.placeVolume(l_vol);
pv.addPhysVolID("layer",n);
layer.setPlacement(pv);
}
if ( x_det.hasAttr(_U(combineHits)) ) {
sdet.setCombineHits(x_det.combineHits(),sens);
}
pv = description.pickMotherVolume(sdet).placeVolume(assembly,Position(pos.x(),pos.y(),pos.z()));
pv.addPhysVolID("system",sdet.id()).addPhysVolID("barrel",0);
sdet.setPlacement(pv);
return sdet;
}
DECLARE_DETELEMENT(refdet_SolenoidCoil,create_detector)