File indexing completed on 2025-01-18 09:14:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DD4hep/DetFactoryHelper.h>
0016 #include <DD4hep/OpticalSurfaces.h>
0017 #include <DD4hep/Printout.h>
0018 #include <DD4hep/Detector.h>
0019
0020
0021 #include <iostream>
0022 #include <map>
0023
0024 using namespace dd4hep;
0025 using namespace dd4hep::detail;
0026
0027
0028 static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector ) {
0029 xml_det_t x_det = e;
0030 std::string det_name = x_det.nameStr();
0031 DetElement sdet(det_name,x_det.id());
0032 xml_det_t x_tank = x_det.child(_Unicode(tank));
0033 xml_det_t x_bubble = x_det.child(_Unicode(bubble));
0034
0035 Assembly hall_vol("Hall");
0036 Box encl_box(_toDouble("world_x-2*cm"),_toDouble("world_y-2*cm"),_toDouble("world_z-2*cm"));
0037 Volume encl_vol("Enclosure",encl_box,description.air());
0038 Box tank_box(x_tank.x(), x_tank.y(), x_tank.z());
0039 Volume tank_vol("Tank",tank_box,description.material(x_tank.attr<std::string>(_U(material))));
0040 Box bubble_box(x_bubble.x(), x_bubble.y(), x_bubble.z());
0041 Volume bubble_vol("Bubble",bubble_box,description.material(x_bubble.attr<std::string>(_U(material))));
0042
0043 encl_vol.setVisAttributes(description.invisible());
0044 tank_vol.setVisAttributes(description, x_tank.visStr());
0045 bubble_vol.setVisAttributes(description, x_bubble.visStr());
0046
0047 PlacedVolume bubblePlace = tank_vol.placeVolume(bubble_vol);
0048 bubblePlace.addPhysVolID("bubble",1);
0049 PlacedVolume tankPlace = encl_vol.placeVolume(tank_vol);
0050 tankPlace.addPhysVolID("tank",1);
0051 PlacedVolume enclPlace = hall_vol.placeVolume(encl_vol);
0052 PlacedVolume hallPlace = description.pickMotherVolume(sdet).placeVolume(hall_vol);
0053 hallPlace.addPhysVolID("system",x_det.id());
0054 sdet.setPlacement(hallPlace);
0055
0056
0057 OpticalSurfaceManager surfMgr = description.surfaceManager();
0058 OpticalSurface waterSurf = surfMgr.opticalSurface("/world/"+det_name+"#WaterSurface");
0059 OpticalSurface airSurf = surfMgr.opticalSurface("/world/"+det_name+"#AirSurface");
0060 BorderSurface tankSurf = BorderSurface(description, sdet, "HallTank", waterSurf, tankPlace, enclPlace);
0061 BorderSurface bubbleSurf = BorderSurface(description, sdet, "TankBubble", airSurf, bubblePlace, tankPlace);
0062 bubbleSurf.isValid();
0063 tankSurf.isValid();
0064 return sdet;
0065 }
0066 DECLARE_DETELEMENT(DD4hep_OpNovice,create_detector)