File indexing completed on 2026-06-18 07:52:12
0001
0002
0003
0004 #include "DD4hep/DetFactoryHelper.h"
0005 #include "DD4hep/OpticalSurfaces.h"
0006 #include "DD4hep/Printout.h"
0007 #include "DDRec/DetectorData.h"
0008 #include "DDRec/Surface.h"
0009 #include <XML/Helper.h>
0010 #include <XML/Utilities.h>
0011
0012
0013
0014
0015
0016 using namespace std;
0017 using namespace dd4hep;
0018
0019 static Ref_t createDetector(Detector& desc, xml_h e, SensitiveDetector sens) {
0020 xml_det_t x_det = e;
0021 string detName = x_det.nameStr();
0022 int detID = x_det.id();
0023
0024 xml_dim_t dim = x_det.dimensions();
0025 double Width = dim.x();
0026 double Height = dim.y();
0027 double Thickness = dim.z() / 2;
0028
0029 xml_dim_t pos = x_det.position();
0030
0031
0032 Material Vacuum = desc.material("Vacuum");
0033 Material Silicon = desc.material("Silicon");
0034 Material Absorber = desc.material("TungstenDens24");
0035
0036 sens.setType("calorimeter");
0037
0038
0039 Box Tagger_Box(Width, Height, Thickness);
0040 Volume detVol("Tagger_Box", Tagger_Box, Vacuum);
0041 detVol.setVisAttributes(desc.visAttributes(x_det.visStr()));
0042
0043
0044 double abso_z = 8.5 * mm;
0045 double sens_z = 0.3 * mm;
0046
0047
0048 for (int i = 0; i < 20; i++) {
0049
0050
0051 Box Abso_Box(Width, Height, abso_z / 2);
0052 Volume absoVol("AbsorberVolume", Abso_Box, Absorber);
0053 absoVol.setVisAttributes(desc.visAttributes("BlueVis"));
0054
0055 detVol.placeVolume(absoVol, Position(0, 0, Thickness - (i) * (abso_z + sens_z) - abso_z / 2));
0056
0057
0058 Box Cal_Box(Width, Height, sens_z / 2);
0059 Volume calVol("SensVolume", Cal_Box, Silicon);
0060 calVol.setSensitiveDetector(sens);
0061 calVol.setVisAttributes(desc.visAttributes("RedVis"));
0062
0063 PlacedVolume pv_mod = detVol.placeVolume(
0064 calVol, Position(0, 0, Thickness - (i) * (abso_z + sens_z) - abso_z - sens_z / 2));
0065 pv_mod.addPhysVolID("layer", i + 3);
0066 }
0067
0068
0069 std::string mother_nam = dd4hep::getAttrOrDefault<std::string>(x_det, _Unicode(place_into), "");
0070 VolumeManager man = VolumeManager::getVolumeManager(desc);
0071 DetElement mdet = man.detector().child(mother_nam);
0072
0073
0074 Transform3D tr(RotationZYX(0, 0, 0), Position(pos.x(), pos.y(), pos.z()));
0075 PlacedVolume detPV = mdet.volume().placeVolume(detVol, tr);
0076 detPV.addPhysVolID("system", detID);
0077 DetElement det(detName, detID);
0078 det.setPlacement(detPV);
0079
0080
0081 dd4hep::xml::setDetectorTypeFlag(x_det, det);
0082
0083 return det;
0084 }
0085
0086 DECLARE_DETELEMENT(TaggerCalWSi, createDetector)