File indexing completed on 2025-01-18 09:14:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "DD4hep/DetFactoryHelper.h"
0018
0019 using namespace std;
0020 using namespace dd4hep;
0021 using namespace dd4hep::detail;
0022
0023 static Ref_t create_detector(Detector& description, xml_h e, Ref_t sens) {
0024 xml_det_t x_det = e;
0025 string name = x_det.nameStr();
0026 DetElement sdet (name,x_det.id());
0027 Material mat (description.material(x_det.materialStr()));
0028 vector<double> rmin,rmax,z;
0029 int num = 0;
0030
0031 for(xml_coll_t c(e,_U(zplane)); c; ++c, ++num) {
0032 xml_comp_t dim(c);
0033 rmin.push_back(dim.rmin());
0034 rmax.push_back(dim.rmax());
0035 z.push_back(dim.z());
0036 }
0037 if ( num < 2 ) {
0038 throw runtime_error("PolyCone["+name+"]> Not enough Z planes. minimum is 2!");
0039 }
0040 Polycone cone (0,2*M_PI,rmin,rmax,z);
0041 Volume det_vol(name, cone, mat);
0042 PlacedVolume pv = description.pickMotherVolume(sdet).placeVolume(det_vol);
0043
0044 sdet.setPlacement(pv);
0045 det_vol.setVisAttributes(description, x_det.visStr());
0046 det_vol.setLimitSet(description, x_det.limitsStr());
0047 det_vol.setRegion(description, x_det.regionStr());
0048 if ( x_det.isSensitive() ) {
0049 SensitiveDetector sd = sens;
0050 xml_dim_t sd_typ = x_det.child(_U(sensitive));
0051 det_vol.setSensitiveDetector(sens);
0052 sd.setType(sd_typ.typeStr());
0053 }
0054
0055 if ( x_det.hasAttr(_U(id)) ) {
0056 int det_id = x_det.id();
0057 pv.addPhysVolID("system",det_id);
0058 }
0059 return sdet;
0060 }
0061
0062 DECLARE_DETELEMENT(DD4hep_PolyconeSupport,create_detector)