File indexing completed on 2023-03-17 13:02:57
0001 #include "DataFormats/GeometryVector/interface/Phi.h"
0002 #include "DataFormats/Math/interface/GeantUnits.h"
0003 #include "DetectorDescription/Core/interface/DDSplit.h"
0004 #include "DetectorDescription/DDCMS/interface/DDPlugins.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "DD4hep/DetFactoryHelper.h"
0007
0008
0009 using namespace geant_units::operators;
0010
0011 static long algorithm(dd4hep::Detector& , cms::DDParsingContext& ctxt, xml_h e) {
0012 cms::DDNamespace ns(ctxt, e, true);
0013 cms::DDAlgoArguments args(ctxt, e);
0014 double startAngle = args.value<double>("startAngle");
0015 double stepAngle = args.value<double>("stepAngle");
0016 double zoffset = args.value<double>("zoffset");
0017 double roffset = args.value<double>("roffset");
0018 int n = args.value<int>("n");
0019 int startCopyNo = args.value<int>("startCopyNo");
0020 int incrCopyNo = args.value<int>("incrCopyNo");
0021 #ifdef EDM_ML_DEBUG
0022 edm::LogVerbatim("ForwardGeom") << "DDTotemAngular: Parameters for positioning-- " << n << " copies in steps of "
0023 << convertRadToDeg(stepAngle) << " from " << convertRadToDeg(startAngle)
0024 << " \tZoffset " << zoffset << " \tRoffset " << roffset
0025 << "\tStart and inremental copy nos " << startCopyNo << ", " << incrCopyNo;
0026 #endif
0027 std::string childName = args.value<std::string>("ChildName");
0028 dd4hep::Volume parent = ns.volume(args.parentName());
0029 dd4hep::Volume child = ns.volume(ns.prepend(childName));
0030 #ifdef EDM_ML_DEBUG
0031 edm::LogVerbatim("ForwardGeom") << "DDTotemAngular debug: Parent " << parent.name() << "\tChild " << child.name();
0032 #endif
0033
0034 double phi = startAngle;
0035 int copyNo = startCopyNo;
0036
0037 for (int ii = 0; ii < n; ii++) {
0038 Geom::Phi0To2pi<double> phitmp = phi;
0039 #ifdef EDM_ML_DEBUG
0040 edm::LogVerbatim("ForwardGeom") << "DDTotemAngular: Creating a new rotation \t90, "
0041 << convertRadToDeg(phitmp + 90._deg) << ", 0, 0, 90, " << convertRadToDeg(phitmp);
0042 #endif
0043 dd4hep::Rotation3D rotation = cms::makeRotation3D(90._deg, 90._deg + phitmp, 0., 0., 90._deg, phitmp);
0044 dd4hep::Position tran(roffset * cos(phi), roffset * sin(phi), zoffset);
0045
0046 parent.placeVolume(child, copyNo, dd4hep::Transform3D(rotation, tran));
0047 #ifdef EDM_ML_DEBUG
0048 edm::LogVerbatim("ForwardGeom") << "DDTotemAngular: " << child.name() << " number " << copyNo << " positioned in "
0049 << parent.name() << " at " << tran << " with " << rotation;
0050 #endif
0051 phi += stepAngle;
0052 copyNo += incrCopyNo;
0053 }
0054 return 1;
0055 }
0056
0057
0058 DECLARE_DDCMS_DETELEMENT(DDCMS_forward_DDTotemAngular, algorithm)