File indexing completed on 2024-04-06 12:14:37
0001 #include "DataFormats/Math/interface/GeantUnits.h"
0002 #include "DetectorDescription/Core/interface/DDSplit.h"
0003 #include "DetectorDescription/DDCMS/interface/DDPlugins.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "DD4hep/DetFactoryHelper.h"
0006
0007 #include <string>
0008 #include <vector>
0009 #include <sstream>
0010
0011
0012
0013 static long algorithm(dd4hep::Detector& , cms::DDParsingContext& ctxt, xml_h e) {
0014 cms::DDNamespace ns(ctxt, e, true);
0015 cms::DDAlgoArguments args(ctxt, e);
0016
0017 const auto& xpos = args.value<std::vector<double> >("positionX");
0018 const auto& ypos = args.value<double>("positionY");
0019 const auto& zpos = args.value<double>("positionZ");
0020 const auto& childName = args.value<std::string>("ChildName");
0021
0022 dd4hep::Volume parent = ns.volume(args.parentName());
0023 dd4hep::Volume child = ns.volume(ns.prepend(childName));
0024 #ifdef EDM_ML_DEBUG
0025 edm::LogVerbatim("ForwardGeom") << "DDRPDPosition: Parameters for positioning-- " << xpos.size() << " copies of "
0026 << child.name() << " to be positioned inside " << parent.name() << " at y = " << ypos
0027 << ", z = " << zpos << " and at x = (";
0028 std::ostringstream st1;
0029 for (const auto& x : xpos)
0030 st1 << x << " ";
0031 edm::LogVerbatim("ForwardGeom") << st1.str() << ")";
0032 #endif
0033
0034 for (unsigned int jj = 0; jj < xpos.size(); jj++) {
0035 dd4hep::Position tran(xpos[jj], ypos, zpos);
0036 parent.placeVolume(child, jj + 1, tran);
0037 #ifdef EDM_ML_DEBUG
0038 edm::LogVerbatim("ForwardGeom") << "DDRPDPosition: " << child.name() << " number " << jj + 1 << " positioned in "
0039 << parent.name() << " at " << tran << " with no rotation";
0040 #endif
0041 }
0042 return cms::s_executed;
0043 }
0044
0045
0046 DECLARE_DDCMS_DETELEMENT(DDCMS_rpdalgo_DDRPDPosition, algorithm)