File indexing completed on 2025-01-18 09:15:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "DD4hep/DetFactoryHelper.h"
0011 #include "DD4hep/Printout.h"
0012 #include "TMath.h"
0013 #include <XML/Helper.h>
0014
0015 using namespace std;
0016 using namespace dd4hep;
0017
0018 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector ) {
0019
0020 using namespace ROOT::Math;
0021 xml_det_t x_det = e;
0022 string det_name = x_det.nameStr();
0023 int det_id = x_det.id();
0024 Material m_Vacuum = description.material("Vacuum");
0025 string vis_name = dd4hep::getAttrOrDefault<std::string>(x_det, _Unicode(vis), "BeamPipeVis");
0026
0027 string grandmotherName = x_det.attr<string>(_Unicode(grandmother));
0028 string motherName = x_det.attr<string>(_Unicode(mother));
0029 bool detStart = getAttrOrDefault<bool>(x_det, _Unicode(end), true);
0030 DetElement mother = description.detector(grandmotherName).child(motherName);
0031
0032 DetElement sdet(det_name, det_id);
0033
0034
0035 Volume mother_vol = mother.volume();
0036
0037
0038 ConeSegment mother_shape = mother_vol.solid();
0039
0040
0041 double rOuter1 = mother_shape.rMax1();
0042 double rOuter2 = mother_shape.rMax2();
0043 double length = 2 * mother_shape.dZ();
0044
0045 double sensitive_thickness = 100 * mm;
0046
0047
0048 double rEnd = rOuter2 - (rOuter2 - rOuter1) * sensitive_thickness / length;
0049 double zPos = length / 2.0 - sensitive_thickness / 2.0;
0050 if (detStart) {
0051 rEnd = rOuter1 - (rOuter1 - rOuter2) * sensitive_thickness / length;
0052 zPos = -length / 2.0 + sensitive_thickness / 2.0;
0053 }
0054
0055 ConeSegment s_start_disk(sensitive_thickness / 2, 0.0, rOuter2, 0.0, rEnd);
0056 Volume v_start_disk("stop_disk_" + motherName, s_start_disk, m_Vacuum);
0057
0058 v_start_disk.setLimitSet(description, "kill_limits");
0059
0060 auto disk_placement = mother_vol.placeVolume(v_start_disk, Position(0.0, 0.0, zPos));
0061
0062 sdet.setPlacement(disk_placement);
0063 description.declareParent(det_name, mother);
0064
0065 return sdet;
0066 }
0067
0068 DECLARE_DETELEMENT(BeamPipeStop, create_detector)