File indexing completed on 2025-01-18 09:16:00
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
0011
0012
0013
0014 using namespace std;
0015 using namespace dd4hep;
0016
0017 static Ref_t createDetector(Detector& desc, xml_h e, SensitiveDetector sens) {
0018 xml_det_t x_det = e;
0019 string detName = x_det.nameStr();
0020 int detID = x_det.id();
0021
0022 xml_dim_t dim = x_det.dimensions();
0023 double Width = dim.x();
0024 double Thickness = dim.z();
0025
0026 xml_dim_t pos = x_det.position();
0027 xml_dim_t rot = x_det.rotation();
0028
0029 Material Vacuum = desc.material("Vacuum");
0030
0031 xml_comp_t mod = x_det.child(_Unicode(module));
0032 string modName = mod.nameStr();
0033 Material mPbWO4 = desc.material(mod.materialStr());
0034 double mThickness = mod.attr<double>(_Unicode(thickness));
0035 double mWidth = mod.attr<double>(_Unicode(width));
0036 double mGap = mod.attr<double>(_Unicode(gap));
0037 int mNTowers = mod.attr<double>(_Unicode(ntower));
0038
0039
0040 Box ffi_ZDC_GVol_Solid(Width * 0.5, Width * 0.5, Thickness * 0.5);
0041 Volume detVol("ffi_ZDC_GVol_Logic", ffi_ZDC_GVol_Solid, Vacuum);
0042 detVol.setVisAttributes(desc.visAttributes(x_det.visStr()));
0043
0044
0045
0046 Box ffi_ZDC_ECAL_Solid_Tower(mWidth * 0.5, mWidth * 0.5, mThickness * 0.5);
0047 Volume modVol("ffi_ZDC_ECAL_Logic_Tower", ffi_ZDC_ECAL_Solid_Tower, mPbWO4);
0048 modVol.setVisAttributes(desc.visAttributes(mod.visStr()));
0049 sens.setType("calorimeter");
0050 modVol.setSensitiveDetector(sens);
0051
0052
0053 double mod_x = 0.0 * mm;
0054 double mod_y = 0.0 * mm;
0055 double mod_z = -1.0 * Thickness / 2.0 + mThickness / 2.0 + 2.0 * mm;
0056
0057 int k = -1;
0058
0059 for (int j = 0; j < mNTowers; j++) {
0060 if (j == 0)
0061 mod_y = Width / 2.0 - mWidth / 2.0 - mGap;
0062 else
0063 mod_y -= (mWidth + mGap);
0064
0065 if (abs(mod_y + mWidth / 2.0) > Width / 2.0)
0066 continue;
0067
0068 mod_x = Width / 2.0 - (mWidth + mGap) * 0.5;
0069
0070 for (int i = 0; i < mNTowers; i++) {
0071 if (i > 0)
0072 mod_x -= (mWidth + mGap);
0073 if (abs(mod_x + mWidth / 2.0) > Width / 2.0)
0074 continue;
0075 k++;
0076 string module_name = detName + _toString(k, "_ECAL_Phys_%d");
0077 PlacedVolume pv_mod = detVol.placeVolume(modVol, Position(mod_x, mod_y, mod_z));
0078 pv_mod.addPhysVolID("module", k + 1);
0079 }
0080 }
0081
0082 DetElement det(detName, detID);
0083 Volume motherVol = desc.pickMotherVolume(det);
0084 Transform3D tr(RotationZYX(rot.z(), rot.y(), rot.x()), Position(pos.x(), pos.y(), pos.z()));
0085 PlacedVolume detPV = motherVol.placeVolume(detVol, tr);
0086 detPV.addPhysVolID("system", detID);
0087 det.setPlacement(detPV);
0088 return det;
0089 }
0090 DECLARE_DETELEMENT(ZDC_ECAL, createDetector)