File indexing completed on 2025-01-18 09:15:58
0001
0002
0003
0004 #include "DD4hep/DetFactoryHelper.h"
0005 #include "DD4hep/Printout.h"
0006 #include "DD4hep/Shapes.h"
0007 #include "DDRec/DetectorData.h"
0008 #include "DDRec/Surface.h"
0009 #include "XML/Layering.h"
0010 #include <XML/Helper.h>
0011
0012 using namespace std;
0013 using namespace dd4hep;
0014
0015 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector ) {
0016
0017 xml_det_t x_det = e;
0018 xml_comp_t x_dim = x_det.child(_Unicode(dimensions));
0019 xml_comp_t x_pos = x_det.child(_Unicode(position));
0020
0021 string det_name = x_det.nameStr();
0022 string mat_pipe = getAttrOrDefault<string>(x_det, _Unicode(pipeMaterial), "Aluminum");
0023 string mat_entrCap = getAttrOrDefault<string>(x_det, _Unicode(entrCapMaterial), "Aluminum");
0024 string mat_exitCap = getAttrOrDefault<string>(x_det, _Unicode(exitCapMaterial), "Beryllium");
0025 string mat_conv = getAttrOrDefault<string>(x_det, _Unicode(convMaterial), "Aluminum");
0026 string mat_fill = getAttrOrDefault<string>(x_det, _Unicode(fillMaterial), "Vacuum");
0027
0028 double posZ1 = x_pos.attr<double>(_Unicode(z1));
0029 double posZ2 = x_pos.attr<double>(_Unicode(z2));
0030 double posZconv = x_pos.attr<double>(_Unicode(z_conv));
0031 double rmin = x_dim.attr<double>(_Unicode(rmin));
0032 double pipe_DR = x_dim.attr<double>(_Unicode(pipe_dr));
0033 double entrCap_DZ = x_dim.attr<double>(_Unicode(entrCap_dz));
0034 double exitCap_DZ = x_dim.attr<double>(_Unicode(exitCap_dz));
0035 double conv_DZ = x_dim.attr<double>(_Unicode(conv_dz));
0036
0037
0038 DetElement det(det_name, x_det.id());
0039
0040
0041 Volume motherVol = description.pickMotherVolume(det);
0042
0043
0044 Assembly assembly(det_name);
0045 assembly.setVisAttributes(description.invisible());
0046
0047
0048
0049
0050 Tube tube(rmin, rmin + pipe_DR, fabs(posZ1 - posZ2) / 2.0, 0, 2 * TMath::Pi());
0051
0052 Tube vac1(0, rmin, fabs(posZ1 - posZconv - conv_DZ / 2.0) / 2.0, 0, 2 * TMath::Pi());
0053 Tube vac2(0, rmin, fabs(posZconv - posZ2 - conv_DZ / 2.0) / 2.0, 0, 2 * TMath::Pi());
0054
0055
0056 Tube entrCap(0, rmin + pipe_DR, entrCap_DZ / 2.0, 0, 2 * TMath::Pi());
0057
0058 Tube exitCap(0, rmin + pipe_DR, exitCap_DZ / 2.0, 0, 2 * TMath::Pi());
0059
0060 Tube convFoil(0, rmin, conv_DZ / 2.0, 0, 2 * TMath::Pi());
0061
0062
0063
0064 Volume vol_vac1(det_name + "_vol_vac1", vac1, description.material(mat_fill));
0065 vol_vac1.setVisAttributes(description.invisible());
0066 Volume vol_vac2(det_name + "_vol_vac2", vac2, description.material(mat_fill));
0067 vol_vac2.setVisAttributes(description.invisible());
0068
0069 Volume vol_tube(det_name + "_vol_tube", tube, description.material(mat_pipe));
0070 vol_tube.setVisAttributes(description.visAttributes(x_det.visStr()));
0071
0072 Volume vol_entrCap(det_name + "_vol_entrCap", entrCap, description.material(mat_entrCap));
0073 vol_entrCap.setVisAttributes(description.visAttributes(x_det.visStr()));
0074
0075 Volume vol_exitCap(det_name + "_vol_exitCap", exitCap, description.material(mat_exitCap));
0076 vol_exitCap.setVisAttributes(description.visAttributes(x_det.visStr()));
0077
0078 Volume vol_conv(det_name + "_vol_conversionFoil", convFoil, description.material(mat_conv));
0079 vol_conv.setVisAttributes(description.visAttributes(x_det.visStr()));
0080
0081
0082 assembly.placeVolume(vol_tube,
0083 Transform3D(RotationZYX(0, 0, 0), Position(0, 0, (posZ1 + posZ2) / 2.)));
0084 assembly.placeVolume(vol_entrCap,
0085 Transform3D(RotationZYX(0, 0, 0), Position(0, 0, posZ1 + entrCap_DZ / 2.)));
0086 assembly.placeVolume(vol_exitCap,
0087 Transform3D(RotationZYX(0, 0, 0), Position(0, 0, posZ2 - exitCap_DZ / 2.)));
0088 assembly.placeVolume(vol_conv, Transform3D(RotationZYX(0, 0, 0), Position(0, 0, posZconv)));
0089 assembly.placeVolume(
0090 vol_vac1,
0091 Transform3D(RotationZYX(0, 0, 0), Position(0, 0, (posZ1 + (posZconv + conv_DZ / 2.0)) / 2.)));
0092 assembly.placeVolume(
0093 vol_vac2,
0094 Transform3D(RotationZYX(0, 0, 0), Position(0, 0, (posZ2 + (posZconv - conv_DZ / 2.0)) / 2.)));
0095
0096
0097 PlacedVolume phv = motherVol.placeVolume(assembly, Position(0.0, 0.0, 0.0));
0098
0099 det.setPlacement(phv);
0100
0101 return det;
0102 }
0103
0104 DECLARE_DETELEMENT(LumiPhotonChamber, create_detector)