File indexing completed on 2026-05-15 07:41:49
0001
0002
0003
0004
0005
0006
0007 #include <DD4hep/DetFactoryHelper.h>
0008 #include <DD4hep/Detector.h>
0009 #include <DD4hep/OpticalSurfaces.h>
0010 #include <DD4hep/Printout.h>
0011
0012 using namespace dd4hep;
0013
0014 static Ref_t create_raindrop(Detector &description, xml_h e, SensitiveDetector sens)
0015 {
0016 xml_det_t x_det = e;
0017 std::string name = x_det.nameStr();
0018 DetElement sdet(name, x_det.id());
0019
0020
0021 xml_det_t x_container = x_det.child(_Unicode(container));
0022 xml_det_t x_medium = x_det.child(_Unicode(medium));
0023 xml_det_t x_drop = x_det.child(_Unicode(drop));
0024
0025
0026 Box container_box(x_container.x(), x_container.y(), x_container.z());
0027 Volume container_vol("CtPMT", container_box, description.material(x_container.attr<std::string>(_U(material))));
0028
0029 Box medium_box(x_medium.x(), x_medium.y(), x_medium.z());
0030 Volume medium_vol("Md", medium_box, description.material(x_medium.attr<std::string>(_U(material))));
0031
0032 Box drop_box(x_drop.x(), x_drop.y(), x_drop.z());
0033 Volume drop_vol("Dr", drop_box, description.material(x_drop.attr<std::string>(_U(material))));
0034
0035
0036 if (x_container.hasAttr(_U(vis)))
0037 container_vol.setVisAttributes(description, x_container.visStr());
0038 if (x_medium.hasAttr(_U(vis)))
0039 medium_vol.setVisAttributes(description, x_medium.visStr());
0040 if (x_drop.hasAttr(_U(vis)))
0041 drop_vol.setVisAttributes(description, x_drop.visStr());
0042
0043
0044 container_vol.setSensitiveDetector(sens);
0045
0046
0047 PlacedVolume drop_pv = medium_vol.placeVolume(drop_vol);
0048 drop_pv.addPhysVolID("drop", 1);
0049
0050 PlacedVolume medium_pv = container_vol.placeVolume(medium_vol);
0051 medium_pv.addPhysVolID("medium", 1);
0052
0053
0054 PlacedVolume container_pv = description.pickMotherVolume(sdet).placeVolume(container_vol);
0055 container_pv.addPhysVolID("system", x_det.id());
0056 sdet.setPlacement(container_pv);
0057
0058
0059 OpticalSurfaceManager surfMgr = description.surfaceManager();
0060 OpticalSurface surf = surfMgr.opticalSurface("/world/" + name + "#MediumContainerSurf");
0061 if (surf.isValid())
0062 {
0063 BorderSurface bsurf = BorderSurface(description, sdet, "MediumContainer", surf, medium_pv, container_pv);
0064 bsurf.isValid();
0065 printout(INFO, "Raindrop", "Attached border surface MediumContainer (air/lead)");
0066 }
0067
0068
0069 OpticalSurface skinSurf = surfMgr.opticalSurface("/world/" + name + "#ContainerSkinSurf");
0070 if (skinSurf.isValid())
0071 {
0072 SkinSurface ssf = SkinSurface(description, sdet, "ContainerSkin", skinSurf, container_vol);
0073 ssf.isValid();
0074 printout(INFO, "Raindrop", "Attached skin surface ContainerSkin with EFFICIENCY");
0075 }
0076
0077 return sdet;
0078 }
0079
0080 DECLARE_DETELEMENT(DD4hep_Raindrop, create_raindrop)