File indexing completed on 2025-01-18 09:15:52
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.dimensions();
0019 xml_comp_t x_pos = x_det.position();
0020 xml_comp_t x_rot = x_det.rotation();
0021
0022 string det_name = x_det.nameStr();
0023 string mat_name = dd4hep::getAttrOrDefault<string>(x_det, _U(material), "StainlessSteel");
0024
0025 double sizeR = x_dim.r();
0026 double sizeZ = x_dim.z();
0027 double sizeR_el = x_dim.x();
0028 double sizeR_had = x_dim.y();
0029 double posX = x_pos.x();
0030 double posY = x_pos.y();
0031 double posZ = x_pos.z();
0032 double rotX = x_rot.x();
0033 double rotY = x_rot.y();
0034 double rotZ = x_rot.z();
0035
0036 Tube tube(0.0, sizeR, sizeZ);
0037 Tube tube_el(0.0, sizeR_el, sizeZ);
0038 Tube tube_had(0.0, sizeR_had, sizeZ);
0039 SubtractionSolid exit_window(tube, tube_had, Position(0.0, 0.0, 0.0));
0040 exit_window = SubtractionSolid(exit_window, tube_el, Position(-posX, 0.0, 0.0));
0041
0042 Volume vol(det_name + "_vol_ExitWindow", exit_window, description.material(mat_name));
0043 vol.setVisAttributes(description.visAttributes(x_det.visStr()));
0044
0045 Transform3D pos(RotationZYX(rotX, rotY, rotZ), Position(posX, posY, posZ));
0046
0047 DetElement det(det_name, x_det.id());
0048 Volume motherVol = description.pickMotherVolume(det);
0049 PlacedVolume phv = motherVol.placeVolume(vol, pos);
0050
0051 det.setPlacement(phv);
0052
0053 return det;
0054 }
0055
0056 DECLARE_DETELEMENT(B0Window, create_detector)