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 <XML/Helper.h>
0007
0008 using namespace std;
0009 using namespace dd4hep;
0010
0011 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens) {
0012 sens.setType("tracker");
0013
0014 xml_det_t x_det = e;
0015 string det_name = x_det.nameStr();
0016 int det_ID = x_det.id();
0017 string vis_Si = getAttrOrDefault<string>(x_det, _Unicode(vis), "TrackerVis");
0018 string vis_Cu = getAttrOrDefault<string>(x_det, _Unicode(visCu), "TrackerServiceVis");
0019 string Si_name = getAttrOrDefault<string>(x_det, _Unicode(materialSi), "SiliconOxide");
0020 string Cu_name = getAttrOrDefault<string>(x_det, _Unicode(materialCu), "Copper");
0021 double Si_DZ = getAttrOrDefault<double>(x_det, _Unicode(thicknessSi), 0.03 / 2.0);
0022 double Cu_DZ = getAttrOrDefault<double>(x_det, _Unicode(thicknessCu), 0.014 / 2.0);
0023
0024 Material m_Si = description.material(Si_name);
0025 Material m_Cu = description.material(Cu_name);
0026
0027
0028 DetElement det(det_name, det_ID);
0029
0030
0031 Volume motherVol = description.pickMotherVolume(det);
0032
0033
0034 Assembly assembly(det_name);
0035 assembly.setVisAttributes(description.invisible());
0036
0037
0038
0039 for (xml_coll_t mi(x_det, _Unicode(module)); mi; mi++) {
0040
0041 xml_comp_t x_mod(mi);
0042 int module_id = x_mod.id();
0043
0044
0045 for (xml_coll_t si(mi, _Unicode(sector)); si; si++) {
0046
0047 xml_comp_t x_sector(si);
0048 int sector_id = x_sector.id();
0049 string name = getAttrOrDefault<string>(x_sector, _Unicode(name), "");
0050
0051 double posX = x_sector.position().x();
0052 double posY = x_sector.position().y();
0053 double posZ = x_sector.position().z();
0054 double sizeX = x_sector.dimensions().x();
0055 double sizeY = x_sector.dimensions().y();
0056
0057
0058 Box box_Si(sizeX, sizeY, Si_DZ);
0059 Volume vol_Si(det_name + "_" + name, box_Si, m_Si);
0060 vol_Si.setVisAttributes(description.visAttributes(vis_Si));
0061 vol_Si.setSensitiveDetector(sens);
0062
0063
0064 Box box_Cu(sizeX, sizeY, Cu_DZ);
0065 Volume vol_Cu(det_name + "_" + name + "_Cu", box_Cu, m_Cu);
0066 vol_Cu.setVisAttributes(description.visAttributes(vis_Cu));
0067
0068
0069 PlacedVolume pv = assembly.placeVolume(
0070 vol_Si, Transform3D(RotationZYX(0.0, 0.0, 0.0), Position(posX, posY, posZ)));
0071 assembly.placeVolume(vol_Cu, Transform3D(RotationZYX(0.0, 0.0, 0.0),
0072 Position(posX, posY, posZ - (Si_DZ + Cu_DZ))));
0073
0074
0075 pv.addPhysVolID("sector", sector_id).addPhysVolID("module", module_id);
0076
0077 }
0078 }
0079
0080
0081 PlacedVolume detPV = motherVol.placeVolume(assembly, Position(0.0, 0.0, 0.0));
0082
0083
0084 detPV.addPhysVolID("system", det_ID);
0085
0086 det.setPlacement(detPV);
0087
0088 return det;
0089 }
0090
0091 DECLARE_DETELEMENT(LumiSpecTracker, create_detector)