CMS 3D CMS Logo

DDRPDPosition.cc
Go to the documentation of this file.
5 #include "DD4hep/DetFactoryHelper.h"
6 
7 #include <string>
8 #include <vector>
9 #include <sstream>
10 
11 //#define EDM_ML_DEBUG
12 
13 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
14  cms::DDNamespace ns(ctxt, e, true);
16 
17  const auto& xpos = args.value<std::vector<double> >("positionX");
18  const auto& ypos = args.value<double>("positionY");
19  const auto& zpos = args.value<double>("positionZ");
20  const auto& childName = args.value<std::string>("ChildName");
21 
22  dd4hep::Volume parent = ns.volume(args.parentName());
23  dd4hep::Volume child = ns.volume(ns.prepend(childName));
24 #ifdef EDM_ML_DEBUG
25  edm::LogVerbatim("ForwardGeom") << "DDRPDPosition: Parameters for positioning-- " << xpos.size() << " copies of "
26  << child.name() << " to be positioned inside " << parent.name() << " at y = " << ypos
27  << ", z = " << zpos << " and at x = (";
28  std::ostringstream st1;
29  for (const auto& x : xpos)
30  st1 << x << " ";
31  edm::LogVerbatim("ForwardGeom") << st1.str() << ")";
32 #endif
33 
34  for (unsigned int jj = 0; jj < xpos.size(); jj++) {
35  dd4hep::Position tran(xpos[jj], ypos, zpos);
36  parent.placeVolume(child, jj + 1, tran);
37 #ifdef EDM_ML_DEBUG
38  edm::LogVerbatim("ForwardGeom") << "DDRPDPosition: " << child.name() << " number " << jj + 1 << " positioned in "
39  << parent.name() << " at " << tran << " with no rotation";
40 #endif
41  }
42  return cms::s_executed;
43 }
44 
45 // first argument is the type from the xml file
46 DECLARE_DDCMS_DETELEMENT(DDCMS_rpdalgo_DDRPDPosition, algorithm)
Log< level::Info, true > LogVerbatim
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
static constexpr long s_executed
dd4hep::Volume Volume
float x
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:276
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99